This article demonstrates how to generate DOCX Word document from a template with the help of Microsoft Flow.
I will use actions from Plumsail Documents connector, which is a part of Plumsail Actions.
We will generate a hiring contract from a template. This is how our final Word file looks:
Our template and result document has to be stored somewhere. Microsoft Flow has a lot of connectors for different systems. Here are just a few of them:
You can store your source file anywhere. In this example, we will store our documents in SharePoint. Our Flow will get a template from a SharePoint document library, generate a new document based on this template and on some data. The resulting document will be stored back to SharePoint document library.
Firstly, we have to prepare the template file. Please follow this instruction to prepare your template.
Now we need to create a Microsoft Flow that will get the template from the SharePoint document library, apply data to this template and save result document back to the document library. This is how complete flow looks:
Here is the step by step description for the flow.
Flow trigger
You can actually pick any trigger. For example, you can start Flow on file creation in a SharePoint document library. We use "Manually trigger a flow" trigger here to simplify the Flow.
Get file content
This action gets file content of the specified file from a SharePoint document library. You just specify SharePoint site URL and path to your file. We use this action to read .docx template.
You can use any other connector to get files from your system.
Create document from DOCX template
This is an action from Plumasail Documents connector, which is a part of Plumsail Actions.
There are two parameters:
In the first parameter 'DOCX document content' we specified file content of a template from the output of the previous action. Use this link to download it.
In the second parameter, we specified data to apply to the template in JSON format. This is information about a sample employee. You can actually request this information from an external system with the help of another Microsoft Flow action.
This is our sample data:
{
"EmployerFullName": "David Navarro",
"EmployeeFullName": "Anil Mittal",
"CompanyName": "Contoso LLC",
"Position": "Marketing manager",
"SalaryAmount": "5000",
"ListOfBenefits": "list of any benefits that come with employment, including healthcare, retirement, gym membership, etc",
"BonusesPolicyDescription": "annual evaluation",
"EffectiveDate": "10/27/2017",
"TerminationDate": "10/27/2018",
"State": "New York"
}
You can find more information about this action here.
Create file
Once the result document is generated, we need to store the Word file somewhere. In our example, we use "Create file" action from SharePoint connector to store the document in SharePoint document library.
You can use any other connector to store the Word document into your system.
This article was originally published here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.