To create a custom Trigger you need to follow the next steps.
Create my_triggers.cs in Console\App_Code\Custom folder (see code block for the content of the file)
using Centralpoint.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace Centralpoint.WebSite.Console
{
public class My_Triggers
{
public static void my_CustomTrigger(SqlConnection connect, Guid moduleId, Triggers.Events trigger, Guid id, CpCollection collection, string[] addParams)
{
switch (trigger)
{
case Triggers.Events.Upsert:
case Triggers.Events.UpsertBatch:
break;
case Triggers.Events.PreUpsert:
collection.Set("Keywords", "my_CustomTrigger");
break;
case Triggers.Events.Delete:
break;
case Triggers.Events.UpdateProperties:
break;
}
}
}
}
Change the my_CustomTrigger name in the file to the name of your trigger
1. In Client Console navigate to /Console/ConsoleTriggers.aspx?sn=ConsoleTriggers
2. Click Add New Button
a. Select the Module
b. Enter the Name of your trigger
c. In Method Type change the default namespace to Centralpoint.WebSite.Console.My_Triggers
d. In Method Name use the same name as you did in the my_triggers.cs
3. Save Record
Now every time the record is saved your custom code executes and can update/modify existing module attributes.
The trigger supports the following events:
PreUpsert - Module attributes are already updated by the record and are not saved in the database.
Upsert - The record is already updated in the database.
Delete - when the record is deleted.
UpdateProperties - When module Properties are updated.
Keywords: Triggers