Developer forum

Forum » CMS - Standard features » ItemList Relations - relations in database different from ItemList.GetItemListById(itemlistId)

ItemList Relations - relations in database different from ItemList.GetItemListById(itemlistId)

Marie Louise Veigert
Reply

Hi,

Im using a ItemRelation list in an item.

DW version 9.17.6

I experience that some relations in the list isn't returned when I call ItemList.GetItemListById(itemlistId).
I checked in the database, at all relations are there as expected.

Any suggestions to why they are not all available in the  ItemList.GetItemListById(itemlistId); ?

The code below:

List<string> list = new List<string>();
if (item != null)
{
    var itemlistId = Convert.ToInt32(item["TypeFacets"]);
    var itemList = ItemList.GetItemListById(itemlistId);

    foreach(var it in itemList.Relations)
    {
       list.Add(it.Id);
     }
}

feedRoot.availableFacets.TypeFacetEcom = list;

 

In the feed I get these IDs:

"TypeFacetEcom"["6","8","12","5","10","14","11","13","7","15","17","18","4","74"

]

 In the database it looks like this, which means item '9' is missing:

 

BR Marie Louise


Replies

 
Vladimir Dynamicweb Employee
Vladimir
Reply

Hello Marie,

Most likely the item 'TypeFacets' with id '9' was deleted, so ItemList skips this relation.
Please, could  you run a check with the query:
 Select * From ItemType_TypeFacets Where [Id] = '9'

The 'ItemListRelation' table stores relations to records from different item tables, so unfortunately it has no a constraint to ensure data integrity.

Best regards,
Vladimir

 
Marie Louise Veigert
Reply

Hi Vladimir,

Thanks for the idea.

Its in the database the Item with ID 9.

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

hmm.. you wrote previously a code with item name 'TypeFacets'?
The name of table should be ItemType_TypeFacets

 
Marie Louise Veigert
Reply

I understand the confusion.

The itemrelation field on the item is called TypeFacets in the templatetag and systemname.

The item possible to select is called 'ItemType_Type'

 

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

I'm sorry, you are right about a name of course :)
But then I don't understand what's going on, I can't reproduce the issue on my solution.
Could you debug this place - what count of items in  list.Relations?


Best regards,
Vladimir

 

You must be logged in to post in the forum