Survey123 Select Multiple Default

137
10
a week ago
JordanHolt
New Contributor III

I have a select multiple list of possible "Pole Issues" , one of the options being "NO_ISSUE". I want to default this to "NO ISSUE" but after any other option is selected the default to be removed. Is this possible? 

0 Kudos
10 Replies
magisian
Occasional Contributor

You can apply a constraint on the the combination of 'no issue' and other answers. This would require the user to unselect the 'no issues' choice before proceeding. The constraint message can also be added to help guide the user.  

Have not tested it but a sample constraint could be something like the below (constraint is not having more than one selection if 'no issues' is selected).

not(selected(., 'no_issues') and count-selected(${issues})>1)

https://support.esri.com/en/technical-article/000020969

https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm#ESRI_SECTION1_8979CBF...

An alternate approach to this scenario is to have two questions and add relevancy:

  • Are there one or more issues?
  • Issues (relevant to issue = yes)

 

Please don't forget the kudos 🙂

JordanHolt
New Contributor III

I appreciate the response! I am trying to eliminate clicks and make it as easy as possible for the guys in the field. This did work but its adding clicks. I went ahead and just removed "NO_ISSUE" from the choices list and will just know moving forward if blank it will indicate "NO_ISSUE".

LaurenceTait
New Contributor III

You can do this fairly easily using javascript.

The script itself is three part process. First convert the answer to a string, then check if the string contains any answers other than "no issue". If there are other answers, delete the "no issues" response and keep the rest.

I've attached an example. The modified answer is currently visible so that you can see the workings of the script. For the final version the "held_condition" field should be set to hidden. The initial question should also be set to "null" so that only the modified answer is saved. 

Because this site won't allow the upload of js files, you'll have to copy the contents of the .txt document into a js function called "Replacefunctions.js".

Katherine_Clark
MVP Regular Contributor

That's an awesome idea, @LaurenceTait , thank you for sharing your wisdom! 🙂

0 Kudos
JordanHolt
New Contributor III

I appreciate all your help! I am still working on making this all make sense. Below is what I have currently and its no working right now. If you see anything thats wrong please let me know! If you need anything further from me or have any follow up questions please let me know!! I really appreciate it!

 

JordanHolt_0-1660175487337.png

JordanHolt_1-1660175536443.png

JordanHolt_2-1660175585969.png

 

0 Kudos
LaurenceTait
New Contributor III

There is a minor glitch in your code at Line 10. Should be const issuesString = issues.join (', '); and you have const issuesString = issues.join ('', ' '); But that won't stop it from working.

What do you mean when you say it's not working? Are you getting an error message in the script compiler, or when you save the xlsx sheet, or something else"

What happens when you test your code? Click the "fx" button on the scripts page, then copy in one or two of your choices from the worksheet, separated by a comma ",". Then click the execute button ">".

script.jpg

I've tried to replicate the sheet and code that you are using, and it works fine. I've attached the files below. Try those and see if you can get them to work, then you can use that as the basis for your own suvey.

If you upload your xlsx sheet and your js code, I'll try it at my end and see if it works. That might be the fastest option.

Cheers.

JordanHolt
New Contributor III

Sorry for the confusion, when I say its not working - When I go to my Pole Issues list and click another from the select multiple, it is not unselecting the "No Issue" that is defaulted. Hope this clears up what I mean. I attached the xlsx and .js below.

 

0 Kudos
LaurenceTait
New Contributor III

Two minor problems.

You have the [relevant] field for [held_condition] set to “false". Any field that is not relevant has the value set to null, so the held condition field can never store any values.

The other problem is that you have only added the first 4 of your 11 issues to your javascript finction, so the function will only work if you select one of those 4. Add all 11 to the function and it will work fine.

JordanHolt
New Contributor III

So what I am seeing is that the "held_condition" is being updated when I select from my "Pole_issues" list. In your initial response you were saying the "held_condition" needed to be hidden and the initial question should be set to "null". What I am not seeing is the initial question with the default set to "no issue" unselecting when I select another issue on the list. I was hoping to default the question to "no issue" so if they crew doesn't find anything they question is already filled out for them, but if they do find an issue and select "hand_hole_cover_missing" it would unselect "no_issue" and only have one of the boxes checked. Sorry for all the questions and confusion on this. I think I am misunderstanding what the script is completing. 

0 Kudos