Skip to main content
Nintex Community Menu Bar

I am working on a validation rule that will be triggered if a checkbox is checked. If checked, either a value will need to be entered in the textbox or an attachment will need to be added. 

 

Currently I have one rule assigned to the textbox control and another to the attachment control.

Ultimately, I want a single rule, but I have not been able to get the syntax correct. The textbox validation works as expected. However, the attachment validation will only activate after the textbox validation.

 

Here is the configuration.

 

Checkbox: MFO_Spec_Exception

Textbox: Spec_Exception_Comments

Attachment: Spec_Exception_Attach (css class attCtrlClassName7)

 

JavaScript:

 

// Spec_Except_Attach

// Spec_Except_Attach

function GetNumberOfAttachments7(attCtrlClassName7)

{

return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#" + NWF$("." + attCtrlClassName7 + " .nf-attachmentsRow")t0].id)).data('controlid'))

}
Textbox Validation

 

and(MFO_Spec_Exception, isNullOrEmpty({Self}))

 

Attachment Validation

 

and(lessThan(GetNumberOfAttachments("attCtrlClassName7"),1), MFO_Spec_Exception)

The and-function normally only accepts two inputs, but you can chain multiple together to create rules based on more than two boolean conditions, as the and-function also outputs a boolean. You can chain them like this:

and(MFO_Spec_Exception,and(lessThan(GetNumberOfAttachments("attCtrlClassName7"),1),isNullOrEmpty(Spec_Exception_Comments)))

You could put this validation rule on the Save button of the form (or Start button if it is a form starting a workflow).


thank you for the explanation, it was very helpful.


I have noticed when testing the attachments check will only trigger after I enter a value in the text box, click save, remove the value and click save again. Do I need to check the order of the validation? The textbox and attachment control are associated with the same rule.


I don’t know about that I’m afraid. Maybe instead of the lessThan(GetNumberofAttachments combination you could try an isNullOrEmpty function on the attachment field instead, I think that might work too.


Reply