Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good afternoon,
We are in the process of developing an extension, and one of the key steps involves creating a bookmark. We are utilizing the app.bookmark.create capability API to achieve this. However, we have encountered an issue where certain aspects of the layout, such as column positions in a table, are not being preserved when the bookmark is created.
Is there a recommended approach or solution to ensure that the layout, including column positions, is properly saved when creating a bookmark?
Thanks for your reply.
I managed to create a bookmark and save the layout using the following code.
Adding `"qObjectIdsToPatch": []` did the trick.
var app = qlik.currApp(this);
var qix = this.backendApi.model.enigmaModel.session;
var sheet_id = qlik.navigation.getCurrentSheetId().sheetId;
qix.app.createBookmarkEx({
"qProp": {
"qInfo": {
"qId": "",
"qType": "bookmark"
},
"qMetaDef": {
"title": "Bookmark with Layout",
"description": "Bookmark with Layout",
"isExtended": true
},
"sheetId": sheet_id,
"qIncludeVariables": true
},
"qObjectIdsToPatch": []
});
return qlik.Promise.resolve();
Hi @christianborg , for doing this you have to use Engine APIs. Bookmark API from Capability APIs doesn't offer this.
You have to use CreateBookmarkEx method from Engine API. As you can see from our help, this is an experimental method, but actually this method is used by our product, so you can stay with it.
Below an example
{
"delta": true,
"handle": 1,
"method": "CreateBookmarkEx",
"params": [
{
"qInfo": {
"qType": "bookmark"
},
"qMetaDef": {
"title": "Bookmark with Layout",
"description": "",
"isExtended": true
},
"creationDate": "2023-11-03T10:23:49.321Z",
"qIncludeVariables": false,
"sheetId": "10c25f6a-2d96-42e0-b034-6f27b548984d",
"selectionFields": "Dim1"
},
[]
]
}
Thank you for your response.
I successfully executed the Qlik Sense Engine API to create a bookmark using the Qlik Sense Engine Explorer within the Dev Hub. However, I have a follow-up question, and I'm wondering if you can assist with it:
Is it possible to programmatically connect to a specific user session, perhaps using a tool like Python, before making calls to the Engine API? I'm interested in saving selections and layouts for that session.
Alternatively, can I use the Qlik Sense Capability API to gather layout and selection details and then pass that information to the Qlik Sense Engine API?
Your guidance on these matters would be greatly appreciated.
Thank you in advance.
1. Could you please describe wht is the main requirement here?
2. You can read current layout and selections, but I'm not understanding what you mean by "pass this to Qlik Sense Engine API".
Hi again @alex_colombo
The primary goal of our extension is to both create a bookmark and trigger an internal API.
In my previous experience, I've typically interacted with Qlik Sense Engine APIs programmatically using Python. However, I'd like to seek your opinion on whether it would be advisable to call these Engine APIs directly via JavaScript within the custom extension itself. This approach could potentially streamline the process by automatically accessing the sheet layout and selections. What are your thoughts on this?
Your insights and recommendations would be greatly appreciated.
Good morning @alex_colombo
I've successfully executed code similar to the one you shared and was able to save the layout using javacript code.
Nevertheless, even though the bookmark indicates that the layout is saved (marked as "saved layout: True"), in practice, the layout doesn't seem to persist.
For instance, fields in a table revert to their default positions.
Have you encountered and resolved this issue?
var app = qlik.currApp(this);
var qix = this.backendApi.model.enigmaModel.session;
var sheet_id = qlik.navigation.getCurrentSheetId().sheetId;
qix.app.createBookmarkEx({
"qProp": {
"qInfo": {
"qType": "bookmark"
},
"qMetaDef": {
"title": "Bookmark with Layout",
"description": "Bookmark with Layout",
"isExtended": true
},
"sheetId": sheet_id
}
});
return qlik.Promise.resolve();
Hey @christianborg , how are you applying the bookmark? By using Qlik app?
Looking at what product is doing, if you are applying a bookmark from a Qlik app with layout saved, these ar the Engine API calls made:
Instead, if you are applying bookmark from API, you have to do what I have explained above.
About your question in the previous message, you can absolutely use Engine APIs directly from a custom extension.
Thanks for your reply.
I managed to create a bookmark and save the layout using the following code.
Adding `"qObjectIdsToPatch": []` did the trick.
var app = qlik.currApp(this);
var qix = this.backendApi.model.enigmaModel.session;
var sheet_id = qlik.navigation.getCurrentSheetId().sheetId;
qix.app.createBookmarkEx({
"qProp": {
"qInfo": {
"qId": "",
"qType": "bookmark"
},
"qMetaDef": {
"title": "Bookmark with Layout",
"description": "Bookmark with Layout",
"isExtended": true
},
"sheetId": sheet_id,
"qIncludeVariables": true
},
"qObjectIdsToPatch": []
});
return qlik.Promise.resolve();