CustomTable Global event handler

Gideon Gontor asked on March 12, 2019 13:23

I have implemented event handler for our bizforms , they all work perfectly well but I am still having issue with the custom tables see my code below and advise.Are the implementation for custom tables different from bizforms? It is suppose to update our CRM system.

[assembly: RegisterModule(typeof(CustTableventsModule))] namespace custTable { public class CustTableventsModule : CMS.DataEngine.Module { public CustTableventsModule() : base("CustTablevents") { }

    // Contains initialization code that is executed when the application starts
    protected override void OnInit()
    {
        base.OnInit();

        // Assigns custom handlers to events
        CustomTableItemEvents.Insert.After += CustomTable_Insert_After;
    }

    private void CustomTable_Insert_After(object sender, CustomTableItemEventArgs e)
    {
        CustomTableItem item = e.Item;
        if (item != null && item.CustomTableClassName.ToLower() == "customtable.producttype")
        {

            //string itemTextValue = item.GetStringValue("ProductName","");
            string itemTextValue = ValidationHelper.GetString(item.GetValue("ProductName"), "");

            string documentUrl = DocumentContext.CurrentDocument.NodeAliasPath.Replace("/", "-");
            CRM.customtable(itemTextValue, documentUrl);

        }
    }
}

}

Correct Answer

Gideon Gontor answered on March 14, 2019 11:14

Thanks Roma and David for getting back to me, I have resolved the issue, The documenturl was the issue in my code.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Roman Hutnyk answered on March 12, 2019 13:42 (last edited on March 12, 2019 13:47)

First of all what is your issue? Please provide more details

Second: are you sure document context is available in custom table item event handler?

And to answer your question - yes, they work almost the same way as biz form events.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on March 12, 2019 13:46

Also are you using MVC or Portal?

When utilizing the MVC development model, you may need to deploy the assembly containing the event registration code and handler methods to the separate MVC application (in addition to the Kentico administration project).

This is required if you are customizing any functionality that occurs on the live site. For example, if you have a custom handler for the Insert event of user objects, the event is raised both when creating a new user in the administration interface (Kentico application) and when a user registers on the live site (MVC application).

0 votesVote for this answer Mark as a Correct answer

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