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

Notifications

Announcements

Community site session details

Community site session details

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

Get URL of the Site Collection for the Flow?

(0) ShareShare
ReportReport
Posted on 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.  

Categories:
I have the same question (0)
  • Verified answer
    v-bacao-msft Profile Picture
    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
    on at

    This worked, thanks!

  • Community Power Platform Member Profile Picture
    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
    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
    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
    on at

    @Anonymous thank you

  • Community Power Platform Member Profile Picture
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard