Nintex for SharePoint Forum
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Hi
I hope someone can help. I have a requirement to make the attachments control mandatory if one of two number columns >= x number:
IF numberColumn1 OR numberColumn2 >=4 THEN Attachments control is mandatory (a document must be attached to submit the form).
I can't seem to make this work with regular validation rules. Dose anyone have any guidance on how I could achieve this?
Thanks in advance
Harry
Platform: SharePoint 2013 Enterprise On Prem
Nintex version: Nintex Forms 2013 ( 2.11.7.10 )
Solved! Go to Solution.
@harryr You can do this by counting the number of attachments, see my example below:
If Witness equals yes then there must be at least 1 attachment
Validation rule: Witness=="Yes"&&GetNumberOfAttachments("nf-form-input5")<1
JS: function GetNumberOfAttachments(attCtrlClassName){
return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + attCtrlClassName + " .nf-attachmentsRow")[0].id)).data('controlid'))};
Thanks both.
I did manage to get this working using a mixture of other posts and muddling through it.
Step 1. Put this function in the custom JavaScript section in the Settings window.
function getNumberOfAttachments(attCtrlClassName){
return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + attCtrlClassName + " .nf-attachmentsRow")[0].id)).data("controlid"));
}
2. Then on the attachments control, I put in a validation rule that looks at two fields and checks if either (or) has matched a specific value for each:
or(greaterThanOrEqual(DepartmentsInvolved,2), or(greaterThanOrEqual(TotalProjectTeam2,5)) ) && getNumberOfAttachments("nf-form-input") <1
The above condition checks if field:DepartmentsInvolved is more than or equal to 2 or if field:TotalProjectTeam2 is greater than or equal to 5.
Apologies for not crediting the other posts but it was a mish mash of multiple browser tabs and a few nights sleep since then 🙂
Thanks for all the support on this.
I hope this helps someone else. Basically, you can reuse that JavaScript as it is and then assign a rule to the attachments control to check for field values.