Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » Change item list to item relation list

Change item list to item relation list

Simon Eldevig
Reply

Hi,

We are currently working on upgrading from a DW 8.6 to DW 9.1, where we use a lot of items with the type item list.

Since item list is deprecated from 8.8.1 we want to find a way to convert the item list into a item relation list, so we will be able to use these instead.

The problem here is that the only way to do this is to delete the current item list and create a new item relation list with the same system name and so on, but then we will lose all content connected to the old item.

Is there any way to do this in a smarter way since it's not posbile to change the item type or system name directly from DW backend?


Replies

 
Vladimir
Reply
This post has been marked as an answer

Hi Simon,
item list still supported, so there is no urgent need to convert them.

However I if you want to make it anyway...
 The instruction is not hard but rather big so it is necessarily to make backup of data before begin!!!

 For example I convert item [ItemList_15555] with field [FldList] of type item list to a relation list:

1) Convert item xml definition
 a) Open Files\System\Items\ItemType_ItemList_15555.xml
 b) Find definition of item list field
 c) replace it type:
    type="System.Collections.Generic.IEnumerable`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib"
to
    type="System.Int32, mscorlib" 
 d) replace editor type:
    type="Dynamicweb.Content.Items.Editors.ItemListEditor, Dynamicweb"
to
    type="Dynamicweb.Content.Items.Editors.ItemRelationListEditor, Dynamicweb"
 e) replace all rows 
    addin="Dynamicweb.Content.Items.Editors.ItemListEditor"
to
    addin="Dynamicweb.Content.Items.Editors.ItemRelationListEditor"
 f) insert a row into <editorConfuguration> section:
    <Parameter addin="Dynamicweb.Content.Items.Editors.ItemRelationListEditor" name="Item source" value="ListItem" />

2) Run sql script(see attached file):
 NOTE! You have to replace 4 places in this script:
  a) SET @TypeOfItemListItems = 'ItemListDetail' - there should be type of your field items
   b) 3 rows with [FldList] and [ItemType_ItemList_15555] - this is system name of field and name of item table (ItemType_ + itemname)

3) Relogin into admin

 

Kind regards,

Vladimir

 

Votes for this answer: 1
 
Simon Eldevig
Reply

Hi Vladimir,

Thank you for the response.

This task was put on hold, so sorry for not getting back to you before now.

Nether the less - is it possible to convert the item defination when it is stored in the database? In short terms  - can I just change the ItemTypeDefinitionsMetadata in ItemTypeDefinitions table directly in the database?

I also tried to open your script, but i returns 404. Could you please insert it into a comment? :-)

 
Vladimir
Reply

Hi Simon,

I'm not offended:)

item definitions in ItemTypeDefinitions table have same structure - you could change it directly of course  - but you should run script to convert data in new format

PS I attached the script in zip archive now

Kind regards,

Vladimir

 
Simon Eldevig
Reply

Hi Vladimir,

Thank you for quick response!

What do you mean be running script to convert data in new format? :)

 
Vladimir
Reply

Hmm... This is sql script for MS SQL Server Management Studio (Or any similar tool)

Old format for item list is csv string of detail item ids eg: 1,23,35,76,89

The new format is just an id of related list which is stored relation to items in tables ItemList+ItemListRelation

Script performs needed transformations

hmm... did I answer the question?

 
Simon Eldevig
Reply

I think you misunderstood.

I just want to understand your approach a 100%

For clarification:

Step 1: 

Convert item xml definition - This will be done directly on the ItemTypeDefinitionsMetadata for the specific item instead of XML file
 a) Open Files\System\Items\ItemType_ItemList_15555.xml
 b) Find definition of item list field
 c) replace it type:
    type="System.Collections.Generic.IEnumerable`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib"
to
    type="System.Int32, mscorlib" 
 d) replace editor type:
    type="Dynamicweb.Content.Items.Editors.ItemListEditor, Dynamicweb"
to
    type="Dynamicweb.Content.Items.Editors.ItemRelationListEditor, Dynamicweb"
 e) replace all rows 
    addin="Dynamicweb.Content.Items.Editors.ItemListEditor"
to
    addin="Dynamicweb.Content.Items.Editors.ItemRelationListEditor"
 f) insert a row into <editorConfuguration> section:
    <Parameter addin="Dynamicweb.Content.Items.Editors.ItemRelationListEditor" name="Item source" value="ListItem" />

Step 2 

Run your sql script with correct values from the specific item.

Step 3

Relogin into admin

 

Please confirm that this is the correct approach for changing the Item List to Item Relation List? :)

 
Vladimir
Reply

