Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
Wuzhong_Zhu
Former Employee
Former Employee

You are a Qlik coder and for the past 3 years you have built so many mashups, extensions, and widgets using Qlik’s Capability API. It is your Swiss army knife in the jungle until one day you read a blog about enigma.js. You are wondering if enigma.js is a better tool than the Capability API. Well, why not give it a try?

There you go: This is a Qlik cloud-based sandbox. It is a repository in which every Capability API function is mapped to its corresponding enigma.js function. The code is ready-to-use; just past them in their respective projects and you should see the result. However, I really hope you can finish this article before start trying.


The first thing you should know is that almost every function in the Capability API has a substitute in enigma.js. Comparing their designs, enigma.js is more concise and simpler.


Capability API program designCapability API program designThe enigma.js program design is simpler. Note that visualization parts are handled by nebula.js.The enigma.js program design is simpler. Note that visualization parts are handled by nebula.js.

However, if you have been using the Capability API for a long time, you will probably find enigma.js surprisingly confusing. Even though the classes are named similarly, they are actually very different.


For example, the App class in the Capability API is referred to as Doc class in enigma.js. So “openApp” in the Capability API is “openDoc” in enigma.js. In enigma.js, Global class and Root class are combined even though it is still referred to as Global class. The functions’ return statement or return object is completely different too. When you try the code yourself, you may find out the similarity between these two libraries is only about 50%.

So bear in mind that even though classes in enigma.js and Capability API have similar names, look the same, they are in fact different.


If you want to transform your old extensions and mashups to enigma.js — in fact, I encourage you to do so — these are some tips to take note of.

First, you don’t need to put the main code inside this require([“js/qlik”]){} block anymore.

3.png

Instead, you manually connect to Qlik instance. And make all functions async.

4.png

The best documentation about enigma.js I have found is this one on qlik.dev. It doesn’t explicitly say it is for enigma.js, but from version 3.20 onwards, enigma.js functions are the same as Qlik’s QIX API.


There is no hypercube, list, chart object, and sheet object in enigma.js. All of them are referred to as “generic objects”. To access them, you need to specify their “qTypes” in the “getObject” function.


The Visualization API and theme API are not in enigma.js; they have been replaced by nebula.js.


When you are ready to try it yourself. These are the sample programs for you to try.

· Sandbox for Capability API

· Sandbox for enigma.js

· Capability API to enigma.js code mapping repository

The first thing you need is a Qlik Sense SaaS tenant. If you have not done so, you can follow the instructions from this tutorial to start:

· Start Qlik Sense SaaS.

· Configure deployment.

· Create a new web integration from the Management console.

· To allow Glitch.com to access Qlik cloud, you need to add its address to the allowlist. You can find it on the share tab. For example, mine is https://capability-api.glitch.me and https://enigma-js.glitch.me.

5.png

 

So your web integration portal should have something like this.

6.png

· Once the web integration has been created, an ID is assigned to it. This is the qlik-web-integration-id you need later on.

· Upload an app. If you don’t have an app or data already prepared, you can download the movies dataset from the GitHub repository and upload it to the cloud. Each app on Qlik Sense SaaS has a global unique identifier (GUID), which you need later. The GUID can be extracted from the URL and is the part that follows /app. For example, if the URL is https://your-tenant.us.qlikcloud.com/sense/app/7fc4d85c-0e07-4160-90a9-c2ca4a45fd81 , then the GUID of the app is 7fc4d85c-0e07–4160–90a9-c2ca4a45fd81.


In the code mapping repository, you can find ready-to-use code snippets. The commented code is a Capability API function, Uncommented code is the relevant enigma.js function.

7.png

 

To test the code, simply paste it into the test sandbox. The sandbox for the Capability API is here. Replace the code between line 29 and line 32 to see it in action. Remember to fill in your own tenant host name and web integration ID.

8.png

 

The sandbox for enigma.js is here. Replace the code between line 21 and line 29 to see the result.

9.png

 

And that is the end of this article. It is not easy to adapt to change. I hope this tutorial and sample codes will help you learn enigma.js.

Happy coding.

Wu

 

7 Comments
rzenere_avvale
Partner - Specialist II
Partner - Specialist II

Thanks Wu! I personally find your post really clear and helpful!

Regarding Enigma.js' documentation: do you know if there will be any other place (other than qlik.dev) where we will be able to find it?
On qlik.dev there is the latest version (as far as I know), aligned with the release available on Qlik SaaS... So if we use Enigma.js on a on-premise environment, I'm afraid we could need to use a different release of Enigma (and so, the documentation for that specific release could be really helpful)

Riccardo

1,448 Views
rarpecalibrate
Contributor III
Contributor III

Hi @rzenere_avvale,

All the info I think you are looking for is at https://github.com/qlik-oss/engima.js

Regards, 

Ryan Arpe 

1,428 Views
rzenere_avvale
Partner - Specialist II
Partner - Specialist II

Hey @rarpecalibrate ,

thank you! Do you also know if there is an easy way to consult the documentation for a specific release? On API Documentation I see only the latest release, and using the history is not really easy to target an older release

Riccardo

0 Likes
1,408 Views
rarpecalibrate
Contributor III
Contributor III

Hi,

You can do npm install engima.js@[version-number]. The version are mentioned in the following link: https://github.com/qlik-oss/enigma.js/blob/master/CHANGELOG.md

 

Ryan Arpe 

0 Likes
1,387 Views
rzenere_avvale
Partner - Specialist II
Partner - Specialist II

So if I need the documentation for (i.e.) release 2.3.2, I will still need to perform a manual check... Not really easy nor fast from my point of view, but that's ok

Riccardo

0 Likes
1,370 Views
rarpecalibrate
Contributor III
Contributor III

If you install that particular release, it would provide you with all the documentation at that point in time. You can also look at the version in github https://github.com/qlik-oss/enigma.js/tree/v2.3.2

1,353 Views
rzenere_avvale
Partner - Specialist II
Partner - Specialist II

Thank you @rarpecalibrate!

1,337 Views