Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Oct 27, 2020 6:07:56 AM
May 16, 2019 11:12:38 AM
On the machine where you have Qlik Sense Desktop installed, install node.js, create a new folder for your node project and install the following modules:
npm install ws enigma.js
Copy the following code in a file named scramble.js and save it in the same folder:
const WebSocket = require('ws'); const enigma = require('enigma.js'); const schema = require('enigma.js/schemas/12.170.2.json'); const qParam = { "qInfo": { "qId": "", "qType": "FieldList" }, "qFieldListDef": { "qShowSystem": true, "qShowHidden": true, "qShowSemantic": true, "qShowSrcTables": true } }; (async () => { try { console.log('Creating app on engine.'); const session = enigma.create({ schema, url: 'ws://localhost:9076/app/', createSocket: url => new WebSocket(url), }); const qix = await session.open(); var app = await qix.openDoc(process.argv[2]); const objsession = await app.createSessionObject(qParam); const fields = await objsession.getLayout(); const results = fields.qFieldList.qItems; for (var p in results) { var myfield = JSON.stringify(results[p]['qName']).replace(/"/gi,''); if (myfield.includes("$")==false){ console.log(myfield); await app.scramble(myfield); } } await app.doSave(); await session.close(); console.log('Session closed.'); } catch (err) { console.log('Whoops! An error occurred.', err); process.exit(1); } })();
Launch Qlik Sense desktop and log in, once you reach your list of apps, open a command prompt, move to the folder where scramble.js has been copied and execute the following:
node scramble.js "Consumer Sales"
Replace "Consumer Sales" by the name of the app you want to scramble.
If this is successful, the list of fields getting scrambled will be displayed, and a message "Session Closed" will be printed when the process is over.
Now, if you close Qlik Sense Desktop, reopen it and open your app again, you can verify that the fields in the app have been scrambled correctly.