Decode Domains in Multiple Choice Answer

210
2
11-08-2021 11:35 AM
BenClark
New Contributor III

Hi all,

I'm racking my brain over how to achieve something and so far I'm not having much luck. I've deployed a survey with multiple choice questions built off of a feature class that uses a few coded domains, the results from which are published to our 10.8.1 Portal deployment. The problem I've run into is that records with multiple selections for a given question don't decode correctly in the associated Portal service, i.e. the coded values are rendered instead of the plain language descriptions. Single selections decode fine, but any field containing more than one CSV domain code stay that way--they don't decode.

I get why this is happening, but I'm curious to know if anyone knows of a workaround to force decoding of multiple values in one field. 

Thanks!

Ben

0 Kudos
2 Replies
DougBrowning
MVP Notable Contributor

No you cannot decode it automatically.  Domains are just 1 to 1 mappings of Val A to Val B.   When you use select multiple the domains have no way to separate out the values as it just looks like a line of text to Arc.  Arc never had anything that stores like that it is a 123 thing.  To Arc A,B,C and B,C,A are totally diff strings.  123 will not create domains at all for select multiple because well it cannot be done.

Storing a comma list like that is always a pain so I try to avoid it and use repeats whenever possible.  But sometimes it does make the form simpler for the user.

Here are some workarounds I have used.

In the form use jr:choice:name to create a comma list of the domain values.  You have to just list the max possibilities and deal with extra spaces or commas.

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}'))

You can then use Arcade to pull them apart by the comma if you need to.  This works well in Ops Dashboard data expressions.  See here  https://www.esri.com/arcgis-blog/products/ops-dashboard/announcements/introducing-data-expressions-i... 

Next you could do it all in Arcade if there are not many.  Would be a big if statement - if Val A return Val B etc.  

The one I use most is post process the values into rows so that there is one row for each value.

Some people do the counting in the form.  So they have if(contains(Val A), 1, 0).  This is a lot of extra fields of course.  I do not use this one because if the value is fixed later on in the web map those calcs will not re-fire and all your counts are wrong.

Also consider not using codes if the data allows.  We had so many things like storing L and D and I just changed to store Live and Dead.  Makes more sense anyway.  Of course select multiple can still not have spaces yet (XLSForms stores with spaces which was not a great design choice).

Hope that helps it is not a easy problem.  Others may have other tricks.

BenClark
New Contributor III

Thanks a bunch, Doug. These are just the kinds of ideas I was looking for. Trying to sort this out myself it quickly became evident that the structure of my survey isn't optimal because of this reason, but I'm trying to improve a legacy tool so unfortunately schema decisions like this are the baggage that I have to carry...

I really appreciate your time. Thanks again!

Ben