Introduction
Fill the word document values that are stored in a SharePoint document library through power automate (earlier called MS flow). It’s not a new one, as it's been around since SharePoint/Office 2010.
Steps
Create a document library in your SharePoint Site and create a column that needs to be added in the word document.
Highlighted (orange) – Those are the columns that I am going to add to my word template. I have uploaded my template in the same document library highlighted
in black.
The above one is my template document design and highlighted fields that are going to be capture from the SharePoint Document library.
I will show you how to connect document library data in the template that you uploaded in the same document library.
Open your document using open in the word option from SharePoint.
In Word, go to the Insert Tab, click quick parts and choose the document property. From the list of document properties, you’ll see your library’s metadata. Click a property to insert it in your document.
Use your cursor and choose the spot in the document to add the property wherever you want as per the above image (highlighted in black).
Save your file in place and close the word.
Go to flow.microsoft.com, and create a new or blank flow. For this simple example, I am using it when an item is created or modified.
I have a SharePoint list, when the item added in that list, it will trigger this flow and current item values are filled into the document (Template) that I have in my document library.
Your first action will be a SharePoint action called Get File Content. Remember that file you created at step 1? That is the file that you want to get.
Next, add a SharePoint action, Create File. I just created mine in the same library, but you could put it in a different library. For the file name, I'm using “ApplicationForm” with an ID value of the current item.
Add a SharePoint Action Update file properties next. For the ID, I chose it from the create file item id and used input values from my current item action.
Unfortunately, the deal with Quick Parts is that they’re a little weird when using Word Online. The file looks fine when you open it up in the Word client software (on your computer), but in Word Online, the values don’t show in the Quick Parts. Here’s the trick: when people have read-only access to the file or when you preview the file, the Quick Parts show correctly in Word Online. Also, when you send it in an email it looks fine.
Here’s what the file looks like in mail:
Conclusion
This is the way how we can fill the document through flow. Finally, if you want to send the filled document through the mail, just get the file content again from your document and add content in the “send an email” action.