Developer forum

Forum » CMS - Standard features » Reading an Item relation list

Reading an Item relation list

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Guys,

I have an ItemType called Settings. One of the fields on this ItemType based page is a relation list.

I have stored in the Area the id of the Setting page and now I am trying to access the list.

My knowledge is limited. I tried:

Dynamicweb.Content.Items.Item generalSettings = Dynamicweb.Content.Items.Item.GetItemById("Settings","215");

Then I tried getting the value of the field :

generalSettings["Menu"] but this returns a number instead of a list of comma separated Id's. I assume the number is the ID of the Relations List.

How do I get the actual list?

Thanks,

Adrian


Replies

 
Ole Panhardt Christensen
Reply

If anyone else stumbles upon this like I did, the value you get is the id of the itemrelationlist. To get the actual items you need to use the method Dynamicweb.Content.Items.ItemList.GetItemListById(int).Relations. Note that the list will contain items of the type "itemEntry", but you can just cast it to Dynamicweb.Content.Items.Item.
 

Relevant link:
ItemList: https://doc.dynamicweb.com/api/html/31360718-d43b-666a-f062-f47a3740ef3f.htm

 
Nicolai Pedersen
Reply

Yes! Thanks for taking the time to share!

Have a nice weekend, Nicolai

 
Lars Larsen
Lars Larsen
Reply

Hi

When using Dynamicweb.Content.Items.ItemList.GetItemListById(int).Relations the itemlist items are always read from the database. Is it possible to get a cached version of the itemlist items?

 

You must be logged in to post in the forum