<?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 Re: Survey123 - get first element of a javascript array in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/831351#M18524</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&amp;nbsp; Here is one way to do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="458624" alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/458624_Untitled.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make your custom JS function return a JSON object. Then use &lt;EM&gt;pulldata("@json")&lt;/EM&gt; to extract the X and Y.&lt;/P&gt;&lt;P&gt;Here is a hyper-simplified JS Function showing the creation of your JSON object from the output you have from proj4js.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;function projectCoords(location){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var coords = "348465.3828225266 283140.21524795296";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var coordsArray = coords.split(' ');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return '{"x":"' + coordsArray[0] + '" , "y":"' + coordsArray[1] + '" }';&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The result will put the projected coords in separate fields as shown below.&lt;/P&gt;&lt;P&gt;You may want to set the &lt;EM&gt;bind::esri:fieldType&lt;/EM&gt; XLSForm column to null, so the JSON output of your JS function is not unnecessarily stored in your feature service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji jive-image image-2 j-img-original" src="https://community.esri.com/legacyfs/online/458625_Untitled01.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Sep 2019 16:05:10 GMT</pubDate>
    <dc:creator>IsmaelChivite</dc:creator>
    <dc:date>2019-09-04T16:05:10Z</dc:date>
    <item>
      <title>Survey123 - get first element of a javascript array</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/831350#M18523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I succeeded in converting coordinates from WGS84 to a local coord. system using the pulldata @javascript function.&lt;/P&gt;&lt;P&gt;The javascript function I use (from &lt;A class="link-titled" href="https://github.com/proj4js/proj4js" title="https://github.com/proj4js/proj4js"&gt;GitHub - proj4js/proj4js&lt;/A&gt;&amp;nbsp;) takes a geopoint and return what seems to be an array of coordinates (348465.3828225266 283140.21524795296 for exemple). I can see it as a string value.&lt;/P&gt;&lt;P&gt;I need to extract X and Y from this array in separate fields but I can't do a pulldata("@geopoint" ... "x") because it is not recognized as a geopoint.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I extract 1st and 2nd values in decimal fields ?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/458552_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2019 05:50:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/831350#M18523</guid>
      <dc:creator>DSIProvince_Nord</dc:creator>
      <dc:date>2019-09-04T05:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123 - get first element of a javascript array</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/831351#M18524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&amp;nbsp; Here is one way to do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="458624" alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/458624_Untitled.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make your custom JS function return a JSON object. Then use &lt;EM&gt;pulldata("@json")&lt;/EM&gt; to extract the X and Y.&lt;/P&gt;&lt;P&gt;Here is a hyper-simplified JS Function showing the creation of your JSON object from the output you have from proj4js.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;function projectCoords(location){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var coords = "348465.3828225266 283140.21524795296";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var coordsArray = coords.split(' ');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return '{"x":"' + coordsArray[0] + '" , "y":"' + coordsArray[1] + '" }';&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The result will put the projected coords in separate fields as shown below.&lt;/P&gt;&lt;P&gt;You may want to set the &lt;EM&gt;bind::esri:fieldType&lt;/EM&gt; XLSForm column to null, so the JSON output of your JS function is not unnecessarily stored in your feature service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji jive-image image-2 j-img-original" src="https://community.esri.com/legacyfs/online/458625_Untitled01.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2019 16:05:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/831351#M18524</guid>
      <dc:creator>IsmaelChivite</dc:creator>
      <dc:date>2019-09-04T16:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123 - get first element of a javascript array</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/831352#M18525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Ismael it works like a charm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not related, but I noticed that your coordinates now have a comma ( , ) as 1000 separator. In my case I have a space, and I get a message "invalid number".&lt;/P&gt;&lt;P&gt;I tried to do an int(value) or number(value) but doesn't work.&lt;/P&gt;&lt;P&gt;Anyway at the end the value sent is valid but it looks weird for the end user.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="458656" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/458656_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2019 21:26:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/831352#M18525</guid>
      <dc:creator>DSIProvince_Nord</dc:creator>
      <dc:date>2019-09-04T21:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123 - get first element of a javascript array</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/1155549#M41416</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;Sorry this is an old thread, but if anyone had an example script incorporating proj4js into survey123 they could share that would be much appreciated.&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 22:03:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/1155549#M41416</guid>
      <dc:creator>Marc_Graham</dc:creator>
      <dc:date>2022-03-20T22:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Survey123 - get first element of a javascript array</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/1336142#M52177</link>
      <description>&lt;P&gt;HI IsmaelChivite&lt;/P&gt;&lt;P&gt;I need to use proj4.js &lt;STRONG&gt;offline&lt;/STRONG&gt; to convert my geopoint from survey123 to local coordinate system (WKID 21036).&lt;/P&gt;&lt;P&gt;Ive set up the custom javascript function and saved the .js file in the scripts folder within the survey123 project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ive also copied proj4.js file from the dist folder of the&amp;nbsp;&lt;A href="https://github.com/proj4js/proj4js/releases" target="_self"&gt;latest release&lt;/A&gt;&amp;nbsp;to my project scripts folder.&lt;/P&gt;&lt;P&gt;when i test the script in survey123 I get "error: proj4 not found". How to I reference the proj4.js library locally and make the coordinate transformation function available offline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sarah&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2023 13:52:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/survey123-get-first-element-of-a-javascript-array/m-p/1336142#M52177</guid>
      <dc:creator>SarahLQuick1</dc:creator>
      <dc:date>2023-10-08T13:52:04Z</dc:date>
    </item>
  </channel>
</rss>

