web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get URL of the Site Co...
Power Automate
Answered

Get URL of the Site Collection for the Flow?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am going to have Flows running on many sites and keeping a separate history of all approvals across all the modern sites.  The flows will run on typical document libraries doing standard-like approvals.  I have it all working, I just need the URL of the site collection.  I've tried expressions to split the URL of a file, but struggling with where to stop.  I just think Flow has to know where it is. 

 

If I peek code at the trigger, I can see it there under parameters called dataset:

2019-04-30_18-30-14.jpg

 

The workflow() expression only dumps info of the environment which doesn't include the site URL.  Anyone know how I can reference this information?  Just seems like it should be easier than this.  

Categories:
I have the same question (0)
  • Verified answer
    v-bacao-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    The site Url cannot be obtained directly through For a selected file.

    Please refer to the method below to get Site Url.

    • Use Get file properties action to get Link to file, then use Folder Path to split Link to File into "Site url+File Name".

    Expression:

    first(split(body('Get_file_properties')?['{Link}'],concat('/',body('Get_file_properties')?['{Path}'])))

    Image reference:

    2.PNG

    Flow run history:

    3.PNG

     

    Please take a try.

     

    Best Regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    This worked, thanks!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi, 

     

    You can achieve the same result by using some of the properties of the SharePoint item like "Link to Item" and "Full Path".

    The formula would be:

    substring("Link to Item",0, length("Link to Item")-lenght("Full Path")-1)

     

    Regards,

    Kailash

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous i am in need of the site url too and i saw your formula but it isnt working for me.  Can you help me fix this?

     

    substring(outputs('Get_file_properties')?['body/{Link}'],0,length(outputs('Get_file_properties')?['body/{Link}']))-length(outputs('Get_file_properties')?['body/{FullPath}'])-1)
     
    It is giving me invalid expression error.
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Anonymous , 

     

    My mistake, I was lazy in posting my last reply and you have some bracketing errors in your expression. *hint: Use Notepad++ to write up the expressions*.

    You cannot use a minus directly in an expression. You need to use sub instead. Your expression after correction should look like this:

    substring(outputs('Get_file_properties')?['body/{Link}'],0,sub(length(outputs('Get_file_properties')?['body/{Link}']),length(outputs('Get_file_properties')?['body/{FullPath}'])))

     

    Regards,

    Kailash

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous thank you

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous I got this to work on the datset value that you mentioned:

     

    trigger()['inputs']['parameters']['dataset']

  • dropack Profile Picture
    9 on at

    Another way to achieve this solution is to use uri functions to construct the site collection Url.   Add the action Compose (Data Operation) to your flow.  Then under the Expression tab, add uriScheme (protocol) and uriHost (hostName) inside a concat function.

     

    concat(uriScheme(triggerOutputs()?['body/{Link}']),'://',uriHost(triggerOutputs()?['body/{Link}']),'/')
     
    ComposeUrlwithUriFunctions.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 813

#3
Haque Profile Picture

Haque 526

Last 30 days Overall leaderboard