“I’d like to send a link to the whole folder with the newly created file, how can I get such link with Power Automate?”
If you trigger flow on a new file in a SharePoint library, you probably send a link to this file in some message, whether it’s a Teams message or an email. The link is hidden under the ‘Link to item’ dynamic content and that’s all you need. Just one dynamic content. But what if it’s not just about the single file? If the users should know about all the other files in the same folder? How do you build a link like that?
Start with the Folder path
There’re two dynamic contents related to the file location – Full Path and Folder path.
Full Path will give you the path to the file on the specific site, including the file name, e.g.
Shared Documents/PDF files/Subfolder/file.pdf
Folder path will give you the same, excluding the file name, e.g.
Shared Documents/PDF files/Subfolder/
…and that’s where you want to start. But it’s only the start as you can see that it’s missing the url of the SharePoint site.
Add the site url
Since all flows are bound to a SharePoint site, you can hardcode that site in the url. Use the concat(…) expression to combine it with the folder path.
concat('https://xxx.sharepoint.com/sites/siteName/', triggerOutputs()?['body/{Path}'])
Replace the spaces
Depending on your usage of the link there might be one more thing to do. If you send it as a plain link, it’ll end the url with the first space.
To turn it into a whole link you must get rid of the spaces. Add one more expression around the concat(…) to replace(…) each space with the %20 character (an url representation of a space).
replace(concat('https://xxx.sharepoint.com/sites/siteName/', triggerOutputs()?['body/{Path}']),' ', '%20')
Once you replace the spaces you’ll get a fully working (and clickable) url.
Summary
While Power Automate doesn’t give you a direct link to a folder with a specific file, you can build it yourself. Take the SharePoint site url that’s fixed, add the folder path, and replace the spaces. That’s it, you just built a direct link to a folder with that specific file.
Thank you for your post.
It helped me a lot and saved a tone of time!
I used the manual trigger of a document to start an approval process.
Therefore, I needed to save the URL in a Sharepoint-List.
I just used the expression concat(‘https://xxx.sharepoint.com/sites/sitname/’, — dynamic conent — )
The “dynamic content” was selected and inserted with the mouse-click. The input for the “dynamic content” I used is called “link to file”.
Best regards,
Max
Good feature, very interesting. In fact I want to link the folder link and list item in sharepoint. The user submits the new item and get also the folder link created in document library,so the approval can see the contain of document to approve by clicking the link in the item instead of using attachment files
Powerautomate handles now the space of link and replace it automatically by %20;
What if the folder is renamed? How can you use Power Automate to update the link?
Hello Stephanie,
you can’t, sending the link is a one time action. If you rename the file you’d have to recreate all the links and send them to all the users again.
Yet another great tutorial 😊.
Thanks a lot