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

Folder Path in function

Hi

 

Have a library where users will drop a file.

The folder name will include a number in the end and I want to extract that number and use it in a link to an item in a list where the ID is that extracted number.

 

In Power Automate I have this line:

   <strong>Folder:</strong> <a href="https://tenant.sharepoint.com/sites/sitename/@{triggerBody()?['{Path}']}">Link to folder</a><br>

 

Sample link from above:   https://tenant.sharepoint.com/sites/sitename/libraryname/foldername-93 

 

Now I want to extract "93" from folder name which is "foldername-93" and use that number to create a link to a list item with ID=93.

 

So question is, how do I extract "93" which is a part of the folder name?

 

The link I want to build should be something like this, which for now doesn't work. I don't get that "93" - it's blank:

 

Link to list item: <A href="https://tenant.sharepoint.com/sites/sitename/Lists/listname/DispForm.aspx?ID= @{first(split(last(split(concat(triggerBody()?['Folder path']),'[')),']'))}">Link to item</a>

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User
Super User

Re: Folder Path in function

@NMLM  to get 93 number please use this expresion

 

last(split('YourPath-93','-'))


Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

View solution in original post

Highlighted
Advocate II
Advocate II

Re: Folder Path in function

Fixed that, this works:

 

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

View solution in original post

6 REPLIES 6
Highlighted
Super User
Super User

Re: Folder Path in function

hi @NMLM please could you paste here an example of your folder path?



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Advocate II
Advocate II

Re: Folder Path in function

Added sample link now

Highlighted
Super User
Super User

Re: Folder Path in function

@NMLM  to get 93 number please use this expresion

 

last(split('YourPath-93','-'))


Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

View solution in original post

Highlighted
Community Support
Community Support

Re: Folder Path in function

Hi @NMLM,

 

You could use the '-' as the separator, then use index '1' to get the second member of the return of split() function.

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

Annotation 2020-04-23 110547.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Advocate II
Advocate II

Re: Folder Path in function

That works but I also got a trailing '/' which I don't want. How do I get rid of that? Just want to remove the last character

 

Link ending with "DispForm.aspx?ID=91/" will not load the form, only "DispForm.aspx?ID=91"

Highlighted
Advocate II
Advocate II

Re: Folder Path in function

Fixed that, this works:

 

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

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Top Kudoed Authors
Users online (7,631)