cancel
Showing results for 
Search instead for 
Did you mean: 
antonkhrit

Create DOCX Word document from template based on dynamic data in Microsoft Flow

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:

 

docx-sample-doc.png

 

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:

  • SharePoint
  • Salesforce
  • Box
  • OneDrive
  • Google Drive
  • Dropbox
  • SFTP
  • File System

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:

 

Select fields

 

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:

  1. DOCX document content
  2. Template data

 

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.

 

Select fields

 

You can use any other connector to store the Word document into your system.

 

This article was originally published here.

Comments
Meet Our Blog Authors
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Blog site: https://ganeshsanapblogs.wordpress.com/ MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. Working on some cool stuff that you're going to enjoy. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/