cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
audrieg
Power Automate
Power Automate

Flow to Create File

Environment details: Sharepoint in Office 365 - creating the Flow from the List Ribbon in the new Modern Experience.

 

When I use the template "When a new item is added in SharePoint, complete a custom action" to create a file in a SharePoint Library, it does not seem to allow me to select a Content Type at the library destination. Is it possible to specify the content type to be used?

 

I didn't specify one, and yet, it did not pick up the default content type either - it created a file without an extension. (I guess that means I need to add the extension in the file name area, right?)

 

screenshot.PNG

 

Here is the updated flow with the extension added. The file is created (default content type picked up) but the new file can not be opened.

 

flow.PNG

 

sessionID.PNG

 

If I click "Edit in Word" - it opens the file blank (even though the template has preformatted placeholders).

 

Creating a default file using the New command opens the template with preformatted text.

1 ACCEPTED SOLUTION

Accepted Solutions
v-monli-msft
Community Support
Community Support

Hi audrieg,

 

I reproduced the issue:

Capture.PNG

 

I think this is because that flow treat "File Content" field as a whole exsiting file. I mean that if you got a file in the trigger, then you put this trigger file content into this "File Content" field in SharePoint create file action, this will create a correct file and you can open it in SP.

Capture1.PNG

 

Regards,

Mona Li

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

13 REPLIES 13
v-monli-msft
Community Support
Community Support

Hi audrieg,

 

I reproduced the issue:

Capture.PNG

 

I think this is because that flow treat "File Content" field as a whole exsiting file. I mean that if you got a file in the trigger, then you put this trigger file content into this "File Content" field in SharePoint create file action, this will create a correct file and you can open it in SP.

Capture1.PNG

 

Regards,

Mona Li

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-monli-msft
Community Support
Community Support

See above.

 

Moan Li

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I love your idea, but I don't see FileContent as a tag in my UI. I typed it but I don't think that's what you mean.

 

FileContentMissing.PNG

Hi,

 

This might be something to do with your SharePoint list library type?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Yes, and no. Smiley Happy

It has to do with the fact that I'm not starting with a library, I am initiating the flow from a list.

What I also found out is that the same 'bug' occurs when I try to create the file using SharePoint Designer (which does have a way to specify the content type name).

 

So, I revised my flow to start by copying a template file from one library to the destination library (since that file already has content I thought that would get me that "FileContent" tag - but alas it doesn't. Flow copies over the file, but I get the same error message - it appears the file is corrupting on creation.

 

Any ideas of what I might be able to do to get a new file in a library (I'm ok with it being based on the default content type since there is only one in the library. Do you think it could be becaue the template is customized? (It has headers and footers for company branding.)

 

FYI: I never have this problem when I create a new file using the "New" command directly in the library in the UI....only when I try to create it from a workflow method external to that library.

 

Appreciate any ideas...

 

 

Hi,

 

You mentioned "I never have this problem when I create a new file using the "New" command directly in the library in the UI".

 

So here are you creating the title first and attach the file?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Hi,

 

I think this might helps. So for every lists there is an 'Attachments' in SharePoint. Try to set the following in Create File Flow

 

Site URL:
Your SP Site

 

Folder Path:
/List/YourListName/Attachments

 

Filename:
Set the Filename

 

FileContent:
Set the File Content

 

Please let me know how it goes?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

I give you BIG KUDOS for such a great idea! Only, even if it works I can't use it. I need to create a file based on a template (and I can't set a template for a list attachment). Let me know if I'm wrong....but without being able to specify a content type the attachment approach won't work. (I did put this in my idea journal....cause I will go back to it if/when they add Content Type to the Create File options in Flow.

 

Update: For some reason FileContent is not available for attachments either.

Hi,

 

Thanks for the BIG KUDOS Smiley Happy Can you please check your List settings > Advanced settings > Attachtment to list items are enabled or not?

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Yes, and I tested that I can add an attachment manually without issue (I believe that is default unless you turn it off).

Anonymous
Not applicable

I'm getting this same error. Can the "File Content" be the content of a file other than the source file that is the trigger which creates the file?

How is this the solution? Maybe I missed it, but I don't see the answer to the question, "how is the File Content created?"

 

@v-monli-msft 

@audrieg 

man-verma
Microsoft
Microsoft

Try using below expression for file name:

concat(variables('ID'),'Invoice.docx')

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (3,485)