Validate Multi-Select: Any combination but one

  • 10 October 2019
  • 3 replies
  • 9 views

Badge +2

I have a multi-select field called Funding Sources which has the choices:

Not Required

Other

Capital Request

IT Captial

(Note: there are much more choices than this.)

Valid selections are:

1. Not Required is only selected

2. Any combination of all the choices EXCEPT Not Required

 

I know I could check for every combination with something like:

contains(FundingSources,'Not Required')&&contains(FundingSources,'Other')

but there must be a more graceful way.

 

Thanks for your help.


3 replies

Badge +12

@cmykkid .....There is a much simpler way to do that, below are the steps:

 

  1. Name your choice control on the form ctrl_ch_Funding_Sources
  2. Add another calculated control and name it ctrl_calc_Funding_Sources_Validation. Always hide this control (use 1<2 rule to hide)
  3. Use this formula in above calculated control "If(greaterThan(count(ctrl_calc_Funding_Sources_Validation),1), If(inArray(ctrl_calc_Funding_Sources_Validation, "Not Required"), "invalid", "valid"), "valid")
  4. Now create a validation rule on your choice control:
    1. Condition - ctrl_calc_Funding_Sources_Validation == "invalid"
    2. Message - Please un-check Not Required option.
Badge +2

Excellent Kunal. Nicely written. Thanks.

 

But I believe there's a typo in step 3. The Choice control needs to be targeted. It should be:

If(greaterThan(count(ctrl_ch_Funding_Sources),1), If(inArray(ctrl_ch_Funding_Sources, "Not Required"), "invalid", "valid"), "valid")"

 

Regardless, much simpler and works like a charm.

Badge +12

@cmykkid ....yes it is...sorry....wrong copy and pastein hurry ;)

 

Please mark this solution if it worked for you.

Reply