I want to understand how to incorporate a JavaScript function into Survey123. I've read this post: CHALLENGE: JavaScript functionality · Issue #144 · tedrick/Survey123-Testing · GitHub and my goal was just to make something really simple. I created the extensions directory inside my survey folder. I created a JS file, MyJSFunctions, with one function:
function lastName(FullName){
return FullName;
}
One of the fields in my survey is FullName another is LastName. In the xlsForm in the calculation column I added:
pulldata("@javascript","myJSFunctions.js","lastName",${FullName})
My expectation is (was?) that when I added data into the FullName field that the function would add exactly the same value into the LastName field. I realize this is not the correct way to take data from one field in the survey and replicate it in another field. I'm just making sure I understand the basic functionality before I tackle something more complicated.
Once I had that set up, I closed and saved the spreadsheet and published the survey.
When I download the survey to my phone and open it the following text is in the LastName field:
Error: Qt.createQmlObject(): failed to create object:
qrc:/var/mobile/Containers/Data/Application/E1C84E25-205E-4EB7-BCB1-983CFB06576F/Documents/ArcGIS/My Surveys/c0e1879901d442cc8b4bbbddc96c1716/esriinfo/extensions:2:1: Script file:///var/mobile/Con
What am I doing wrong?
Thanks,
Sean
Solved! Go to Solution.
The issue is that your file is called MyJSFunctions.js but in XLSForm you are referencing myJSFunctions.js. If you change the expression in the calculation to pulldata("@javascript","MyJSFunctions.js","lastName",${FullName}) is will work well. M != m
JS Functions are still not ready for prime time, hence why we have not officially documented this outside of the Early Adopter Program. Please use Early Adopter Program to report feedback on this particular feature (to avoid confusion). Thanks a lot!
Just some things you should be aware: 1) Every time you change your JS file, you need to re-open Connect. 2) JS Functions only work in the field app. 3) JS functions do not run if you sign out.
Hi.
you can find detailed instructions about using custom JS functions in our Early Adopter Program. First login into the Survey123 Early Adopter Program, and then look in the Documentation section for the JS article (is at the bottom of the list). Here is a direct link (you will need to be logged-in into the EAC website).
To diagnose the issue you are having, it would be easier if you share the entire survey folder you are building.
Ismael
The issue is that your file is called MyJSFunctions.js but in XLSForm you are referencing myJSFunctions.js. If you change the expression in the calculation to pulldata("@javascript","MyJSFunctions.js","lastName",${FullName}) is will work well. M != m
JS Functions are still not ready for prime time, hence why we have not officially documented this outside of the Early Adopter Program. Please use Early Adopter Program to report feedback on this particular feature (to avoid confusion). Thanks a lot!
Just some things you should be aware: 1) Every time you change your JS file, you need to re-open Connect. 2) JS Functions only work in the field app. 3) JS functions do not run if you sign out.
Ugh.
I was just working through the exercises you pointed me to and thought, "oh, i hope it's not because i've referenced the wrong file name" and then i got your email. 🙂
thanks. and sorry to waste your time. but i appreciate you pointing me to the EAP resources.
sean