yes, steps are right:)

 
Simon Eldevig
Reply

Great!

I will give it a try :-)

 
Simon Eldevig
Reply

Hello Vladimir,

Just tested out your procedure which worked, but the item lost of all of it's data.

Is there a way to do this without losing content? :-)

 
Vladimir
Reply

hmm... script purpose exactly is to preserve data
Could you send me your version of script and structure of table with the item data - so I could check them?

 
Vladimir
Reply

Btw - did you check what happened with data in field with list after the script? Still old csv values? 

 
Simon Eldevig
Reply

Hello Vladimir,

I've attached the script and here is the specific ItemList table before and after running the script.

ItemType_SwipeJSList table before running the script:

https://www.screencast.com/t/5zaGwz6WCo5

ItemType_SwipeJSList table after running the script:

https://screencast.com/t/982oPfqJrLec

 

How can we fix this? :-)

 
Vladimir
Reply

Hi Simon,

It seems script performed convertation correctly (Well, you could also check [ItemListRelation] table  that it contains relations 13,12, 8, 11 etc to be sure 100%)

So it could mean only that 1 step wasn't completed - fiedl type definition probably is not correct now.
How SwipeJSList Item type looks in backend - on item type edit page? Has the SwipeJSItem field new definition?

 

Btw setting Control panel -> File manager -> ITEM TYPES - >Synchronize = Database?

 
Simon Eldevig
Reply

The  [ItemListRelation] table seems to contain the relations - see attachment

I've attached a screenshot of the SwipeJSList item definition.

The Synchronize is set to Database, yes.

Screen_Shot_2017-09-08_at_14.41.13.png Screen_Shot_2017-09-08_at_14.44.13.png
 
Vladimir
Reply

Yep, data was converted right - script works fine 

The problem is that field still has old type - Item list (after 1 step it should be changed to Item relation list)

Obviously ItemTypeDefinitionsMetadata was not updated. I tested these steps with xml files, don't sure why 1 step doesn't work for ItemTypeDefinitionsMetadata table.

Could you stop solution at all (stop pool), then repeat step 1 and run site pool again?

 
Simon Eldevig
Reply

Hello Vladimir,

Yes, conversion was working, but it seems wierd that ItemTypeDefinitionsMetadata was not updated, but maybe there is some issues with using "Edit top 200" in SSMS.

I will just try again with a replace query instead.

I will try to do it again.

 
Simon Eldevig
Reply

Hi  Vladimir,

Just tried the above which didn't solve the problem.

Maybe it would be easier if I sent you a copy of the solution files and DB to your email? :)

 
Vladimir
Reply

Hi Simon,

It seems I found a way how to make 1 step work:

1. Change item definiton according instruction (I attached the sql script for 1 step- just run it)

2 Recycle the application pool (see attached image)

3. Check Item definition

 

Best regards,

Vladimir

recycle_application_pool.png
 
Simon Eldevig
Reply

Hi Vladimir,

Thank you for the script!

Unfortunately we are still losing the data even though the Item Definition is correct - https://www.screencast.com/t/44gmBN5eN

I did the following steps.

1. Run the Upgrade_item_list_definition_-_SwipeJSList script

2. Recycle App Pool

3. Run the Convert_item_list script

4. Relogin into admin

 
Simon Eldevig
Reply

Hello again Vladimir,

Just an update - I went to check the Item after conversion and I can see that there isn't chosen an Item for the Relation list, so maybe that is causing the data loss. 

Neither am I able to choose the SwipeJS_Item as the item in the Relation list item.

 
Simon Eldevig
Reply

Hello Vladimir,

I now managed to get it to work correctly.

There were two problems.

1. The item that was used in the ItemList was restricted to only ItemList and not paragraph, which meant that it was not allowed on the Item Relation list

2. I was testing on our current DW version 8.5.x which did not support a inline source for Item Relation List and the data was therefore lost.

I was able to make a succesfull conversion on version 9.x where I first of all removed the restriction for the item and then followed the steps above.

 

Thank you very much for your help!

Your scripts will make it a lot easier to upgrade older versions of DW to DW 9.x :-)

 
Vladimir
Reply

great:)

I tested this on 8.9.1, and it seems my item properties were compatable with new list:(

 
Simon Eldevig
Reply

Yes, inline source was introduced in 8.8, so I will note that the solution has to be on 8.8 in order to use this procedure.

 
Martin Møller Christensen
Reply

I'm a little late to the party, but when I use this solution some of my itemtypes just straight up disappear. There doesn't seem to be a pattern.

Any ideas as to why this could be happening?

 

You must be logged in to post in the forum