I'm using experience builder to allow a user to select a point in a map and complete a survey for that feature. In Survey123 web designer I have set up a a type question that uses a calculation to grab a value from the attribute table. This value uses coded domains. Is it possible to return the description in the survey rather than the code? i.e. when a red point is selected Type returns 1, not red.
Hey there,
This seems like a great case to use the jr:choice-name() function! Details are about 3/4 of the way down in this thread from Ismael:
Survey123 Tricks of the Trade: XLSForm functions for lists
Essentially that function allows you to return the label of the domain instead of the code.
Hope that helps!
More info on how to actually do this.
You domain values have to be in your "choices" tab:
list_name | name | label |
domainA | 1 | bla bla 1 |
domainA | 2 | bla bla 2 |
domainA | 3 | bla bla 3 |
Then in the "survey" tab:
type | name | label | appearance | readonly | calculation | relevant | bind::esri:fieldType |
select_one domainA | field_name | field_name | hidden | yes | null | ||
text | whatever | description | yes | jr:choice-name(${field_name}, '${field_name}') | string-length(${field_name}) > 0 | null |
At that point why not just make the name and label the same? I always do now, no real need for short codes these days.
I don't know, good database practices? 😇
I would argue that having codes and values that are different is bad practice actually. It will drive you nuts for years. I have even seen companies lose what the code values mean. New user training on all these cryptic codes also. Lookups tables and all that junk. Only real reason for codes in the past was quick typing but now with drop downs no real need. In the example above you are just storing the label anyway so why go through all of that?
Looks promising! I should have specified that I am using Web Designer though - we don't use Survey123 Connect at my organization unless there's a good use case for it.
Can you just make the name and label the same? I always do this now. It is easier for everyone to understand and no need for lookup tables. Works better on exports also. No real need to use codes anymore.
The domains in the dataset seem to be set up that way but when I submit a survey response the type field is populated with a number