Page 1 of 1

Issue creating a scheduled task

Posted: Thu Jan 18, 2024 12:54 am
by dn_garza
I've attempted using a code snippet found on the forum to start a scheduled task. I'm getting an thrown exception. Any ideas? In the screenshot, 'trigger' is of type IScheduledTrigger. Is it possible that this is causing the issue on 'tm.ApplyChanges(trigger)'? 'ApplyChanges' per the docs says to pass a trigger of type 'ITrigger'.
schedulerIssue.png
schedulerIssue.png (88.62 KiB) Viewed 2108 times

Re: Issue creating a scheduled task

Posted: Thu Jan 18, 2024 4:52 pm
by BobRichards
Please post the source code and exception call stack.

Re: Issue creating a scheduled task

Posted: Sat Jan 20, 2024 2:03 am
by dn_garza
I resolved this. I think my issue was that I was performing this operation before the services were available. Question on the topic - in order to get the scheduled task not to be added as a scheduled task every time the package loads, what would be a clear and simple solution? Is there some table that I can set some value on and read as a condition to registering the scheduled task?

Re: Issue creating a scheduled task

Posted: Mon Jan 29, 2024 9:25 pm
by PaulMcCullough
Yes. To check your trigger has already been created, check the [core].[Trigger] table for a row where the Handler column matches the id of your ITriggerHandler. If it exists, then your trigger is already created and you should not create it again.