We have written a custom Javascript function to parse lists of coordinates defining a polygon from several websites. The function parses out the parts of DMS coordinates and converts them to DD coordinates. They are then re-concatenated into a semicolon-separated list of space-separated coordinate pairs, which we would like to input as a calculation for a geoshape field.
The function has been tested in both a browser console log and in the Scripts tab of Survey123 connect and returns the expected list with no errors, however, when the pulldata call of
pulldata("@javascript", "convertCoords.js", "convertCoordString", ${dms_string}, ${country})is put into the calculation cell for the polygon field, it defaulty returns an error:
@javascript error:TypeError: Cannot read property 'split' of undefined in convertCoords.js:convertCoordString
Once you enter a value into both of the fields used in the function and hit 'enter', the function calculates the expected string. But, it seems that the error is causing an XLSX error that won't let the survey be saved when the resulting field is placed in the calculation field for the geoshape question.
I've attached the Javascript function and samples of each DMS coordinate string (${dms_string}) form and its corresponding ${country} values are included in the comments section at the top of the script file. Is there something that can be changed in the script so that it doesn't defaultly calculate an error in the Survey123 and consequently calculates the geoshape quesiton?