Skip to main content
Nintex Community Menu Bar
Solved

Validation Rule - Attachments, Checkbox, and Textbox

  • October 28, 2024
  • 4 replies
  • 57 views

Forum|alt.badge.img+1

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")[0].id)).data('controlid'))

}
Textbox Validation

 

and(MFO_Spec_Exception, isNullOrEmpty({Self}))

 

Attachment Validation

 

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

Best answer by BobR

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

View original
Translate
Did this topic help you find an answer to your question?

  • October 29, 2024

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

Translate

Forum|alt.badge.img+1

thank you for the explanation, it was very helpful.

Translate

Forum|alt.badge.img+1

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.

Translate

  • November 4, 2024

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.

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings