Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
christianborg
Partner - Contributor II
Partner - Contributor II

Qlik Sense app.bookmark.create: How to Preserve Layout, Including Column Positions?

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?

Labels (4)
1 Solution

Accepted Solutions
christianborg
Partner - Contributor II
Partner - Contributor II
Author

Hi @alex_colombo 

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();

 

View solution in original post

7 Replies
alex_colombo
Employee
Employee

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"
        },
        []
    ]
}
christianborg
Partner - Contributor II
Partner - Contributor II
Author

Hi @alex_colombo

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:

  1. 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.

  2. 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.

alex_colombo
Employee
Employee

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".

christianborg
Partner - Contributor II
Partner - Contributor II
Author

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.

christianborg
Partner - Contributor II
Partner - Contributor II
Author

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();

christianborg_0-1699258761764.png

 

alex_colombo
Employee
Employee

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:

  1. ClearAllSoftPatches method called for removing all the possible soft patches applied by the user. This basically reset the whole sheet layout
  2. ApplyBookmark. this apply your bookmark

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.

christianborg
Partner - Contributor II
Partner - Contributor II
Author

Hi @alex_colombo 

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();