I have been looking around for an answer to this question but never really saw something that fit what I was looking for. But I have a survey with a select_multiple question where there are quite a few selections that a user can make. However, in the pop-ups for those features in a web map, the attributes are displayed as the name field rather than the label, and they all run together, not very appealing or user-friendly. See photo attached. This wouldn't be much of a problem if the labels didn't have spaces, which you obviously can't have spaces in the name field.
Is there a way to have the resulting selections show up as the label instead? Otherwise, the survey results have no meaning for my stakeholders and would make the survey userless.
Solved! Go to Solution.
I think I had this come up and what I ended up having to do was this
concat(jr:choice-name(selected-at(${Rash1},0), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},1), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},2), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},3), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},4), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},5), '${Rash1}'))
Basically I used jr:choice-name combined with selected-at then strung those together in a concat up to the max number of choices possible. So if you have a list of 5 you need 5 pairs. If the user only picks 3 options it just gives blanks for 4 and 5. If you have a lot of options its not going to be fun but it did work.
Also note if you wanted say one per line you could use '\n' instead of ' - ' above.
Hope that makes sense.
Easiest way I can think of is an Arcade expression in your pop-up, something like:
var value = "7,6,1,7";
var lookup = {
"1": "Apple",
"2": "Banana",
"3": "Pear",
"4": "Orange",
"5": "Cherry",
"6": "Pineapple",
"7": "Pen"
};
var items = Split(value, ",")
var retval = ""
for (var i in items) {
retval += lookup[items[i]] + ", "
}
return Left(retval, Count(retval) - 2)
Replace that "value" variable with whatever you need to do to get the field. This will involve maintaining the name to label lookup in both the form and the Arcade script.
I think I had this come up and what I ended up having to do was this
concat(jr:choice-name(selected-at(${Rash1},0), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},1), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},2), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},3), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},4), '${Rash1}'), ' - ', jr:choice-name(selected-at(${Rash1},5), '${Rash1}'))
Basically I used jr:choice-name combined with selected-at then strung those together in a concat up to the max number of choices possible. So if you have a list of 5 you need 5 pairs. If the user only picks 3 options it just gives blanks for 4 and 5. If you have a lot of options its not going to be fun but it did work.
Also note if you wanted say one per line you could use '\n' instead of ' - ' above.
Hope that makes sense.
Thank you for the reply I will definitely need to work on this since my code is a bit rusty and unfortunately with this survey I have about 20 options that they can choose from (yikes!).