patrickabel
Automation Master
Automation Master

Re: Remove Add attachment option in edit mode

Jump to solution

Hey Sojan Mathew​ – this is definitely doable! If you investigate the above code, you'll notice that I'm using a Nintex driven CSS class to hide the DOM element with jQuery (.nf-attachmentsLink). If you want to do this with a specific attachment controls (or several), you'd just need to look for the same CSS class that also has an ancestor of a custom CSS class you configure.

If you check out the sample below, I've added a custom CSS class (hideMe) and am instead looking for all elements with the .nf-attachmentsLink class that also have an element with the .hideMe class as an ancestor.

NWF$().ready(function() {

  // if the form is in edit mode (mode=1)

  if (window.location.href.indexOf("mode=1") !== -1) {

    // Hide the "add attachments" aspect of the attachments control

    NWF$(".hideMe .nf-attachmentsLink").hide();

  }

});

Good luck to you!

Reply
sojanm
Workflow Veteran

Re: Remove Add attachment option in edit mode

Jump to solution

Hi Patric,

Thanks for the reply, I am not really good in css. Should I give attachment control the "css class" as .hideMe or .hideMe .nf-attachmentsLink

I tried giving both, but it didn't work. My be I am doing something wrong. with .nf-attachmentsLink alone it hide all of them. Or should i creat a custom class in css.

Thanks

sojan

0 Kudos
Reply
sojanm
Workflow Veteran

Re: Remove Add attachment option in edit mode

Jump to solution

Please ignore the reply, it is working. the naming was not correct. Thanks for the help.

Reply
patrickabel
Automation Master
Automation Master

Re: Remove Add attachment option in edit mode

Jump to solution

Oh no problem, I'm happy to help. You can just give it the CSS class of hideMe like the above screenshot.

The leading period in the jQuery syntax just denotes a "class" selector as opposed to an "ID" for the element (which would use a #).

Reply
joshlanl
Forms Fledgling

Re: Remove Add attachment option in edit mode

Jump to solution

Will this work on SharePoint 2013 and a Classic form? I'm trying to do something very similar, except instead of disabling the add/delete attachment options in Edit mode, I want to do so based on a check box. I tried pasting the code from this post directly into the Custom JavaScript box on the form with no alterations  and the form won't open. Am I missing a step? 

 

 

NWF$().ready(function() {

  // if the form is in edit mode (mode=1)

  if (window.location.href.indexOf("mode=1") !== -1) {

   // Hide the "add attachments" aspect of the attachments control

    NWF$(".nf-attachmentsLink").hide();

    NWF$(".nf-default-attachment-control td.propertysheet").hide();

  }

 

});

0 Kudos
Reply