Installation and deployment
Version 7.x > Installation and deployment > Missing Custom Field Data After Import (Kentico V7) View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
a.newton-rocksolid.com - 6/23/2013 6:01:09 PM
   
Missing Custom Field Data After Import (Kentico V7)
I've noticed that the values of some document fields/properties are missing after I use the Kentico export/import functionality, i.e. http://devnet.kentico.com/docs/devguide/index.html?export_and_import_overview.htm. Not the fields themselves, but the actual values.

For example - I have the custom field 'PromotedHomeLeft' in two versions of my database - test_stagingTest (my local, target copy that I import into) and staging_stagingTest (my staging copy, the export source).

I run an export with the default settings from staging_stagingTest. I then import into a new website pointing to the database test_stagingTest. Everything seems to run smoothly, however I have a transformation on my home page which uses the custom document field which is not working correctly.

For the source database, the following:

USE local_stagingTest;
SELECT TOP(1) * FROM CONTENT_MenuItem WHERE PromoteHomeLeft = 1

returns a row as expected with MenuItemId = 978. For the target database (imported to) this row is present, but PromoteHomeLeft = 0.

So far I have not been able to resolve this issue, however I did come across this post:

http://stackoverflow.com/questions/5972019/kentico-required-document-no-longer-exists/7154796#7154796

Is this the issue? In this case, am I going to have to drop the table each time?

User avatar
Certified Developer v7
Certified  Developer v7
a.newton-rocksolid.com - 6/23/2013 6:32:57 PM
   
RE:Missing Custom Field Data After Import (Kentico V7)
Sorry, just a correction on that.

USE staging_stagingTest;
SELECT TOP(1) * FROM CONTENT_MenuItem WHERE PromoteHomeLeft = 1


returns 1 row:

MenuItemID MenuItemName MenuItemTeaserImage
----------- ---------------- ------------------------------------
978 Get informed NULL

(1 row(s) affected)

I have omitted some information for brevity - obviously PromoteHomeLeft = 1.

while:

SELECT * FROM CONTENT_MenuItem
selects 158 rows.

However, for the target database:

USE test_stagingTest;
SELECT TOP(1) * FROM CONTENT_MenuItem WHERE PromoteHomeLeft = 1


returns nothing. For the same database:

SELECT * FROM CONTENT_MenuItem

selects 94 rows:

SELECT * FROM CONTENT_MenuItem WHERE MenuItemID = 978

selects nothing, and:

SELECT * FROM dbo.CONTENT_MenuItem WHERE MenuItemName = 'Get informed'

selects 2 rows:

MenuItemID MenuItemName PromoteHomeLeft
----------- -------------- ---------------
989 Get informed NULL
1653 Get informed 0

(2 row(s) affected)


If I run that last query on the staging database, I get 3 rows:

MenuItemID MenuItemName PromoteHomeLeft
----------- -------------- ---------------
978 Get informed 1
989 Get informed NULL
1653 Get informed 0

(3 row(s) affected)


I have also checked in the XML of the export. It contains these lines for a <cms.menuitem> node:

<MenuItemID>978</MenuItemID>
<MenuItemName>Get informed</MenuItemName>
<MenuItemGroup></MenuItemGroup>
<PromoteHomeLeft>true</PromoteHomeLeft>


Has anyone encountered a problem like this under Kentico 7?

User avatar
Certified Developer v7
Certified  Developer v7
a.newton-rocksolid.com - 6/23/2013 7:24:25 PM
   
RE:Missing Custom Field Data After Import (Kentico V7)
It occurred to me to try a full import again as I had worked on some other tasks on Friday that may have caused the databases to be out of sync.

After a full import from staging to test (to a completely new site on test) this is what I found:

USE staging_stagingTest;

SELECT MenuItemID, MenuItemName, PromoteHomeLeft FROM CONTENT_MenuItem WHERE PromoteHomeLeft = 1;

USE test_stagingTest;

SELECT MenuItemID, MenuItemName, PromoteHomeLeft FROM CONTENT_MenuItem WHERE PromoteHomeLeft = 1;


result:

MenuItemID MenuItemName PromoteHomeLeft
----------- ------------- ---------------
978 Get informed 1

(1 row(s) affected)

MenuItemID MenuItemName PromoteHomeLeft
----------- ------------- ---------------
2114 Get informed 1

(1 row(s) affected)


