Posts

Showing posts with the label Scheduler

Execute PowerShell Script with Sitecore Scheduler

Image
If you have a requirement like execute PowerShell script in form of a scheduler then Sitecore Scheduler provides an option for the same. For Example, you want to delete some Sitecore Items after a specific date or remove the ideal user at some specific time. For that, you have written a PowerShell script instead of C# code and you want to schedule the PowerShell Script with a Scheduler. Then Sitecore Scheduler provides you a good option to execute PowerShell Script. If you want to know How to Install the PowerShell module with your Sitecore instance and the ideas about the PowerShell command and Scripts then, please refer series of blog posts written on: PowerShell with Sitecore . Here I am giving you an example to create a Sitecore Item using PowerShell Script and Schedule that Script by Sitecore Scheduler. You can update your PowerShell script as per your requirement. Step 1: Go to the PowerShell ISE, you can open it by Sitecore Launchpad or ...

Pass Sitecore Items in .Net Class with Scheduler: Part-3

Image
In my previous blog , we had discussed Create and Configure Scheduler in Sitecore . At the end of this series of Sitecore Scheduler blogs, I will discuss with you about Pass Sitecore Items in the .NET class with Scheduler. Suppose in your .Net class your scheduler logic has some condition based on the Sitecore Items field values and to access those values you can opt for one of the below options: Get the Sitecore Item by its Item ID and write the logic of the get the respective field value by Item as below: var scItem = Sitecore.Context.Database.GetItem(new ID("{11111111-1111-1111-1111-111111111111}")); var fieldValue = scItem.Fields["Field Name"].Value; In the above approach, you have restricted the user for a constant ID and in the case of multiple items, your line of code will increase. Pass Sitecore Items into the Items field and get the values of those Sitecore Items fields by code. In this approach, you can pass multiple items and dynamically you can change...

Create and Configure Scheduler in Sitecore: Part-2

Image
In my previous blog , we had discussed Sitecore Scheduler . In this blog, I am going to discuss with you about How to create a scheduler in Sitecore and schedule it with the PowerShell interface. First, you need to write a class that will have the logic of functionality you want to execute.  namespace Helixbase.Foundation.Scheduler { public class DataImportScheduler { public void DataImport(Item[] items, Sitecore.Tasks.CommandItem command, Sitecore.Tasks.ScheduleItem schedule) { //Code here } } } The above piece of code will take three arguments: Array of Items Task command Item Task Schedule Item I will discuss with you more about the above three parameters in the next blog “Pass Sitecore Items”. Once you write your logic into .Net Class then you need to create Sitecore Command into Sitecore. Go to the path: “ /sitecore/system/Tasks/Commands ” and create a new command item. Right-click on the...

Sitecore Scheduler: Part-1

Image
In one of my projects, the client requirement was, to migrate data from an external Database to Sitecore Database and the import task should run automatically with a specific time interval on a scheduled day. In this blog I will discuss with you about Sitecore Scheduler in three sections: Sitecore Scheduler Create Scheduler in Sitecore Pass Sitecore items as a parameter in Scheduler As the name suggested, the scheduler is a task that gets executed with a defined interval in terms of the day, date, or can be a specific time in the day. There are three ways in Sitecore to schedule task in Sitecore CMS: Configure agent in web.config: It’s a very common and easy approach to create a scheduler in Sitecore. Using this approach, you have to restart the ASP.NET worker process as it requires changing into the web.config file. Create Window Task Scheduler or Window Service to call web service in Sitecore: In this approach, you can write a Window Service, or a Console application trigger it with...