Error Modifying Trigger Type

This forum is designated to discuss SiComponents Scheduling Agent.
Post Reply
partha
Posts: 5
Joined: Tue May 10, 2005 5:22 am

Error Modifying Trigger Type

Post by partha »

Hello,

I am using the following code with D7:

Task.Activate;
with Task.Triggers.Add do begin
TriggerType := ttDaily; // adding this line produces the error
BeginDate := ...;
EndDate := ...;
StartTime := ...;
Duration := ...;
Interval := ...;
end;
Task.Triggers.UpdateTriggers;
Task.Deactivate(True);


but I get an EOleSysError error "The parameter is incorrect". If I comment the line:
TriggerType := ttDaily;
everything works fine.

How can I overcome this problem?

thanks and regards,
Partha
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

You have to specify TriggerDetails when setting TriggerType to ttDaily:

Code: Select all

var
   TriggerDetails: TTriggerDetails;
begin
  with Scheduler.CreateNewItem(Format('New task %d', [GetTickCount])) do
  begin
    ApplicationName := ParamStr(0);
    Triggers.Add;
    Triggers[0].TriggerType := ttDaily;
    Triggers[0].StartTime := IncHour(Now, 1);
    Triggers[0].BeginDate := Date;
    Triggers[0].EndDate := Date + 30;
    Triggers[0].HasEndDate := False;
    TriggerDetails.Daily.DaysInterval := 1; // check this line!
    Triggers[0].Details := TriggerDetails; // check this line!
    Triggers[0].Duration := 24 * 60;
    Triggers[0].Interval := 10;
    // could be used UpdateTriggers and Save
    Triggers.UpdateTriggers;
    Save;
    // or just Deactivate(True)
    //Deactivate(True);
  end;
end;
Post Reply