So now I can see both values coming through, but the content I was expecting still isn't showing up on the home page.

I have checked CMS Site Manager > Administration > System, and the database was as expected in both cases.

The transformation used would roughly translate to the following SQL -

SELECT TOP 1 * -- ParentDocument.DocumentName AS 'DocName', CMS_Tree.NodeAliasPath AS ParentDocumentNodeAliasPath, *
FROM View_CMS_Tree_Joined_Attachments
JOIN CONTENT_File on FileAttachment = AttachmentGUID
JOIN CMS_Document ParentDocument ON NodeParentID = ParentDocument.DocumentID
JOIN CONTENT_MenuItem ON MenuItemID = ParentDocument.DocumentForeignKeyValue
JOIN CMS_Attachment ON FileAttachment = CMS_Attachment.AttachmentGUID
JOIN CMS_Tree ON CMS_Tree.NodeID = ParentDocument.DocumentID
WHERE
1=1
AND CMS_Attachment.AttachmentImageWidth = 273
AND CONTENT_MenuItem.PromoteHomeLeft = 1


As I'd already suspected, this might be a problem with these IDs being out of sync. I ran the following query:

USE staging_stagingTest;

SELECT MenuItemID, MenuItemName, PromoteHomeLeft FROM CONTENT_MenuItem WHERE PromoteHomeLeft = 1;

SELECT DocumentID, DocumentName, DocumentModifiedWhen, DocumentForeignKeyValue FROM dbo.CMS_Document WHERE DocumentForeignKeyValue = 978

USE test_stagingTest;

SELECT MenuItemID, MenuItemName, PromoteHomeLeft FROM CONTENT_MenuItem WHERE PromoteHomeLeft = 1;

SELECT DocumentID, DocumentName, DocumentModifiedWhen, DocumentForeignKeyValue FROM dbo.CMS_Document WHERE DocumentForeignKeyValue = 978
SELECT DocumentID, DocumentName, DocumentModifiedWhen, DocumentForeignKeyValue FROM dbo.CMS_Document WHERE DocumentForeignKeyValue = 2214;

Results:

MenuItemID MenuItemName PromoteHomeLeft
----------- ------------- ---------------
978 Get informed 1

(1 row(s) affected)

DocumentID DocumentName DocumentModifiedWhen DocumentForeignKeyValue
----------- ------------- ----------------------- -----------------------
1209 Get informed 2013-06-12 17:53:12.363 978

(1 row(s) affected)

MenuItemID MenuItemName PromoteHomeLeft
----------- ------------- ---------------
2114 Get informed 1

(1 row(s) affected)

DocumentID DocumentName DocumentModifiedWhen DocumentForeignKeyValue
----------- ------------- ----------------------- -----------------------
3951 images 2013-05-23 16:54:57.223 978

(1 row(s) affected)

DocumentID DocumentName DocumentModifiedWhen DocumentForeignKeyValue
----------- ------------- ----------------------- -----------------------

(0 row(s) affected)



So it seems that the problem is indeed that the CMS_Document IDs are getting out of sync as a result of the auto-increment on the CMS_Document table. Is there a way to resolve this without physically dropping the table from test_stagingTest? I might try and rework my query to avoid this issue, but it would be really nice to be able to do this without needing to worry about this issue.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/24/2013 1:44:02 AM
   
RE:Missing Custom Field Data After Import (Kentico V7)
Hi,

1. Are you importing the site into another, exiting site on the target? If so, existing documents are not updated. Only new documents are imported in this case. You need to import the package and a fully new site.

2. After import/export or content staging, the IDs may not match. The reason is that there could be already another item with the same ID. So, the uniquie identifier in this case is the GUID of given object. So, one solutuion is to use GUID to identify the object. Or, backup and restore the source DB on the target for the first time to ensure both DBs and IDs are identical.

Best regards,
Juraj Ondrus

User avatar
Certified Developer v7
Certified  Developer v7
a.newton-rocksolid.com - 6/28/2013 2:51:10 AM
   
RE:Missing Custom Field Data After Import (Kentico V7)
Thank you for your reply Juraj.

Could you please provide me with an example for such a query for the example provided?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/28/2013 3:11:09 AM
   
RE:Missing Custom Field Data After Import (Kentico V7)
Hi,

I am not sure what example you mean. You need to check the GUID of object in the source DB and then find given object in the target DB - in given DB table.


Best regards,
Juraj Ondrus