Javascript examples: working with a feature service...attributes

1211
4
02-17-2022 11:54 AM
PaulPetersen1
Occasional Contributor

Hello,

I am attempting to use pulldata() with javascript to query a nonspatial hosted feature service item and query out an record (and associated attributes) based on an existing value of another data field on my Survey123 form. I've been looking at the Javascript Examples from the Survey123 Connect "samples" library. The example called "Working with a Feature Service" and the featureByLocation script gets me really close to what I need, but I don't need the location functions...just want to pull a record using another attribute (a simple WHERE clause).

Are there any examples of this exact use case someone could point me toward?

Thanks!

0 Kudos
4 Replies
HuubZwart
Occasional Contributor

Have a look at the ArcGIS Rest API documentation for query, this also works for table layers. There are a couple of useful examples at the bottom of the page. Have a look at the outFields parameter as well to specify what attributes you need.

IsmaelChivite
Esri Notable Contributor
PaulPetersen1
Occasional Contributor

Thank you Ismael, this puts me on the right track. I can get the getRecord JS working if I hard-code certain parts of it, but I'm having trouble with the "where" parameter. In particular, it's failing when I use the following:

pulldata("@javascript","QueryFeatureService.js","getRecord",${adminURL},"ISO_CODE='"+${adminISO}+"'",'NAME')

If I just hard-code it as:

pulldata("@javascript", "QueryFeatureService.js", "getRecord",${adminURL},"ISO_CODE='USCO'",'NAME')

...then it totally works fine. So I think I must have something simple messed up in my syntax for that parameter when I try to send an attribute. Any ideas?

0 Kudos
BryanWright
New Contributor III

I've been having the same issue.  Did you have any luck figuring this out?

0 Kudos