cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Create Sharepoint folder if it does not exist, else add file to existing folder

I'm very new to Powerapps and have gotten a bit stuck. I have a Sharepoint Library which follows the structure: SITENAME/PROJECTS/<ClientRef>/<ProjectRef>

 

The ClientRef and ProjectRef folders are dynamically added from PowerApps when a new client and project is registered. The issue I have is that any photos, drawings or notes taken after registration then need to be uploaded to the relevant client's SP folder. Ultimately, each client will have a ClientRef folder, followed by a ProjectRef then 3 subfolders (drawings, photos, notes). These folders are where the files created in Powerapps will be stored. 

 

At present, my MS Flow fails because it cannot find the 'drawings', 'notes', 'photos' folders. I'm sure it's very simple but I can't seem to work out how to insert something into my flow which basically does the following:

 

- check if a subfolder named 'drawings' exists within the relevant client's structure

- if it does, then upload the file here

- if it doesn't exist, then create the folder and upload the file afterwards

 

This is the formula within Powerapps itself...

UploadDrawing.Run(Concatenate(ClientRef,"_",ProjectRef,"_Drawing"),JSON(ThisItem.Url,JSONFormat.IgnoreBinaryData),Concatenate(ClientRef,"/",ProjectRef,"/drawings"))

 

The flow creates a filename using the variables, sets the content then specifies the path. 

 

Any help would be greatly appreciated!

1 REPLY 1
braydenlarson
Community Support
Community Support

Hello,

 

The connections used for Sharepoint to grab folder's does not directly detect if there is a subfolder inside of the folder, instead you would need to setup the action to navigate into the folder and then check inside for existing folders.

So in your scenario where you are looking through your list for a specific name you are likely going to use the Get Folder and/or the List Folder Actions in order to grab the folders that currently exist

Capture.JPG

 

 

 

 

 

 

 

 

The big thing to note is that with the list you can setup a loop to go through and compare a specified value(such as name) to each item to see if it can identify the folder and confirm it exits, then if you have a variable that switched to true once it confirms it exists, you can use a condition after that to perform any steps you want or just skip to the create item in the folder, otherwise it has to go through and create the folder first.

 

 

Documentation of the actions:

https://docs.microsoft.com/en-us/Connectors/sharepointonline/#create-new-folder

https://docs.microsoft.com/en-us/Connectors/sharepointonline/#get-folder-metadata

https://docs.microsoft.com/en-us/Connectors/sharepointonline/#list-folder

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

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

Community Call Conversations

Introducing the Community Calls Conversations

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

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,423)