Frontend - Alpha Solutions

To create a scheduled task in Sitecore, you must first create a .net class which contains logic that you wish to execute.

5.8.17

BY SUSMITHA KATKOORI

Here is a small example when I run the Task Scheduler.

This method will trigger all the failed Newsletters user requests to the third-party service.

Namespace Feature.Newsletter.Jobs
{
public class JobTrigger
{
public void NewsLetter(Item[] items, Sitecore.Tasks.CommandItem newsLetterSignupCmdItem, Sitecore.Tasks.ScheduleItem newsLetterSignupScheduleItem)
{
// Put your code here.
}
}
}

Create a Command Task under /sitecore/system/Tasks/Commands/

Insert command template from Templates /sitecore/templates/System/Tasks/Command

Scheduler - Alpha Solutions


Give the Type field enter the assembly qualified type and in the Method field enter the name of the method to be called in your class

Type: Feature.Newsletter.Jobs.JobTrigger, Feature.Newsletter

Method: mention the method name which needs to be executed. Example: Newsletter

Create a _Task Schedule under /sitecore/system/Tasks/Schedules/Job

Scheduler2 LI - Alpha Solutions

CREATE A SCHEDULE TO RUN THE JOB

Under the Command Field: Specify the path of command.
Commands/Newsletter
In the Schedule field: specify the time how often need the job to be run.
Schedule field will have several piped values.
20170208|99990101|127|1.00:00
Start Date: 20170208
End Date: 99990101
Days of the week: Calculate based on the days of the week no.
Sunday = 1
Monday = 2
Tuesday = 4
Wednesday = 8
Thursday = 16
Friday = 32
Saturday = 64.

Let's say I want to run the job every day. It’s going to be (Sunday + Monday + Tuesday + Wednesday + Thursday + Friday + Saturday)
= (1+2+4+8+16+32+64)
= 127

The minimum interval the task is to be run in HH.MM.SS format

The task is setup now to run at specified interval.