cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hfdigital
Frequent Visitor

Check if file exist on SharePoint from Power Automate

Hi there, I've developed my first PowerApps and Power Automate app that creates a PDF document in SharePoint from a PowerApp input form.  However on testing, I get an error message that the file already exists, which I expected.   On trying to resolve this, I'm running into issues.

 

I have checked existing posts and watched YouTube videos on how to check to see if a file name already exist and if it does, alert the user but can't find anything that achieves this.  I think I will need to do this before the create file 2 action but not sure what action/component to use.  Thanks

 

 

hfdigital_0-1623661976004.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

It works better if you have your flow set up before you try to link it into your Power App. I agree, test for the filename before you attempt to create a file with the same name or the flow fails. Here's a screenshot with the basic flow functionality:

BCLS776_0-1623680182087.png

Three main steps:

  1. List the files/folders in your target SP folder
  2. Loop through each one and test whether its filename matches the one you want to use. This condition gets expressed in the area I circled in green, and I am assuming you have this filename available to the flow through dynamic content
  3. Use the Condition block to determine what you want to do if the condition results in a Yes or a No. If you like, you can set up the condition so that only a Yes does something (circled in yellow) and then you can leave the No side (circled in blue) blank.

You can have the flow send some sort of response back to the app using the "Respond to Power App or Flow" block. By doing this, your MyFlow.Run() statement will return a value you can use in a variable, label Text property, or some other purpose. 

However, I use an easy way to avoid all of this - try attaching a timestamp or random number to your filenames. In this way, you can allow your app to perform the same operation and each file resulting from it will have a different filename. It generates extra files, but it's unlikely to fail the flow due to a duplicated filename.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
BCLS776
Super User
Super User

You'll want to include a Condition block in your flow to handle at least two cases: finding a file with the name or not. It's the flow equivalent of an If-Then statement. If you want PowerApps to return a message to the app user, you will need to structure it to respond in a way you can use in your app.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Thanks.

Do you have an example?  I understand what it is I need but not sure  how/where to structure it. The create file action/component creates a file with an hexadecimal string as seen below:

 

hfdigital_0-1623677654332.png

 

so, I think the conditional action will need to come before this.

Can you elaborate on the point you made concerning the return message.

It works better if you have your flow set up before you try to link it into your Power App. I agree, test for the filename before you attempt to create a file with the same name or the flow fails. Here's a screenshot with the basic flow functionality:

BCLS776_0-1623680182087.png

Three main steps:

  1. List the files/folders in your target SP folder
  2. Loop through each one and test whether its filename matches the one you want to use. This condition gets expressed in the area I circled in green, and I am assuming you have this filename available to the flow through dynamic content
  3. Use the Condition block to determine what you want to do if the condition results in a Yes or a No. If you like, you can set up the condition so that only a Yes does something (circled in yellow) and then you can leave the No side (circled in blue) blank.

You can have the flow send some sort of response back to the app using the "Respond to Power App or Flow" block. By doing this, your MyFlow.Run() statement will return a value you can use in a variable, label Text property, or some other purpose. 

However, I use an easy way to avoid all of this - try attaching a timestamp or random number to your filenames. In this way, you can allow your app to perform the same operation and each file resulting from it will have a different filename. It generates extra files, but it's unlikely to fail the flow due to a duplicated filename.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

Thanks.  I will give this a try.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,434)