Apply a bookmark
const Qlik = require('@qlik/sdk').default;
const { AuthType } = require("@qlik/sdk");
const host = process.env['host']
const clientId = process.env['clientId']
const clientSecret = process.env['clientSecret']
const appId = process.env['appId']
const config = {
authType: AuthType.OAuth2,
host: host,
clientId: clientId,
clientSecret: clientSecret
};
(async () => {
const qlik = new Qlik(config);
await qlik.auth.authorize();
const app = await qlik.apps.get(appId);
await app.open();
const bmk = await app.applyBookmark('SmDXrz');
if(!bmk)
{
console.log("bookmark apply failed.");
process.exit();
}
const sessObj = await app.createSessionObject({
"qInfo": {
"qType": "CurrentSelections"
},
"qSelectionObjectDef": {}
}
);
const selectionLayout = await sessObj.getLayout();
for (const item of selectionLayout.qSelectionObject.qSelections)
{
console.log(item.qField);
console.log("==========");
const myListObj = await getListObject(app, item.qSelectedCount, item.qField);
const listLayout = await myListObj.getLayout();
for (const pages of listLayout.qListObject.qDataPages)
{
for (const val of pages.qMatrix)
{
console.log(val[0].qText);
}
}
console.log("==========");
}
process.exit();
})();
async function getListObject(app, valCount, fieldName)
{
const listObj = await app.createSessionObject({
"qInfo": {
"qId": "LB01",
"qType": "ListObject"
},
"qListObjectDef": {
"qStateName": "$",
"qLibraryId": "",
"qDef": {
"qFieldDefs": [
fieldName
],
"qFieldLabels": [
fieldName
],
"qSortCriterias": [
{
"qSortByLoadOrder": 1
}
]
},
"qInitialDataFetch": [
{
"qTop": 0,
"qHeight": valCount,
"qLeft": 0,
"qWidth": 1
}
]
}
});
return listObj;
}