pulldata @json to query Feature Service; Need help with security token

3755
12
01-07-2019 12:38 PM
AndrewHargreaves2
Occasional Contributor III

Hello Survey123 for ArcGIS‌ Team

I'm attempting to use the example given in the Custom pulldata() JavaScript Functions

here. However, I'm struggling with how to request a security token. Here's my setup:

  1. I query a Feature Service for a particular feature ID using the below:

    var url = "https://services1.arcgis.com/xxxxxxx/arcgis/rest/services/xxxxxx/FeatureServer/0/query?where="

    +"FACILITYID+%3D+%27" + ID +"%27"
    +"&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=*&returnHiddenFields=false&returnGeometry=true&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token=BIG OLD SECURITY TOKEN"
  2. The above URL works great, and returns a JSON object for the desired feature that I can parse out and populate various fields within my Survey. However, I got that URL from experimenting with the Service URL query function. Because I was logged into to AGO when doing that I got a security token as part of the URL.

However, now I'm struggling with how to go about adding in a token request to my JS script. So:

  1. Is there a way to register this app in order to follow these steps?
  2. Or, is there a method to pull a users password (I know there's one for username)? 
  3. Or, the example given in the Custom pulldata() JavaScript Functions here includes the below. However, there's no further documentation on how I use the 'token' property to pull a token:

"Sometimes, particularly when using JS to access web services and secure ArcGIS services, you may need some properties that are not available through standard XLSForms. For this reason, we have also extended the collection of properties you can obtain through property() function as follows:

property('propertyname')

  • portalurl
  • token

..."

Any help would be greatly appreciated.

Jake Skinner

12 Replies
CarlosReyes2
New Contributor III

Hi James, 

Are there any updates regarding this? Our Org would like to implement the pulldata JS functionality for one of our surveys and share it with different Orgs. The pulldata JS functionality works for users that are native from our Org, but we get the same " "Extension disabled" error for outside users. Any help or update would be appreciated!

Carlos 

Reply
0 Kudos
MikeBruening1
Regular Contributor

This looks very promising for something that I will be attempting to do with one of my surveys. I have one question about the use of this function and it pertains to being offline. If I have a worker out in the middle of nowhere without connectivity to the internet, then will this function still work or is this a function that requires you to be connected to the internet? I am guessing there would be a need to be connected in order for it to work.

Thank you for posting this for other to use.

Reply
0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Mike,

If you are particularly planning to query a feature service, then the JS function will not work without connectivity.

Reply
0 Kudos