EventId: String;
The EventId property determines the event, on occurring of which the task is executed.
The event must be determined on the Custom Metadata > Events tab of the dialog of repository parameters setup.
Executing the example requires:
Scheduled tasks container with the TASK_CONTAINER identifier that contains a task.
Event with the CUSTOM_EVENT identifier.
Task settings must be determined on the Scheduletab :
The Perform Task checkbox is selected.
The None option of task performing frequency is selected.
Add links to the Metabase, Fore system assemblies.
Sub UserProc;
Var
MB: IMetabase;
cont: IScheduledTasksContainer;
task: IScheduledTask;
prop: IScheduledTaskProperties;
alerts: IScheduledTaskAlerts;
EventId: String;
alert: IScheduledTaskAlert;
CustomAlert: IScheduledTaskCustomAlert;
Begin
MB := metabaseClass.Active;
cont := MB.ItemById("TASK_CONTAINER").Edit As IScheduledTasksContainer;
task := cont.Tasks.Item(0).Edit As IScheduledTask;
prop := task.Properties;
alerts := prop.Alerts;
EventId := prop.EventId;
EventId := "CUSTOM_EVENT";
alert := alerts.Add(ScheduledTaskAlertType.Custom);
CustomAlert := alert As IScheduledTaskCustomAlert;
CustomAlert.EventId := EventId;
(task As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the After Custom Event option of task execution frequency is set for the task, and the Start Download event is selected.
See also: