Skip to main content

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.

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

}

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.


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.


Reply