JavaScript to query attribute

507
1
04-19-2021 04:25 PM
KerryKang
Occasional Contributor II

Hello all, 

 

I am quite new to JavaScript and ArcGIS REST API and looking for some help on creating JavaScript that works for querying attribute with feature services. I hope to pull out relevant information through hosted feature layer instead of CSV pull data function. I tried the sample with intersect with geometry, but I'd like to achieve this by using attribute values.

 

For example, there is a store database which has store names, address, operating hours and type of store. Once I select store name from the dropdown in the survey, store address, hours, type in the feature layer would be entered automatically. 

 

Kerry

0 Kudos
1 Reply
ZacharySutherby
Esri Regular Contributor

Hello @KerryKang

I would suggest taking a look at the Query feature service/layer documentation as the where parameter in the request is going to be very important when using attribute data. 

 

I've attached a sample that uses the public facing COVID layer to do an attribute query using a Survey123 JS function. The main difference from the sample that is in Survey123 Connect is you don't need to work with the geometry, you can pass in the information for the fields you would like to use for the lookup. For example in the sample passed along we use state and county to extract the record from the feature service. 

Thank you, 

Zach

Thank you,
Zach
0 Kudos