Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ludmillab
Contributor II
Contributor II

Qlik Sense .NET SDK: How to save layout when creating a bookmark

Dear all,

We have implemented saving a bookmark in our C# .NET application:

 

using var app = location.App(appIdentifier, session);
var metadef = new NxMetaDef();
metadef.Set("title", title);
metadef.Set("description", description);
var createBMResult = app.CreateGenericBookmark(
new GenericBookmarkProperties
{
    Info = new NxInfo
       {
           Id = string.Empty,
           Type = "bookmark"
       },
       MetaDef = metadef
     });

var bookmark = app.GetGenericBookmark(createBMResult.Info.Id);
bookmark.Publish();

 

 

We would like to also save the layout with the bookmark. How do we achieve this?
(When creating a bookmark in Qlik you can check the alternative "Save layout". How is this done programmatically?)


create_bm.PNG

1 Solution

Accepted Solutions
ludmillab
Contributor II
Contributor II
Author

I found a solution that works:

using var app = location.App(appIdentifier, session);
                var metadef = new NxMetaDef();
                metadef.Set("title", title);
                metadef.Set("description", description);

                // Get the sheet object and its layout and object ids of objects in layout
                var sheetObject = (Sheet)app.GetObject<GenericObject (sheetId);
                var sheetLayout = sheetObject.Layout;
                var idsOfObjectsInSheetLayout = sheetLayout.Cells.Select(x => x.Name);

                var createBMResult = app.CreateBookmarkEx(
                    new GenericBookmarkProperties
                    {
                        Info = new NxInfo
                        {
                            Id = string.Empty,
                            Type = "bookmark"
                        },
                        MetaDef = metadef
                    },
                    idsOfObjectsInSheetLayout);

 

View solution in original post

2 Replies
ludmillab
Contributor II
Contributor II
Author

I found a solution that works:

using var app = location.App(appIdentifier, session);
                var metadef = new NxMetaDef();
                metadef.Set("title", title);
                metadef.Set("description", description);

                // Get the sheet object and its layout and object ids of objects in layout
                var sheetObject = (Sheet)app.GetObject<GenericObject (sheetId);
                var sheetLayout = sheetObject.Layout;
                var idsOfObjectsInSheetLayout = sheetLayout.Cells.Select(x => x.Name);

                var createBMResult = app.CreateBookmarkEx(
                    new GenericBookmarkProperties
                    {
                        Info = new NxInfo
                        {
                            Id = string.Empty,
                            Type = "bookmark"
                        },
                        MetaDef = metadef
                    },
                    idsOfObjectsInSheetLayout);

 

Damien_Villaret
Support
Support

Hello @ludmillab 

Glad to see that you could find a solution.

That is correct.

CreateGenericBookmark (.NET SDK) / CreateBookmark (Engine API) do not save the layout.

CreateBookmarkEx (.NET SDK) / CreateBookmarkEx (Engine API) will save the layout.

If the issue is solved please mark the answer with Accept as Solution.