cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Require Single Text Field based on a 'Checkbox Type' Choice field

Jump to solution

Hey Everyone,

     I'm working on a form and I'm running into issues requiring fields. I have one choice field that is set as check boxes. based on which option they select, determines which fields are required. Below you will see that the "Impact" field is the check boxes field I'm referring to. If a user selects "Cost Avoidance" from the "Impact" field it will require the "Initial Cost" and "Final Cost" fields. However, it does not require them if they also select "Labor Savings" in the "Impact" field. How do I require both "Initial Cost" and "Final Cost" fields when both "Cost Avoidance" and "Labor Savings" is selected? Thanks in advance for any help!

 

0 Kudos
Reply
3 Replies
Workflow Hero

Re: Require Single Text Field based on a 'Checkbox Type' Choice field

Jump to solution

I'm not sure I've understood your requirements correctly, since some of them sounds to me to be contradicting...

but let's go step by step

you have to use validation rules to achieve your target.

If a user selects "Cost Avoidance" from the "Impact" field it will require the "Initial Cost" and "Final Cost" fields.

for this requirement validation formula might look like

inArray(ImpactNamedControl,"Cost Avoidance") && (IsNullOrEmpty(InitialCostNamedControl) || IsNullOrEmpty(FinalCostNamedControl))‍‍‍

However, it does not require them if they also select "Labor Savings" in the "Impact" field.

I understand this that it extends previous requirement.

and I understand this that if both "Cost Avoidance" and "Labor Saving" are selected then it doesn't matter what's the content of 'Initial cost" and "Final cost" fields.

combining the two requirements, it means that if one doesn't select "Cost Avoidance" you do not put any requirement on any of the other selections (ie. "Labor Savings") nor any requirements on whether cost fields are populated or not, ie if "Cost avoidance" is not selected, whatever (combination of) state/content of "Labor Savings" and cost fields should be accepted.

further, if "Cost Avoidance" is selected AND "Labor Savings" is not selected AND both "Initial Cost" and "Final Cost" are populated (1st requirement) the form should be accepted as well.

so we're left situations when "Cost Avoidance" is selected AND "Labor Savings" is not selected AND either or both of cost fields are empty - in these scenarios the form shouldn't be accepted and validation error should pop up.

so let's rewrite above into a validation formula, which might then look like

(inArray(ImpactNamedControl,"Cost Avoidance") && not(inArray(ImpactNamedControl,"Labor Saving"))) && 
(IsNullOrEmpty(InitialCostNamedControl) || IsNullOrEmpty(FinalCostNamedControl))‍‍‍‍

How do I require both "Initial Cost" and "Final Cost" fields when both "Cost Avoidance" and "Labor Savings" is selected?

this I understand as a completely different question/scenario since it negates above mentioned requirements.

so for this requirement validation formula might look like

(inArray(ImpactNamedControl,"Cost Avoidance") && inArray(ImpactNamedControl,"Labor Saving")) && (IsNullOrEmpty(InitialCostNamedControl) || IsNullOrEmpty(FinalCostNamedControl))‍‍‍‍‍‍
Reply
Highlighted
Workflow Hero

Re: Require Single Text Field based on a 'Checkbox Type' Choice field

Jump to solution

Ok, to make it clear. I need the "Initial Cost" and "Final Cost" fields to be required when the "Cost Avoidance" option is selected from the "Impact" field. Currently, it will require them if the user only selects "Cost Avoidance". IF the user selects both "Cost Avoidance" AND "Labor Savings", it currently does not require the field (which is not what I want). I am wanting it to require the fields anytime "Cost Avoidance" is selected. So, if you the user selects just "Cost Avoidance" it will require the "Initial Cost" and "Final Cost" fields and it will also require the "Initial Cost" and "Final Cost" fields when they select "Cost Avoidance" AND "Labor Savings". I have tried your rule above and it still does not require the "Initial Cost" and "Final Cost" fields when the user selects both "Cost Avoidance" and "Labor Savings".

Rule used: 

(inArray(Impact, "Cost Avoidance") && not(inArray(Impact, "Labor Savings"))) && (isNullOrEmpty(InitialCost) || isNullOrEmpty(FinalCost))

Reply
Workflow Hero

Re: Require Single Text Field based on a 'Checkbox Type' Choice field

Jump to solution

I was able to get the validation to work by removing the "not" from the 2nd Array statement. Thanks for your help!

Rule used: 

(inArray(Impact, "Cost Avoidance") && not(inArray(Impact, "Labor Savings"))) && (isNullOrEmpty(InitialCost) || isNullOrEmpty(FinalCost))

Reply