cancel
Showing results for 
Search instead for 
Did you mean: 
cwentzel
Nintex Newbie

Validation Rule: Conditionally Require User to add Attachment

Jump to solution

Within the Nintex form, I have 4 different attachment fields.  I need to validate before the user hits ‘Submit’, that there is at least one attachment loaded into one of those fields (could be any of the 4 attachment fields), when another field has a specific value.  I believe, after doing some research, that custom JavaScript will be needed to build this validation rule.  Basically, I need to make sure there is an attachment (conditional formatting to make a field required), when a specified field has a specific answer.

Labels: (1)
0 Kudos
Reply
14 Replies
Automation Master
Automation Master

Re: Validation Rule: Conditionally Require User to add Attachment

Jump to solution

have a look on this

https://community.nintex.com/message/42747?commentID=42747#comment-42747 

in your case validation formula might look like

AnotherControl == 'X' && 
(GetNumberOfAttachments('AttControlClass1') +  
GetNumberOfAttachments('AttControlClass2') + 
GetNumberOfAttachments('AttControlClass3') +  
GetNumberOfAttachments('AttControlClass4') < 1)‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
Reply
cwentzel
Nintex Newbie

Re: Validation Rule: Conditionally Require User to add Attachment

Jump to solution

What does 'X' mean in your formula? 

What values do I put in the 'AttControlClass' fields? 

Would that be the names of the attachment controls?

Thank you!

0 Kudos
Reply
cwentzel
Nintex Newbie

Re: Validation Rule: Conditionally Require User to add Attachment

Jump to solution

Sorry, I have a few more things to add.

Where would this rule be put on the form?  I was thinking of encompassing the 4 attachment fields inside a panel and putting the rule on that panel.  Additionally, the requirement of at least 1 attachment is determined based on outcome of 2 other fields.  Would this still work? 

If field A = 'Yes' and Field B = 'True', then there needs to be at least 1 attachment within the 4 attachment fields.

Thank you!

0 Kudos
Reply
Automation Master
Automation Master

Re: Validation Rule: Conditionally Require User to add Attachment

Jump to solution

quite a big homework with so many questions

What does 'X' mean in your formula? 

that's placeholder for your 'specific value' in 'another field'

What values do I put in the 'AttControlClass' fields?

these are CSS class names configured for single attachment controls. class names configured for single controls have to exactly match with ones used in validation formula

Would that be the names of the attachment controls?

controls' names play no role

Where would this rule be put on the form?  I was thinking of encompassing the 4 attachment fields inside a panel and putting the rule on that panel.

in a whatever validation rule.

you can assign the to a panel as you depicted

Additionally, the requirement of at least 1 attachment is determined based on outcome of 2 other fields.  Would this still work? 

sure. you just need to extend validation formula with one another expression

If field A = 'Yes' and Field B = 'True'

be carefull. first of all comparison operator is == (or better ===), single = is assignment operator.

at second, if FieldB evaluates to string "True" then your formula is correct. but if it evaluates to boolean TRUE (eg. yes/no control) do not compare it with string! boolean variable is being used as single expression on it own.

so, your overall formula might look like

FieldA == 'Yes' && 
FieldB &&
(GetNumberOfAttachments('AttControlClass1') + 
GetNumberOfAttachments('AttControlClass2') + 
GetNumberOfAttachments('AttControlClass3') + 
GetNumberOfAttachments('AttControlClass4') < 1)‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
Reply
cwentzel
Nintex Newbie

Re: Validation Rule: Conditionally Require User to add Attachment

Jump to solution

Thank you Marian.

My attachment controls look like the following S.S.

We have predefined CSS Class for different fields.  Each attachment control has it's own name.  If we do not have unique values in the CSS Class field, will what I am trying to accomplish not work?

My complete formula: Major_TH_Project=="Tower Integration Project" &&New_Renewal_Amendment!="Termination"&&(GetNumberofAttachments('CapReqAttachment') + GetNumberofAttachments('MultiReqAttachment') + GetNumberofAttachments('QuoteAttachment') + GetNumberofAttachments('SOWAttachment') >1)

***I also tried the formula using what we do have in the CSS Class field currently.  Neither formula is highlighting the panel as being required when no attachments are included.

Thank you!

0 Kudos
Reply
cwentzel
Nintex Newbie

Re: Validation Rule: Conditionally Require User to add Attachment

Jump to solution

Sorry for multiple responses...I thought of something to try but still no luck.  I removed what was defaulted into the CSS class and added the code onto the panel (same outcome for the fields!).  I then gave each attachment control the unique value below in the CSS Class field.

Current formula: Major_TH_Project=="Tower Integration Project" &&New_Renewal_Amendment!="Termination"&&(GetNumberofAttachments('AttControlClass1')+ GetNumberofAttachments('AttControlClass2')+ GetNumberofAttachments('AttControlClass3') + GetNumberofAttachments('AttControlClass4') >1)

Again, when I make the selections for the first 2 criteria above, the panel in which the validation rule resides, is not indicating it is now required.

Thank you!

0 Kudos
Reply
Automation Master
Automation Master

Re: Validation Rule: Conditionally Require User to add Attachment

Jump to solution

We have predefined CSS Class for different fields.

they are just default (formatting) classes.

you can define as many classes as you need, just separate them by a space.

eg

will what I am trying to accomplish not work?

No.

not with my with my GetNumberofAttachments function.

it's much easier to identify controls by their (unique) CSS class (or by a javascript variable for controls which support it) then by name.

I also tried the formula using what we do have in the CSS Class field currently

they are very generic classes and they are used on plenty of other (type of) controls.

very likely on other type of control formula will fail or cause errors.

Again, when I make the selections for the first 2 criteria above, the panel in which the validation rule resides, is not indicating it is now required.

ops! sorry, my mistake.

sum of all attachments over four controls has to be less the 1 to invalidate form (not greater then 1).

I updated my above formulas.

0 Kudos
Reply
cwentzel
Nintex Newbie

Re: Validation Rule: Conditionally Require User to add Attachment

Jump to solution

Good Morning Marian,

Below is a screen shot of my attachment controls.  Each of the 4 attachment controls are setup the same (but with the number incrementing), so that each has their own unique AttControlClass name.

Below is my updated formula, showing the 4 attachment controls added together are less than 1.

Unfortunately, this rule is still not working.  When I have the first 2 criteria selected within the form, and do not add any attachments, it is not indicating the attachments are required.

Thank you.

0 Kudos
Reply
Automation Master
Automation Master

Re: Validation Rule: Conditionally Require User to add Attachment

Jump to solution

what are 'Major_TH_Project' and 'New_Renewal_Amendment'?

if they are named controls - they should have been highlighted in red. you can not type them in manually, you have to select them from above Named controls list.

0 Kudos
Reply