<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic JavaScript Function Returning Error in Survey123 Calculation in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/javascript-function-returning-error-in-survey123/m-p/1169424#M42469</link>
    <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;pulldata("@javascript", "convertCoords.js", "convertCoordString", ${dms_string}, ${country})&lt;/LI-CODE&gt;&lt;P&gt;is put into the calculation cell for the polygon field, it defaulty returns an error:&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;@javascript error:TypeError: Cannot read property 'split' of undefined in convertCoords.js:convertCoordString&lt;/LI-CODE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2022 17:42:22 GMT</pubDate>
    <dc:creator>AbigailStephens</dc:creator>
    <dc:date>2022-04-29T17:42:22Z</dc:date>
    <item>
      <title>JavaScript Function Returning Error in Survey123 Calculation</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/javascript-function-returning-error-in-survey123/m-p/1169424#M42469</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;pulldata("@javascript", "convertCoords.js", "convertCoordString", ${dms_string}, ${country})&lt;/LI-CODE&gt;&lt;P&gt;is put into the calculation cell for the polygon field, it defaulty returns an error:&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;@javascript error:TypeError: Cannot read property 'split' of undefined in convertCoords.js:convertCoordString&lt;/LI-CODE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 17:42:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/javascript-function-returning-error-in-survey123/m-p/1169424#M42469</guid>
      <dc:creator>AbigailStephens</dc:creator>
      <dc:date>2022-04-29T17:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript Function Returning Error in Survey123 Calculation</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/javascript-function-returning-error-in-survey123/m-p/1169518#M42479</link>
      <description>&lt;P&gt;When I use pulldata it gives me DD right away.&amp;nbsp; Maybe change the settings of the map in 123 to DD?&amp;nbsp; Tried that?&lt;/P&gt;&lt;P&gt;pulldata("@geopoint", ${PitLocation}, "x")&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DougBrowning_1-1651271768131.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/40256i936089A35750CADB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DougBrowning_1-1651271768131.png" alt="DougBrowning_1-1651271768131.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 22:36:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/javascript-function-returning-error-in-survey123/m-p/1169518#M42479</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2022-04-29T22:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript Function Returning Error in Survey123 Calculation</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/javascript-function-returning-error-in-survey123/m-p/1169681#M42490</link>
      <description>&lt;P&gt;Thanks for the reply &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/16421"&gt;@DougBrowning&lt;/a&gt;! Unfortunately, I had updated that setting for the survey, but because we are trying to use a Javascript function to convert a list of DMS coordinates like this&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;36-56.00N 023-29.00E;36-42.00N 023-32.00E;36-41.00N 023-48.00E;36-47.00N 023-55.00E&lt;/LI-CODE&gt;&lt;P&gt;to a list of DD coordinates like this&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;36.93333 23.48333;36.70000 23.53333;36.68333 23.80000;36.78333 23.91667&lt;/LI-CODE&gt;&lt;P&gt;this setting doesn't resolve the error returned by the pulldata calculation.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 12:33:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/javascript-function-returning-error-in-survey123/m-p/1169681#M42490</guid>
      <dc:creator>AbigailStephens</dc:creator>
      <dc:date>2022-05-02T12:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: JavaScript Function Returning Error in Survey123 Calculation</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/javascript-function-returning-error-in-survey123/m-p/1172053#M42649</link>
      <description>&lt;P&gt;In case anyone else runs into a similar problem and comes across this post, we found a way to get the calculation to work without changing the JS function. To prevent the pulldata calculation from calculating with an error when the input fields hadn't been filled out yet, we set that field to only be relevant if the final field used in the calculation has a value in it using the following statement in the 'relevant' column of the XLSForm:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;string-length(${dms_string})!=0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this change, the pulldata calculation doesn't run until the necessary fields are filled out, preventing the error from appearing and allowing us to publish the survey!&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 16:37:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/javascript-function-returning-error-in-survey123/m-p/1172053#M42649</guid>
      <dc:creator>AbigailStephens</dc:creator>
      <dc:date>2022-05-09T16:37:05Z</dc:date>
    </item>
  </channel>
</rss>

