cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dougallen
Advocate I
Advocate I

Get URL of the Site Collection for the Flow?

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.  

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

Hi @dougallen ,

 

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 Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-bacao-msft
Community Support
Community Support

Hi @dougallen ,

 

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 Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This worked, thanks!

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

 

@KailashK 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.

Hi @skarthanal , 

 

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

@KailashK thank you

Jamsie
Frequent Visitor

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

 

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

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,100)