Skip to main content
Nintex Community Menu Bar

Just wondering if there is way to remove the Add Attachment option from attachment control in edit mode. I have tried disabling the control but that also, removes the option to view the attachments. I am just wanted to remove option to add more attachments once form has been submitted.

Hello Abhi Pathania​,

I just built a sample form to test out the attachments control and don't see an OOTB means of accomplishing what you're needing. However, you can control the presence of the "add attachments" button through CSS. Here's a quick example on how you could do this:

.nf-attachmentsLink {

    display: none !important;

}

Building upon this proof-of-concept, you could instead use some JavaScript which checks to see if you're in "edit mode" and then changes the display of that "add attachments" button conditionally. With the below code, you can now remove the ability for additional attachments to be added when in edit mode without impacting the behavior of the control while in new/display mode.

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

  }

});

Good luck Abhi Pathania!

Patrick

FYI, I believe there's several ways to determine what mode your form is in but I went this route since I built my test in an O365 environment.


Hi Patrick

Thanks for your response. JS worked like a treat. Would you also be able to advise, if I can also hide the "delete" option.

Thanks


Yes sir – you can do this as well once you know which CSS class to hook into... Here's the code needed to hide the delete button in tandem with the "add attachments" button while in edit mode:

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

  }

});

The only way I could see to access the delete button was the .propertysheet class, but since that's likely not unique to the attachments control I made sure to look for td.propertysheet DOM objects within the .nf-default-attachment-control class to minimize the risk of impacting other controls.

Good luck Abhi Pathania!

Patrick .nf-default-attachment-control td.propertysheet


Perfect! Thanks a lot Patrick


not a problem, happy to help!


Hi Patrick

Not sure if you can help me with this as well. I am trying to hide Print to Pdf button from the tool bar. Any suggestions?


Good Morning Abhi Pathania​ – Off hand, I'm not sure of a good way. I provided Cassy Freeman​ with a similar ribbon altering solution​, but that was outside of Nintex on the SharePoint list itself. After investigating the CSS briefly, I'm not sure a similar solution could be leveraged.

I see Print to PDF configuration in Settings but these relate to size/orientation and not overall inclusion of the feature.


I agree, even I was unable to find anything in settings. Thanks anyway


Hi Patrick,

Is there a way to show/hide some attachment control, I have 5 attachment control. I just need to remove the add attachment only for two.

Thanks,

Sojan


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!


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


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


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 😵.


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



  }



 



});


Reply