Open Related Document in Client Application

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
TonyDuke
Posts: 71
Joined: Mon Sep 11, 2017

02 Oct 2018

Good Afternoon,

We have a related item view on a display form that displays word documents. We need these word documents to open in the client application as opposed to Word Online. From the Document Library itself they open in the Client Application, but this doesn't seem to pass through to the related item view.
We don't want to download a copy of the file so simply having a HTML Link won't work as the document needs to save back to the SharePoint list...

How can we implement the above please??

Thanks

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

02 Oct 2018

Hi!

Related documents provide the same behavior in part of opening web apps or client apps as regular list views. That behavior can be configured for the whole site collection, not a certain form or related items control.

Please, check this Microsoft Community forum topic: https://answers.microsoft.com/en-us/mso ... a1b?auth=1

User avatar
TonyDuke
Posts: 71
Joined: Mon Sep 11, 2017

04 Oct 2018

Hi Alex,

Unfortunately this does not seem to be the case, our Site collection is set to open documents in the client app, however this functionality only seems to work in I.E and not in Chrome, and due to other restrictions in I.E our users all use Chrome. I do have an open case with Microsoft and they are looking into this, however in the meantime I need a fix for the issue...
What I am thinking is something along the lines of hijacking the link and adding "ms-word:ofe|u|" to the beginning of the URL string to force the document to open in the client app, I just need a little help with the right way of doing this if possible??

Thanks

User avatar
TonyDuke
Posts: 71
Joined: Mon Sep 11, 2017

04 Oct 2018

Hi Alex,

I have resolved this issue with the following code: -

Code: Select all

$('.ms-vb2 a').click(function() {
	var documentURL = $(this).attr('href');
	documentURL = 'ms-word:ofe|u|'+documentURL;
	window.location.href = documentURL;
});
Not sure if you can see any issues with this but it seems to be working ok at the moment...

Thanks

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

04 Oct 2018

Hi!

I'm really glad you've found a solution, great work! It's a tricky issue, I'm sure your solution will be helpful for all community.

andyb
Posts: 25
Joined: Fri Oct 26, 2018

14 Aug 2019

This no longer appears to work for me in Classic Forms Designer, although I'm sure it did at some point (or I'm going mad!).

Can anyone suggest an alternative?

Kind regards
Andy

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

15 Aug 2019

Hello andyb,

Please check how the related items control renders, depending on this you need to use a different element name in the code, as DOM may differ depending on the rendering mode.
render.PNG
render.PNG (8.12 KiB) Viewed 7363 times

If it renders on the client-side you need to use the below code.

Code: Select all

$('.ms-listlink').click(function(){
	var documentURL = $(this).attr('href');
	documentURL = 'ms-word:ofv|u|'+documentURL;
	window.location.href = documentURL;
});
If it renders on the server-side use $('.ms-vb a') in the code.

Note, that to make the code work you need to enable opening documents in client applications in Site collection features. Please see how to enable it in the instructions at Microsoft site.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 24 guests