Skip to main content
Variable API

ON THIS PAGE

Variable API

Information noteIf you are using Qlik Sense Business or Qlik Sense Enterprise SaaS, see the API documentation at the Qlik (Developer Portal).
Information noteSTABLE.

This API is reliable and breaking changes are unlikely.

qlik.app.variable

The Variable API is the external interface to Qlik Sense variables.

Version history

Each method and property contain information around when it was introduced, updated, deprecated or removed. A list of all relevant API changes per version release can be found in API version history.

Version history
Version state Details
Introduced 1.0
Updated 2.1

Getting started

You must first connect to the Qlik Sense app, and you do this with the qlik.openApp method. You can then use the qlik.app.variable.get method to get an existing variable.

and QSEoK }; require(["js/qlik"], function(qlik) { //open the app var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config); //get an existing variable app.variable.get('yTgsRI').then(function(model){ myvar = model; }); });
var config = {
	host: 'QSE_domain',
	prefix: '/',
	port: 443,
	isSecure: true,
	webIntegrationId: 'web-integration-id-here' //only needed for SaaS editions

Examples of use

Learn what you can do with the Variable API.

Create a new variable

Use the qlik.app.variable.create method to create a new variable.

and QSEoK }; require(["js/qlik"], function(qlik) { //open the app var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config); //create a new variable app.variable.create({ qName : 'myvar', qDefinition : 'Month' }); });
var config = {
	host: 'QSE_domain',
	prefix: '/',
	port: 443,
	isSecure: true,
	webIntegrationId: 'web-integration-id-here' //only needed for SaaS editions

Create a session variable

You can also create a variable that only exists in the session. To do so, use the qlik.app.variable.createSessionVariable method.

and QSEoK }; require(["js/qlik"], function(qlik) { //open the app var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config); //create a new session variable app.variable.createSessionVariable({ qName : 'myvar', qDefinition : 'Month' }); });
var config = {
	host: 'QSE_domain',
	prefix: '/',
	port: 443,
	isSecure: true,
	webIntegrationId: 'web-integration-id-here' //only needed for SaaS editions

Get the variable content

Use the qlik.app.variable.getContent method to get the variable content.

and QSEoK }; require(["js/qlik"], function(qlik) { //open the app var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config); //get the variable content app.variable.getContent('MYVAR',function ( reply ){ alert( JSON.stringify( reply ) ); }); });
var config = {
	host: 'QSE_domain',
	prefix: '/',
	port: 443,
	isSecure: true,
	webIntegrationId: 'web-integration-id-here' //only needed for SaaS editions

Set a numeric value

Use the qlik.app.variable.setNumValue method to set a numeric variable value.

Information noteThe setNumValue method replaces the setContent method, which was deprecated in version 2.1.
and QSEoK }; require(["js/qlik"], function(qlik) { //open the app var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config); //set numeric value app.variable.setNumValue('MYVAR',5); });
var config = {
	host: 'QSE_domain',
	prefix: '/',
	port: 443,
	isSecure: true,
	webIntegrationId: 'web-integration-id-here' //only needed for SaaS editions

Set a string value

Use the qlik.app.variable.setStringValue method to assign a string value.

Information noteThe setStringValue method replaces the setContent method, which was deprecated in version 2.1.
and QSEoK }; require(["js/qlik"], function(qlik) { //open the app var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config); //set string value app.variable.setStringValue('MYVAR','=(1+1)'); });
var config = {
	host: 'QSE_domain',
	prefix: '/',
	port: 443,
	isSecure: true,
	webIntegrationId: 'web-integration-id-here' //only needed for SaaS editions