Create a Custom Document Template from SharePoint List using Microsoft Flow

In this Microsoft Tutorial, We will discuss how to create a Custom Document Template from SharePoint Online List using various templates of Microsoft Flow. Also, we will see how we can edit and save a document template in the SharePoint Online Document Library settings.

Create a Custom Document Template from SharePoint List using Microsoft Flow

For this Microsoft Flow example, I have One SharePoint Online List as “TSInfo List” and other one SharePoint Online Document Library as “TSInfo Document“.

Both SharePoint Online List and SharePoint Online Document Library are having the same data type of column with the same name which I will discuss below.

Below screenshot represents the SharePoint Online List (TSInfo List) which I have taken for this Microsoft Flow example.

Create a Custom Document Template from SharePoint List Using Microsoft Flow
Create a Custom Document Template from SharePoint List Using Microsoft Flow

This “TSInfo List” is having below different data types of columns as:

  • Title (By default)
  • Available Offer (Single line of text)
  • Offer Description (Multiple lines of text)
  • Quantity (Number)
  • Price (Currency)
  • Date Of Packaging (Date and Time)
  • Date Of Expiry (Date and Time)
Custom Document Template from SharePoint List by using Microsoft Flow
Custom Document Template from SharePoint List by using Microsoft Flow

Here, Multiple lines of text work best as a Plain or Rich text in this case since Enhanced rich text passes on HTML tags to the document with the Flow. For that, you have to specify the type of text to allow as “Rich text“.

Custom Document Template from SharePoint List using Microsoft Flow
Custom Document Template from SharePoint List using Microsoft Flow

Below screenshot represents the SharePoint Online Document Library (TSInfo Document) which I have taken for this Microsoft Flow example.

Microsoft Flow Create a Custom Document Template from SharePoint List
Microsoft Flow Create a Custom Document Template from SharePoint List

This “TSInfo Document” is having below different data types of columns which is purely similar to the “TSInfo List” column.

Create a Custom Document Template from SharePoint List Microsoft Flow
Create a Custom Document Template from SharePoint List Microsoft Flow

Edit and Save a Template URL in Document Library Settings

To create a Custom Document Template, the main and most important thing is, We just need to save the “Document Template” from “.dotx” to “.docx“.

For saving the document template, Go to “Library Settings” -> “Advanced Settings” -> “Edit Template” -> “Open it on Local MS Word application” as shown in below screenshot. Also, you can see in the below screenshot, Before editing the template URL, the URL will display as like “LibraryName/Forms/template.dotx” (Default template).

So we have to change the URL as like “LibraryName/Forms/template.docs“.

Create Custom Document Template from SharePoint List Using Microsoft Flow
Create Custom Document Template from SharePoint List Using Microsoft Flow

Once you will edit the template in your local MS Word application, you will see nothing will be present in that MS word document. That means the document will open with a fully blank page.

To add the Document content, Go to “Insert” -> “Quick Parts” -> “Document Property”. Once you will tap on “Document Property”, You can see all the columns which are present in that specific Document Library (“TSInfo Document”).

As per my requirement, I have added all the data type of columns which are present in the Document Library. Then I saved the template as “LibraryName/Forms/template.docs“.

Create a Custom Document Template from SharePoint List in Microsoft Flow
Create a Custom Document Template from SharePoint List in Microsoft Flow

After saving the Template URL, You can see the URL is changed to “.docx”. Also, you can change the template URL by itself in the “Document Template” of “Advanced Settings”.

Create Custom Document Template from SharePoint List by Using Microsoft Flow
Create Custom Document Template from SharePoint List by Using Microsoft Flow

Create Microsoft Flow to create Custom Document Template from SharePoint Online List

By using various types of Microsoft Flow templates, You can easily create a Custom Document Template, You can view the whole structure of Microsoft flow process in the below screenshot which I am going to explain you individually in below.

Custom Document Template from SharePoint List in Microsoft Flow
Custom Document Template from SharePoint List in Microsoft Flow

When an item is created or modified:

  • Site Address: Provide the existing Site address URL.
  • List Name: Specify the name of List where the flow will trigger when an item will create or modified. Here, I am taking my list name as “TSInfo List”.
Microsoft Flow Custom Document Template from SharePoint List
Microsoft Flow Custom Document Template from SharePoint List

Copy file (deprecated): This action helps to create a document in the library as a copy of the library template file as (“LibraryName/Forms/CustomTemplateName“).

  • Site Address: Provide the existing Site address URL.
  • Source File Path: Specify the source file path of the custom template as “/LibraryName/Forms/template.docx“. Here, my custom template name as “template“, So I have taken as template.docx.
  • Destination File Path: Specify the destination file path with the name of the document to correspond the list item title and create a .docx file. The file path should be like “/LibraryName/Title.docx“. Take the “Title” field from the list (When an item is created or modified) using Dynamic content.
  • Overwrite Flag: Select the flag as “Yes” from the dropdown.
create word doc with microsoft flow
create word doc with microsoft flow

Get file metadata using path:

  • Site Address: Provide the existing Site address URL.
  • File Path: Specify the file path as “/LibraryName/Name“. Take the “Name” from “Copy file (Deprecated)” using Dynamic content.
with microsoft flow create word doc
with microsoft flow create word doc

Update file properties:

  • Site Address: Enter the existing Site address URL
  • Library Name: Specify the name of the Document Library.
  • Id: Take the Id from “Get file metadata using path” by using Dynamic content.
  • Title: Specify the Title from the SharePoint Online list (When an item is created or modified) by using Dynamic content.

Similarly, as like title field, Take all the rest field values from the SharePoint Online list (When an item is created or modified) by using Dynamic content.

microsoft flow create word document from template
microsoft flow create word document from template

Now “Save” and “Test” the Microsoft Flow. To test the Microsoft flow, Create or modify one item in the SharePoint Online List. In the below screenshot, I have created a new item.

create word document from template microsoft flow
create word document from template microsoft flow

Once an item will create or modify in the SharePoint Online List, Then the Microsoft flow will trigger. If there is no error in the Microsoft flow, then after some time, you can see the message as “Your flow ran successfully” as like below screenshot.

create word document from template using microsoft flow
create word document from template using microsoft flow

Now go to your SharePoint Document Library. In that library, you can see there will be a document present which you created in the SharePoint List. Just click on the document.

create word document from template by using microsoft flow
create word document from template by using microsoft flow

Once you will click on the document, Just no need to be shocked that it is an empty document. Click on “Open in Word” option which is present on the top of the document template.

create word document from template in microsoft flow
create word document from template in microsoft flow

When you will open the document in your local MS Word, then you can see all the values as like below figure.

by using microsoft flow create word document from template
by using microsoft flow create word document from template

Create Versioning Settings:

In this case, one additional setting that you’d be needed to do with setting this flag as Yes is set versioning on the document library to Create major and minor (draft) versions, so that each change adds a new version to the same file.

create word doc with microsoft flow
create word doc with microsoft flow

After creating the major and minor (draft) versions, if you will go to a particular Document version history, then you can see the different type of versions as like below screenshot.

create word doc using microsoft flow
create word doc using microsoft flow

You may like following Microsoft flow tutorials:

Hence, In this Microsoft Tutorial, We discussed how to create a Custom Document Template from SharePoint Online List using Microsoft Flow. Also, we saw how we can edit and save a document template in the SharePoint Online Document Library settings.

Also, We discussed how to create a different type of versioning (major and minor) in the SharePoint Document Library.

>