I have a document library in SPO where I've used JSON column formatting to display the Name (filename) field as the Title, and clicking opens the document. The JSON has a target of _blank, so docs open in a new tab. PDF files have the expected behavior of opening in a new tab in the browser. O365 documents open a new tab and then the user gets prompted to open in the Client Application. The library is set to "open in browser" as default. "Open in Client Application" is not turned on at the site collection level.
When I look at the "get link" for a document in SPO, it's always link plus a bunch of stuff, and I assume the rest of that stuff is what opens the doc in the web browser. Is there a way to do this programmatically with JSON? Clarification: I want the documents to open in the browser, NOT the client application. I'm getting the opposite result with the JSON below.
For reference, the JSON I'm using is nearly identical to what was posted in this question as a workaround to force opening in the client application: https://answers.microsoft.com/en-us/msoffice/forum/all/sharepoint-online-document-library-not-opening-in/6012959a-d5e5-4e64-8ac0-5cb153317fe4
My code is:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"txtContent": "[$Title]",
"attributes": {
"target": "_blank",
"href": "='[DOCUMENT LIBRARY LINK]' + @currentField"
}
}
I can't find anything in the "Use column formatting to customize SharePoint" article that's specific to how SharePoint opens O365 documents: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting