Select to view content in your preferred language

Pulling data from layer and matching it with prepopulated question in survey 123

246
4
Jump to solution
a week ago
MariaSlowik
Emerging Contributor

Hi everyone. I am trying to build a Survey with pulling data from the layer which will be related to the prepopulated value in the previous question. I will describe what have I done so far: 

1. Created arcade expression to intersect applications layer with school catchments layer, this contains codes and names of schools. When the polygon is clicked on the map arcade gives me Seed_Code for each school which intersect with it. I can have as many as 11 of them. 

2. Arcade send coma separated values to the survey 123 (Seed_Codes). I have tried pull names, but they are too long for parameter, so that didn't work. 

3. The Seed_Code question in survey 123 is populated with all of the seed_codes, then I use "selected-at(${catchments_field,0)" to separate each code. That works as well. 

4. This part doesn't work. I would like to pull school name from the Catchment layer and match it to the Code I already have in a Seed_Code question, but it doesn't populate it. I don't get an error, but the field is blank if I have Seed_Code question populated. (Survey is launched from the pop up window with arcade expression.)  If I run the survey as a free stand it does populate school name. not sure how. but the name is there. Seed_Code is blank as there is no parameter then coming from the arcade.  I think it's random. I use this in calculation: pulldata("@layer","getValue","attributes.Name","https://services2.arcgis.com/.....FeatureServer/1",${seed_code})

Any ideas what am I doing wrong? 

thank you,

Maria 

0 Kudos
1 Solution

Accepted Solutions
Neal_t_k
MVP Regular Contributor

If I am reading correctly you need a where clause, not just referencing the seed code. Something like:

helper field:

name:  whcl     calc:  concat("seed_code=", ${seed_code})   (may need quotes around seed_code if it is a text field)

then do your pulldata:

pulldata("@layer","getValue","attributes.Name","https://services2.arcgis.com/.....FeatureServer/1",${whcl)

View solution in original post

4 Replies
Neal_t_k
MVP Regular Contributor

If I am reading correctly you need a where clause, not just referencing the seed code. Something like:

helper field:

name:  whcl     calc:  concat("seed_code=", ${seed_code})   (may need quotes around seed_code if it is a text field)

then do your pulldata:

pulldata("@layer","getValue","attributes.Name","https://services2.arcgis.com/.....FeatureServer/1",${whcl)

abureaux
MVP Frequent Contributor

This. pulldata(@layer) is the best way to do this.

Here is the blog post: Survey123 Tricks of the Trade: pulldata("@layer")

Depending on the use-case, you can also go with a CSV and pulldata from that rather than a separate layer. Better for offline use.

MariaSlowik
Emerging Contributor

Thank you. I have tried csv but we need this to be up up to date. The solution from  Neal_t_k worked perfectly! and it was so easy! 

0 Kudos
MariaSlowik
Emerging Contributor

Thank you. It worked! 

0 Kudos