Skip to content

Instantly share code, notes, and snippets.

@mindspank
Created January 21, 2016 18:10
Show Gist options
  • Save mindspank/9aafa9cb9bd4ff0b3fbc to your computer and use it in GitHub Desktop.
Save mindspank/9aafa9cb9bd4ff0b3fbc to your computer and use it in GitHub Desktop.
CreateMeasure with qsocks
const qsocks = require('qsocks');
/**
* Creating a master measure in Qlik Sense Desktop
*/
qsocks.Connect().then(function(global) {
// Open a document
global.openDoc('TestScript').then(function(app) {
// Creating a measure in the master library
// See this article for the request structure
// http://help.qlik.com/sense/2.1/en-us/developer/Subsystems/EngineAPI/Content/Classes/AppClass/App-class-CreateMeasure-method.htm
app.createMeasure({
qInfo: {
qId: '',
qType: 'measure'
},
qMeasure: {
qLabel: 'This is a measure created with the Engine API',
qDef: '=Sum(Expression1)'
},
qMetaDef: {
title: 'This is a measure created with the Engine API', // Yes this is annoying
description: 'A description'
}
})
.then(function() {
// Persist changes to disk.
return app.doSave();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment