<?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: how to get last item from selection array in mashup in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2038186#M85531</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi SerhanKaraer,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you please correct and share the same&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;cause I tried but it's not working&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2023 11:11:23 GMT</pubDate>
    <dc:creator>mk09123</dc:creator>
    <dc:date>2023-02-15T11:11:23Z</dc:date>
    <item>
      <title>how to get last item from selection array in mashup</title>
      <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2036467#M85399</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using the below code for getting selection in my mashup&lt;/P&gt;
&lt;PRE&gt;let fieldData = app.field('FinancialYear').getData()
console.log(fieldData.rows)&lt;BR /&gt;console.log(fieldData.rows.length) // getting 0 everytime &lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mk09123_0-1676027342736.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/100189i71420B431A0E2A4A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mk09123_0-1676027342736.png" alt="mk09123_0-1676027342736.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the issue is whenever I run the above code I am getting 0 lengths (cause I think that code gets run before the array is found )&lt;/P&gt;
&lt;P&gt;so what I am trying to do is I want the last value of the array (2022-2023)&lt;/P&gt;
&lt;P&gt;But after the dom load, I am getting 0 that the issue.&lt;/P&gt;
&lt;P&gt;any help??&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 11:11:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2036467#M85399</guid>
      <dc:creator>mk09123</dc:creator>
      <dc:date>2023-02-10T11:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to get last item from selection array in mashup</title>
      <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2036522#M85402</link>
      <description>&lt;P&gt;Hello mk,&lt;/P&gt;
&lt;P&gt;getdata is an async operation, so you have to wait for it to end.&lt;/P&gt;
&lt;P&gt;Use help site:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/November2022/Subsystems/APIs/Content/Sense_ClientAPIs/CapabilityAPIs/FieldAPI/getData-method.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense-developer/November2022/Subsystems/APIs/Content/Sense_ClientAPIs/CapabilityAPIs/FieldAPI/getData-method.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You can find a lot of stuff on this forum:&amp;nbsp;&lt;A id="link_52ce2b0fef5b46_1" class="lia-link-navigation crumb-board lia-breadcrumb-board lia-breadcrumb-forum" href="https://community.qlik.com/t5/Integration-Extension-APIs/bd-p/qlik-sense-integration-extension-api" target="_blank"&gt;Integration, Extension &amp;amp; APIs&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 13:01:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2036522#M85402</guid>
      <dc:creator>SerhanKaraer</dc:creator>
      <dc:date>2023-02-10T13:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to get last item from selection array in mashup</title>
      <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2036957#M85424</link>
      <description>&lt;P&gt;Hello SerhanKaraer,&lt;/P&gt;
&lt;P&gt;Thanks for reply&lt;/P&gt;
&lt;P&gt;As per the example which you share I have added below code in Js file.&lt;/P&gt;
&lt;PRE&gt; var fieldData = app.field('FinancialYear').getData();
		fieldData.OnData.bind( function(){
			fieldData.rows.forEach(function(row){
			console.log(row.qElemNumber)	
		})
	})
		
fieldData.field('FinancialYear').select([0,1,2],true,true)&lt;/PRE&gt;
&lt;P&gt;But now I am getting below error&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mk09123_0-1676265419041.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/100315i3D89FC3DC6D49EDA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mk09123_0-1676265419041.png" alt="mk09123_0-1676265419041.png" /&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;</description>
      <pubDate>Mon, 13 Feb 2023 05:17:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2036957#M85424</guid>
      <dc:creator>mk09123</dc:creator>
      <dc:date>2023-02-13T05:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to get last item from selection array in mashup</title>
      <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2036996#M85428</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;There seems a problem with the documentation.&lt;/P&gt;
&lt;P&gt;It must be like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; var fieldData = app.field('FinancialYear').getData();
		fieldData.OnData.bind( function(){
			fieldData.rows.forEach(function(row){
			console.log(row.qElemNumber)	
		})
	})
		
app.field('FinancialYear').select([0,1,2],true,true)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Feb 2023 07:06:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2036996#M85428</guid>
      <dc:creator>SerhanKaraer</dc:creator>
      <dc:date>2023-02-13T07:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to get last item from selection array in mashup</title>
      <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2037044#M85436</link>
      <description>&lt;P&gt;Hello SerhanKaraer,&lt;/P&gt;
&lt;P&gt;Thanks for reply&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;   var fieldData = app.field('FinancialYear').getData();
   
		fieldData.OnData.bind( function(){
		let value =[];
		fieldData.rows.forEach(function(row){		
			value.push(row.qText)
		})
		console.log([value.length -1 ])
		app.field('FinancialYear').select([value.length -1 ],true,true)
	})
	&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mk09123_0-1676277763787.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/100326i4E6B780F8897FAB9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mk09123_0-1676277763787.png" alt="mk09123_0-1676277763787.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I am getting the last array value in the console and in selection as well&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But now the console and selection value getting triggered each sec (so when you remove the selection it's get added automatically)&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 08:42:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2037044#M85436</guid>
      <dc:creator>mk09123</dc:creator>
      <dc:date>2023-02-13T08:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to get last item from selection array in mashup</title>
      <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2037098#M85439</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;When selection state changes on the server, the clients are updated with new selection state. This is the default behavior of QS. If you do not what to be updated, you have to unbind the listener as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;var fieldData = app.field('FinancialYear').getData();

let value =[];

var listener = function() {
   fieldData.rows.forEach(function(row){		
      value.push(row.qText)
   })
   console.log([value.length -1 ])
   fieldData.OnData.unbind( listener );
}

fieldData.OnData.bind( listener )
app.field('FinancialYear').select([value.length -1 ],true,true)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to be updated, just comment the line with unbind method.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 15:01:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2037098#M85439</guid>
      <dc:creator>SerhanKaraer</dc:creator>
      <dc:date>2023-02-13T15:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to get last item from selection array in mashup</title>
      <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2037111#M85440</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello SerhanKaraer,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Try with your code, but somehow it's not working as expected&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Not getting any selection or console after adding the code&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks in advance&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;</description>
      <pubDate>Mon, 13 Feb 2023 11:39:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2037111#M85440</guid>
      <dc:creator>mk09123</dc:creator>
      <dc:date>2023-02-13T11:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to get last item from selection array in mashup</title>
      <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2037235#M85445</link>
      <description>&lt;P&gt;Just corrected parentheses and braces&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/212711"&gt;@mk09123&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 15:02:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2037235#M85445</guid>
      <dc:creator>SerhanKaraer</dc:creator>
      <dc:date>2023-02-13T15:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to get last item from selection array in mashup</title>
      <link>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2038186#M85531</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi SerhanKaraer,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you please correct and share the same&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;cause I tried but it's not working&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 11:11:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/how-to-get-last-item-from-selection-array-in-mashup/m-p/2038186#M85531</guid>
      <dc:creator>mk09123</dc:creator>
      <dc:date>2023-02-15T11:11:23Z</dc:date>
    </item>
  </channel>
</rss>

