CapabilityAPI

v1.7.1

The Capability APIs are a collection of JavaScript APIs that allows you to easily embed Qlik Sense content into a web page, and interact with data. With just a few lines of code, it is possible to create a visualization that leverages the Qlik Sense visualization library.

js/qlik

module

External interface to qlik, for mashups and including qlik in foreign web pages.

Properties

navigation

No description

theme

No description

var config = {
	 host: "myhost.com",
	 prefix: "/",
	 port: window.location.port,
	 isSecure: true
};
requirejs(["js/qlik"], function(qlik) {
	 // open the app
  var app = qlik.openApp("c31e2aba-3b46-4b13-8b87-c5c2514dea1d", config);
	 // insert Qlik objects into the page.
	 app.getObject(document.getElementById("LB01"), "uPyZavD");
}

js/qlikcallRepository(path, method?, body?)

function
deprecated

Call Qlik repository.

Parameters

path
string

Path to the Qlik Sense repository. Refer to Qlik Sense repository documentation for the available paths.

method
optional, default='GET'
string

HTTP method.

body
optional
string

Body of the post.

Returns

Promise<object>

A promise of a Qlik repository reply.

qlik.callRepository("/qrs/extension/schema").then(function(reply) {
		console.log(JSON.stringify(reply));
	  });

js/qlikcurrApp(reference?)

function

Get a reference to the current app. Use in an extension to get a reference to the app displayed.

Parameters

reference
optional
object

Reference to extension object. Since Qlik Sense 1.1

Returns

An App JavaScript object with app methods.

var app = qlik.currApp(this);
   app.clearAll();

js/qlikgetAppList(callback, config?)

function

Get a list of Qlik apps and register a callback to receive the data. The reply will contain all apps the user has access to.

Parameters

callback
function

Callback method.

config
optional

Additional configuration parameters.

var config = {
		host: "myhost.com",
		prefix: "/",
		port: window.location.port,
		isSecure: true
	};
 qlik.getAppList(function(list){
		var str = "";
		list.forEach(function(value) {
			str +=  value.qDocName + "("+ value.qDocId +") ";
		});
		console.log(str);
	}, config);

js/qlikgetExtensionList(callback?)

function
deprecated

Get the list of extensions installed in the system. The reply will contain all extensions such as visualizations, mashups, and so on.

Parameters

callback
optional
function

Callback method.

Returns

A promise of a Qlik engine reply.

qlik.getExtensionList(function(list){
		var str = "";
		list.forEach(function(value) {
			str +=  value.id + "(" + value.data.type + ") ";
		});
		console.log(str);
	});

js/qlikgetGlobal(config?)

function

Open a connection with a Web Socket to engine for global methods.

Parameters

config
optional

Additional configuration parameters.

Returns

A global JavaScript object with global methods.

var config = {
		host: "myhost.com",
		prefix: "/",
		port: window.location.port,
		isSecure: true
	  };
   var global = qlik.getGlobal(config);
   global.getAuthenticatedUser(function(reply){
		console.log("User:"+reply.qReturn);
	  });

js/qlikgetThemeList()

function

Get a list of themes from the system. The list will contain both default and custom themes.

Returns

A promise of a list of themes including the ID and the metadata name.

qlik.getThemeList().then(function(list){
		var str = "";
		list.forEach(function(value) {
			str += value.name + '(' + value.id + ")\n";
		});
		console.log(str);
	});

js/qlikoff(eventName?)

function

Remove listener(s) for the qlik instance events.

Parameters

eventName
optional
string

Name of the event. If no eventName is provided, removes all listeners.

qlik.on("error", err=>{
  console.error(err);
});
qlik.off("error");

js/qlikon(eventName, callback)

function

Add listener(s) to the qlik instance events. Possible events are error, warning, and closed. Multiple listeners can be added to an event.

Parameters

eventName
string

Name of the event. Can be: error, warning, closed. Note: this event handler will be overridden by app event handlers or global event handlers if set.

callback
function

Callback method.

qlik.on("error", err=>{
  console.error(err);
});
qlik.on("warning", warn=>{
  console.warn(warn);
});

js/qlikopenApp(appId, config?)

function

Opens the app. You can open multiple apps. Most other methods are defined on the app. Introduced in Qlik Sense 1.0.

Parameters

appId
string

The app ID.

config
optional

Additional configuration parameters.

Returns

An App JavaScript object with app methods.

var app = qlik.openApp("2abac31e-3b46-4b78-8bxf-c5cea1d2514d");
     var config = {
		  host: "myhost.com",
		  prefix: "/",
		  port: window.location.port,
		  isSecure: true
	    };
     var app2 = qlik.openApp("c31e2aba-3b46-4b13-8b87-c5c2514dea1d", config);

js/qlikPromise(executor)

function

Promise utility that can be used for asynchronous operations. Very useful for the paint method to indicate that the rendering is complete. Full documentation available on: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise.

Parameters

executor
function

The executing function with two parameters: resolve and reject.

var Promise = qlik.Promise;
qlik.registerExtension("dumpchart",
       {
     	paint:function($element,layout) {
       		return new Promise(function(resolve, reject) {
       	    	setTimeout(function() {
       	        	$element.html(JSON.stringify(layout));
       	        	resolve(); // Extension painted successfully
       	    	}, 1000);
       		});
       	}
   });

js/qlikregisterExtension(id, impl, metadata?)

function

Register an extension for use in this mashup. The extension will not be installed on Qlik Sense server, but only available in the session where it is created.

Parameters

id
string

Set the ID of the visualization extension.

impl
object

Set the extension implementation.

metadata
optional, default={"type":"visualization"}
object

Extension metadata, same format as QEXT file.

qlik.registerExtension("dumpchart",

   {
       paint:function($element,layout){
           $element.html(JSON.stringify(layout));
       }
   });
requirejs([path +"/wordcloud/wordcloud.js"],function(wordcloud)
{
   qlik.registerExtension( "wordcloud", wordcloud );
});

js/qlikresize(ID?)

function

Sends a resize event to all Qlik objects.

Parameters

ID
optional
string

Object ID. Optional: if no ID, resize event will be sent to all objects.

//create the tabs and make qlik objects resize
 //when a new tab is selected
 $("#tabs").tabs().bind("tabsselect", function(event, ui) {
		qlik.resize();
	});

js/qliksessionApp(config?)

function

Creates a session/cached QApp object.

Parameters

config
optional

Additional configuration parameters.

Returns

An app JavaScript object with app methods.

Basic usage

var sessionApp = qlik.sessionApp();

Basic usage with config

var config = {
  host: "myhost.com",
  prefix: "/",
  port: window.location.port,
  isSecure: true
};
var sessionApp =  qlik.sessionApp(config);

js/qliksessionAppFromApp(appId, config?)

function

Creates a session/cached QApp object from an existing app.

Parameters

appId
string

App ID of the app to base the session app upon.

config
optional

Additional configuration parameters.

Returns

An app JavaScript object with app methods.

Basic usage

var sessionApp = qlik.sessionAppFromApp("2abac31e-3b46-4b78-8bxf-c5cea1d2514d");

Basic usage with config

var config = {
  host: "myhost.com",
  prefix: "/",
  port: window.location.port,
  isSecure: true
};
var sessionApp = qlik.sessionAppFromApp("2abac31e-3b46-4b78-8bxf-c5cea1d2514d", config);

Multiple apps

var sessionApp = qlik.sessionAppFromApp("2abac31e-3b46-4b78-8bxf-c5cea1d2514d");
var sessionApp2 = qlik.sessionAppFromApp("c31e2aba-3b46-4b13-8b87-c5c2514dea1d");

js/qliksetDeviceType(deviceType)

function

Sets device type, which modifies the UI accordingly. The device type is automatically detected if it is not manually set.

Parameters

deviceType
string

Type of device. One of: auto, touch, desktop.

qlik.setDeviceType('desktop');

js/qliksetLanguage(lang)

function

Set language.

Parameters

lang
string

Language code

qlik.setLanguage("es");

js/qliksetOnError(onError, onWarning?)

function
deprecated

Parameters

onError
function

Error handling function.

onWarning
optional
function

Warning handling function. Since Qlik Sense 2.1.

qlik.setOnError(function(error) {
  //contains code, message
	 console.log(error.message);
},
function(warning){
	 windows.console.log(warning);
});

js/qliktable(ext, path?)

function

Create a QTable object that wraps data in your extension and provides an object-oriented interface.

Parameters

ext
object

Extension or angular scope for the extension.

path
optional, default='qHyperCube'
string

Path to the hypercube.

Returns

table - A QTable object that holds data and options for the table.

$scope.table = qlik.table(this);

<tr ng-repeat="row in table.rows">
   <td ng-repeat="cell in row.cells"> {{cell.qText}} </td>
</tr>

new Notification()

class

Notificationbind(observer)

function

Observe a Notification by sending in an observer function.

Parameters

observer
function

The observer function to handle the notification.

Notificationunbind(observer)

function

Stop observing a notification.

Parameters

observer
function

The observer function that now should ignore any future notifications.

ObjectMetricSize

object

Describes the size, in millimeters (mm), of a 2D object.

Properties

height
number

Object height in millimeters (mm).

width
number

Object width in millimeters (mm).

ObjectPixelSize

object

Describes the size, in pixels, of a 2D object.

Properties

height
number

Object height in pixels.

width
number

Object width in pixels.

new QApp()

class

Properties

bookmark

No description

theme

No description

variable

No description

visualization

No description

QAppaddAlternateState(qStateName)

function

Add an alternate state.

Introduced in Qlik Sense 1.1.

Parameters

qStateName
string

Alternate state name.

Returns

A promise of a Qlik engine reply.

app.addAlternateState("X");

QAppback()

function

Back to prev selection.

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d');
app.back();

QAppclearAll(lockedAlso?, state?)

function

Clear all selections.

Parameters

lockedAlso
optional
boolean

Also clear locked fields. Since Qlik Sense 2.1

state
optional, default='$'
string

Alternate state name. Since Qlik Sense 2.1

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d');
app.clearAll();

QAppclose()

function

Close an app.

Will also close the web socket and clear out client side data.

Introduced in Qlik Sense 1.1

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d');
app.close();

QAppcreateCube(qHyperCubeDef, callback?)

function

Defines a Qlik Hypercube and registers a callback to receive the data.

Parameters

qHyperCubeDef
object

Cube definition.

callback
optional
function

Callback method. Parameter will contain a qHyperCube.

Returns

A promise of an object model.

app.createCube({
  qDimensions : [{
    qDef : {
      qFieldDefs : ["FirstName"]
    }
  }, {
    qDef : {
      qFieldDefs : ["LastName"]
  }
}],
qMeasures : [{
  qDef : {
    qDef : "1"
  }
}],
qInitialDataFetch : [{
  qTop : 0,
  qLeft : 0,
  qHeight : 20,
  qWidth : 3
}]
}, function(reply) {
  var str = "";
  $.each(reply.qHyperCube.qDataPages[0].qMatrix, function(key, value) {
    str += '<li>' + value[0].qText + ':' + value[1].qText + '</li>';
  });
  $('#list').html(str);
});

QAppcreateGenericObject(param, callback?)

function

Creates a Qlik Generic object and registers a callback to receive the data. The generic object can contain qHyperCubeDef, qListObjectDef and/or qStringExpression and qValueExpression. It will be a session object and disppears when the session is closed. The callback method will be called whenever the selection state changes in a way that affects the generic object. The parameter will be the evaluated version of the definition.

Parameters

param
object

Generic object definition.

callback
optional
function

Callback method.

Returns

A promise of an object model.

app.createGenericObject( {
  user: {
    qStringExpression: "=QVUser ()"
  },
  version : {
    qStringExpression: "=QlikViewVersion ()"
  },
  fields: {
    qValueExpression: "=Count (DISTINCT $Field)"
  }
}, function ( reply ) {
  var str = "Version:" + reply.version + " Fields:" + reply.fields;
  if ( reply.user ) {
    str += " User:" + reply.user;
  }
  $( "#info" ).html(str);
});

QAppcreateList(qListObjectDef, callback?)

function

Defines a Qlik list of field values and registers a callback to receive the data.

Parameters

qListObjectDef
object

List definition.

callback
optional
function

Callback method. Parameter will contain a qListObject.

Returns

A promise of an object model.

app.createList({
  "qDef": {
    "qFieldDefs": [
      "LastName"
    ]
   },
   "qInitialDataFetch": [{
     qTop : 0,
     qLeft : 0,
     qHeight : 20,
     qWidth : 1
   }]
   }, function(reply) {
     var str = "";
     $.each(reply.qListObject.qDataPages[0].qMatrix, function(key, value) {
       str += '<li>' + value[0].qText + '</li>';
     });
     $('#list').html(str);
   });

QAppcreateTable(dimensions, measures, options?)

function

Defines a Qlik Hypercube and creates a table object wrapping the hypercube.

Introduced in Qlik Sense 2.1.

Parameters

dimensions
Array<string | NxDimension>

Dimensions to use. Should be a field name or a NxDimension structure for each entry.

measures
Array<string | NxMeasure>

Measures to use. Should be an expression or a NxMeasure structure for each entry.

options
optional
object

Options to set.

Returns

A table object of type QTable, which is initially empty but eventually will contain data. The table object will be updated when selection state changes.

var users = app.createTable(["FirstName", "LastName"], ["Count(Case Id)"],{rows:200});

QAppdestroySessionObject(id)

function

Destroys a Qlik Session object created with createGenericObject or any of createCube, createList, or getList calls.

The object will be removed from engine, no more updates will be sent to the client and all methods on the object will be invalid.

Introduced in Qlik Sense 1.1.

Parameters

id
string

Session object ID.

Returns

A promise of a Qlik engine reply.

app.destroySessionObject( 'xcVtY');
app.destroySessionObject(reply.qInfo.qId);

QAppdoReload(qMode?, qPartial?, qDebug?)

function

Reload the app.

Introduced in Qlik Sense 1.1

Parameters

qMode
optional
number

Error handling mode: 0 = default mode, 1 = attempt recovery on all errors, 2 = fail on all errors.

qPartial
optional
boolean

Set to true for partial reload.

qDebug
optional
boolean

Set to true if debug breakpoints are honored. Execution of the script will be in debug mode.

Returns

A promise of a Qlik engine reply.

app.doReload();

QAppdoSave(qFileName?)

function

Save the app.

Introduced in Qlik Sense 1.1.

Parameters

qFileName
optional
string

File name of the file to save.

Returns

A promise of a Qlik engine reply.

app.doReload().then(function(){
   app.doSave();
});

QAppfield(fld, statename?)

function

Get a field reference with methods to manipulate field.

Parameters

fld
string

Name of the field.

statename
optional, default='$'
string

Alternate state name.

Returns

A QField object with methods and properties that can be used to manipulate the field.

QAppforward()

function

Forward

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d');
app.forward();

QAppgetAppLayout(callback?)

function

Get layout for this app and register a callback to receive the data.

Introduced in Qlik Sense 1.1.

Parameters

callback
optional
function

Callback method.

Returns

A promise of a Qlik engine reply.

app.getAppLayout(function(layout){
  console.log(layout.qTitle);
});

QAppgetAppObjectList(type?, callback?)

function
deprecated

Get a list of Qlik application objects and register a callback to receive the data.

Parameters

type
optional, default='sheet'
string

Type of object. One of: sheet, MasterObject.

callback
optional
function

Callback method.

app.getAppObjectList( 'sheet', function(reply){
  var str = "";
  $.each(reply.qAppObjectList.qItems, function(key, value) {
    str +=  value.qData.title + ' ';
    $.each(value.qData.cells, function(k,v){
      str +=  v.name + ' ';
    });
  });
  console.log(str);
});

QAppgetFullPropertyTree(id)

function

Get properties for a Qlik object including children properties.

Parameters

id
string

Object ID.

Returns

A promise of an object model.

app.getFullPropertyTree(value.qInfo.qId).then(function(model){
  console.log(model.propertyTree.qChildren.length + ' children');
});

QAppgetList(type, callback?)

function

Get a list of internal Qlik objects and register a callback to receive the data.

Parameters

type
string

Type of object. One of: FieldList, MeasureList, DimensionList, BookmarkList, SelectionObject, SnapshotList Since Qlik Sense 1.1, MediaList Since Qlik Sense 1.1, sheet Since Qlik Sense 1.1, MasterObject Since Qlik Sense 1.1, VariableList Since Qlik Sense 2.0, story Since Qlik Sense 2.1

callback
optional
function

Registers a callback that is executed every time data is returned.

Returns

A promise of an object model.

app.getList("FieldList", function(reply){
  var str = "";
  $.each(reply.qFieldList.qItems, function(key, value) {
    str +=  value.qName + ' ';
  });
 console.log(str);
});

QAppgetObject(elem?, id, options?)

function

Inserts a Qlik object into an HTML element. The object will fill the HTML object, so you can size and position the element to determine how large the Qlik object will be.

If you only supply one parameter, you will just get the model without displaying the object.

Parameters

elem
optional
HTMLElement | string

HTML element. Since version 1.1, it is also possible to define a string of the HTML element ID.

id
string

Object ID or 'CurrentSelections' if used for Selections bar. Since version November 2017 it is also possible to use 'AppNavigationBar' to on-demand app navigation bar.

options
optional

Additional options.

Returns

A promise of an object model.

app.getObject(document.getElementById("LB01"), "uPyZavD");
app.getObject("LB01","uPyZavD");
app1.getObject('MyAppNavigationToolbarDIVid', 'AppNavigationBar', { sheetId: "RWcstb", openAppCallback: function ( appId, targetSheetId ) {
  console.log("Open generated app event handled.  App ID: " + appId + " target sheet to open by default: " + targetSheetId);
}});

QAppgetObjectProperties(id)

function

Get properties for a Qlik object.

Parameters

id
string

Object ID.

Returns

A promise of an object model.

app.getObjectProperties("uPyZavD").then(function(model){
  this.title = model.properties.title;
});

QAppgetScript()

function

Gets the data load script of this app.

Introduced in Qlik Sense 4.0

Returns

A promise of a qScript object with the load script values.

var app = qlik.openApp( "MY_APP_ID");
app.getScript().then( function(script){
  console.log(script);
});

QAppgetSnapshot(element?, id)

function

Inserts a Qlik snapshot into an HTML element. The snapshot will fill the HTML object, so you can size and position the element to determine how large the Qlik object will be.

If you only supply one parameter you will just get the model without displaying the object.

Parameters

element
optional
HTMLElement | string

HTML element or string with HTML element id.

id
string

Snapshot ID.

Returns

A promise of an object model.

app.getSnapshot(document.getElementById("SNAPSHOT"), "uPyZavD");

QApplockAll(state?)

function

Lock all selections.

Parameters

state
optional, default='$'
string

Alternate state name. Since Qlik Sense 2.1.

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d');
app.lockAll();

QAppoff(eventName?)

function

Remove listener(s) for the app events.

Introduced in Qlik Sense February 2018.

Parameters

eventName
optional
string

Name of the event. Can be: error, warning, closed. If no eventName is provided, removes all listeners.

var app = qlik.openApp("MY_APP_ID");
app.on("error", function ( error ) {
  console.log("error listener called for app", error);
});
app.off("error");

QAppon(eventName, callback)

function

Add listener(s) to the app events. Possible events are error, warning and closed. Multiple listeners can be added to an event.

Introduced in Qlik Sense February 2018.

Parameters

eventName
string

Name of the event. Can be: error, warning, closed.

callback
function

Callback method.

var app = qlik.openApp("MY_APP_ID");
app.on("error", function ( error ) {
  console.log("error listener called for app", error);
});
app.on("warning", function ( warning ) {
  console.log("warning listener called for app", warning);
});
app.on("closed", function ( closed ) {
  console.log("closed listener called for app", closed);
});

QAppremoveAlternateState(qStateName)

function

Remove an alternate state.

Introduced in Qlik Sense 1.1.

Parameters

qStateName
string

Alternate state name

Returns

A promise of a Qlik engine reply.

app.removeAlternateState("X");

QAppsearchAssociations(qTerms, qPage, qOptions?, callback?)

function
deprecated

Searches for one or more terms in the values of an app.

Introduce in Qlik Sense 1.1.

Parameters

qTerms
Array<string>

Terms to search for.

qPage

No description

qOptions
optional

Search options.

callback
optional
function

Callback method.

Returns

A promise of a Qlik engine reply.

app.searchAssociations(["se"],
  {qOffset:0,qCount:15,qMaxNbrFieldMatches:5},
  {qContext: 'CurrentSelections'},
  function(reply){
    var str = "";
    reply.qResults.qFieldDictionaries.forEach(function(dic){
      dic.qResult.forEach(function(result){
        str += result.qText;
      });
    });
    console.log(str);
});

QAppsearchResults(qTerms, qPage, qOptions?, callback?)

function

Searches for one or more terms in the values of an app.

Introduced in Qlik Sense 2.2.

Parameters

qTerms
Array<string>

Terms to search for.

qPage

No description

qOptions
optional

Search options.

callback
optional
function

Callback method.

Returns

A promise of a Qlik engine reply.

app.searchResults( ["ma"],
  { qOffset: 0, qCount: 15},
  {qContext: 'CurrentSelections'},
  function ( reply ) {
    if ( reply.qResult.qTotalNumberOfGroups === 0 ) {
      console.log('No matches');
    } else {
      var str = "";
      reply.qResult.qSearchGroupArray.forEach( function ( value ) {
        value.qItems.forEach( function ( item ) {
          str += item.qIdentifier +": ";
          item.qItemMatches.forEach( function ( match ) {
            str += match.qText + ' ';
          });
        });
      });
      console.log(str);
    }
});

QAppsearchSuggest(qTerms, qOptions?, callback?)

function

Returns search suggestions.

Introduced in Qlik Sense 1.1.

Parameters

qTerms
Array<string>

Terms to search for.

qOptions
optional

Search options.

callback
optional
function

Callback method.

Returns

A promise of a Qlik engine reply.

app.searchSuggest(["se"], {}, function(reply) {
  var str = "";
  reply.qResult.qSuggestions.forEach(function(sugg){
    str += sugg.qValue + ' ';
  });
  console.log(str);
});

QAppselectAssociations(qMatchIx?, qTerms?, qOptions?, qSoftLock?)

function

Make a selection based on searchAssociaton results.

Introduced in Qlik Sense 1.1.

Parameters

qMatchIx
optional
number

Index to search result.

qTerms
optional
Array<string>

Values to select.

qOptions
optional

Parameter sent to the Qlik engine containing information about the search fields and the search context.

qSoftLock
optional
boolean

Use the qOptions.qContext parameter instead.

Returns

A promise of a Qlik engine reply.

app.selectAssociations( 0, ["May","Mar"] );

QAppselectionState(state?)

function

Creates a SelectionState object that encapsulates the selection state.

Introduced in Qlik Sense 2.2.

Parameters

state
optional, default='$'
string

Sets the state.

Returns

A selection state object for the selection state of type QSelectionState.

QAppsetScript(script)

function

Sets the data load script of this app. Also validates the script syntax and returns the syntax errors if errors exist.

Introduced in Qlik Sense 4.0.

Parameters

script
string

The script content.

Returns

A promise of an empty object or a list of syntax errors depending on the validation result.

Load script inline

var script = "Load Chr(RecNo()+Ord('A')-1) as Alpha, RecNo() as Num autogenerate 26;"
var app = qlik.openApp( "MY_APP_ID");
app.setScript(script).then( function(result){
	console.log(result);
});

Load script from file

var script = 'LOAD Sales FROM [lib://data/sample.xlsx];';
var app = qlik.openApp( "MY_APP_ID");
app.setScript(script).then( function(result){
  console.log(result);
});

QAppunlockAll(state?)

function

Unlock all selections.

Parameters

state
optional, default='$'
string

Alternate state name. Since Qlik Sense 2.1.

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d');
app.unlockAll();

new QAppTheme()

class

QAppThemeget(id?)

function

Get theme as a QTheme object.

Parameters

id
optional
string

Theme ID. If no ID is specified, the theme saved for the app is returned.

Returns

A promise of a QTheme object.

app.theme.get('my-theme-id').then(function(qtheme){
   console.log('Theme background color: ' + qtheme.properties.backgroundColor);
	});

QAppThemegetApplied()

function

Get currently applied theme as a QTheme object.

Returns

A promise of a QTheme object.

app.theme.getApplied().then(function(qtheme){
   console.log('Current theme background color: ' + qtheme.properties.backgroundColor);
	});

QAppThemesave(id)

function

Save a theme ID of an app.

Introduced in Qlik Sense February 2018.

Parameters

id
string

Theme ID.

app.theme.save('my-theme-id');

new QAppVisualization()

class

QAppVisualizationcreate(type, cols?, options?)

function

Create a new visualization. The visualization will be based on a session object and not persisted in the app.

Parameters

type
string

Visualization type. Built-in visualization like barchart, piechart, linechart, combochart or an extension.

cols
optional
Array<string | NxDimension | NxMeasure>

Column definitions, dimensions and measures. Each entry can be a string, an NxDimension or NxMeasure structure. If the NxDimension or NxMeasure refers to a library dimension or measure, you also might need to add qType measure or dimension.

options
optional

Options to set. Refer to documentation for the visualization used for additional options.

Returns

A promise of a {@link QVisualization}.

create a barchart on the fly
var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.visualization.create('barchart',["Case Owner Group","=Avg([Case Duration Time])"],{title:"Great on-the-fly barchart"}).then(function(bar){
  bar.show('QV04');
});
create a table
app.visualization.create( 'table', ["Case Owner Group", "=Avg([Case Duration Time])", "Priority", "Quarter"] ).then( function ( table ) {
  table.show( 'QV04' );
});
create a toolbar using an extension
app.visualization.create('com-qliktech-toolbar',null,
  {"buttons":{"clear":true,"back":true,"forward":true}}).then(function(vis){
    vis.show("QV05");
});

QAppVisualizationget(id)

function

Get an existing visualization.

Introduced in Qlik Sense 2.2.

Parameters

id
string

ID for an existing visualization.

Returns

A promise of a {@link QVisualization}.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
   app.visualization.get('xGhjKl').then(function(vis){
     vis.show("QV01");
   });

new QBookmark()

class

QBookmarkapply(id)

function

Apply bookmark.

Parameters

id
string

Bookmark ID.

Returns

A promise of a Qlik engine reply. Since Qlik Sense 1.2.

var app = qlik.openApp("c31e2aba-3b46-4b13-8b87-c5c2514dea1d");
app.bookmark.apply("pPvpTN");

QBookmarkcreate(title, description, sheetId?)

function

Create bookmark based on current selection.

Parameters

title
string

Bookmark title.

description
string

Bookmark description.

sheetId
optional
string

Bookmark sheet ID. Since Qlik Sense 2.2.

Returns

A promise of a Qlik engine reply. Since Qlik Sense 1.2.

var app = qlik.openApp("c31e2aba-3b46-4b13-8b87-c5c2514dea1d");
app.bookmark.create("Test","Test bookmark","fmcJkH");

QBookmarkremove(id)

function

Remove bookmark.

Parameters

id
string

Bookmark ID.

Returns

A promise of a Qlik engine reply. Since Qlik Sense 1.2.

var app = qlik.openApp("c31e2aba-3b46-4b13-8b87-c5c2514dea1d");
app.bookmark.remove("pPvpTN");

new QDimensionCell()

class

Wrapper around a HyperCube dimension cell.

Properties

qText
string

Cell value formatted as set up in properties.

qElemNumber
number

Cell value index.

qState
string

Cell state.

qNum
optional
number

Cell numeric value, if cell is numeric.

QDimensionCellselect()

function

Select the value contained in this cell.

<div class="selectable" ng-class="{'selected':cell.selected}" ng-click="cell.select($event)">{{cell.qText}}</div>

new QField()

class

External interface to the fields in a Qlik Sense app and contains methods for field level commands.

Properties

OnData

OnData notification

qStateCounts
object

Object with number of values in different states. Only after getData() call.

Introduced in Qlik Sense 2.1.

rowCount
number

Number of different values. Only after getData() call.

Introduced in Qlik Sense 2.1.

rows

Field values. You need to call getData() method to make this available. Since Qlik Sense 2.1.

QFieldclear()

function

Clears a field selection.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').clear();

QFieldclearOther(softlock?)

function

Clears all field selections except this one.

Parameters

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').clearOther(true);

QFieldgetData(options?)

function

Gets field data. The values are available as QFieldValue in array field.rows and is updated when the selection state changes. Notification OnData will be triggered after each update.

Introduced in Qlik Sense 2.1

Parameters

options
optional

Object containing options for the getData call.

Returns

The field object.

var app = qlik.openApp("c31e2aba-3b46-4b13-8b87-c5c2514dea1d");
$scope.months = app.field("Month").getData();

<button ng-repeat="row in months.rows" class="btn" ng-click="row.select();"
  ng-class="{'btn-success':row.qState === 'S'}">{{row.qText}}</button>

QFieldgetMoreData()

function

Get more data for your field. Notification OnData will be triggered when complete.

Introduced in Qlik Sense 2.1

Returns

The field object

<button ng-if="fieldMonth.rowCount>fieldMonth.rows.length" ng-click="fieldMonth.getMoreData()">More</button>

QFieldlock()

function

Locks a field selection.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').lock();

QFieldselect(Array, toggle?, softlock?)

function

Select field values using indexes.

Parameters

Array
Array<any>

of indexes to values to select.

toggle
optional
boolean

If true, toggle selected state.

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').select([0, 1, 2], true, true);

QFieldselectAll(softlock?)

function

Select all values in field.

Parameters

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').selectAll();

QFieldselectAlternative(softlock?)

function

Select alternative values in field.

Parameters

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').selectAlternative();

QFieldselectExcluded(softlock?)

function

Select excluded values in field.

Parameters

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').selectExcluded();

QFieldselectMatch(match, softlock?)

function

Select matching field values.

Parameters

match
string

Match string.

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').selectMatch('A', true);

QFieldselectPossible(softlock?)

function

Select possible values in field.

Parameters

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').selectPossible();

QFieldselectValues(values, toggle?, softlock?)

function

Select field values.

Parameters

values
Array<object>

Array of qFieldValues to select. Since 1.1, a simplified syntax with strings OR numbers also works. Note that for a numeric field, you need to provide the numeric value.

toggle
optional
boolean

If true, toggle selected state. If false replace the current selection.

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise of an engine response.

app.field("Month").selectValues([5], true, true);
app.field(fld).selectValues(["Wetterberg"], true, true);

QFieldtoggleSelect(match, softlock?)

function

Toggle field selection.

Parameters

match
string

Match string.

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').toggleSelect('A', true);

QFieldunlock()

function

Unlocks a field selection.

Returns

A promise of an engine response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.field('LastName').unlock();

new QFieldSelections()

class

Selection state for a field.

Introduced in Qlik Sense 2.2.

Properties

fieldName
string

The field name.

qSortIndex
number

Sort index, starting from 0.

field

Reference to the field.

locked
boolean

Is field locked?

isNumeric
boolean

Is field numeric?

totalCount
number

Total number of values in field.

selectedCount
number

Number of selected values.

qSelectionThreshold
number

Number of values that will be listed.

qStateCounts
object

Object with number of values in different states.

qSelected
string

Concatenated string of selected values if # of values are less than the threshold or string of format "7 of 123".

selectedValues
Array<number>

Array with a maximum of qSelectionThreshold values that are selected. For each value the text plus the selection mode (NORMAL/AND/NOT).

notSelectedValues
Array<number>

Array with a maximum of qSelectionThreshold values that are not selected. For each value the text plus the selection mode (NORMAL/AND/NOT).

new QFieldValue()

class

Field value for a Qlik Field.

Properties

qText
string

Cell value formatted as set up in properties.

qElemNumber
number

Cell value index.

qState
string

Cell state.

qNum
optional
number

Cell numeric value, if cell is numeric.

qFrequency
optional
string

Frequency, if calculated by engine.

QFieldValueselect(toggle?, softlock?)

function

Select field value.

Introduced in Qlik Sense 2.1.

Parameters

toggle
optional
boolean

If true, toggle selected state.

softlock
optional
boolean

If true, locked selections can be overridden.

Returns

A promise.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
var field = app.field('LastName');
field.getData();
//after data is loaded fieldvalues will be in rows array
field.rows[0].select();

new QGlobal()

class

QGlobalcancelReload()

function

Cancel reload.

Returns

A promise of a Qlik engine reply.

var global = qlik.getGlobal(config);
global.cancelReload();

QGlobalgetAppList(callback)

function

Get app list.

Parameters

callback
function

callback method.

qlik.getGlobal(config).getAppList(function(list){
  var str = "";
  $.each(list, function(key, value) {
    str +=  value.qDocName + '('+ value.qDocId + ')';
  });
  console.log(str);
});

QGlobalgetAuthenticatedUser(callback?)

function

Retrieves information about the authenticated user. Note: This method is only applicable to Qlik Sense Enterprise on Windows. For Qlik Sense Enterprise SaaS, use {@link https://qlik.dev/apis/rest/users#%23%2Fentries%2Fusers%2Fme-get|User API}

Parameters

callback
optional
function

callback method.

Returns

A promise of a Qlik engine reply.

var global = qlik.getGlobal(config);
global.getAuthenticatedUser(function(reply){
  console.log('User:'+reply.qReturn);
});

QGlobalgetProductVersion(callback?)

function
deprecated

Get Product Version.

Introduced in Qlik Sense 1.2.

Parameters

callback
optional
function

callback method.

Returns

A promise of a Qlik engine reply.

var global = qlik.getGlobal(config);
global.getProductVersion(function(reply){
  console.log('Product Version:'+reply.qReturn);
});

QGlobalgetProgress(qRequestId, callback?)

function

Get Progress.

Introduced in Qlik Sense 2.1.

Parameters

qRequestId
number

RequestId from doReload call or 0. Complete information is returned if the identifier of the request is specified. If qRequestId = 0, less information is returned.

callback
optional
function

callback method.

Returns

A promise of a Qlik engine reply.

var global = qlik.getGlobal(config);
global.getProgress();

QGlobalgetQTProduct(callback?)

function

Get QT Product.

Parameters

callback
optional
function

callback method.

Returns

A promise of a Qlik engine reply.

var global = qlik.getGlobal(config);
global.getQTProduct(function(reply){
  console.log('QT Product:'+reply.qReturn);
});

QGlobalisPersonalMode(callback?)

function

Get isPersonalMode.

Parameters

callback
optional
function

callback method.

Returns

A promise of a Qlik engine reply.

var global = qlik.getGlobal(config);
global.isPersonalMode(function(reply){
  console.log('Personal mode:'+reply.qReturn);
});

QGlobaloff(eventName?)

function

Remove listener(s) for the global events.

Introduced in Qlik Sense February 2018.

Parameters

eventName
optional
string

Name of the event. Can be: error, warning, closed. Removes all listeners if no eventName is provided.

var global = qlik.getGlobal(config);
global.on("error", function (error) {
  console.log("error listener called for global", error);
});
global.off("error");

QGlobalon(eventName, callback)

function

Adds listeners to the global events. Possible events are error, warning, and closed. Multiple listeners can be added to an event.

Introduced in Qlik Sense February 2018

Parameters

eventName
string

Name of the event. Can be: error, warning, closed.

callback
function

Callback method.

var global = qlik.getGlobal(config);
global.on("error", function (error) {
  console.log("error listener called for global", error);
});
global.on("warning", function (warning) {
  console.log("warning listener called for global", warning);
});
global.on("closed", function (closed) {
  console.log("closed listener called for global", closed);
});

new QGlobalTheme()

class

QGlobalThemeapply(id)

function

Apply a theme to all visualizations on the web page.

Parameters

id
string

ID of theme to apply.

Returns

Promise of a boolean to indicate success or not.

qlik.theme.apply('my-theme-id').then(function(result){
  console.log('theme applied with result: ' + result);
});

QGlobalThemeget(id)

function

Get theme as a QTheme object.

Parameters

id
string

Theme id

Returns

A promise of a QTheme object.

qlik.theme.get('my-theme-id').then(function(qtheme){
  console.log('Theme background color: ' + qtheme.properties.backgroundColor);
});

new QHeader()

class

Wrapper around a HyperCube header cell.

Introduced in Qlik Sense 2.1.

Properties

qFallbackTitle
string

Column title.

qSortIndicator
string

A: ascending, D:Descending

isOrderedBy
boolean

Is this the first column for sort?

qReverseSort
boolean

Is sort order currently reversed for this column?

col
number

Column number.

qCardinal
optional
number

Number of different values. Only for dimensions.

qStateCounts
optional
object

Object with number of values in different states. Only for dimensions.

field
optional

Field object with methods to manipulate the underlying field. Only used for dimensions.

qMin
optional
number

Minimum value. Only for measures.

qMax
optional
number

Maximum value. Only for measures.

errorCode
optional
number

Error code for this column. Only if column has an error. Since Qlik Sense 2.2.

errorMessage
optional
string

Error message for this column. Only if column has an error. Since Qlik Sense 2.2.

<th ng-repeat="head in data.headers" class="header" ng-click="head.orderBy()">
  {{head.qFallbackTitle}}
       <i ng-if="head.isOrderedBy" ng-click="head.reverseOrder()"
           ng-class="{ 'icon-triangle-top': head.qSortIndicator === 'A',
			'icon-triangle-bottom': head.qSortIndicator === 'D'}">
       </i>
</th>

QHeaderorderBy()

function

Set this column to be the first in the sort order.

QHeaderreverseOrder()

function

Reverse the sorting order for the column.

QHeaderselectRange(min, max, inclMin?, inclMax?)

function

Select a range in this measure.

Parameters

min
number

Sets the minimum value of the range.

max
number

Sets the maximum value of the range.

inclMin
optional
boolean

Set to true to include minimum value.

inclMax
optional
boolean

Set to true to include maximum value.

Returns

No description

this.table.headers[1].selectRange( this.minval, this.maxval );

new QMeasureCell()

class

Wrapper around a HyperCube measure cell.

Properties

qText
string

Cell value formatted as set up in properties.

qNum
optional
number

Cell numeric value, if cell is numeric.

QMeasureCellgetPercent()

function

Get the value of this cell as percent of total. Note that this might be more than 100% if this is an average.

<div class="bar" style="width:{{row.measures[0].getPercent()}}%">

QMeasureCellgetPercentOfMax()

function

Get the value of this cell as percent of maximum.

<div class="bar" style="width:{{row.measures[0].getPercentOfMax()}}%">

new QNavigation()

class

Properties

ANALYSIS
string

Used for analysis mode.

EDIT
string

Used for edit mode.

QNavigationgetCurrentSheetId()

function

Get current sheet ID.

Returns

Return value from sheet navigation methods.

var result = qlik.navigation.getCurrentSheetId();
console.log('sheet id: ' + result.sheetId);

QNavigationgetMode()

function

Get current mode.

Returns

string

mode The current mode.

var mode = qlik.navigation.getMode();
console.log('mode: ' + mode);

QNavigationgotoSheet(sheetId)

function

Navigates to a given sheet in the current app. Note that the method will return before the actual navigation takes place.

Parameters

sheetId
string

The ID of the sheet to navigate to.

Returns

Return value from sheet navigation methods.

var navigationResult = qlik.navigation.gotoSheet('xYgfJ');

QNavigationgotoStory(storyId)

function

Navigates to a given story in the current app. Note that the method will return before the actual navigation takes place.

Parameters

storyId
string

The ID of the story to navigate to.

Returns

Return value from story navigation methods.

var navigationResult = qlik.navigation.gotoStory('xYgfJ');

QNavigationisModeAllowed(mode)

function

Checks if a given mode is allowed.

Parameters

mode
string

The mode to check availability of. Can be either {@link QNavigaton#EDIT} or {@link QNavigaton#ANALYSIS}.

Returns

boolean

If the mode is allowed or not.

if (qlik.navigation.isModeAllowed(QNavigation#EDIT)) {
  //enable edit button
};

QNavigationnextSheet()

function

Navigates to the next sheet in the current app. It will do nothing if you do not have sheets in the current context. Note that the method will return before the actual navigation takes place.

Returns

Return value from sheet navigation methods.

var navigationResult = qlik.navigation.nextSheet();

QNavigationprevSheet()

function

Navigates to the previous sheet in the current app. It will do nothing if you do not have sheets in the current context. Note that the method will return before the actual navigation takes place.

Returns

Return value from sheet navigation methods.

var navigationResult = qlik.navigation.prevSheet();

QNavigationsetMode(mode)

function

Set current mode.

Parameters

mode
string

The mode to change to. Can be either {@link QNavigation#EDIT} or {@link QNavigation#ANALYSIS}.

Returns

Return value from mode related navigation methods.

var result = qlik.navigation.setMode(QNavigation#EDIT);
console.log('mode: ' + result.mode);

QNavigationModeResult

object

Return value from mode related navigation methods.

Properties

success
boolean

true if the operation was successful.

mode
optional
string

The new mode. Can be either {@link QNavigation#EDIT} or {@link QNavigation#ANALYSIS}.

error
optional
string

The error code if an error occurred, for example, MODENOTALLOWED.

errorMsg
optional
string

The error message, for example, 'Mode not allowed'.

QNavigationSheetResult

object

Return value from sheet navigation methods.

Properties

success
boolean

true if the navigation was successful.

sheetId
optional
string

The new sheet ID.

error
optional
string

The error code if an error occurred, for example, NOSUCHSHEET or NOCURRENTSHEET.

errorMsg
optional
string

The error message, for example, 'No current sheet'.

QNavigationStoryResult

object

Return value from story navigation methods.

Properties

success
boolean

true if the navigation was successful.

storyId
optional
string

The new story ID.

error
optional
string

The error code if an error occurred, for example, NOSUCHSTORY.

errorMsg
optional
string

The error message, for example, 'No such story'.

new QRow()

class

Wrapper around a HyperCube data row.

Properties

dimensions

Dimension cells.

measures

Measure cells.

cells
Array<any>

All cells, in the order defined in properties.

<div ng-repeat="row in data.rows" class="row"  title="{{row.dimensions[0].qText}}"
   data-value="{{ row.dimensions[0].qElemNumber }}">
   <div class="bar" style="width:{{row.measures[0].getPercent()}}%">
       <span>{{row.dimensions[0].qText}}</span>
   </div>
   <div class="per">
       <span class="{{row.measures[0].getPercent()>95 ? 'over':'' }}">{{row.measures[0].qText}}</span>
   </div>
</div>

new QSelectionState()

class

The SelectionState API allows developers to work with selection state data returned from the Qlik engine without having deeper knowledge of internal constructs.

Notification is sent when data is available. Notification will be triggered after each update. To receive notification, bind a listener on <i>'OnData'</i> of QSelectionState instance.

Properties

stateName
string

State name, '$' for default state.

selections

Selections

backCount
number

Number of back steps available.

forwardCount
number

Number of forward steps available.

OnData

OnData notification.

// create an object
const selState = app.selectionState();

const listener = function() {
  console.log('Back count:' + selState.backCount);
  selState.OnData.unbind( listener );  //unregister the listener when no longer notification is needed.
};
selState.OnData.bind( listener ); //bind the listener
Example based on using AngularJS.

Your main script:

$scope.selState = app.selectionState();

In your AngularJS template:
<button type="button" class="btn btn-default btn-xs" ng-click="selState.clearAll()" aria-label="Clear">
  <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>

<li ng-repeat="sel in selState.selections">{{sel.fieldName}}: {{sel.qSelected}}
  <button type="button" class="btn btn-default btn-xs" ng-click="sel.field.clear()" aria-label="Lock">
    <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
  </button>
</li>

QSelectionStateclearAll(lockedAlso?)

function

Clear all selections in this state.

Parameters

lockedAlso
optional
boolean

Clear locked fields also.

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
var selState = app.selectionState();
selState.clearAll(true);

QSelectionStatelockAll()

function

Lock all selections in this state.

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
var selState = app.selectionState();
selState.lockAll();

QSelectionStateunlockAll()

function

Unlock all selections in this state.

Returns

A promise of a Qlik engine reply

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
var selState = app.selectionState();
selState.unlockAll();

new QTable()

class

The Table API allow developers to work with tabular data returned from the Qlik engine without having deeper knowledge of internal constructs like, for example, a hypercube. From a technical perspective it is a wrapper around HyperCube data from engine.

Notification is sent when data is available. Notification will be triggered after each update. To receive notification bind a listener on <i>'OnData'</i> of QTable instance.

Properties

rows

Data rows.

headers

Header information.

totals

Total information for measures.

rowCount
number

Total number of rows for the qHyperCube, including rows not fetched from server.

colCount
number

Total number of columns for the qHyperCube.

// Initialization using the hypercube of the current visualization
var table = qlik.table( this );

var listener = function() {
  var rowCount = table.rowCount;
  var colCount = table.colCount;
  table.OnData.unbind( listener );  //unregister the listener when no longer notification is needed.
};
table.OnData.bind( listener ); //bind the listener
// Example based on using AngularJS.

// Your main script:

if ( !this.$scope.table ) {
  this.$scope.table = qlik.table( this );
}

// In your AngularJS template:

<tr ng-repeat="row in table.rows">
   <td ng-repeat="cell in row.cells"> {{cell.qText}} </td>
</tr>

QTableexportData(options?, callback?)

function

Export data of the underlying hyperCube in OOXML or CSV format. Note: The entire hyperCube will be exported, not just the current data-page.

Parameters

options
optional

No description

callback
optional
function

Callback function returning the link to the exported file.

var qTable = qlik.table(this);

var $exportButton = $( document.createElement('button'));
$exportButton.html('Export');
$exportButton.bind('click', function (  ) {
			qTable.exportData({download: true});
		});
$element.append($exportButton);
// Example using AngularJS in a Qlik Sense visualization extension:

// Main script:
...
paint: function ( ) {
		//setup scope.table
		if ( !this.$scope.table ) {
			this.$scope.table = qlik.table( this );
		}
	}
...

// In your template:
<button ng-click="table.exportData({download:true})">Create Excel file</button>

QTablegetColByName(fld)

function

Get column number for a given field name.

Parameters

fld
string

Field name.

Returns

number

Column number, starting with zero. Undefined if no column with that name.

var table = qlik.table( this );
var colNumber = table.getColByName('Closed cases');

QTablegetMoreData()

function

Get more data for your qHyperCube.

// Example based on using AngularJS in a Qlik Sense visualization extension.

// Main extension script file:
...
paint: function ( ) {
		//setup scope.data
		if ( !this.$scope.data ) {
			this.$scope.data = qlik.table( this );
		}
	}
...

// AngularJS template:
<button ng-if="data.rowcount>data.rows.length" ng-click="data.getMoreData()">More</button>

new QTheme()

class

Wrapper for a theme with helper methods.

Introduced in Qlik Sense February 2018.

Properties

id
string

Theme id

properties
object

Theme properties tree structure with calculated styling values. Functions, variables, and inheritance have been computed from the original theme JSON file.

QThemeapply()

function

Apply theme to all visualizations on the web page.

Returns

Promise of a boolean to indicate success or not.

qlik.theme.get('my-theme-id').then(function(qtheme){
  qtheme.apply().then(function(result){
    console.log('theme applied with result: ' + result);
  });
});

QThemegetStyle(basePath, path, attribute)

function

Get the value of a style attribute in the theme by searching in the theme's JSON structure. The search starts at the specified base path and continues upwards until the value is found. If possible, it will get the attribute's value using the given path.

Parameters

basePath
string

Base path in the theme's json structure to start the search in (specified as a name path separated by dots).

path
string

Expected path for the attribute (specified as a name path separated by dots).

attribute
string

Name of the style attribute.

Returns

string

The style value.

qlik.theme.get('my-theme-id').then(function(qtheme){
  console.log('Object title font size: ' + qtheme.getStyle('object', 'title.main', 'fontSize'));
});

new QVariable(app, qapp)

class

Creates an instance of the Variable API.

Parameters

app
object

The app object.

qapp
object

The qlik.app wrapper for the app object.

QVariablecreate()

function

Create variable.

Returns

Promise of a Variable model.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.variable.create('myvar').then(function(model){
  // do something with myvar
});

QVariablecreateSessionVariable(qProp)

function

Create session variable, which is a temporary variable that is not persisted and needs to be recreated for each new session.

Introduced in Qlik Sense 2.1.

Parameters

qProp

Variable properties.

Returns

Promise of a Variable model.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.variable.createSessionVariable({qName : 'myvar', qDefinition: 'Month'}).then(function(model){
  // do something with myvar
});

QVariableget(qId)

function

Get a variable by ID.

Introduced in Qlik Sense 2.1.

Parameters

qId
string

Variable ID.

Returns

Promise of a Variable model.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.variable.get('yTgsRI').then(function(model){
  // do something with myvar
});

QVariablegetByName(qName)

function

Get a variable by name.

Introduced in Qlik Sense 2.1.

Parameters

qName
string

Variable name.

Returns

A promise of a Variable model.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.variable.getByName('myvar').then(function(model){
  // do something with myvar
});

QVariablegetContent(name, callback)

function

Get variable content.

Parameters

name
string

Variable name.

callback

Callback to receive the content.

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.variable.getContent('myvar',function ( reply ) {
  console.log( JSON.stringify( reply ) );
});

QVariablesetContent(name, content)

function
deprecated

Set variable content.

Parameters

name
string

Variable name.

content
string

Variable content.

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.variable.setContent('myvar','=(1+1)');

QVariablesetNumValue(qName, qVal)

function

Set variable numeric value.

Introduced in Qlik Sense 2.1.

Parameters

qName
string

Variable name.

qVal
number

Variable value.

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.variable.setNumValue('myvar',5);

QVariablesetStringValue(qName, qVal)

function

Set variable string value.

Introduced in Qlik Sense 2.1.

Parameters

qName
string

Variable name.

qVal
string

Variable value.

Returns

A promise of a Qlik engine reply.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.variable.setStringValue('myvar','=(1+1)');

QVariablegetContentCallback(data, qapp)

function

Parameters

data

Content of the variable.

qapp
object

The qlik.app object wrapping the app.

new QVisualization(qapp, model)

class

The Visualization API allows developers to get visualizations defined in an app and to create temporary visualizations on the fly.

Introduced in Qlik Sense 2.2.

Parameters

qapp

The app referenced in the visualization.

model
object

The visualization model.

Properties

table

Table object for this visualization. Only for visualizations built on a hypercube.

QVisualizationclose()

function

Close visualization.

Returns

No description

QVisualizationexportData(options)

function

Exports data of the underlying hyperCube in OOXML or CSV format. Note: The entire hyperCube will be exported, not just the current data-page.

Parameters

options

No description

Returns

any

Promise<string> - A promise of the file location URL.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.visualization.get('xGhjKl').then(function(vis){
  vis.exportData({format:'CSV_T', state: 'A'}).then(function (link) {
    window.open(link);
  });
});

QVisualizationexportImg(settings)

function

Exports a QVisualization instance to an image.

Parameters

settings

Image export settings.

Returns

any

Promise<string> - A promise of a link to the exported file.

var element = document.getElementById('QV01');
var settings = { imageType: 'png', height: element.offsetHeight, width: element.offsetWidth }

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.visualization.get('xGhjKl').then(function(vis){
  vis.exportImg(settings).then(function (result) {
    console.log('Image download link: ', result);
  });
});

QVisualizationexportPdf(settings)

function

Exports a QVisualization instance to PDF.

Parameters

settings

PDF export settings.

Returns

any

Promise<string> - A promise of a link to the exported file.

var settings = {
  documentSize: "a4",
  aspectRatio: 2,
  orientation: "landscape"
};
var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.visualization.get('xGhjKl').then(function(vis){
  vis.exportPdf(settings).then(function (result) {
    console.log('PDF download link: ', result);
  });
});

QVisualizationresize()

function

Inform the visualization it has been resized and should repaint.

QVisualizationsetOptions(options)

function

Set visualization options.

Parameters

options
object

Options to set. Refer to visualization.create for documentation.

Returns

A promise of the RPC call's response.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.visualization.get('xGhjKl').then(function(vis){
  vis.setOptions({title:"Now improved"});
});

QVisualizationshow(element?, options?)

function

Show visualization in HTML element.

Parameters

element
optional
HTMLElement | string

HTML element or HTML element ID.

options
optional

Options to set. Since Qlik Sense 3.0.

Returns

object

Scope of the visualization.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.visualization.get('xGhjKl').then(function(vis){
  vis.show("QV01");
});

QVisualizationtoggleDataView()

function

Toggles data view.

Creates a DataView object if it doesn't already exist and toggles data view.

Introduced in Qlik Sense June 2018.

Disclaimer: The element that is provided as a parameter to the QVisualization.show method must have CSS property position set to relative and must not have any padding. If these rules are not followed, the visualization object may not calculate its width and height correctly and you may not be able to scroll and navigate after toggling data view.

Proposed action: Wrap the element with another element. The wrapper can then be styled without any limitations.

var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d');
app.visualization.get('xGhjKl').then(function(vis){
  vis.show("QV01");
  vis.toggleDataView().then(function(toggled){
    if(toggled){
      this.getElementsByClassName('qv-st')[0].focus();
    }
  }
});
Was this page helpful?