Select to view content in your preferred language

Hide option values in a multi select question based on the URL

749
11
11-27-2023 11:50 AM
DarrylKlassen1
Occasional Contributor II

I am creating a Dashboard to track users watching safety videos.  When a user selects a "season" and a piece of "equipment" they are presented with a multi - select that allows them to click which videos on that specific piece of equipment they have watched.  Then they submit the survey.  

Subsequently, in my Dashboard, i am showing this information, but would like to provide them with a link to the survey - with most of the data already filled in.  I have accomplished this using URL parameters, but what I cannot figure out is, if they watched video 1 and video 2 on a certain piece of equipment, how to eliminate those choices on this newly linked URL?  So they can only select videos they have not already watched and acknowledged.

DarrylKlassen1_0-1701114444642.png

As you can see from above in my Dashbord Table - i have a URL created using this syntax:

?field:username=" + f['username'] + "&field:season=" + f['season'] + "&field:equipment=" + f['equipment']
but is it possible to have the Video 1 and Video 2 eliminated from my form as choices when it opens?
 
DarrylKlassen1_1-1701114576201.png

 

Thanks

 

11 Replies
abureaux
MVP Regular Contributor

You should be able to use choice_filter to achieve that.

Excel:
abureaux_0-1701115815894.png

abureaux_1-1701115825453.png

Result:
abureaux_2-1701115835455.png

Just dump a comma delineated list into your hidden field. (EDIT: Do this in place of the "default" column I have above. Don't put anything into "default" when you do this)

EDIT2: I realize that this is technically the opposite of what you are looking for. But using this as a base, you can use either calculates (such as nested IF( ) statements) or JS to achieve the desired reverse outcome.

0 Kudos
DougBrowning
MVP Esteemed Contributor

I have seen people use regex in the choice filter coming from a field like this.  I do not totally get it but it worked.  So you could pass into a field from the URL then use that field in the choice filter.

regex(${SpeciesListJoin}, name)

0 Kudos
abureaux
MVP Regular Contributor

I may be wrong, but I thought that regex(), when used like that, acted like selected().

For example, you can use that same regex() or selected() expression in an IF() statement interchangeably.

All of my older surveys use regex() instead of selected() simply because I found out about regex() first, but I have been slowly updating everything to be selected(). It's probably all in my head, but I feel like selected( )gives me less trouble. Ultimately, I am not sure which is "more correct", but if you are looking to make advanced statements, regex() is probably best, and if you are looking for something simple, selected() is probably best.

For anyone looking for more info on either function, they are both found here.

0 Kudos
DougBrowning
MVP Esteemed Contributor

This is in choice filter not the calculation so it will make the list of choices dynamic. At least I think it did.  Which is what they wanted I think.

0 Kudos
abureaux
MVP Regular Contributor

Check out my screen cap above. I have selected() in the choice_filter as well.

0 Kudos
DarrylKlassen1
Occasional Contributor II

Thanks you for the replies and ideas.  I am still not sure how this applies to my URL parameter.  My original list of videos that are in the "Videos Watched" multiselect question are coming from a CSV - which is generated dynamically, so I don't necessarily know what the values are going to be.  But I have figure this out and populated it with my URL parameters - just not sure now how to filter the "Videos Watched" to not equal a value in the "hide_multiselect":

DarrylKlassen1_0-1701126547644.png

So basically, based on the above, i would like to hide Video 5, 6 and 7 from the choices.

 

0 Kudos
DougBrowning
MVP Esteemed Contributor

You would pass the values from the URL into a string field then give that field to the choice filter.

DarrylKlassen1
Occasional Contributor II

Hi Doug, I don't think I am still fully grasping this concept.  Can you provide a simple example of this?  

DarrylKlassen1_0-1701192106345.png

My URL to populate the image above is suffixed with this: 
https://survey123.arcgis.com/share/{MYAGOLID}?field:hide_multiselect=Video_URL_5,%20Video_URL_6,%20V...

Which populates the "hide_multiselect" text box - but then in my XLS form - the choice filter for the "Videos Watched" question would be 
selected(${hide_multiselect}=hidemultiselect) ??  This doesn't really make sense to me?

 

Thanks

0 Kudos
abureaux
MVP Regular Contributor

Using my example below:

arcgis-survey123://?itemID=xxxxxxxxxxxxxxxxxx&field:s123_field1={database_field1}&field:s123_field2={database_field2}&field:test_hidden={database_field3}

Above, I have three fields (purely for example). One of those s123 fields (test_hidden) is in my example below. All you need to do is have a comma separated list of all the videos they have watched (database_field3).