Select to view content in your preferred language

Populating text field from geopoint location

182
2
07-31-2024 11:59 AM
NateExley
New Contributor II

I am using Survey123 Connect.

I'm creating an APPA Audit form that our janitorial manager can use to audit space cleanliness. I'd like the form to populate the Building Name and Room# fields from the point he selects in the geopoint field. The closest syntax I've found that comes to this functionality is:

pulldata("@layer", "getRecordAt", "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Time_Zones/FeatureServer/0", ${location})

My understanding is that the "@layer" is the layer in the web map where the required data (building name, room#) lives, the "getRecordAt" is the field within that layer to query, the url is the ArcGIS online link to the web map, and the "${Location}" is the name of the geopoint question where the location is specified.

I've entered the syntax in the "calculation" column of a subsequent read-only text question.

Suffice it to say... what I have doesn't work. So, I've got it wrong somewhere. Anyone know a better solution or where I'm messing this up? 

Much appreciated!

0 Kudos
2 Replies
Jim-Moore
Esri Regular Contributor

Hi @NateExley 

Your syntax is very close. There are two operations you can use with pulldata("@layer") to query a layer by location. These are getRecordAt and getValueAt. The distinction is that getRecordAt returns the whole record as JSON (that is, all attributes for the first match the query gets); so you would need to use one or more subsequent pulldata("@json") calculations to retrieve the exact values you want. On the other hand, getValueAt allows you to skip the pulldata("@json") step and get straight to the exact attribute you want. 

So getRecordAt is useful if you want to run the query once, but retrieve multiple attributes; whereas getValueAt is useful if you just want to retrieve a single attribute.

In your case, if you want to retrieve both the building name and room number from a record in the same layer, you could either:

  1. Run pulldata("@layer") with a getRecordAt operation, then use two pulldata("@json") calculations, one for each value; or
  2. Run two pulldata("@layer") calculations with a getValueAt operation - one calculation for each value.

The difference is, with option 2 you're running two queries against the feature layer, whereas with option 1 you're only doing the query once. 

Note the syntax is slightly different for getValueAt because you also have to supply the attribute you want.

This blog post has heaps of useful tips. The Query a feature layer section of the documentation has lots of great information too.

Hope this helps, Jim

0 Kudos
NateExley
New Contributor II

Thank you, Jim. I ended doing that and it worked! How could I get this to work for point feature classes? From what I'm finding, this only works when the given geopoint is within a polygon feature - I have a tree survey that is point data only and I'd like to use this same function to populate tree's common name and physical tree tag#.

For anyone else reading this in the future, I finally found another forum article that addressed this question too. Jim, you were right on the money. https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-laye...

0 Kudos