Unfortunately the project was scrapped and worked on by another team so I was not able to implement any of this myself. I cannot validate the solution above works or not. Maybe someone else will use it and validate it.
This is exactly what I'm looking to do. I have the script in form settings > custom js, but when I get no results from a form variable when I add the formula = GetNumberOfAttachments("attCtrl"). "attCtrl" is the class on each attachment control
I have a attachment requirement condition on my form and attached a copy of my form if anyone wants to give it a try.
return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + attCtrlClassName + " .nf-attachmentsRow").id)).data('controlid'))
Step 2: Select the attachments control and create a validation rule like below on the attachments control.
RequestType == "New Badge or Name Change" && GetNumberOfAttachments("this is the CSS Class on the attachment control") <1
My Valadation Rule: RequestType == "New Badge or Name Change" && GetNumberOfAttachments("nf-form-input") <1
It seems your function works for a form validation rule, but not a formatting (hide/disable) rule. I couldn't get it to work with the latter.
I need to hide a field for as long as GetNumberOfAttachments("AttachmentControlClass") < 1. How can we get this to work?
it doesn't matter whether you use the formula/script for formatting or validation rule.
they are evaluated just the same way behind the scene.
check for other possible problems/errors on the form.