Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Josh_Rmg
Contributor II
Contributor II

Qlik .Net SDK - Get ID of default bookmark

Is there a way identify a sheet/app's default bookmark? 

We have a Qlik sense app that has a default bookmark, so it is applied whenever the app is opened in a browser.

However, when using the .net sdk and "opening" the app via code/backend it does not apply that default bookmark. 

I am able to get a list of the bookmarks and see the titles/IDs etc. so I can apply the bookmark that way. But if someone changes the title or adds new bookmark (with a different ID) and makes that one the default my code won't be accurate anymore.

 

So, is there a way to identify from the list of bookmarks which one is marked as the default bookmark?

 

Kind Regards,

Josh

1 Solution

Accepted Solutions
Øystein_Kolsrud
Employee
Employee

The concept of a default bookmark is a pure client concept. The engine does not really know anything about this. There is a special app object created by the client that stores app metadata that the client requires such as some color schemes and theme information. This object also contains the ID of the default bookmark, and upon connection to the app, the client will read these properties and simply call ApplyBookmark with that ID.

There are several ways to access this client properties object, but I find the simplest one (though not the most efficient) is to do like this:

using (var app = location.App(appId))
{
    var objectInfo = app.GetAllInfos().Single(info => info.Type == "appprops");
    var clientAppPropsObject = app.GetGenericObject(objectInfo.Id);
    var defaultBookmarkId = clientAppPropsObject.Properties.Get<string>("defaultBookmarkId");
    Console.WriteLine(defaultBookmarkId);
}

The reason why I said this is not the most efficient, is that call to App.GetAllInfos really returns information about all app entities, and you're really looking for one single. Efficiency wise it's better to do the filtering server-side. You can do that either by creating a list session object, or use the filter capability of the repository API. This thread shows you how to get the app properties using a list object:

https://community.qlik.com/t5/New-to-Qlik-Sense/Qlik-sense-Net-SDK-app-theme-name/td-p/1738177

If you prefer to use the repository API, then you can do something like this with the following library https://www.nuget.org/packages/QlikSenseRestClient/

var client = new RestClient(url);
client.AsNtlmUserViaProxy();
var clientPropsObjectInfo = client.Get<JArray>($"/qrs/app/object?filter=app.id eq {appId} and objectType eq 'appprops'").First;
var clientPropsObjectId = clientPropsObjectInfo["id"].Value<string>();
Console.WriteLine(clientPropsObjectId);

 

View solution in original post

2 Replies
Øystein_Kolsrud
Employee
Employee

The concept of a default bookmark is a pure client concept. The engine does not really know anything about this. There is a special app object created by the client that stores app metadata that the client requires such as some color schemes and theme information. This object also contains the ID of the default bookmark, and upon connection to the app, the client will read these properties and simply call ApplyBookmark with that ID.

There are several ways to access this client properties object, but I find the simplest one (though not the most efficient) is to do like this:

using (var app = location.App(appId))
{
    var objectInfo = app.GetAllInfos().Single(info => info.Type == "appprops");
    var clientAppPropsObject = app.GetGenericObject(objectInfo.Id);
    var defaultBookmarkId = clientAppPropsObject.Properties.Get<string>("defaultBookmarkId");
    Console.WriteLine(defaultBookmarkId);
}

The reason why I said this is not the most efficient, is that call to App.GetAllInfos really returns information about all app entities, and you're really looking for one single. Efficiency wise it's better to do the filtering server-side. You can do that either by creating a list session object, or use the filter capability of the repository API. This thread shows you how to get the app properties using a list object:

https://community.qlik.com/t5/New-to-Qlik-Sense/Qlik-sense-Net-SDK-app-theme-name/td-p/1738177

If you prefer to use the repository API, then you can do something like this with the following library https://www.nuget.org/packages/QlikSenseRestClient/

var client = new RestClient(url);
client.AsNtlmUserViaProxy();
var clientPropsObjectInfo = client.Get<JArray>($"/qrs/app/object?filter=app.id eq {appId} and objectType eq 'appprops'").First;
var clientPropsObjectId = clientPropsObjectInfo["id"].Value<string>();
Console.WriteLine(clientPropsObjectId);

 

Josh_Rmg
Contributor II
Contributor II
Author

Thank you, this was very helpful.

Kind Regards,

Josh