Survey123 Javascript Function on Public Surveys

3261
8
11-03-2020 12:01 PM
Status: Closed
DanielStoelb
Occasional Contributor III

We are looking at creating a public survey that would pre-populate information based upon user location selection in order to gather and update data on a particular service, similar to the pulldata from another service idea (https://community.esri.com/ideas/12910 ). However, we are wanting this functionality for public surveys for a specific project we're working on as it relates to fire recovery response and pre-pulling data on the backend to populate taxlot information about the property affected.

8 Comments
SFM_WillBrewer

I agree. This functionality would have a ton of applications. I'm a little surprised it has not yet been implemented.

DanielStoelb

FYI - this has been logged as an enhancement: 

  • ENH-000135167: Enable JavaScript function on public surveys. Use the Survey123 pulldata from an existing feature service option for public surveys. 
JeffMay2

Where can we find additional info on this enhancement (ENH-000135167)? Any updates on if/when this capability will be added?

ChelseaRozek

@JeffMay2 At the 2021 ESRI UC, Ismael said that it was not going to be possible due to security considerations. Users will need to be logged in for custom JS functions. They are looking into alternatives. 

StanislausCounty

I think it has more to do with Esri wanting to get users onto their platform with an account and fear of lawsuits rather than 'Security Considerations.' If you've set up your scripts correctly and your data is already publicly accessible there isn't really any security risk for the user.

JamesTedrick
Status changed to: Closed

As mentioned in previous comments, the security team raised concerns with implementing this feature as it can potentially lead to untrusted JavaScript running on a user's device or browser (this was the reason for the original design limitation of requiring a user to be in the same organization as the form's author that currently exists).

PJ
by

Hi @JamesTedrick @DanielStoelb @ChelseaRozek ,

I am using pulldata function (pulldata("@json", ${jsonresponse}, "weather[0].main") ) to pull weather data from https://home.openweathermap.org/.

I plugged the weatherkey code (32 characters) into the default field in the Survey123 form to pull weather data. Its working fine in survey123 app but its not working on Survey123 website. I changed the survey from Public survey to private, still no luck. 

I will appreciate if you could help me.

Here are the screen shots 

PJ_0-1649172865593.png

 

 

PJ_1-1649172865732.png

 

PJ_2-1649172865666.png

Thanks

StanislausCounty

We've run into this a couple of times; use the inspect tool in your web-browser to see what, if anything, is failing. When this has happened to us it had to do with how tokens were being handled or how the attribute names were entered. In the attribute case the names had to exactly match the attribute column names and not the alias (e.g. exact capitalization). For whatever reason the app was able to tell what we were referencing but the browser version was not.