Created
February 2, 2016 21:24
-
-
Save mindspank/c44b5422127b44a98a61 to your computer and use it in GitHub Desktop.
Creates a measure on the server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const qsocks = require('qsocks'); | |
| const fs = require('fs'); | |
| /** | |
| * Creating a master measure in Qlik Sense Desktop | |
| */ | |
| const config = { | |
| host: 'usrad-aklprobook', | |
| isSecure: true, | |
| rejectUnauthorized: false, | |
| port: 4747, | |
| ca: fs.readFileSync('C:/ProgramData/Qlik/Sense/Repository/Exported Certificates/.Local Certificates/root.pem'), | |
| cert: fs.readFileSync('C:/ProgramData/Qlik/Sense/Repository/Exported Certificates/.Local Certificates/client.pem'), | |
| key: fs.readFileSync('C:/ProgramData/Qlik/Sense/Repository/Exported Certificates/.Local Certificates/client_key.pem'), | |
| headers: { | |
| 'X-Qlik-User': 'UserDirectory=QTSEL;UserId=akl' | |
| } | |
| }; | |
| qsocks.Connect(config).then(function(global) { | |
| // Open a document | |
| global.openDoc('2422586d-89ba-4e68-b790-418526bb1079').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', | |
| description: 'A description' | |
| } | |
| }) | |
| .then(function() { | |
| // Persist changes to disk. | |
| return app.doSave(); | |
| }); | |
| }); | |
| }).catch(function(error) { | |
| console.log(error) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment