<?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: Working with the getData() function in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-the-getData-function/m-p/11665#M191</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I really don't know how this works because the API documentation is sketchy, but using vanilla javascript with no ES6 notation ("let" keyword, arrow functions, etc). I got this to do what I want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15222417936916064 jive_text_macro" jivemacro_uid="_15222417936916064" modifiedtitle="true"&gt;
&lt;P&gt;var aCopyOfTheVariableIWantToFill = this.theVariableIWantToFill;&lt;/P&gt;
&lt;P&gt;this.$qlikOpenApp.field(fieldName).getData().OnData.bind(&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function(){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do stuff - "this" refers to the OnData object&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aCopyOfTheVariableIWantToFill = ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;);&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, within the bind function "this" refers to OnData and not the scope of the parent. But, by creating a local variable with the "var" keyword (aCopyOfTheVariableIWantToFill) I can get calculations out of the bind function and into the parent object. The this.theVariableIWantToFill is filled. If I used "let" instead of "var" it wouldn't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Mar 2018 13:00:53 GMT</pubDate>
    <dc:creator>jonvitale</dc:creator>
    <dc:date>2018-03-28T13:00:53Z</dc:date>
    <item>
      <title>Working with the getData() function</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-the-getData-function/m-p/11664#M190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am developing a mashup where I will be using the API to collect data with the getData method (in particular field.getData()). From what I gather from experimentation and the API, if I want to work with the data that I receive from getData I will need to wait for the "OnData" notification.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/February2018/Subsystems/APIs/Content/CapabilityAPIs/FieldAPI/getData-method.htm" style="font-size: 10pt;" title="https://help.qlik.com/en-US/sense-developer/February2018/Subsystems/APIs/Content/CapabilityAPIs/FieldAPI/getData-method.htm"&gt;https://help.qlik.com/en-US/sense-developer/February2018/Subsystems/APIs/Content/CapabilityAPIs/FieldAPI/getData-method.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I can tell, "OnData" is a function that is called whenever the data is refreshed. The API (as far as I can tell) has no real details about it. They suggest to bind a listener function to OnData. So, something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field.getData().OnData.bind(mylistener)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within "mylistener" the "this" keyword will be the returned data from the getData function. That's okay, but what I really want is to be able to retain "this" at the scope of my class (using ES6). As far as I can tell at this moment, when I am in my listener function I have no way to save the data where it needs to go because this is being re-purposed to store the qlik data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas about how to do this without having to do some kind of hacky search through global variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Mar 2018 16:22:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-the-getData-function/m-p/11664#M190</guid>
      <dc:creator>jonvitale</dc:creator>
      <dc:date>2018-03-26T16:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Working with the getData() function</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-the-getData-function/m-p/11665#M191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I really don't know how this works because the API documentation is sketchy, but using vanilla javascript with no ES6 notation ("let" keyword, arrow functions, etc). I got this to do what I want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15222417936916064 jive_text_macro" jivemacro_uid="_15222417936916064" modifiedtitle="true"&gt;
&lt;P&gt;var aCopyOfTheVariableIWantToFill = this.theVariableIWantToFill;&lt;/P&gt;
&lt;P&gt;this.$qlikOpenApp.field(fieldName).getData().OnData.bind(&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function(){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do stuff - "this" refers to the OnData object&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aCopyOfTheVariableIWantToFill = ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;);&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, within the bind function "this" refers to OnData and not the scope of the parent. But, by creating a local variable with the "var" keyword (aCopyOfTheVariableIWantToFill) I can get calculations out of the bind function and into the parent object. The this.theVariableIWantToFill is filled. If I used "let" instead of "var" it wouldn't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2018 13:00:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-the-getData-function/m-p/11665#M191</guid>
      <dc:creator>jonvitale</dc:creator>
      <dc:date>2018-03-28T13:00:53Z</dc:date>
    </item>
  </channel>
</rss>

