Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

bryan_sng
New Contributor III

qlik.openApp and qlik.close

Hello guys,

I was trying to open an App using qlik.openApp(...);

I thought I should also do a clean up after opening using app.close();

However later I would need to open the app again using the exact same qlik.openApp(...);

It turns out that the later openApp command would randomly fail, do you guys have any ideas?

Below is a code sample to replicate.

I would like to point out that if I do not clean up using app.close, the entire extension has no problem.

paint: function(...) {

  var config1 = {

    host: window.location.hostname,

    port: window.location.port,

    prefix: "/",

    isSecure: window.location.protocol === "https:",

    identity: '1234567890'

  };


  var app1 = qlik.openApp('myapp', config1);

  // do something here but long enough for rpc session to be successfully opened at openApp

  app1.close();

  // do something here but long enough for rpc session to be successfully closed at close



  var config2 = {

    host: window.location.hostname,

    port: window.location.port,

    prefix: "/",

    isSecure: window.location.protocol === "https:",

    identity: '9999999999'

  };


  var app2 = qlik.openApp('myapp', config); // this method will randomly fail

  app2.close(); // this method will randomly fail


  console.log(app1 == app2); // this actually return true!

}


The error would be:

TypeError: Cannot read property 'promise' of undefined

    at client.js??1423665506275:100

    at k.$get.k.$eval (require.js?1423665506275:43)

    at k.$get.k.$apply (require.js?1423665506275:43)

    at Object.m.$apply (client.js??1423665506275:11)

    at Object.o [as openApp] (client.js??

10 Replies
erik_wetterberg
Honored Contributor

Re: qlik.openApp and qlik.close

Hi Bryan,

This might be a bug, what version are you using?? I know that we have had problems with this, but it should be fixed.

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
bryan_sng
New Contributor III

Re: qlik.openApp and qlik.close

Hello Erik, the version I'm using is Qlik Sense Desktop version 1.1 that was downloaded from Qlik Sense Desktop | Qlik

about a month ago.

erik_wetterberg
Honored Contributor

Re: qlik.openApp and qlik.close

Could you verify this in version 2.0 ?? If it still does not work, please report it as a bug.

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
bryan_sng
New Contributor III

Re: qlik.openApp and qlik.close

Haven't got a chance to verify this but I will get to it soon.

Meanwhile, I'm quite puzzled why app1 == app2 when a unique identity via config is provided for each case.

Is this a bug too?

erik_wetterberg
Honored Contributor

Re: qlik.openApp and qlik.close

I don't know if this is a type in your post, but your second openApp doesn't actually use config2 but config which is not included in your post.

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
bryan_sng
New Contributor III

Re: qlik.openApp and qlik.close

Ok I have verify and great news, 2.0 seems to have fix the close issue (however I still cannot close my opened app because that will close off the main session, see below)

As for the app1 == app2, I also realised it's no longer the same.

However though, I does discover app1.model == app2.model

Hmm I'm thinking is it because of this reason, I cannot open the same app in a separate context?

Eventually what I'm looking for is an alternative solution to alternateState by open an application in a separate context.

Meaning to be able to do selectValues, getting data from there via createCube and cleanup via close without affecting the current app.

By doing so, I should be able to overcome the selection history problem @

Qlik sense extension load data without dimension

erik_wetterberg
Honored Contributor

Re: qlik.openApp and qlik.close

Separate sessions are not supported in desktop, since this is essentially a single user environment. Have you tried this in a server installation??

Erik Wetterberg

Extending Qlik – Use Qlik in your own apps and sites

Erik Wetterberg
https://extendingqlik.upper88.com/
bryan_sng
New Contributor III

Re: qlik.openApp and qlik.close

Hmm interesting, my extension eventually needs to be deployed at a server installation.

Let me work up a copy of a server installation (central node only, no RIM) at my machine and give it a shot.

Thanks Eric, you been a great help so far!

bryan_sng
New Contributor III

Re: qlik.openApp and qlik.close

I have done up a server installation and tested a bare extension using the following codes:

paint: function(...) {

  var config1 = {

    host: window.location.hostname,

    port: window.location.port,

    prefix: "/",

    isSecure: window.location.protocol === "https:",

    identity: '1234567890'

  };

  // 1st app

  var app = qlik.openApp(qlik.currApp().id, config1);

console.log(app);

// 2nd app

console.log(qlik.currApp());

}

At the developer tool of chrome, I register from console, the 1st app as temp1 and 2nd app as temp2.

Then I run the following statements:

temp1 == temp2 // yield false

temp1.model == temp2. model // yield true

Seems like the results are the same as desktop

I go ahead and do an alternate state on temp1 just to try out and my current app got affected (the selection history)

Erm.. any steps I'm missing?

Community Browser