Workflow and ServiceDesk Community

 View Only

Using TaskManagement with ScheduleTaskCustom 

Jul 21, 2014 12:35 PM

Ever tried to schedule a task using ASDK which should repeat but not every day? It is not easy but it works...

Here the is what the help says about custom schedule. Using the following customScheduleXML:

<schedule><Trigger Type='1' Duration='0' Interval='0' KillAtEnd='0' Disabled='0' Description='At 9:00 AM every day, starting Wednesday, 1 January 2003'><BeginDate>2003-01-01 09:00:00</BeginDate><DaysInterval>1</DaysInterval></Trigger></schedule>"

and the followning inputParameters:

<inputParameters><parameter><name>@AssignedResources</name><value>replace-with-computerguid</value></parameter><parameter><name>@CompRequirements</name><value><minWaitTime>1 minutes</minWaitTime><maxWaitTime>10 minutes</maxWaitTime><minCompletion>95 %</minCompletion></value></parameter><parameter><name>@OverrideMaintenanceWindows</name><value><boolean>true</boolean></value></parameter></inputParameters>

gives you this schedule for a specified task:

daily_sched.png

So far so good. That was easy just copy paste and done However if you like the repeat to be within minutes or hours range you have to start your calculator! Why is that you might ask yourself. See yourself.

It is quite obious that if you like to change the repeat that you have the following values Trigger Type='1' Duration='0' Interval='0' in the customScheduleXml to play with. I have found out soon that changing the Trigger Type does not give any results which leaves us with Duration='0' Interval='0'. But what numbers should we have.

If you do not want to go yourself and do the try and error path here I can give you the answer.

If you want the repeat in the minutes range you choose Duration='60' and the Interval is the number of minutes you want to repeat the task. Kind of makes sense does't it.

So here we go for the example with a repeat every 5 minutes:

<schedule><Trigger Type='1' Duration='60' Interval='5' KillAtEnd='0' Disabled='0' Description='At 9:00 AM every day, starting Wednesday, 1 January 2003'><BeginDate>2014-04-30 10:45:00</BeginDate><DaysInterval>1</DaysInterval></Trigger></schedule>

gives you this schedule for a specified task:

min_sched.png

Ok that was kind of straight forward too I admit. But how about if you like a repeat within hour range. Ok first guess would be to have the Duration='24' because you have 24 hours in a day and that you would have the interval as the hours of repeation. But first guess was wrong and after several different tries I came up with this that i might be related to the schedules used earlier when using a repeat within minutes range. And here it is where you need to take your calculator out. Because what is 24 * 60 yes that is correct it is 1440. So we have 1440 minutes within a day and then the calcuation is easy for the interval if you want the task to repeat for example every 6 hours. Yes correct again 6 * 60 is 360.


So here we go for the example with a repeat every 6 hours:

<schedule><Trigger Type='1' Duration='1440' Interval='360' KillAtEnd='0' Disabled='0' Description='At 9:00 AM every day, starting Wednesday, 1 January 2003'><BeginDate>2014-04-30 10:45:00</BeginDate><DaysInterval>1</DaysInterval></Trigger></schedule>

gives you this schedule for a specified task:

hour_sched.png

Now it is just one open question left how about a schedule on a weekly base. Yeah that question is still open and I hope one day I find out and can add this to this article. Anyhow I hope this helps for those you have not figured this out earlier.

 

Statistics
0 Favorited
2 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Jul 25, 2014 08:06 AM

Hi Stefan

This scheduleXML will schedule the task every Wednesday at 10:45.

"<schedule tz='Local' start='2014-04-30 10:45:00 '><trigger type='Weekly' exact='True' at='10:45:00 ' frequency='1' weekdays='3' /></schedule>"

Regards
Stephan

Related Entries and Links

No Related Resource entered.