Select to view content in your preferred language

Survey123 Connect If statement and Pull data

944
12
Jump to solution
07-22-2024 08:40 AM
Ethiopia
Occasional Contributor

Hello everyone. I am having a hard time trying to construct a statement so that the if the point drawn on the map is intersecting the feature layer to pull data from the feature layer if not to select "Not in a priority Area" from the choice field. Please help I am not knowledgeable in coding or connect

if (
within ( pulldata("@layer", "getValueAt", "attributes.Name", "https://services2.arcgis.com/sBoGufkdR7jFytOm/arcgis/rest/services/shedMap_WFL1/FeatureServer/8", ${Location_of_Project}, "")), "Not in a Priority Area"
)

0 Kudos
2 Solutions

Accepted Solutions
Ethiopia
Occasional Contributor

Ethiopia_0-1721769061459.png

Ended up breaking it up, and it's working both on web/desktop. I am sure you can make the code much simpler. Thanks, abureaux and Doug!!

View solution in original post

DougBrowning
MVP Esteemed Contributor

Sorry must not be saying it right.  As posted above simply move pulldata to its own hidden field.  Then the rest of your code if(${FieldWithPulldataInIt}, etc, etc) in your final field.  Clear now?

View solution in original post

0 Kudos
12 Replies
DougBrowning
MVP Esteemed Contributor

Pulldata does not work well inside an if.  Move it out to a temp field and then check that in the if.

Ethiopia
Occasional Contributor

Thanks for reply Doug! I wish I was able to get an auto populate if a feature does not intersect with a point. 

0 Kudos
abureaux
MVP Frequent Contributor

Doug just means you need to split up the operation. You can still do what you want.

Calculate #1 is your pulldata(@layer)
  E.g., pulldata("@layer", "getValueAt", "attributes.Name", "https://services2.arcgis.com/sBoGufkdR7jFytOm/arcgis/rest/services/shedMap_WFL1/FeatureServer/8", ${Location_of_Project}, "")

Calculate #2 is your IF statement.
  E.g., if(${pulldata_calc}='','Not in a Priority Area',${pulldata_calc})

Not saying these calculates are correct. They are just examples. This is generally what you'd be looking to do.

Ethiopia
Occasional Contributor

Thank you for your help! I was able to get it to work. I used two calculation fields and it worked perfectly, but I ended up combining it. 

0 Kudos
abureaux
MVP Frequent Contributor

Glad you got it working!

Going back to what Doug already said though, sometimes pulldata doesn't like being nested within IF() statements. If it is working for you, great. But if it starts acting odd, consider breaking it out the steps into separate calculates.

Good luck.

Ethiopia
Occasional Contributor

Ethiopia_0-1721769061459.png

Ended up breaking it up, and it's working both on web/desktop. I am sure you can make the code much simpler. Thanks, abureaux and Doug!!

DougBrowning
MVP Esteemed Contributor

Note this may not work in a web form using that if statement if you use those.

0 Kudos
Ethiopia
Occasional Contributor

It's working so far, hopefully it won't generate errors. Do you have any suggestions if that was the case? 

0 Kudos
DougBrowning
MVP Esteemed Contributor

Sorry must not be saying it right.  As posted above simply move pulldata to its own hidden field.  Then the rest of your code if(${FieldWithPulldataInIt}, etc, etc) in your final field.  Clear now?

0 Kudos