cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous5
Level: Powered On

Using Split Function for Folder Path

Hi Everyone,

 

I'm working on a flow which is successfully working but I'd like to add a parallel branch to work on the same initial trigger of File Creation in Sharepoint (properties only).

 

I've made this branch get the file content and attach it to an email in Outlook which is working. What I would like to do is personalize the email using info from the filepath. For example, the complete file with the folderpath would look something like:

 

Job Site Name/Service Reports/Vendor Name/PO 12345 Service Report.pdf

 

What I'd like to do is have Flow compose an email and enter the subject with dynamic content dictated by the "Vendor Name" above from the file path. Also, I'd like to use the filename (without extenstion) as an output for use later in the flow This would look something like:

 

Subject: (filename) from (Vendor Name)

Body: Please see the attached (filename) from recent attendance by (Vendor Name). Thank you.

 

I assume that extracting this information would use some combination of the compose function with last and split expressions. I've tried many combinations but I cannot get it to execute properly. I also tried to "Set Variable" but that cannot be done at the branch level of the flow.

 

Can anyone assist in this effort?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Using Split Function for Folder Path

 

Hi @Anonymous5 ,

 

Please refer to the following methods to get the data you need.

Note that the Folder Path of the trigger output does not contain filename.

Expression reference:

split(triggerBody()?['{Path}'],'/')
last(take(outputs('Compose'),sub(length(outputs('Compose')),1)))

Image reference:

21.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
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

6 REPLIES 6
Highlighted
Super User
Super User

Re: Using Split Function for Folder Path

@Anonymous5 

Please see my screen shot below.

The output of the Get Vendor Compose action will give you the vendor.

The output of the Get Filename Without Extension will give you the file name.

I could have combined the first two actions into a single action with the following expression: split(body('Get_file_properties')?['{Path}'],'/')[3]

ParsePath.jpg

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Anonymous5
Level: Powered On

Re: Using Split Function for Folder Path

Hi Scott,

 

Thanks very much for the guidance. I have been incorporating your suggestions and I feel I am very close to what I need. Since I am already getting the file properties at the initial trigger I am using the following to split out the folder path:

 

split(triggerBody()?['{Path}'],'/')

 

This is working and produces an output of each portion of the filepath listed in order as the output. Using the second "compose" expression to grab the 5th (in my case) item did not work. Trying to combine the bracketed number at the end is NOT working and creates a blank input and output. 

 

split(triggerBody()?['{Path}'],'/')[5]

 

Ideally, I'd like to use the "last" feature to go after the final folder name. I've tried a few combinations of last(split(...)) but still no luck. On top of that, the split feature that is working produces a list of folder names all surrounded by quotes with the last one being "". My fear is that if the "last" feature works it will just produce an empty output.

 

I know this is long-winded but I'm hopeful that I'm very close to getting it figured out with a little more help. 

Community Support Team
Community Support Team

Re: Using Split Function for Folder Path

 

Hi @Anonymous5 ,

 

Please refer to the following methods to get the data you need.

Note that the Folder Path of the trigger output does not contain filename.

Expression reference:

split(triggerBody()?['{Path}'],'/')
last(take(outputs('Compose'),sub(length(outputs('Compose')),1)))

Image reference:

21.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
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

Super User
Super User

Re: Using Split Function for Folder Path

@Anonymous5 

The folder path from my post above looks like this:

ParsePath/MyJobSite/Service Reports/My Vendor/

 

The output of my split expression from my post looks like this:

[
"ParsePath",
"MyJobSite",
"Service Reports",
"My Vendor",
""
]

 

As you can see, the vendor folder, although it is the last folder in the path is not the last item listed.  As a result, the last() expression will not work.

Also, the elements in the array are zero based - the first element is element zero.  Therefore, I need to refer to element 3 to get the vendor folder:  split(body('Get_file_properties')?['{Path}'],'/')[3]

 

If the folder depth will vary, you'll want to use the solution provided by @v-bacao-msft 

 

 

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Anonymous5
Level: Powered On

Re: Using Split Function for Folder Path

Hi Scott,

This is great information thank you. I’m always learning working with Flow. It seems like another way to accomplish the same goal. I suppose this could also be considered a solution.
Anonymous5
Level: Powered On

Re: Using Split Function for Folder Path

Hi Barry,

Thank you! This has solved my issue.

Rgds,
Rob

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 319 members 1,692 guests
Please welcome our newest community members: