Select to view content in your preferred language

Survey123 calculation - use domain description

1819
8
03-30-2023 08:21 AM
by Anonymous User
Not applicable

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.

8 Replies
Vinzafy
Frequent Contributor

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!

mikaël
Frequent Contributor

More info on how to actually do this.

You domain values have to be in your "choices" tab:

list_namenamelabel
domainA1bla bla 1
domainA2bla bla 2
domainA3bla bla 3

 

Then in the "survey" tab:

typenamelabelappearancereadonlycalculationrelevantbind::esri:fieldType
select_one domainAfield_namefield_namehiddenyes  null
textwhateverdescription yes

jr:choice-name(${field_name}, '${field_name}')

string-length(${field_name}) > 0null

 

DougBrowning
MVP Esteemed Contributor

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.

mikaël
Frequent Contributor

I don't know, good database practices? 😇

0 Kudos
DougBrowning
MVP Esteemed Contributor

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?

0 Kudos
by Anonymous User
Not applicable

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.

0 Kudos
DougBrowning
MVP Esteemed Contributor

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.

0 Kudos
by Anonymous User
Not applicable

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

0 Kudos