cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cyberco01
Level 8

Check if folder exists or not using MS Flow

I create a folder in document library using the solution in link - https://www.c-sharpcorner.com/article/create-folder-in-sharepoint-list-using-microsoft-flow/

Now, in the same flow i want to check if the folder exists or not and then create the folder in the document library.

Kindly help.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Check if folder exists or not using MS Flow

HI @cyberco01 ,

Yeah, it's my fault. Please consider modify your flow's configuration as below:10.JPG

 

11.JPG

Within the Condition action, left input field set to following formula:

empty(body('Filter_array_2'))

right input field set to following formula:

true

Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
14 REPLIES 14
Super User
Super User

Re: Check if folder exists or not using MS Flow

Hey! you can follow the steps as shown in the screenshot to check if the folder exists and if not, create one with the HTTP Request. 

testdd.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks, 

 

Community Support Team
Community Support Team

Re: Check if folder exists or not using MS Flow

Hi @cyberco01 ,

Do you want to create a sub-folder in your SP Library? And want to check if the same folder name has been existed within your SP Library, if true, not create same folder, otherwise, create a new sub-folder within it?

 

I have made a test on my side, please take a try with the following workaround:2.JPG

Within the "Filter array" action, From field set to Body dynamic content of the "List folder" action. Click "Edit in advanced mode", type the following formula:

@and(equals(item()?['IsFolder'], true), equals(item()?['Name'], triggerBody()?['Title']))

Within the "Condition" action, left field set to Body dynamic content of the "Filter array" action, right input field remains blank.

The flow works successfully as below:3.JPG

Please consider take a try with above flow's configuration, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
cyberco01
Level 8

Re: Check if folder exists or not using MS Flow

Hi @v-xida-msft ,

I tried the solution provided, the flow is run successfully, but folder is not created and the flow detail is as below:

 

FlowIssue1.PNG

Kindly help as I am completely new to Powerapps and MS Flow. All your help is truely helpful for me a lot.

 

Below is the snapshot of my flow:

FlowIssue2.PNG

Super User
Super User

Re: Check if folder exists or not using MS Flow

Hi @cyberco01 , 

 

Can you share a screenshot of the expanded flow? Just wanted to check what is going on in the if condition. I suspect that we might have to alter that condition to check the folder. 

 

Thanks, 

cyberco01
Level 8

Re: Check if folder exists or not using MS Flow

In the if its just checks Body is not equal to n right side is blank left as it is..
Community Support Team
Community Support Team

Re: Check if folder exists or not using MS Flow

Hi @cyberco01 ,

Based on the screenshot that you mentioned, your flow goes into the "If/yes" branch, so the "If/no" branch would be skipped, the "Send an HTTP request to SharePoint" action would not be executed.

 

Based on your flow's running detail, it means that there already have same name sub-folder in your Parent SP Library (the "Condition 2" action has been calculated as True). Please check if you have add same name sub-folder in your Parent SP Library.

 

Also please consider re-add a new SP List Item with different Title value, then check if the flow could be executed successfully, and create a sub-folder in your Parent SP Library.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
cyberco01
Level 8

Re: Check if folder exists or not using MS Flow

Hi @v-xida-msft,

 

I created a new list item as below and the flow was executed. But, no sub-folder was created (even if same name sub-folder was not present). The condition is evaluated as true even if no sub-folder of same name exists.

 

Please find below my folder structure :-

SP_FolderStructure2.PNG

As shown below, it is the new list item i created.

Newest Item in List.PNG

 

Also below is my flow detail, the Body in output is empty. May be that is causing the condition to be true always and that is why folder is not created.

FlowIssue3.PNG

 

Kindly help.

Community Support Team
Community Support Team

Re: Check if folder exists or not using MS Flow

Hi @cyberco01 ,

Based on the flow's configuration that you mentioned, I think there is something wrong with your flow's configuration.

 

I have made a test on my side, please consider modify your flow as below:3.JPG

Within the "Filter array" action, click "Edit in advanced mode", type the following formula:

@and(equals(item()?['IsFolder'], true), equals(item()?['Name'], concat(triggerBody()?['RequestingDepartment'],'-',triggerBody()?['Title'],'-',triggerBody()?['ID'])))

Within the "Condition" action, left input field set to Body dynamic content of the "Filter array" action, middle condition set to "is equal to", right input field set to following:

[]

Note: The Sub-folder name you specified within the "Filter array" action (highlight as yellow in above screenshot) must be same as that in your "Send an HTTP request to SharePoint" action.

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
cyberco01
Level 8

Re: Check if folder exists or not using MS Flow

Hi @v-xida-msft ,

 

While pasting the formula :

@and(equals(item()?['IsFolder'], true), equals(item()?['Name'], concat(triggerBody()?['RequestingDepartment'],'-',triggerBody()?['Title'],'-',triggerBody()?['ID'])))

 

in Filter Array section i get the below error :

"The power flow's logic app flow template was invalid. The object expression property name 'equals' at line '1' and column '1016' of action 'Condition_2' has parameters of types 'Array' which are not supported. Only 'Object,Integer,String,Float,Boolean,Null' types are supported."

 

My RequestingDepartment is of Type String, Title of Type String, ID is the autogenerated ID Field in SP.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 41 members 3,978 guests
Please welcome our newest community members: