Expand my Community achievements bar.

How to force user to upload specific number of attachments?

Avatar

Former Community Member

I have a form where users select checkboxes to attach a document.  I need to script that will compare the number of checkboxs selected with the number of attachments, and pop up an error message if these aren't the same.

Suggestions?

Thanks!

1 Reply

Avatar

Level 10

Hi,

Maybe something along the lines of;


var selectedCheckboxesCount = Subform1.resolveNodes('#field.[ui.oneOfChild.className == "checkButton" and $ == 1]').length;


var attachmentCount = event.target.dataObjects == null ? 0 : event.target.dataObjects.length;


if (selectedCheckboxesCount != attachmentCount)


{


app.alert("Something is missing")


}


Line 1 assumes all your checkboxes are in a subform called Subform1 and that they have the default value for true (which is 1), you may need to change these two things.

Regards

Bruce