<?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: S123 Pulldata from Repeat to Main using javascript in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/s123-pulldata-from-repeat-to-main-using-javascript/m-p/1369343#M53949</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/600184"&gt;@SpatialSean&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You don't need to use a JavaScript function you can use the &lt;A href="https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm#ESRI_SECTION1_A3C2F3566F974734B55ECECD31C6CA91:~:text=indexed%2Drepeat(question%2C%20repeat%2C%20index%20number)" target="_self"&gt;indexed-repeat()&lt;/A&gt; function to do this. Something like the following should work:&amp;nbsp;&lt;/P&gt;&lt;P&gt;indexed-repeat(${Capture_Info}, ${rpt_Info},count(${Capture_Info}))&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2024 01:35:03 GMT</pubDate>
    <dc:creator>ZacharySutherby</dc:creator>
    <dc:date>2024-01-12T01:35:03Z</dc:date>
    <item>
      <title>S123 Pulldata from Repeat to Main using javascript</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/s123-pulldata-from-repeat-to-main-using-javascript/m-p/1345204#M52656</link>
      <description>&lt;P&gt;I have a repeat that collects several rounds of information that is then passed into the main layer to provide current information using&amp;nbsp; a JavaScript function.&lt;/P&gt;&lt;P&gt;The issue I am having is that the calculation is not running &lt;U&gt;unless&lt;/U&gt; I add another blank record to the repeat.&amp;nbsp; I've tried adding&amp;nbsp;calculationMode=always in&amp;nbsp;bind::esri:parameters but it could be an error in the script&lt;/P&gt;&lt;P&gt;I created one I can share here attached.&amp;nbsp; Using this in S123 WebApp for data entry, created in S123 Connect&amp;nbsp; 3.15.165&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;FYI for anyone looking at this in the future, using the Join with a ',' causes an error in the script hence why you'll see I am using a +&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function getFirstNonNullValue(vals,separator,reverse) {
    let repeat = vals.split(separator);
	if (reverse == 'true'){
		for (let i = repeat.length-2;i &amp;gt;= 0; i--){
			let val = repeat[i];
			if (val != null &amp;amp;&amp;amp; val.trim().length != 0){
    			return val;
			}
		}
	}
	else {
		for (let i = 0;i &amp;lt;= repeat.length-1; i++){
			let val = repeat[i];
			if (val != null &amp;amp;&amp;amp; val.trim().length != 0){
    			return val;
			}
		}
	}
}

function getMergedValues(vals,separator,reverse) {
    let repeat = vals.split(separator);
    let mergedVals = '';
    if (reverse == 'true'){
		for (let i = repeat.length-2;i &amp;gt;= 0; i--){
			let val = repeat[i];
			if (val != null &amp;amp;&amp;amp; val.trim().length != 0) {
            	mergedVals = mergedVals + repeat[i];
            	mergedVals = mergedVals + '\n------\n';
			}	
        }
    }
    else {
        for (let i = 0;i &amp;lt;= repeat.length-1; i++){
            let val = repeat[i];
			if (val != null &amp;amp;&amp;amp; val.trim().length != 0) {
            	mergedVals = mergedVals + repeat[i];
            	mergedVals = mergedVals + '\n------\n';
			}	
        }
    }

    return mergedVals;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Information is entered into repeat:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Information entered" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84887i742767065B6DDA5D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="First capture.png" alt="Information entered" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Information entered&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Populated after adding second record:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Populated after adding next record" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/84888i8B2CF6ECFC1CE505/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Populates after adding a 2nd repeat.png" alt="Populated after adding next record" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Populated after adding next record&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 19:24:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/s123-pulldata-from-repeat-to-main-using-javascript/m-p/1345204#M52656</guid>
      <dc:creator>SpatialSean</dc:creator>
      <dc:date>2023-11-02T19:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: S123 Pulldata from Repeat to Main using javascript</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/s123-pulldata-from-repeat-to-main-using-javascript/m-p/1369343#M53949</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/600184"&gt;@SpatialSean&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You don't need to use a JavaScript function you can use the &lt;A href="https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm#ESRI_SECTION1_A3C2F3566F974734B55ECECD31C6CA91:~:text=indexed%2Drepeat(question%2C%20repeat%2C%20index%20number)" target="_self"&gt;indexed-repeat()&lt;/A&gt; function to do this. Something like the following should work:&amp;nbsp;&lt;/P&gt;&lt;P&gt;indexed-repeat(${Capture_Info}, ${rpt_Info},count(${Capture_Info}))&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 01:35:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/s123-pulldata-from-repeat-to-main-using-javascript/m-p/1369343#M53949</guid>
      <dc:creator>ZacharySutherby</dc:creator>
      <dc:date>2024-01-12T01:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: S123 Pulldata from Repeat to Main using javascript</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/s123-pulldata-from-repeat-to-main-using-javascript/m-p/1369541#M53961</link>
      <description>&lt;P&gt;Unfortunately it is not as simple as my example posted above.&amp;nbsp; There are multiple questions within the repeat - some of which remain blank and when using indexed repeat it will pull the null values.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 14:09:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/s123-pulldata-from-repeat-to-main-using-javascript/m-p/1369541#M53961</guid>
      <dc:creator>SpatialSean</dc:creator>
      <dc:date>2024-01-12T14:09:53Z</dc:date>
    </item>
  </channel>
</rss>

