cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Nintex Newbie

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

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

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.

Labels: (1)
0 Kudos
Reply
2 Replies
Highlighted
Nintex Newbie

Re: Count of Number of Attachments? Does the JavaScript solution still 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);
}
0 Kudos
Reply
Highlighted
Nintex Newbie

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

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.

0 Kudos
Reply