Summary: I introduce qcb-qlik-sse, a community Server Side Extension to share custom Qlik functions.
At the Masters Summit for Qlik, I dive into several different methods of creating reusable script and custom functions. In QlikView we have the ability to write custom functions using VbScript/Jscript in the qvw Module.
Custom functions have been useful for things like regular expressions, geo calculations, url encoding, encryption and others. I’ll call them “edge functions” — some of us need them, some of us don’t.
Qlik Sense does not have the module facility. How can we satisfy the requirement for custom function in Qlik Sense? The Server Side Extension (SSE) facility can fill the need and is available to both Qlik Sense and QlikView.
An SSE Plugin runs as a separate task and provides communication with a Qlik Script or chart Expression via a TCP port. The same SSE Plugin can serve both QS and QV.
Anyone can write an SSE. The Qlik team provides the SSE base and you write a plugin that wires your new functions to Qlik. The new functions can be used in both Script and Charts. A number of plugins have already been produced.
SSE seems to be the ideal place to provide a collection of edge functions. Rather than a bunch of one-offs, I’m thinking a good idea would be to pool resources into a single effort that could be shared, much like QlikView Components did for Script.
I’ve implemented this idea as qcb-qlik-sse. This server uses as it’s base the qlik-sse package created by Miralem Drek.
qcb-qlik-sse is written in javascript and runs in node.js. At startup, the server scans it’s “/functions” directory and discovers what functions are available. The general idea is that you can add new function by creating a new js file. You can remove function you don’t want available by deleting the corresponding js file.
See what functions I’ve already implemented in the doc here. I’ve also provided an example qvf and qvw that exercise the functions.
If you want to try it out, download the project and define the plugin to QS or QV as documented here. You will also need node.js 8 or later installed.
Defined functions will show up in the suggestion list in both the script and expression editors.
If you want to add functions, some javascript skills are required. Follow the directions in the readme and submit a PR.
I’ve labeled the project as “experimental” at this stage because I anticipate there could be some significant restructuring as I get feedback.
Let me know your ideas and if you find this useful!
-Rob
Want to kick the tires on reusable code and make your Qlik team more efficient? Come to the Masters Summit for Qlik, a three day advanced training event for Qlik Developers.
I am amazed by how people is exploiting and expanding Qlik Sense functionalities with extensions like this one.
Thanks for sharing Rob!
thank you.
Great idea , Rob !
(but this is just business as usual, for you , right ? 😉
I do not have much JS abilities by myself, but some of my colleagues do, so let me know if there is something we can help you with.
Sempre fi,
Cotiso
Hello Rob,
Any idea how to prevent caching in these functions?
Clever Anjos
Hello Clever,
I understand from the doc that you can suppress caching by setting a http header. I have not tried it myself.
https://github.com/qlik-oss/server-side-extension/blob/master/docs/writing_a_plugin.md#cache-control