Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
_jespers_
Partner - Creator II
Partner - Creator II

Enigma and September 2017 issue

When I upgraded to the September 2017 release I got some issues with all my extensions using enigma.js. I even get an issue when just copying the enigma.js example from https://help.qlik.com/en-US/sense-developer/September2017/Subsystems/APIs/Content/enigmajs/enigmajs-...

Code to my example:

define( [

        "qlik",

        "text!./template.html",

        'util',

        'enigma',

        'autogenerated/qix/engine-api'

    ],

    function ( qlik, template, Util, enigma, schema ) {

        var app = qlik.currApp(this);

        var cfg = {

            schema: schema,

            appId: app.id,

            session: {

                host: Util.hostname,

                port: Util.port || undefined,

                prefix: Util.basePath,

                unsecure: !Util.isSecure,

                reloadURI: Util.reloadURI

            }

        };

        return {

            template: template,

            support: {

                snapshot: true,

                export: true,

                exportData: false

            },

            paint: function () {

                return qlik.Promise.resolve();

            },

            controller: ['$scope', function ( $scope ) {

                enigma.getService('qix', cfg).then(function(qix) {

                    console.log("Nothing went wrong!");

                }).catch(function(err) {

                    console.log('Something went wrong', err);

                });

            }]

        };

    } );

Error message I receive:

issue.PNG

FYI: QIX.js is the name of the extension in this case

Does anyone have any idea what can be the cause of this issue?

1 Solution

Accepted Solutions
ErikWetterberg

Hi,

Your URL looks wrong: should probably just be one / before app.

And should you really open another websocket in your extension?  Why not use the one that already exists? In June 2017 the session is at this.backendApi.model.enigmaModel.session, I don't know if it has changed in September.

Hope this helps

Erik Wetterberg

View solution in original post

4 Replies
ErikWetterberg

Hi,

Your URL looks wrong: should probably just be one / before app.

And should you really open another websocket in your extension?  Why not use the one that already exists? In June 2017 the session is at this.backendApi.model.enigmaModel.session, I don't know if it has changed in September.

Hope this helps

Erik Wetterberg

_jespers_
Partner - Creator II
Partner - Creator II
Author

Yes, you are absolutely correct. In this case there is a "/" too much. So if I hardcode the prefix in cfg to this:

var cfg = {

            schema: schema,

            appId: app.id,

            session: {

                host: Util.hostname,

                port: Util.port || undefined,

                prefix: '',

                unsecure: !Util.isSecure,

                reloadURI: Util.reloadURI

            }

        };

It starts to work.

But now the question is why I need to do this for the September release? Because since we use this extension on multiple clients with different versions we need a version of the extension that works for all the clients.

And I didn't know you could access the enigmaModel like that. Couldn't find any documentation on https://help.qlik.com/en-US/sense-developer/September2017/Subsystems/APIs/Content/backend-api-refere... for that.

Do you know where I can find any documentation for this or if you can give me an example on how to do the following with your type of expression:

enigma.getService('qix', cfg).then(function(qix) {

                    console.log("Nothing went wrong!");

                }).catch(function(err) {

                    console.log('Something went wrong', err);

                });

ErikWetterberg

Hi,

Looks like there are changes in the Util module that breaks the example. I don't think that's documented. I don't know if this is still the case, but it used to take host etc from the URL which works fine in the client, but would break in many mashup scenarios (like when you deploy your mashup on another server).

Validating that enigma loads OK is not really relevant, since you would be using the same enigma instance as the client and your extension would not load if loading enigma failed. But you can find app, global etc in the enigma model and use that.

Hope this helps

Erik Wetterberg

_jespers_
Partner - Creator II
Partner - Creator II
Author

Hi,

I now understood how to use the same instance of enigma as the client, and it works perfectly.

Thank you!

If someone else have struggle in understanding in how to use the same instance of enigma as the client I will post a small example how to get started:

define( [

        "qlik",

        "text!./template.html"

    ],

    function ( qlik, template ) {

        var app = qlik.currApp(this);

        return {

            template: template,

            support: {

                snapshot: true,

                export: true,

                exportData: false

            },

            paint: function () {

                var qix = this.backendApi.model.enigmaModel.session;

                qix.app.getVariableByName('nameOfVariable').then(function(variable){

                });

                return qlik.Promise.resolve();

            },

            controller: ['$scope', function ( $scope ) {

            }]

        };

    } );