cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rsymmons
Resolver I
Resolver I

Link to file to open PDF in SharePoint reader view

I'm using a "link to file" within an approval workflow to try and open a PDF in the SharePoint browser reader. Currently the link that is generated will automatically download the PDF however I want it to open within the browser using the built-in SharePoint PDF reader. Is there a way to achieve this?

 

Thanks,

Rob

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @rsymmons,

 

Can you try this expression instead? Instead of using the FilenameWithExtension this example uses the FullPath for the replacement. Hopefully it now also supports subfolders 😁

 

concat(replace(outputs('Get_file_properties')?['body/{Link}'], replace(outputs('Get_file_properties')?['body/{FullPath}'], ' ', '%20'), split(replace(outputs('Get_file_properties')?['body/{FullPath}'], ' ', '%20'), '/')[0]),'/Forms/AllItems.aspx?id=', replace(replace(replace(outputs('Get_file_properties')?['body/{Link}'], split(actions('Get_file_properties')['inputs']['parameters']['dataset'], '/sites')[0], ''), '/', '%2F'), '.', '%2E'), '&parent=', replace(replace(replace(outputs('Get_file_properties')?['body/{Link}'], split(actions('Get_file_properties')['inputs']['parameters']['dataset'], '/sites')[0], ''), replace(outputs('Get_file_properties')?['body/{FilenameWithExtension}'], ' ', '%20'), ''), '/', '%2F'))

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


View solution in original post

10 REPLIES 10
Expiscornovus
Super User
Super User

Hi @rsymmons,

 

I haven't seen a property for this link in the standard actions. I will have a look later if there is a property in the REST API.

 

I did find a workaround by using the link to item property {link} and using an expression to write it to the format below.

 

It looks like the format of that link direct SharePoint reader view link is:

https://tenantdomain.sharepoint.com/sites/SiteName/DocumentLibrary/Forms/AllItems.aspx?id=%2Fsites%2...

 

Below is an example of that approach.

In this example I reuse the Site Address from the Get file properties action. I also replace the / and . characters by there url encoded ones. That is all concatenated together into a link which should open in the SharePoint reader view 😁

 

 

 

replace(outputs('Get_file_properties')?['body/{Link}'], outputs('Get_file_properties')?['body/{FilenameWithExtension}'], concat('Forms/AllItems.aspx?id=', replace(replace(replace(outputs('Get_file_properties')?['body/{Link}'], split(actions('Get_file_properties')['inputs']['parameters']['dataset'], '/sites')[0], ''), '/', '%2F'), '.', '%2E'), '&parent=', replace(replace(replace(outputs('Get_file_properties')?['body/{Link}'], split(actions('Get_file_properties')['inputs']['parameters']['dataset'], '/sites')[0], ''), '/', '%2F'), outputs('Get_file_properties')?['body/{FilenameWithExtension}'], '')))

 

 

 

linktoitem_inbrowser.png

 

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Ok looks promising thanks for the tip will give it a try! 

rsymmons
Resolver I
Resolver I

Sadly didn't work, I can see the URL composed differently but returned an incorrect URL

Expiscornovus
Super User
Super User

Hi @rsymmons,

 

How is your URL composed? Can you share a screenshot?

 

I might be able to fix/adapt the expression to your situation.



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


rsymmons
Resolver I
Resolver I

Expiscornovus
Super User
Super User

Hi @rsymmons,

 

Thanks for sharing that hyperlink. It looks like your document is located in a subfolder of the Shared Documents library, correct?

 

Let me have a look how I can incorporate that into the expression.



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


rsymmons
Resolver I
Resolver I

Yes exactly 

 

Shared Documents\Screening\Medical forms\forms waiting approval

Expiscornovus
Super User
Super User

Hi @rsymmons,

 

Can you try this expression instead? Instead of using the FilenameWithExtension this example uses the FullPath for the replacement. Hopefully it now also supports subfolders 😁

 

concat(replace(outputs('Get_file_properties')?['body/{Link}'], replace(outputs('Get_file_properties')?['body/{FullPath}'], ' ', '%20'), split(replace(outputs('Get_file_properties')?['body/{FullPath}'], ' ', '%20'), '/')[0]),'/Forms/AllItems.aspx?id=', replace(replace(replace(outputs('Get_file_properties')?['body/{Link}'], split(actions('Get_file_properties')['inputs']['parameters']['dataset'], '/sites')[0], ''), '/', '%2F'), '.', '%2E'), '&parent=', replace(replace(replace(outputs('Get_file_properties')?['body/{Link}'], split(actions('Get_file_properties')['inputs']['parameters']['dataset'], '/sites')[0], ''), replace(outputs('Get_file_properties')?['body/{FilenameWithExtension}'], ' ', '%20'), ''), '/', '%2F'))

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Bingo! Thanks a tonne, @microsoft take note this is a very USEFUL feature. 

Hello

I have the following link to a document.

https://XX.com/sites/burtonplantods/Other%20Documents/CO-SIS-002%20RSA%20SIS%20Gate%20Rev%205.1.pdf?CT=1667227045995&OR=ItemsView

 

I copied the expression in you reply, but does not work. Please can you help

 

Thanks and regards 

Sooraj

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (1,868)