Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
aadil_madarveet
Partner - Creator II
Partner - Creator II

Using GetSheets() - Get Approved/Published sheets only

Hi All,

I using the Qlik Sense .net SDK and trying to get the published sheets only to be loaded in cache.

Can someone help identify the property to get the published sheets only from an app.

The below code execute all the objects in all the sheets. I am trying to restrict this to get only the sheets that are published.

foreach (var sheet in app.GetSheets())
{
var sheetProperty = sheet.GetFullPropertyTree();
foreach (var child in sheet.GetChildInfos().Select(o => app.GetGenericObject(o.Id)).OfType<IVisualizationBase>())
{
child.GetLayoutAsync();
}
}

 Thanks,

Aadil

Labels (2)
2 Replies
Øystein_Kolsrud
Employee
Employee

There is a property in the sheet layout that contains this information. You can access it like this:

var isPublished = sheet.Layout.Meta.Get<bool>("published");

 The property is not a part of the engine API but part of the sheet meta data provided by the Repository. That's why it doesn't appear as a C# property in the SDK.

But if there is a chance that there is a large number of unpublished sheets in the app, then you might want to look into using the QRS API for retrieving the set of published sheets. That way you could filter the sheets directly in the REST request.

Øystein_Kolsrud
Employee
Employee

Another option could be to filter directly on a sheet list items instead of on the sheets. That way you could at least avoid computing the layouts for all the unpublished sheets. A solution could look like this:

var sheetList = app.GetSheetList();
var publishedSheetIds = sheetList.Layout.AppObjectList.Items
    // Only consider the published sheets
    .Where(i => i.Meta.Get<bool>("published"))
    // Get the IDs of the published sheets.
    .Select(i => i.Info.Id);
foreach (var sheet in publishedSheetIds.Select(app.GetSheet))
{
    DoSheetStuff(sheet);
}
app.DestroyGenericSessionObject(sheetList.Id);