Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 8kfUBEtILQ9C7LpGP/18lY
Power Automate - Building Flows
Answered

Get URL of the Site Collection for the Flow?

Like (0) ShareShare
ReportReport
Posted on 30 Apr 2019 23:12:41 by

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.  

  • dropack Profile Picture
    9 on 03 Feb 2023 at 14:22:13
    Re: Get URL of the Site Collection for the Flow?

    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
  • Community Power Platform Member Profile Picture
    on 28 Oct 2021 at 10:27:01
    Re: Get URL of the Site Collection for the Flow?

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

     

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

  • Community Power Platform Member Profile Picture
    on 24 Sep 2020 at 16:30:00
    Re: Get URL of the Site Collection for the Flow?

    @Anonymous thank you

  • Community Power Platform Member Profile Picture
    on 18 Sep 2020 at 16:15:59
    Re: Get URL of the Site Collection for the Flow?

    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
    on 16 Sep 2020 at 15:30:04
    Re: Get URL of the Site Collection for the Flow?

    @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
    on 09 Sep 2020 at 14:25:10
    Re: Get URL of the Site Collection for the Flow?

    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
    on 06 May 2019 at 18:49:50
    Re: Get URL of the Site Collection for the Flow?

    This worked, thanks!

  • Verified answer
    v-bacao-msft Profile Picture
    on 02 May 2019 at 02:33:38
    Re: Get URL of the Site Collection for the Flow?

    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,

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 59

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 47 Super User 2025 Season 1

#3
rzaneti Profile Picture

rzaneti 29 Super User 2025 Season 1

Overall leaderboard