Hello,
I use several JavaScript functions in my survey to query features layers from the living atlas to auto-populate certain fields in the survey. (i.e. city and county name, etc)
I'd like to also query the NWI layer, which is in the living atlas but is marked as "exclusive content for subscribers". Using the same type of script like I did for the other data returns {"code":499,"message":"Token Required","details":[]}, which makes sense since it requires a login to view the data.
Is there a way to utilize the credentials that were used to login to Survey123 within a script so that I can query this layer?
Thanks in advance for any assistance!
Hi @Katie_Clark If you are using a custom JS function to query a layer, you will need to pass the token from the logged-in user. You can get the token with pulldata("@property", "token") and then use that in your JS logic. The only thing to keep in mind is that if your logged-in user is connecting to ArcGIS Enterprise, the token will not be valid against an ArcGIS Online layer from the Living Atlas of the World.
Alternatively, if you want ArcGIS Survey123 to handle the token business in your behalf, you can try the new Beta pullata("@layer", "getRecordAt") function. You will find more info about this function in the last section of https://community.esri.com/t5/arcgis-survey123-blog/survey123-april-2022-now-available-in-beta/ba-p/...
As with custom JS functions, the pulldata("@layer") functions will not be able to use an ArcGIS Enterprise token against an ArcGIS Online secure layer.
This is great, thanks so much for the response Ismael! I'll give it a try later today.
@IsmaelChivite thank you so much for this! It's working.....for the most part.
Sometimes, the query is successful and it returns the JSON, as intended.
Other times, it returns a 500 error.
Also, on occasion I've had it just return '0' as well.
Are these two errors simply due to the size of the service? I am querying this service specifically in my script.
If it is due to size, is there any method to get around that limitation?