Client Pay Portal

Kentico CMS Scheduled Tasks – Real World Examples

In almost every project I’ve developed I’ve had the need to execute some code either once or on a regular basis. With the “one-timers”, sometimes I just write a quick bit of code into an existing ASPX page or user control and run it. For the routine executions, I rely on Kentico’s Scheduled Tasks functionality. It is easily the simplest and best way to execute custom functionality with a Kentico site. Now, none of this is new information for anyone that’s watched my blog. I’ve written a few blogs on the topic that describe the benefits of Scheduled task and how to implement them.

Scheduling Tasks to Run Automatically in Kentico CMS 6.0

Additionally, Kentico has great documentation on setting them up and configuring them:

Scheduler Overview

What I wanted to do in this blog was explain some of the benefits, give actual examples of how I’ve used this great feature, and how it makes the project development go much smoother.

Stop Looking at Me, Swan…

One of my favorite parts about tasks within in Kentico is flexibility and configuration options of the task itself. Kentico provides a very customizable interface for running your task, whether it’s once or as often as every second. When making a task, I always use the “TaskData” feature to enable / disable debugging, which allows the task to run on its own and alert me if it ever encounters an error. I set a Boolean inside my task based on the TaskData value and enable/disable Event Log entry accordingly. This frees up my time to worry about other things, write blogs like this, and explain to people the correct pronunciation of the name “Kentico.”

I’ve used the scheduling aspect the most in my projects with real world tasks such as:
  • Daily routines to sync data with other systems
  • Nightly tasks to send emails to users with expiring content
  • Send reminder emails to event attendees as the event gets closer
  • Get a summary of a specific activity and email an administrator (total updated documents, etc)
  • Generate a report and email it every night

We’re Going to Need a Bigger Boat

With Scheduled Tasks in Kentico you can quickly keep multiple systems and applications in sync. This allows you to propagate your data to a much larger scale than your own application. It also allows for cross communication and integration with multiple systems. Enterprises often have several layers of applications and specific functions for each. In order to make these all play nicely, data needs to be copied between them so that they are all speaking the same language. Scheduling a task within Kentico to do this integration is a great way to achieve this.

Some of the systems I have integrated through scheduled tasks are:
  • CRM Systems (Dynamics CRM, DrivenCRM, etc.)
  • Email Systems
  • Financial Systems (Great Plains, etc.)
  • Native (home grown) applications

My Fingers Hurt REAL Bad!

As with any project, Kentico developers need to think about how to code smart. What I mean is, you should always be thinking of the best way to do something so that it accomplishes the goal, completes it efficiently, and is easy to maintain moving forward. More often than not, this means reusing code by coding it once and leveraging that functionality in multiple areas. Scheduled Tasks within Kentico provide an excellent area for this type of methodology. Coding the functionality once within the task and calling it when you need it provides a fantastic way to consolidate your code and run it as you need. The Scheduler API provides simple calls to execute it, as well as a hefty amount of reporting and exception handling when it runs.

In the previous projects, I’ve used this concept for the following tasks:
  • CRM integration Calls
  • Nightly jobs to replicate content across systems
  • On demand “syncs” of data across systems
  • Specific content publishing routines (that don't always work with the Kentico Content Publishing job)

Insert Tab A into Slot B

Scheduled tasks are not a new concept in Kentico. In fact, they have been around since at least v3.0 (Kentico online document FTW!). Along the way Kentico has continued to provide working examples of how to use this feature to help developers execute their custom code. With v6.0, however, Kentico recognized a lot more companies used the API and modified the application to integrate your code much easier. The new “ClassModuleLoader” concept enables developers to create their tasks independently and integrate them when they need. Once registered, they can quickly set up a routine to run their code on a scheduled basis.
Tip: More information on the ClassModuleLoader can be found here.
As Kentico continues to improve an already fantastic product, expect more improvements to the underlying apis and architecture. These changes will surely bring more customization and deployment options for custom functionality and the ability to execute it. With a little research and practice you’ll quickly see how valuable and usable scheduled tasks within Kentico CMS can be.


Wiz E. Wig, Mascot & Director of Magic
Wiz E. Wig

Director of Magic