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: 
amien
Specialist
Specialist

sample how to read all the master items using SDK and C#

anyone got an example for me in c# or point me in the right direction?

1 Solution

Accepted Solutions
mow
Employee
Employee

There is a public example for traversing apps and retrieving master objects using the .NET SDK.

https://github.com/AptkQlik/PublicExamples/tree/master/AppTraverser

View solution in original post

9 Replies
mow
Employee
Employee

There is a public example for traversing apps and retrieving master objects using the .NET SDK.

https://github.com/AptkQlik/PublicExamples/tree/master/AppTraverser

amien
Specialist
Specialist
Author

Thanks!

amien
Specialist
Specialist
Author

This didn't quite work afterall .. it works fine on the LicenseMonitor app and the Operational app .. but when i create in a new all some master items .. they wont show. any idea why this is?

Øystein_Kolsrud
Employee
Employee

Sounds to me like this is the method you are looking for: AppExtensions.GetMasterObjectList Method

amien
Specialist
Specialist
Author

can you elaborate a bit?

Qlik.Sense.Client.IMasterObjectList masterobjects = Qlik.Sense.Client.AppExtensions.GetMasterObjectList(app);

This .. and then what? How do i loop though the objects?

Øystein_Kolsrud
Employee
Employee

Once you have the IMasterObjectList instance, you can access the information about which master objects are available from the layout of the list. To get the layout, you would do like this:

var listLayout = masterObjectList.GetLayout().As<MasterObjectListLayout>();

Then the set of object IDs for the master objects are available from this property: MasterObjectListLayout.AppObjectList Property

Those IDs can in turn be used to get the actual objects using the "GetObject" method from the app. So the full code would probably look something like this:

var masterObjectList = app.GetMasterObjectList();

var listLayout = masterObjectList.GetLayout().As<MasterObjectListLayout>();

var objectIDs = listLayout.AppObjectList.Items.Select(item => item.Info.Id);

var objects = objectIDs.Select(id => app.GetObject<GenericObject>(id));

Or, if you prefer, you could use the "Items" shortcut on the masterObjectList object to avoid having to explicitly go through the layout. (You will go through the layout anyway, but it will be taken care of in the background.) In that case the code would look like this:

var masterObjectList = app.GetMasterObjectList();

var objectIDs = masterObjectList.Items.Select(item => item.Info.Id);

var objects = objectIDs.Select(id => app.GetObject<GenericObject>(id));

ichimiike
Partner - Contributor III
Partner - Contributor III

Hi there...

I've tried your solution but the AppObjectLlist always comes back with a Count of 0.

As a bit of background on what I'm trying to achieve:

I have several apps... with 100+ master dimensions / measures each. Essentially, I want a ist of each master item along with its description.

Any help will be gratefully received

Ta in advance,

Mat

Øystein_Kolsrud
Employee
Employee

The MasterObjectList will only contain references to generic objects. If you want to list master dimensions and measures, then you need to use these methods instead:

https://help.qlik.com/en-US/sense-developer/April2018/apis/net+sdk/html/M_Qlik_Sense_Client_AppExten...

https://help.qlik.com/en-US/sense-developer/April2018/apis/net+sdk/html/M_Qlik_Sense_Client_AppExten...

ichimiike
Partner - Contributor III
Partner - Contributor III

Thanks for this... but as it happens, I posted the question and then worked it out for myself 😄

Listing master items using .NET SDK

Nice to see I got the same solution as you proposed though