Hi @jcarlson -
I know this is a few years old, but hoping you might be able to assist. I came across this solution and it looked like it would fit the bill for my problem, however I am experiencing a strange output and am baffled.
Problem: I have a hosted feature layer that is managed via Survey123. One of the select_multiple questions stores codes for each selected subbasin. These codes are not helpful in a pop-up, so I wanted to use Arcade to replace the code with the subbasin name.
I am not getting an error, but the returned values are incorrect when I compare the stored subbasin codes with the reported subbasin names in the pop-up.
My code is:
var basinNames = {
'1': 'Asnebumskit (Mill St)',
'2': 'Asnebumskit (Princeton)',
'3': 'Asnebumskit Pond',
'4': 'Babcock Brook',
}
// and so on - this is a sample of code list, which contains 212 values
var splits = Split($feature.Subbasin, ',')
for(var a in splits){
for(var k in basinNames){
splits[a] = Replace(splits[a], k, basinNames[k])
}
}
return Concatenate(splits, ', ')
For example, one record has stored values in the Subbasin attribute field of: 23,40,44,65. These codes correspond with:
But instead, my returned value in the pop-up is:
Even in a situation where only one subbasin was selected the returned subbasin from the Arcade script is incorrect. In this example, there was only one subbasin selected so the name (from domain label) shows up for "Subbasin(s)" in bottom row (65 = this option) and you can see the incorrect name returned in the first row:
Do you have any suggestions? I will keep working on this, but if you see something please let me know!
Thank you,
Erica