<?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 Need help with javascript function in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/need-help-with-javascript-function/m-p/845685#M21990</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am creating a form to assess tree measurements in the field. I have a JS function already in place that calculates the root of mean squares on the top 8 largest trees, sorted by their DBH. However, I need it to only run these calculations on two specific species of trees, and I'm not versed enough in Javascript to do so. I tried to use the relevant column but&amp;nbsp;I realized this just hides the calculations on certain trees while still running the script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The two species abbreviations (name: tree_species) are 'PISI' and 'TSHE'. All other species cannot be included in the calculations, otherwise it will skew results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a script that a previous user on here helped me figure out, as well as the XLS form. If someone could give me some guidance, it would be very appreciated. I can't help but think it's an easy fix, but I have no&amp;nbsp;experience with Javascript&amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/sad.png" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jess&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Apr 2020 18:46:35 GMT</pubDate>
    <dc:creator>JessikaMcFarland</dc:creator>
    <dc:date>2020-04-01T18:46:35Z</dc:date>
    <item>
      <title>Need help with javascript function</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/need-help-with-javascript-function/m-p/845685#M21990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am creating a form to assess tree measurements in the field. I have a JS function already in place that calculates the root of mean squares on the top 8 largest trees, sorted by their DBH. However, I need it to only run these calculations on two specific species of trees, and I'm not versed enough in Javascript to do so. I tried to use the relevant column but&amp;nbsp;I realized this just hides the calculations on certain trees while still running the script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The two species abbreviations (name: tree_species) are 'PISI' and 'TSHE'. All other species cannot be included in the calculations, otherwise it will skew results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a script that a previous user on here helped me figure out, as well as the XLS form. If someone could give me some guidance, it would be very appreciated. I can't help but think it's an easy fix, but I have no&amp;nbsp;experience with Javascript&amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/sad.png" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jess&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Apr 2020 18:46:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/need-help-with-javascript-function/m-p/845685#M21990</guid>
      <dc:creator>JessikaMcFarland</dc:creator>
      <dc:date>2020-04-01T18:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with javascript function</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/need-help-with-javascript-function/m-p/845686#M21991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jessika,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Relevant calculations should prevent the calculation from working when the question is not relevant; the problem is that you function is analyzing the entire repeat data (you would need to make the values used in the calculation relevant or not relevant in the repeat). &amp;nbsp;This would be the most efficient for the javascript function as it currently exists, though you would likely want to prepend a filter to remove empty values before the sort (see&amp;nbsp;&lt;A class="link-titled" href="https://stackoverflow.com/questions/281264/remove-empty-elements-from-an-array-in-javascript" title="https://stackoverflow.com/questions/281264/remove-empty-elements-from-an-array-in-javascript"&gt;Remove empty elements from an array in Javascript - Stack Overflow&lt;/A&gt;&amp;nbsp;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, you could also pass the species values and construct the array used for calculations inside the javascript function, using an if (species == 'PISI' || species == 'TSHE') to add values only when the appropriate species is listed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2020 22:23:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/need-help-with-javascript-function/m-p/845686#M21991</guid>
      <dc:creator>JamesTedrick</dc:creator>
      <dc:date>2020-04-21T22:23:37Z</dc:date>
    </item>
  </channel>
</rss>

