Enforce a maximum number of checkboxes selected in Form Assembly

Screenshot of checkbox question with wording "Which four..."
September 19, 2019 Form Assembly, Salesforce 0 Comments

Enforce a maximum number of checkboxes selected in Form Assembly

I was creating a form for a client and we wanted to enforce a maximum number of checkboxes (tickboxes) to be selected in a multiple choice checkbox question.

The solution was a bit fiddly so we thought I’d post it here for future reference.  The Form Assembly help page on this contains a good video but I wanted a super quick reference to how to do this in future so created this step by step blog:

Step 1

Create your checkbox question.

An example checkbox question in Form Assembly (which four of the following..."There is no easy Form Assembly functionality to simply tick ‘maximum 4 to be selected’ or something like that so proceed to the next steps.

Step 2

Make your checkbox question a variable and set a number of 1 for each of the options.  When you give your Form Assembly variable a name, remember that you can only use letters and that the name is case sensitive – this is a little annoying to be honest (e.g. a prefix of Q5 has to be QFive) but once you know about this nuance, think about how your naming convention can work.

Screenshot showing Calculations / Toggle This is a Variable / Name it / put a 1 for each option

 

Step 3

Create a text field which will be hidden and in the default value write your error message – we’ll essentially call upon this error message in later steps.  Your settings will look something like this:

Screenshot showing a default message with "Please select a maximum of four", toggled 'This is a variable' with a variable name of "ErrorMsg" and radio button Hidden selected.

 

Step 4

Create a new text field.  Mark it as a calculated field with a formula something like the following – this formula is saying, if the maximum selected checkboxes is greater than 4, then show the error message, otherwise show nothing (this is the colon quote quote end of the formula).

MaxSelectedCheckQFour>4?CheckMaxQFourErrorMessage:””

Set up the Validation rules for this text field so that they can’t submit the form if they’ve selected too many check boxes.  Change the expected input format to custom and paste in the regular expression below into the ‘Validate with a Regular Expression’ box:

/^$/

According to the help video, you can add a Custom Error message for the field here too – although that didn’t work in my example, let me know if it does in yours and if you did something different from the help video.

Also, under Presentation Options, select Remove Label (no space) – note: when you do this your field will look like it’s disappeared even in non-preview mode, so don’t forget it’s there and you need it.

Screenshot showing Expected Input Custom, Regular Expression /^$/, custom error message, toggle 'This is a calculated field' and formula MaxSelectedCheckQFour>4?CheckMaxQFourErrorMessage:""

Step 5

Check your question is working in the Preview screen.

Screenshot of the question in preview mode with the error message showing.

Share:

0 Comments on "Enforce a maximum number of checkboxes selected in Form Assembly"

Would you like to share your thoughts?

Your email address will not be published. Required fields are marked *

Leave a Reply