I am trying to open a document in MS Word desktop (like the online version of viewing MS Word can). This is possible by applying a prefix to the document URL on MS Teams. My code in the page already works good:
var docUrl = await request.$context.PDS_UsrColumn1_u8ye1ig;
const wordUrl = `ms-word:ofe|u|${encodeURIComponent(docUrl)}`;
But using the wordUrl variable on a Webinput field, or even a button.click event doing a window.location.ref always results in Creatio still encoding the Url. Creatio always adds the console message:
Launched external handler for 'ms-word:ofe%7Cu%7Chttps%3A%2F%2Fcompany.sharepoint.com%2F%yadayadayada
where it should be ms-word:ofe|u|https://
Does someone know how to bypass the encoding for a specific handler or for this page?
Like
Can you share the complete handler code and explain how have you disabled the "To protect you from unsafe content office has blocked opening this file" error message?
Sure, here is the handler. It already opens MS Word, but because of the safe url encoding it won't open the correct document...
handlers: /**SCHEMA_HANDLERS*/[
{
request: "usr.PushButtonRequest",
/* Implementation of the custom query handler. */
handler: async (request, next) => {
this.console.log("Button Open in MS Word pushed...");
var docUrl = await request.$context.PDS_UsrColumn1_u8ye1ig;
const wordUrl = `ms-word:ofe|u|${encodeURIComponent(docUrl)}`;
// scenario 1: use window.location.href
//window.location.href = wordUrl;
// scenario 2: use the online found solutioon to add a link with a click
const link = document.createElement('a');
link.href = wordUrl;
link.target = '_blank';
link.rel = 'noopener noreferrer';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
this.console.log("MS Word Url set to: " + wordUrl);
/* Call the next handler if it exists and return its result. */
return next?.handle(request);
}
},
]/**SCHEMA_HANDLERS*/,
Bas Kroes,
well I get the same URL in both cases (using a regular text field and the web link input) and in both scenarios I get this popup:
Maybe I am testing in the wrong manner?
Bas Kroes,
I am testing in Chrome, but I get the same error in Edge.