Auto select all multiple choice questions

513
4
Jump to solution
09-30-2020 01:57 PM
JordanMiller4
Occasional Contributor III

How can you tell survey123 to auto select all of the choices for a select_multiple field when a field above is answered? This is based off a choice filter. I'll provide my form below, but I'm trying to build a survey where depending on which office, users will be select automatically. Hoping to use this with inbox so that paperwork goes to a group of people. Please let me know if you can help! 

Note* I am using the survey 3.11 beta that allows you to use choice filters on select_multiple choices but is there a way to select multiple choices regardless? Thanks!

Reply
0 Kudos
1 Solution

Accepted Solutions
ZacharySutherby
Esri Contributor

Hello Jordan Miller‌, 

There is likely a simpler way to clean up the calculations, but what I have thought of so far was to add calculate fields that will return users based on the selected department. 

For example: 

if(selected(${department_1},'Engineering ID 1500'),'jim,bob,sally','')

You can then use the calculations in the select multiple question. 

Since there looks like there may be quite a bit of calculations the syntax that I had tested with on the select multiple question was: 

${cal1} or ${cal2} etc. 

I have attached your sample XLSForm with a few modification. Although I will continue researching to see if there is a more efficient workflow to simplify the calculations. 

Thank you,

Zach

View solution in original post

4 Replies
ZacharySutherby
Esri Contributor

Hello Jordan Miller‌, 

There is likely a simpler way to clean up the calculations, but what I have thought of so far was to add calculate fields that will return users based on the selected department. 

For example: 

if(selected(${department_1},'Engineering ID 1500'),'jim,bob,sally','')

You can then use the calculations in the select multiple question. 

Since there looks like there may be quite a bit of calculations the syntax that I had tested with on the select multiple question was: 

${cal1} or ${cal2} etc. 

I have attached your sample XLSForm with a few modification. Although I will continue researching to see if there is a more efficient workflow to simplify the calculations. 

Thank you,

Zach

View solution in original post

JordanMiller4
Occasional Contributor III

This is amazing! Do you know if there's a way to setup inbox to read the choices? 

I know with a single selection we are able to use field=${username} but when you add more like   ", person1 , person 2"

it's unable to read. 

In ArcMap I've used this WORKORDERID LIKE '%20161008%' becuase it's able to find that string but

LIKE '%${username}%' doesn't seem to be a valid expression. Any help would be greatly appreciated!

Reply
0 Kudos
ZacharySutherby
Esri Contributor

Hello Jordan Miller,

You can set the instance name on the settings sheet in the XLSForm to read from your username question.

For example the instance name could read:

concat("Workers: ", ${workers_1}), which will return the string Workers: <choice names from the question>.

We have an enhancement requesting instance names honoring choice labels in the Inbox and Sent box instead of returning the choice name. The enhancement number is ENH-000126922, I would suggest opening a case with Esri Technical Support to attach your customer number to the enhancement that way you will be notified when further updates are available on the request.

Thank you,

Zach

Reply
0 Kudos
ZacharySutherby
Esri Contributor

Hello Jordan Miller‌, 

A workaround for the Enhancement would require quite a bit of calculations, but can be done using the jr:choice-name() function. 

I have attached a sample XLSForm that calculates a hidden question to be used as the instance name. Since the jr:choice-name() function can only take one input the selected-at() function is needed to grab specific choices from the select multiple question. 

For example: 

jr:choice-name( selected-at(${workers_1}, 0), '${workers_1}')

Once those are defined an if() statement can be used to return varying results from the jr:choice-name() calculations. 

For example: 

if(count-selected(${workers_1})=3, concat(${name_0}, "," , ${name_1}, "," , ${name_2}), if(count-selected(${workers_1})=2, concat(${name_0}, "," ,${name_1}), ${name_0} ))

This sample says if there are three selections in the select multiple return all jr:choice-name() calculation fields, otherwise if two are selected return those two labels, otherwise return only the first selection (assuming that only one choice has been selected) or nothing. 

Thank you, 

Zach

Reply
0 Kudos