Trigger E-mail on row insertion in Custom Table?

Yang Wen asked on July 28, 2016 20:05

Is there a way to trigger Kentico to send email whenever a new row is inserted to my Custom Table?

I looked under Marketing Automation but its rules engine does not include custom table events.


Recent Answers

Bryan Soltis answered on July 28, 2016 21:21

Hi Yang,

Not out of the box, but this would be easy to accomplish with a global event handler by the handling INSERT event of the custom table.

The code would be something like:

ObjectEvents.Insert.After += Insert_After;

private void Insert_After(object sender, ObjectEventArgs e)
    var classname = e.Object.TypeInfo.ObjectClassName;
    DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(classname);
    if(dci != null)
        // Make sure it's the custom table you want 
        if(dci.ClassName.ToLower() == "customtable.sampletable")
            // Send an email
            // ....

You can find more info on the Handling object events here.

  • Bryan
4 votesVote for this answer Mark as a Correct answer

Laura Frese answered on July 28, 2016 22:49

also wanted to add a snippet to help.....

public partial class CMSModuleLoader
    public class CustomTableInterceptor : CMSLoaderAttribute
        public override void Init()
             CustomTableItemEvents.Update.After += CustomTableItem_After_Update;

        protected void CustomTableItem_After_Update(object sender, CustomTableItemEventArgs e)
            CustomTableItem customtableitem = (CustomTableItem)e.Item;
            string tablename = customtableitem.ClassName;
0 votesVote for this answer Mark as a Correct answer

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