FireTime: TableTriggerFireTime;
The FireTime property determines trigger execution time.
Executing this example requires a table with the TABLE_1 identifier in repository.
Sub Main;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Table: ITable;
Triggers: ITableTriggers;
Trigger: ITableTrigger;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("TABLE_1").Edit;
Table := MObj As ITable;
Triggers := Table.Triggers;
Trigger := Triggers.Add;
Trigger.Id := "TriggerX";
Trigger.Name := "Table trigger";
Trigger.Text := "Begin" + #10 + "Insert Into Table_1(Field_1) Values('Trigger');" + #10 + "End;";
Trigger.FireTime := TableTriggerFireTime.After;
Trigger.FireEvent := TableTriggerFireEvent.Insert;
Trigger.ForEachRow := True;
MObj.Save;
End Sub Main;
After executing the example, a trigger with the TriggerX identifier is created in the table. This trigger is executed before an insert of a new row into the table. One more new row is added into the table and value of the Field_1 field is filled at trigger execution.
See also: