cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Martindeter
Level: Powered On

Create a file with a word template

Hi all, 

I would like to create a flow : when an item is created in a list, create a file in a Sharepoint Library with the items from the list. The file is actually a word template document (a custom content type). The problem is that the word document say error when I want to open it. 

Could you help me ? Do you have another solution ?  

flow1.PNGflow2.PNG

 

Thank you, 

Martin


Accepted Solutions
Community Support Team
Community Support Team

Re: Create a file with a word template

Hi @Martindeter,

 

Within the "Create file" action within your flow, the File Content field is required to fill an binary data, but you filled a String within it.

 

More details about the "Create file" action of SharePoint list, please check the following article:

Create file action

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When an item is created" trigger, specify Site Address and List Name.
  • Add a "Compose" action, Inputs set to following json data:17.JPG

     

  • Add a "Create HTML table" action, From set to following formula:

    array(outputs('Compose'))
  • Add a "Create file" action, File Content field set to output of "Create HTML table" action, File Name field set to following formula:

    First Name Dynamic content Last Name Dynamic content .doc

     

Note: File Name ends with .doc rather than .docx within File Name field of "Create file" action.

 

Image reference:18.JPG

The flow works successfully as below:19.JPG

The created file opened successfully in my SharePoint library as below:20.JPG

 

 

 

Best regards,

Kris

 

 

 

 


All Replies
Super User
Super User

Re: Create a file with a word template

It is easier to create a document by getting the content using a Get file content action.

GetFileContent.png

This now gives you Word (or whatever format the tmeplate file is that is referenced in the identfier) formatted file content.

 

Then using the Create File action you can create a fiel wherever you like.

Martindeter
Level: Powered On

Re: Create a file with a word template

Thanks for your help. 
Unfortunately, the Word error is the same

flow3.PNG

Super User
Super User

Re: Create a file with a word template

Hi Martin,

 

Are you able to open the document that you are using as a source within Office Online without the error message appearing?

Martindeter
Level: Powered On

Re: Create a file with a word template

Yes, and when I create a new document in the library it opens correctly. If I fill in the item properties manually the Word Document accepts the fields.

I modified the File identifier (I don't really know what I'm doing but I try to find a solution). If I chose my template document for the file identifier, it opens correctly in the library but the list fiels aren't copied.

 

flow4.PNGflow5.PNG

Super User
Super User

Re: Create a file with a word template

You document lives in the Forms/Content type folder. 

 

Can you try moving your template document into the document library itself and then copy it from there.

Martindeter
Level: Powered On

Re: Create a file with a word template

I added a "Update File Properties" action and the fields from the list are now copied.

 

I moved the template into the document library itself : the document created is a copy of the template but doesn't take the item fields in consideration. Even if I do it manually.

Super User
Super User

Re: Create a file with a word template

Hi @Martindeter,

 

That sounds like a content type issue to me. 

 

Does the ocntent type where you copy the document from match the content type where you copy it to? Are the fields identical in both librasries ( i.e. are you using site collection columns?)

Martindeter
Level: Powered On

Re: Create a file with a word template

Thanks for your answers.

I finally did it thanks to SharePoint Designer.
I followed this article : https://sharepointlibrarian.com/2016/09/30/sp-workflow-to-create-a-document/

 

Community Support Team
Community Support Team

Re: Create a file with a word template

Hi @Martindeter,

 

Within the "Create file" action within your flow, the File Content field is required to fill an binary data, but you filled a String within it.

 

More details about the "Create file" action of SharePoint list, please check the following article:

Create file action

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When an item is created" trigger, specify Site Address and List Name.
  • Add a "Compose" action, Inputs set to following json data:17.JPG

     

  • Add a "Create HTML table" action, From set to following formula:

    array(outputs('Compose'))
  • Add a "Create file" action, File Content field set to output of "Create HTML table" action, File Name field set to following formula:

    First Name Dynamic content Last Name Dynamic content .doc

     

Note: File Name ends with .doc rather than .docx within File Name field of "Create file" action.

 

Image reference:18.JPG

The flow works successfully as below:19.JPG

The created file opened successfully in my SharePoint library as below:20.JPG

 

 

 

Best regards,

Kris

 

 

 

 

>