survey123 automatic based on answer

2225
4
Jump to solution
07-02-2020 12:16 PM
LisaDygert
Occasional Contributor

Hello,

I am creating a survey123 form and am trying to figure out how to accomplish a certain task.  The form will ask the question of which county a feature is in.  Once the county is selected from the drop-down list, I would like the district names and health department names to populate automatically.  There is one district fir any given county and one health department for any given county, but it is more likely that the user will know which county the feature is in than either the district or health department.  

I have already tried setting up calculation and select_one options, but neither of those are working.  I am not sure if that is a default answer or not.  Basically, I would like the survey to grab data from the list_names in the choices tab so that if they select County A, the survey will automatically know to bring over the district and health department names corresponding to that county in the choices.  Because there is a one to many relationship between the counties and districts, as an example, where there are multiple counties per district, I cannot set it up the normal way of cascading selects.  

Any help at all would be greatly appreciated.  An example is below.

List_name         name         label                        district

county            Johnson      Johnson County         #1

county            Jefferson      Jefferson County        #3

county           Lincoln         Lincoln County            #1

district            #1                First Dept.

district            #3                Third Dept.

In this case, if the user selected Lincoln County, then I would want the district to automatically populate with #1.

Thanks,

Lisa

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ZacharySutherby
Esri Regular Contributor

Hello Lisa Dygert‌, 

I know you had said you tested cascading selects and it was not working but I believe it may work out. If you would like there is a sample in Survey123 Connect if you were to create a new survey and select "Samples" on the left hand side, there is a sample survey called "Cascading Selects" that displays the workflow and functionality. (I have also attached a copy of the XLSFrom to this post too)

An alternative workflow may be to use the pulldata() function to pull district values from a csv file. 

Please use these links for reference: 

https://community.esri.com/groups/survey123/blog/2016/10/27/the-pulldata-function-access-external-da... 

Formulas—Survey123 for ArcGIS | Documentation 

As for the 1:M relationship between counties and districts is the schema for the service already created? Meaning are you creating a survey based on an existing feature service that has this relationship set up or are you creating the schema from the XLSForm and creating a hosted feature service when publishing the survey? 

Thank you, 

Zach 

Thank you,
Zach

View solution in original post

0 Kudos
4 Replies
ZacharySutherby
Esri Regular Contributor

Hello Lisa Dygert‌, 

I know you had said you tested cascading selects and it was not working but I believe it may work out. If you would like there is a sample in Survey123 Connect if you were to create a new survey and select "Samples" on the left hand side, there is a sample survey called "Cascading Selects" that displays the workflow and functionality. (I have also attached a copy of the XLSFrom to this post too)

An alternative workflow may be to use the pulldata() function to pull district values from a csv file. 

Please use these links for reference: 

https://community.esri.com/groups/survey123/blog/2016/10/27/the-pulldata-function-access-external-da... 

Formulas—Survey123 for ArcGIS | Documentation 

As for the 1:M relationship between counties and districts is the schema for the service already created? Meaning are you creating a survey based on an existing feature service that has this relationship set up or are you creating the schema from the XLSForm and creating a hosted feature service when publishing the survey? 

Thank you, 

Zach 

Thank you,
Zach
0 Kudos
LisaDygert
Occasional Contributor

Thanks Zach,

I was able to get it to work, but I had to do some tweaking of the choices and how they were set up.

I have a question now regarding null values in the csv file I am using for the pulldata command.  There are list of email addresses in different field names, depending on what role the person has.  In many cases, the fields are null values when there is no one who holds that role for that given feature.  I would prefer to have the note to only display if the value for that feature is not null.  Is there a way to do that and should that go into the relevant field or someplace else?

I have tried using the string-length({AdminEmail})>0 and I get an error.  It doesn't seem to recognize the AdminEmail since it isn't a field in the 'name' column of the survey.  Is there a way to create a condition that will only display the note if the value in the external csv file is not null?

Thanks in advance for any assistance with this?

Lisa

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hello Lisa Dygert‌, 

I think the quick answer would be to create a hidden question above the note that uses the pulldata() function to return the email address. You can then try string-length(${hidden_question})>0 in the relevant column. If you don't want the email stored in the Feature Service you can set the bind::esri:fieldType to null and a field wont be created and the data will only be used temporarily in the form. 

That is correct the relevant column would be the location to place the expression. 

If possible would I be able to obtain a copy of the survey folder for testing on my end? If you don't feel comfortable passing it along on GeoNet feel free to pass it along to my Esri email ZSutherby@esri.com

Thank you, 

Zach 

Thank you,
Zach
0 Kudos
Jing_Sun
Esri Contributor

Hi Lisa,

I would also suggest the pulldata() function like Zach mentioned.

One thing I would add is to put the calculation statement in the 'calculation' column instead of the 'default' column for it to work.

Cheers, 

Sun

0 Kudos