Creating a VIEW ONLY link to SharePoint Office 365 files

Opening files in SharePoint online, all files open in edit mode. This is great when they are your files, but what if I only want to review a document. The view mode is much more desirable. So I set out to find the solution to opening files from a document library in view mode by default.

This is easy enough to do within the document library using JSON formatting in the column.

I am no JSON expert, so I was able to find this solution here.

“$schema”: “”, “elmType”: “a”, “txtContent”: “@currentField”, “attributes”: {“target”: “_blank”,”href”: “=if(indexOf([$ContentTypeId], ‘0x0120’) >= 0, ‘?id=’ + [$FileRef], @currentWeb + ‘/_layouts/15/Doc.aspx?sourcedoc=’+ [$UniqueId] + ‘&action=View’)”

This project did not end there. The next step was linking to the file from PowerApps. By default, the link to the item opens in edit mode. So now I was able to combine the following blog posts to come up with a solution to generate a sharing link that I used in PowerApps and Emails.

I needed to recreate the URL using this format:


Step 1

Get the E Tag -In Power Automate (Flow), the etag property is available, but it has a comma and number at the end. Now what we needed was to remove the parts of the property we didn’t need.

Looking something like this”{xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxx},1″

Step 2

Isolate the etag {} – I followed the instructions in this support post

Add a Compose action, Inputs set to following formula:


Add a Compose 2 action, Inputs set to following formula:


Add a Compose 3 action, Inputs set to following formula:


Add a Compose 4 action, Inputs set to following formula:


Step 3

Create the Sharing Link

Since I was using this link in several places, I decided to create a column on the file properties to hold this link was generated.

Update File Properties – Sharing Link Column

You will need to update your Compose 4 Output with the variable in Power Automate.

https://{tenant}{site}/_layouts/15/Doc.aspx?sourcedoc={{Compose4 Output}}&action=View​

Power Automate

Klarinet Solutions specializes in enhancing system performance, optimizing user experience, and developing a streamlined process supporting business objectives. To find out more about our services or help with O365 PowerApps or Power Automate. Feel free to contact our solutions-delivery team or reach us by phone at (866) 211-8191.

Leave a Reply

Webinar: Is Your Organization Ready for Copilot?
iscover how to embrace the power of Copilot in Microsoft 365 while avoiding the threat to information security, privacy, and compliance.