cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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

@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

Fixed that, this works:

 

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

View solution in original post

6 REPLIES 6
Super User III
Super User III

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

Added sample link now

@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

Community Support
Community Support

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.

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"

Fixed that, this works:

 

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

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Top Kudoed Authors
Users online (13,092)