Overview
We have come across the following real-life scenario in which we need to generate the Offer Letter for every new joiner in the organization using the predefined values.
Whenever a new person is selected, its entry will be added to the SharePoint list. We trigger the flow upon the new item creation. First, we need to read the Word template with Quick Parts values and then we will replace the Quick Parts values with the fetched SharePoint list item value. In the end, we will store the generated Offer Letter to a separate Document Library in SharePoint Site.
So basically, it’s a Trio – SharePoint Word Template – MS Flow – and SharePoint Word Document creation in a separate library.
Example
We have the following three lists,
- Offer Letter Template – Whenever a new person will be selected, their entry is added to this list.
- Offer Letters – The predefined word template will be stored here.
- Offer Letters – The Generated document for each new joiner will be stored in this document library.
The overall procedure is mentioned in below step by step chart.
- MS Flow will read the Word Template stored in one of the Document Library
- Quick Parts are replaced with the fetched Value from the SharePoint list
- A newly created Word Template will be stored in a different document library.
At the end of this article, we will convert the document template to the proper documents.
Now, let’s get started!
Step 1 - Create Site Columns
- To create a list and document library structure, first, create Site Columns to your site collection. The reason is, if we create a list column or library column, it will not replace the proper value in the word document.
- To create a site column, go to Site Settings.
- Click on the Create button.
- Give Column name and click Ok button.
- We created three site columns and add to our custom group named “HR Data”.
Step 2 - Create List and Library
- Create Custom List named “Offer Letter Data”.
- Add three Site columns to the list.
- Create a Document Library named “OfferLetterTemplate”.
- Add three Site columns to the library.
- Create a Document Library named “OfferLetters”.
- Add three Site columns to the library.
Step 3 - Create a Word Document Template in the library
This is a very important step. Follow the below steps very carefully.
- Go to Offer Letter Template Document Library.
- From New, Click on Word document.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- Click on Open in Desktop App.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- From Pop Up, click on Open Word button.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- Type your content.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- To add the Quick Parts, Go to the Insert > Quick Parts > Document Property. Set the Document Property in your Document.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- Save the file and close the file.
Step 4 - Create Microsoft Flow to create a Word Document and Replace Quick Part with List Values
- Go here.
- Create > Automated Flow
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- Give Name of the Flow and Triggering Action.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- In the first step > Add Site Address and List Name.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- Second Step
Add and Action > Get file Content
Add Document Library address where we have stored our template. We stored our template in the OfferLetterTemplate library and the name of the template file is – “Software Developer Template”.
- Third Step
Create a file.
Give the URL for the destination library where we wish to store our documents.
In the File name, we will assign file name as “EmployeeName”.docx
Pass File Content from Get file Content section.
- Step 4
Update file Properties,
Here, we will update the file properties for the OfferLetters library.
Id = ItemId from Create file section.
Date of Joining, Employee Name and Salary= Appropriate field from When an item is created section.
The overall flow will look like in the following screenshot.
Now, It’s time for testing.
- Add a new Entry in the Offer Letter Data list.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- The flow will trigger.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- The document will be stored in the OfferLetters document library.
- Click on the ellipses icon and click on the Preview document.
![Generate MS Word Document Consuming SharePoint List Data From A Document Template Using MS Flow And Quick Parts]()
- Here, you can see replaced values.
Note
The created Word document will not work with Word Online Edit mode. The reason is, Quick Parts only supports the desktop version of Application. You have to open the Word file in Desktop Mode of Word to save any changes.
Conclusion
This is how we can create Word Document from the document template using MS Flow. I hope you love this article! Stay connected with me for amazing MS Flow Articles.