How to find a folder exists (Dynamic) in SharePoint?
This is something I noticed from community often discussed about SharePoint List Folder can’t have dynamic folder mapping. In this blog I will show you how can we use dynamic folder mappings using SharePoint List Folder action. Action step List Folder file identifier represents the path of a valid SharePoint folder name. If folder not found generally flow will fail and stop the execution. Follow below steps how to determine whether the folder exists or not and continue the flow execution.
I have a SharePoint document library called ‘aj’. Here I have couple of folders called Test1, Test2 & Test3.
The flow we are going to build is pass the dynamic folder mappings, find whether a folder exists in SharePoint or not. If folder exists, then get the file contents.
First step is the trigger and here I am using a manual trigger.
Next step is initialising two variables. One is used for identifying whether a folder exists or not (Boolean) and other is a string where we pass the folder name.
Above I have hardcoded the folder name (SharePoint library name/Folder name).
Next, we need to use the SharePoint List Folder action. Here I am using folder name variable under the file identifier setting as dynamic content. If required, you can also use the SharePoint URL mapping via variable.
Above step set the configure run after as follows:
Once it set click done.
Next step we need to add a parallel branch.
Here we need to add two steps under the parallel branch.
(a) First variable sets the IsFolderExists to true.
Also set the configure run (Select the three dot of Set variable True) after as follows:
(b) Second variable (parallel branch action) is as follows:
Set the configure run after as follows:
Finally, we have two parallel actions like below.
Next step is to check the condition whether SharePoint folder found or not?
For the above step set the configure run after as follows:
Remember to set all true except ‘has timed out’ for both set variable True or False. Select using the mouse for each Set variable (True/False) and select the options separately.
Once both variables are set then click done.
Final step is to get the name of the files from the folder under the Yes condition.
Here are my run results:
- A valid SharePoint folder exists Folder name = /aj/Test1
- Folder does not exist. Folder name = /aj/Test999
Thank you for reading.
Comments
-
How to find a folder exists (Dynamic) in SharePoint?
Hello, thank you very much for your post. I encountered some problems (“The response is not in a JSON format.”), but was able to solve them with the help of other sites. For those who may be facing the same problems here goes my solution. Sorry, it is in French, but the difference is simple : Istead of using List Folder, I used Get Folder Metadata.
*This post is locked for comments