cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
StephenM
Advocate II
Advocate II

Need help creating Sharepoint Folders and subfolders with Flow

I have a flow that grabs the body on email. the body of these emails will always be a number. e.g 204. We'll call this item the "job number", so the the flow creates a folder in a sharepoint online Share Documents folder called the job number. e.g. it creates a folder called 204 in this example.

 

And this flow is working perfectly.

 

This list of folders (or job numbers) is going to get very long very quickly.

 

What really need is folders and subfolders.

 

So job 103 would go under a folder called 100-199. And job 104 would go in there too.

But job 204 woudl go under a folder called 200-299

and job 1034 woudl go under a folder called 1000-1099

and so on

 

I just dont know how to tell FLOW the parent folder number to use e.g. i know the job number folder is 287, but how can i automatelly calculate for Flow that this fits under parent folder 200-299 ?

 

flow subfolders.JPG

 

any help would be much appreciated 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @StephenM,

 

Have these parent folders been existed in your SharePoint library?

Are there any other folders except parent folders within your SharePoint library?

How do you create folders within SharePoint library?

Further, could you please share a screenshot of your flow’s configuration?

 

I assume that these parent folders have been existed in your SharePoint library already and there are no other folders except parent folders within your SharePoint library.

 

Creating folder action is not supported in SharePoint connector of Microsoft Flow, but you could consider take a try with the following workaround:

  • Add “When a new email arrives” trigger.
  • Add a “HTML to text” action, Content set to Body dynamic content of the trigger.
  • Add a “List folder” action, specify Site Address and File Identifier.
  • Add a “Apply to each” action, Input parameter set to Body dynamic content of “List folder” action.
  • Within “Apply to each”, Add a Condition, click “Edit in advanced mode”, type the following formula:

 

@contains(items('Apply_to_each')?['Name'], '-')

 

  • Within “If/yes” branch of Condition, add a “Compose” action, Inputs set to following formula:

 

split(item()?['Name'],'-')

 

Add a Condition 2, click “Edit in advanced mode”, type the following formula:

 

@and(greaterOrEquals(body('Html_to_text'), outputs('Compose')?[0]),lessOrEquals(body('Html_to_text'), outputs('Compose')?[1]))

 

           

  • Within “If/yes” branch of Condition 2, add a “Create file” action, specify Site Address, Folder Path set to following formula:

 

/MyLibrary1/item()?[‘Name’]/The plain text content dynamic content of “Html to text” action

14.JPG

 

 

File Name and File Content both set to Test (For test, this file will be deleted in next step).

  • Add a “Delete file” action, specify Site Address and File Identifier set to Id dynamic content of “Create file” action.

Image reference:15.JPG

 

16.JPG

The flow works successfully as below:17.JPG

 

18.JPG 

 

Best regards,

Kris

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.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @StephenM,

 

Have these parent folders been existed in your SharePoint library?

Are there any other folders except parent folders within your SharePoint library?

How do you create folders within SharePoint library?

Further, could you please share a screenshot of your flow’s configuration?

 

I assume that these parent folders have been existed in your SharePoint library already and there are no other folders except parent folders within your SharePoint library.

 

Creating folder action is not supported in SharePoint connector of Microsoft Flow, but you could consider take a try with the following workaround:

  • Add “When a new email arrives” trigger.
  • Add a “HTML to text” action, Content set to Body dynamic content of the trigger.
  • Add a “List folder” action, specify Site Address and File Identifier.
  • Add a “Apply to each” action, Input parameter set to Body dynamic content of “List folder” action.
  • Within “Apply to each”, Add a Condition, click “Edit in advanced mode”, type the following formula:

 

@contains(items('Apply_to_each')?['Name'], '-')

 

  • Within “If/yes” branch of Condition, add a “Compose” action, Inputs set to following formula:

 

split(item()?['Name'],'-')

 

Add a Condition 2, click “Edit in advanced mode”, type the following formula:

 

@and(greaterOrEquals(body('Html_to_text'), outputs('Compose')?[0]),lessOrEquals(body('Html_to_text'), outputs('Compose')?[1]))

 

           

  • Within “If/yes” branch of Condition 2, add a “Create file” action, specify Site Address, Folder Path set to following formula:

 

/MyLibrary1/item()?[‘Name’]/The plain text content dynamic content of “Html to text” action

14.JPG

 

 

File Name and File Content both set to Test (For test, this file will be deleted in next step).

  • Add a “Delete file” action, specify Site Address and File Identifier set to Id dynamic content of “Create file” action.

Image reference:15.JPG

 

16.JPG

The flow works successfully as below:17.JPG

 

18.JPG 

 

Best regards,

Kris

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.

View solution in original post

thanks for the suggesions. we've already got this working by grabbing the job number, initialising some variables and calcualte the lower the lower limit by dividing by 100, grabing the integer and multiplying by 100. then add 99 to get the upper limit. then concat the two for parent path name. 

 

e.g. job number is 1441

so 1441 / 100 = 14.41

integer of that is 14

multiple by 100 to get 1400 which is the lower limit of the path i need  (this is the code folder2.JPGfolders1.JPG

upder limit is 1400+99

concat the two to create the parent folder name so we get "1400 to 1499"

add tha tto the job folder name for the final folder "\1400 to 1499\1441" that gets created and use that as the path for the save action. 

 

done. 

 

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

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
Users online (1,015)