Solved

Change a List Item Attachment's URL to Include a URI Scheme

  • 30 November 2021
  • 3 replies
  • 172 views

Userlevel 4
Badge +10

Hi Folks,

 

We have a Document Change Request list where an item will have one attachment. Up to now, when a user clicked the attachment to edit it, they would get a pop-up to open the corresponding MS Office client app to make the edit (figure 1). Our organization is in the middle of migrating to M365 and migrated users are now prompted to save the attachment on their device to make the edit while the 2016 users are still prompted to open in the client app (figure 2). The customer wants the original prompt (open in the client app and NOT saving to the desktop) for all users. 

 

Figure 1. Original Desired Pop-Up

20787i6E26E42A1D747820.jpg

 

Figure 2. New Unwanted Pop-Up

20788i79CFE36FE930DAAB.jpg

 

I have determined that I need a URL with the appropriate URI Schema.

 

I think I am at the 80% solution mark with this but do not know an elegant way to execute the change. What I have done so far is to find the attachment URL, determine the file extension, and then use a switch to select the appropriate "scheme-name". I then created the new URL wit schema in a build string action. Now that I have the URL that will get the correct prompt, how do I re-write the existing attachment URL? I thought to add a button to the form that fires the new URL but that is not exactly the solution the customer is looking for. They want the change to be transparent to the user. Any guidance would be greatly appreciated!

 

 

 

Current URL Example: https://SharePoint.MyDomain.com/sites/MySiteColection/lists/DocumentChangeRequest/Attachments/106/MyFileName.docx Desired URL Example: ms-word:ofe|u|https://SharePoint.MyDomain.com/sites/MySiteColection/lists/DocumentChangeRequest/Attachments/106/MyFileName.docx

 

 

 

BTW, Thanks to Vadim Tabakman for the Get Attachment URLs UDA and the Get File Extension UDA that I used in this solution! I have been using them for years in other workflows but I wanted to give the UDA Jedi a shout out!

 

Thanks and Regards,

Patrick

icon

Best answer by nico 5 January 2022, 10:19

View original

3 replies

Userlevel 4
Badge +10

Hi Folks. Have not seen any activity on this so I wanted to bump it up in the feed and call on some of the all-stars to see if anyone has an Idea on how I should proceed. Calling on @MegaJerk@cassymfreeman@kunalpatel, and @nico... Do any of you see a way forward with this?


 


Thanks and Kind Regards,


Patrick

Userlevel 4
Badge +10

Hi,


 


I imagine that your scope is SP 2016 and a Nintex classic Forms.


So, this can be achive with JavaScript.


After the forms is load, a JS will re-write the URL of your attachments


 


Here is the code : 


NWF.FormFiller.Events.RegisterAfterReady(function ()
{
NWF$(".nf-attachmentsTable a").each(function( index ) {
var attachmentLink = this.href;
var lastIndex = attachmentLink.lastIndexOf(".");
var extension = attachmentLink.substring(lastIndex + 1);
switch (extension) {
case 'xls':
case 'xlsx':
this.href = "ms-excel:ofe|u|" + this.href;
break;
case 'doc':
case 'docx':
this.href = "ms-word:ofe|u|" + this.href;
break;
case 'ppt':
case 'pptx':
this.href = "ms-powerpoint:ofe|u|" + this.href;
break;
}
});
});

 

Userlevel 4
Badge +10

Thanks @nico! I will try and implement that.


 


Best Regards,


Patrick

Reply