Custom class with parent child sync failing

Stephen D'Olier asked on September 19, 2018 12:46

Hi,

We have a custom module with two classes. A parent class and a child class (1-n).

Syncronisation of the parent type works as expected.

When we try and syncronise content of the child type from a staging server to production, the sync fails with this error:

SyncServer.ServerError: Exception occurred: [DataConnection.HandleError]: Query: 

INSERT INTO client_ModuleItem ([ModuleItemGuid], [ModuleItemLastModified], [ISBN], [ListOrder], [ModuleID]) VALUES (@ModuleItemGuid, @ModuleItemLastModified, @ISBN, @ListOrder, @ModuleID); 

SELECT SCOPE_IDENTITY() AS [ID] Caused exception: Cannot insert the value NULL into column 'ModuleID', table 'kentico.dbo.client_ModuleItem'; column does not allow nulls. INSERT fails. The statement has been terminated.

A profile on the destination server shows that ModuleID is null rather than the translated id of the parent object on the destination server.

We have followed this doc: https://docs.kentico.com/k11/custom-development/creating-custom-modules/setting-the-type-information-for-module-classes/enabling-export-and-staging-for-the-data-of-classes

The TYPEINFO of the child class has the parent ID field and type set in the constructor.

SynchronizationSettings set with LogSynchronization = SynchronizationTypeEnum.TouchParent

Saving a child item on the source server creates a syncronisation task of the parent type with all the child items in the task.

This tells me the parent-child relationship between the classes along with TouchParent is working as expected.

We have also created a Custom ID Translation Module as described here: https://docs.kentico.com/k11/custom-development/handling-global-events/deploying-objects-with-custom-id-fields

ColumnsTranslationEvents.TranslateColumns.Execute += TranslateColumns_Execute;

private void TranslateColumns_Execute(object sender, ColumnsTranslationEventArgs e)
{
    if (e.ObjectType == ModuleItemInfo.OBJECT_TYPE)
    {
        e.TranslationHelper.TranslateColumn(e.Data, "ModuleID", ModuleInfo.OBJECT_TYPE);
    }
}

Where ModuleInfo is the parent type and ModuleItemInfo is the child type.

This is on Kentico 11.

Any idea what we are missing here?

Thanks, Stephen

   Please, sign in to be able to submit a new answer.