<?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 Capability API and Field API call promise timing issue in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/1963327#M17125</link>
    <description>&lt;P class="p1"&gt;Hi all,&lt;/P&gt;
&lt;P class="p1"&gt;I am having issues with some api calls in my dev-hub extension.&amp;nbsp;&lt;BR /&gt;I need to run multiple api calls in sequence to our qlik sense server, but it seems that the returned promises are resolving too early.&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;I have wrote a small script to reproduce this issue. The core of this script is the following:&lt;BR /&gt;&lt;EM&gt;(Assume sleep(x) sleeps for x milliseconds, and app, fieldName, and value are defined properly)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;for (var i = 0; i &amp;lt; 25; ++i) {
  // clear
  await app.clearAll();

  // select
  await app.field(fieldName).toggleSelect(value, false);

  // print selections
  await app.getList("SelectionObject", async function (reply) {
      console.log(reply.qSelectionObject.qSelections.length);
      await app.destroySessionObject(reply.qInfo.qId);
    });

    await sleep(200);

}

await sleep(1000);
await app.clearAll();&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;This script runs 25 loop iterations, where on each iteration it first clears all selections, then selects a value, then prints the number of values selected on each iteration all in sequence.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I made sure that only a single value is indeed selected in the app with toggleSelect, and when running the script i have made sure there are no current selections active.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P class="p1"&gt;Script result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kevindevos_0-1659439703209.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/85650iBDEF22E547E5DBE7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kevindevos_0-1659439703209.png" alt="kevindevos_0-1659439703209.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="p1"&gt;Every so often i get a result of 0 selections, and occasionally an error (either object not found or request aborted). It should always be 1 after each iteration.&amp;nbsp;Does someone have an idea for solving this issue?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2022 11:40:07 GMT</pubDate>
    <dc:creator>kevindevos</dc:creator>
    <dc:date>2022-08-02T11:40:07Z</dc:date>
    <item>
      <title>Capability API and Field API call promise timing issue</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/1963327#M17125</link>
      <description>&lt;P class="p1"&gt;Hi all,&lt;/P&gt;
&lt;P class="p1"&gt;I am having issues with some api calls in my dev-hub extension.&amp;nbsp;&lt;BR /&gt;I need to run multiple api calls in sequence to our qlik sense server, but it seems that the returned promises are resolving too early.&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;I have wrote a small script to reproduce this issue. The core of this script is the following:&lt;BR /&gt;&lt;EM&gt;(Assume sleep(x) sleeps for x milliseconds, and app, fieldName, and value are defined properly)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;for (var i = 0; i &amp;lt; 25; ++i) {
  // clear
  await app.clearAll();

  // select
  await app.field(fieldName).toggleSelect(value, false);

  // print selections
  await app.getList("SelectionObject", async function (reply) {
      console.log(reply.qSelectionObject.qSelections.length);
      await app.destroySessionObject(reply.qInfo.qId);
    });

    await sleep(200);

}

await sleep(1000);
await app.clearAll();&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;This script runs 25 loop iterations, where on each iteration it first clears all selections, then selects a value, then prints the number of values selected on each iteration all in sequence.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I made sure that only a single value is indeed selected in the app with toggleSelect, and when running the script i have made sure there are no current selections active.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P class="p1"&gt;Script result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kevindevos_0-1659439703209.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/85650iBDEF22E547E5DBE7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kevindevos_0-1659439703209.png" alt="kevindevos_0-1659439703209.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class="p1"&gt;Every so often i get a result of 0 selections, and occasionally an error (either object not found or request aborted). It should always be 1 after each iteration.&amp;nbsp;Does someone have an idea for solving this issue?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 11:40:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/1963327#M17125</guid>
      <dc:creator>kevindevos</dc:creator>
      <dc:date>2022-08-02T11:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Capability API and Field API call promise timing issue</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/1963541#M17130</link>
      <description>&lt;P&gt;i would use combination of promise arrays and chained promises.&amp;nbsp; this is a great reference for it:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://web.dev/promises/?gclid=EAIaIQobChMI6Jr-6r-b-AIV-PDjBx1sQwVVEAAYASAAEgKpD_D_BwE" target="_blank" rel="noopener"&gt;JavaScript Promises: an introduction (web.dev)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;esp the part about chaining&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 16:00:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/1963541#M17130</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2022-08-02T16:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Capability API and Field API call promise timing issue</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/1963882#M17140</link>
      <description>&lt;P&gt;Hi, thank you for the link, it looks like a really good resource. I will bookmark it!&lt;/P&gt;
&lt;P&gt;I implemented a variation of the script but using promise chaining, and im getting the same result.&lt;BR /&gt;And i tried adjusting the sleep delay between requests, the lower it is, the worse the results are.&lt;/P&gt;
&lt;P&gt;I really suspect that this is an issue with qlik, as the request promises are simply resolving too early while Qlik is probably still processing something for a very short duration after the resolve. It's the only explanation i can think of for this.&amp;nbsp;I don't think i made any mistakes with the above script using async/await, but if did i apologise in advance.&lt;/P&gt;
&lt;P&gt;I need it to wait properly to prevent requests from arriving and processing out of order and causing an inconsistent app state.&amp;nbsp; Adding timeouts also isn't the solution. (A request could potentially take (timeout+1) seconds to finish so there is no guarantee)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 08:57:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/1963882#M17140</guid>
      <dc:creator>kevindevos</dc:creator>
      <dc:date>2022-08-03T08:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Capability API and Field API call promise timing issue</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/2026279#M17951</link>
      <description>&lt;P&gt;To add some closure to this issue, this was a bug with the qlik selections api and it has been resolved in one of the most recent qlik updates.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 16:49:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/2026279#M17951</guid>
      <dc:creator>kevindevos</dc:creator>
      <dc:date>2023-01-16T16:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Capability API and Field API call promise timing issue</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/2419514#M19917</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/192273"&gt;@kevindevos&lt;/a&gt;&amp;nbsp;, at my work we are having this same problem. D&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;o you know if has any update that solves this problem to Qliksense version of november, 2019 - Patch 4 - 13.51.8 ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;How do I download this patch to solve it on this version of Qliksense?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 13:45:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Capability-API-and-Field-API-call-promise-timing-issue/m-p/2419514#M19917</guid>
      <dc:creator>Dcarvalho</dc:creator>
      <dc:date>2024-02-15T13:45:07Z</dc:date>
    </item>
  </channel>
</rss>

