Synchronizing objects

John Jones asked on August 29, 2018 17:09

Hello,

I have created data in a custom module that has a SiteID field reference. When I try to synchronize the object to another server I get a error message result.

SyncServer.ServerError: Exception occurred: Cannot translate columns 'SiteID', import the dependent objects first.

I have added the RegisterRecords and TranslateColumns handlers on both source and target servers but it doesn't seem to work. Does anyone have any ideas?

private void RegisterRecords_Execute(object sender, ColumnsTranslationEventArgs e)
    {
        // Registers custom column translation data
        if (e.ObjectType == URLRedirection.RedirectionTableInfo.OBJECT_TYPE)
        {
            // Gets the site ID from the data
            int siteId = ValidationHelper.GetInteger(e.Data.GetValue("SiteID"), 0);

            // Prepares parameters for the translation
            TranslationParameters parameters = new TranslationParameters(URLRedirection.RedirectionTableInfo.OBJECT_TYPE)
            {
                CodeName = SiteInfoProvider.GetSiteInfo(siteId).SiteName
            };

            // Maps the site ID value to the corresponding site name for every record
            // Adds the mapping information into the export package
            CMS.EventLog.EventLogProvider.LogInformation("RegisterRecords", "Execute", "siteID: " + siteId + " codename: " + parameters.CodeName + " Data: " + e.Data.ToJSON("", false));
            e.TranslationHelper.RegisterRecord(siteId, parameters);
        }
    }

    private void TranslateColumns_Execute(object sender, ColumnsTranslationEventArgs e)
    {
        // Performs column translation
        if (e.ObjectType == URLRedirection.RedirectionTableInfo.OBJECT_TYPE)
        {
            // Translates the values of the SiteID field in the table's data
            // Uses the mapping information in the import package to find the correct IDs based on the usernames
            CMS.EventLog.EventLogProvider.LogInformation("TranslateColumns", "Execute","CurrentSiteID: " + SiteContext.CurrentSiteID + " Data: " + e.Data.ToJSON("", false));
            e.TranslationHelper.TranslateColumn(e.Data, "SiteID", URLRedirection.RedirectionTableInfo.OBJECT_TYPE, SiteContext.CurrentSiteID, true, true);
        }
    }

Thank you,

Recent Answers


Arun Kumar answered on August 30, 2018 18:00

See this post, it might help in your case.

0 votesVote for this answer Mark as a Correct answer

Stephen D'Olier answered on September 19, 2018 11:55

Hi john,

Did you find a solution to this issue?

I am facing the same problem with v11.

I've followed https://docs.kentico.com/k11/custom-development/handling-global-events/deploying-objects-with-custom-id-fields

But still stuck with issue you raised.

Cheers, Stephen

0 votesVote for this answer Mark as a Correct answer

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