Skip to main content
Nintex Community Menu Bar

Count of Number of Attachments? Does the JavaScript solution still work?

  • November 21, 2019
  • 3 replies
  • 183 views

barryc
Forum|alt.badge.img+5

I need to be able to count the number of attachments in an attachment control. There are a few posts in the forum which refer to a JavaScript solution e.g. https://community.nintex.com/t5/Nintex-for-Office-365/Hi-I-am-trying-to-create-a-form-where-the-minimum-attachment-is/td-p/30888

Myself and a colleague have both tried this and cannot get it to work (Classic forms)...I always get a value of zero from the function regardless of the number of attachments.

These posts are all over a year old, I am wondering if something changed? Does anyone have a working solution to count the number of attachments in an attachment control on the form?

I need to be able to do this on the form, even before the first save...so any workflow based solution or settings on the attachment control based on item properties won't work.

Translate
Did this topic help you find an answer to your question?

3 replies

stantond
Forum|alt.badge.img+3
  • 7 replies
  • November 21, 2019

I was able to get the number of attachments by getting everything with the nf-attachmentFileInput class and subtracting 2 to remove empty elements.


let numberOfAttachments = NWF$('.nf-attachmentFileInput').length - 2

If you want to pull out the names of the attachments you can loop through them after.


for(i=0;i <= numberOfAttachments;i++){
console.log('File attachment names in loop',NWF$('.[your attachment control CSS Class] span')[i].textContent);
}
Translate

barryc
Forum|alt.badge.img+5
  • Author
  • 43 replies
  • November 25, 2019

Thanks for the suggestion @stantond . 


However a couple of us have tried this and couldn't get it to work...the numberOfAttachments value never changes regardless of how many attachments are added.

Translate

Forum|alt.badge.img
  • Novice
  • 2 replies
  • April 2, 2024

Has this ever been resolved?  I also need a working solution to count the number of attachments in an attachment control on the form, and do this on the form before the first save.

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings