kelliganp
Scholar

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

Jump to solution

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

Screen 0001.jpg

 

Figure 2. New Unwanted Pop-Up

Screen 0002.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

0 Kudos
Reply
3 Replies
kelliganp
Scholar

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

Jump to solution

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

0 Kudos
Reply
nico
Explorer

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

Jump to solution

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;
		}	  
	});
});

 

View solution in original post

Reply
kelliganp
Scholar

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

Jump to solution

Thanks @nico! I will try and implement that.

 

Best Regards,

Patrick

0 Kudos
Reply