Call secondary functions from a second JS file

369
2
Jump to solution
01-31-2024 07:55 AM
mattkramer
Occasional Contributor

Hello,

 

We have some JavaScript functions and files that have grown to be rather complex, and are getting used in multiple surveys. I was wondering if it was possible for us to package some of these more common functions into an external JavaScript file and call them from functions being used in Survey123. So the form calls function a in file 1, and that function calls function b in file 2. Is this possible?

1 Solution

Accepted Solutions
ZacharySutherby
Esri Regular Contributor

Hello @mattkramer

Unfortunately this is not possible, as JavaScript functions cannot access local files. If the survey is intended to be used online you can migrate the common functions into a cloud service provider like Azure Functions which would generate an API endpoint that you can call locally from the JS function that ships with your survey. 

Thank you,
Zach

View solution in original post

0 Kudos
2 Replies
ZacharySutherby
Esri Regular Contributor

Hello @mattkramer

Unfortunately this is not possible, as JavaScript functions cannot access local files. If the survey is intended to be used online you can migrate the common functions into a cloud service provider like Azure Functions which would generate an API endpoint that you can call locally from the JS function that ships with your survey. 

Thank you,
Zach
0 Kudos
mattkramer
Occasional Contributor

Thank you for the insight. I was not sure if local files referred to any file that isn't the file containing the function called or related to local files outside of Survey123.

0 Kudos