Qlik sense Mashup – Get App Object Details

This blog is about fetching the objects of an app using Qlik APP API. This will be helpful if you want to build a dashboard that shows insights on the complexity of the app itself apart from the complexity of the data model.

These will also help in some advanced mashups that helps users to create some dynamic content.

The example in full is available (getMasterItems – GitHub). This example uses the default app, Consumer Sales.qvf, that comes with the Qliksense desktop. And hence it can be directly tested with no modifications.

A single method is used to retrieve details of measures, dimensions, variables, fields etc. But you can use it appropriately to fetch only the details that is needed. In this example, the master items – Dimensions and Measures are fetched.

Its part of the App API : app.getList();

function getList(listType){
app.getList(listType, function(reply){
var str="";
$.each(reply["q"+listType].qItems, function(key, value) {
str=str+ "<br>" + value.qData.title + "    -    " + value.qInfo.qId;
});
$('#QV01').html(str);
});
}

The entire list of objects that can be fetched is given here

https://help.qlik.com/en-US/sense-developer/September2017/Subsystems/APIs/Content/CapabilityAPIs/AppAPI/getList-method.htm

While, this gives necessary information about the objects, it does not give enough information about the variable, measure or dimension definition.

In order to fetch, the variable definition you can use app.variable.getContent() function. This fetches the variable definition.

app.variable.getContent(value.qName).then(function(model){
console.log(model);
});

In order to fetch the same details of measure or dimension, you could use Engine API functions: GetLayout

https://help.qlik.com/en-US/sense-developer/September2017/Subsystems/EngineAPI/Content/WorkingWithAppsAndVisualizations/RenderLayout/get-layout-measure.htm

In order to fetch meta information about the App, you can use getAppLayout() function of App API

function getAppDetails(){
app.getAppLayout(function(layout){
console.log("Layout")
console.log(layout);
$('#QV01').html(JSON.stringify(layout))
});
}

You May Also Like

About the Author: codeatroost

Leave a Reply

Your email address will not be published. Required fields are marked *