I have a List or Library Control on a Form that links to a Document Library containing word documents, due to filtering there will only ever be one Word Document returned in the Control. The issue I have is that clicking the item opens it in Word Online which does not give our users required functionality. I know that within Sharepoint Admin settings you can set all items to open in client applications this does not work and we have raised this with Microsoft who are aware.
We had this in Forms Designer on related items controls and I used the code below to fix the issue:
$('.ms-vb2 a').click(openQuoteDocument);
// Function to open Quote Document in Word Application
function openQuoteDocument () {
var documentURL = $(this).attr('href');
documentURL = 'ms-word:ofe|u|'+documentURL;
window.location.href = documentURL;
}
I would like to use this same functionality again but its the on ‘.ms-vb2 a’ I need help with I have tried inspecting the table element and cant see what class I would need to use in its place?
$(fd.control("SPDataTable0").$el).find("a").not(".k-link").not(".k-button").click(openQuoteDocument);
// Function to open Quote Document in Word Application
function openQuoteDocument () {
var documentURL = $(this).attr('href');
documentURL = 'ms-word:ofe|u|'+documentURL;
window.location.href = documentURL;
}
Tried that, still the same, I am clicking the document manually a new window opens and the document opens in Word Online.
I tried to debug the function and it is never called on click of document so I think the issue lies in the selector for the .click as opposed to the function itself…
Got that working great; the next challenge is if I use the code to filter the control it stops this function working is there a way of integrating the two functions below: -
fd.spRendered(function() {
$.urlParam = function(name,url){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url);
return results[1] || 0;
}
var dt2 = fd.control('SPDataTable2');
if (dt2.widget) {
filterDT2();
} else {
dt2.$on('ready', function() {
filterDT2();
});
}
function filterDT2(){
dt2.filter = "<Eq><FieldRef Name='QuotationReference'/><Value Type='Text'>" + quoteReference + "</Value></Eq>";
}
fd.control("SPDataTable2").ready().then(function(dt) {
$(fd.control("SPDataTable2").$el).find("a").not(".k-link").not(".k-button").click(openQuoteDocument);
});
// Function to open Quote Document in Word Application
function openQuoteDocument () {
debugger;
var docUrl = $(this).attr('href');
var docName = $.urlParam("file",docUrl);
var docLibraryUrl = "https://**********.sharepoint.com/ERP/Quotation%20Repository/";
docURL = 'ms-word:ofe|u|'+docLibraryUrl+docName;
window.location.href = docURL;
return false;
}
});
I guess it’s happening because of the filter updates the document link after we set the custom click handler, so the solution is quite simple, just try to add a timeout to set a click handler after the filter has finished its work:
Currently, this can be done only with custom code. The example of the code for Word documents is above.
If you are interested in this feature and don’t want to deal with the code, our paid support team can add an option to open all documents in Client Application in Plumsail Forms.
I made my own custom solution, however it appears to be intermittent. It worked yesterday, today all my documents are opening in the browser! I can see that Microsoft have made some changes to their online apps recently could this be something they have changed? I'm using Office 365 SharePoint.