Survey123 Connect Default Expressions

1381
5
10-17-2018 07:03 AM
KatherinePadilla
Occasional Contributor

Hello,

I was hoping to find out if (hopefully when) Survey123 Connect will support expressions in the default column.  This would be very useful to reduce the cleanup that would need to be done on the back end/feature service.

Thanks!!

0 Kudos
5 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Katherine,

Based on the XLSform specification, default should only be a literal value - not an expression (Survey123 makes an exception for the functions now() and today() ).  Instead of an expression in the default column, you can place it in the calculate column - it will run when the form loads.

0 Kudos
KatherinePadilla
Occasional Contributor

Awesome, this works well with most of the ones I wanted to put a default to.  There are a few others that I cant figure out without adding additional questions and therefore attributes in the feature service (not ideal).  For the time being I will be doing post processing using calculate field.  I have put an image of one example below.  If you have ideas to solve this problem with the same number of fewer questions and no post processing I would greatly receive them.

Calculation that is not working for BIOLOGY:  if(selected(${BIOLOGY_IND},'N'),'None',selected(${BIOLOGY}))

In words the idea of what I would like done: If BIOLOGY_IND was answered N, then populate BIOLOGY field with None, otherwise populate it with what is selected in BIOLOGY (none is not an option in the choice list for BIOLOGY to prevent an answer of none and a type of biology seen for example algae, insect etc.).  The reason for this calculation is so that this one field would contain all the information needed for this one concept.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Katherine,

A formula can't use the question it's in.  Additionally, calculations on select_multiples aren't supported very well at this time, due to the nature of the data (a comma-separated list of choices).  A couple of ideas:

1) You could place 'None' in the BIOLOGY question and have a constraint that looks to see if None is selected along with any other value: not(selected(., 'N') and count-selected(.) > 1)

2) As you mention, you could have additional (calculate/hidden) questions to aggregate the answer.  If so, you could have the bind::esri:fieldType set to null on intermediate questions (the ones that will be aggregated) to prevent having extra fields in the table.

0 Kudos
KatherinePadilla
Occasional Contributor

Thanks for the ideas! Does this mean that select single and multiple now support a null field type. It was my understanding that they were not at this time.

Katie.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Katie,

All questions support the null field type.

0 Kudos