Survey123 Make Rest Queries

716
3
02-06-2020 08:44 AM
roemhildtg
Occasional Contributor III

I'm wondering if this is possible:

We have a project where it would be beneficial to automatically populate several pieces of information from a parcel layer using GPS location. User moves about adding records to a related table using a repeat and for each point, we'd like to capture the Address, and Parcel ID, as well as some other information about the parcel, owner, etc.

To do this, I have  an arcgis server rest endpoint set up that I woudl like to make queries against to populate the values. Is this possible?

I'm imagingin the form would look like this:

begin_repeat Maintenance_Item

Location (point)

Address -> concat(response.features[0].attributes.addr_number, ' ', response.features[0].attributes.street_name)

Parcel ID ->response.features[0].attributes.parcelid

Owner -> response.features[0].attributes.owner_name

end_repeat

I know Javascript extensions are now supported, but what API's are exposed? Is `fetch` an option here? How does async/promise work with Survey123?

0 Kudos
3 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Gregg,

Apologies for the delay in response.  Creating a custom JavaScript function is supported as a beta capability in Survey123; see Welcome to our Customer Validation site. (in the Early Adopter Community).  In your case, you would be using the REST API directly (using JavaScript XHR requests) to retrieve the data.  Survey123 currently models this as a synchronous transfer, not async.

0 Kudos
roemhildtg
Occasional Contributor III

Thanks James. The weather example in the link you posted is super helpful.

So basically, you can do something like this:

```

    xmlhttp.open("GET",url,false);
    xmlhttp.send();

    // handle response data

    return some_result;

```

0 Kudos
JamesTedrick
Esri Esteemed Contributor

That's correct.