Scheduler, Jobs, Agent, Task, command and Schedule in Sitecore

This week, I spent lot of time to get basic understanding of Sitecore scheduler and Automated job. I have gone through with several blog posts on internet and understood the fundamental behind this. But I found the following link very useful to understand it from scratch. So thought of sharing this link and its contents here on my blog site. Idea of sharing this link here may save my time if I am going to refer it again. Or it could be useful for other sitecore learners who are visiting my blogs:
Sitecore provides the ability for custom tasks to run asynchronously.
• Scheduler Basics
• Agents
• Database Scheduler
• Jobs API
Scheduler Basics
Sitecore’s scheduler is responsible for running background tasks.
• Terminology
• Configuring Agents
• How the Scheduler Runs Agents
The following terminology is used to describe how Sitecore handles asynchronous tasks.
• Scheduler – Sitecore component that runs asynchronous tasks based on how the tasks are scheduled.
• Task – A unit of work that is executed asynchronously. A task is implemented as a method.
• Agent – The object used to schedule a task. The scheduler runs agents based on each agent’s configuration.
• Job – A process that is running asynchronously. When an agent runs, it runs as a job.
Configuring Agents
An agent is used to configure a scheduled task. Agents are defined in Web.config and Sitecore patch files under/configuration/sitecore/scheduling.
The following is an example of an agent that is scheduled to run every 4 hours.

How the Scheduler Runs Agents
The initialize pipeline includes a processor Sitecore.Pipelines.Loader.InitializeScheduler. This processor creates a new thread. This thread sleeps for the amount of time specified in Web.config or Sitecore patch file by the value of /configuration/sitecore/scheduling/frequency.
This does not mean that agents run based on this value. It means that the thread wakes up and checks for agents that are ready to run. An agent cannot run more often than this value, but an agent can be set to run less often.
An example is useful for understanding the relationship between the scheduler’s frequency setting and the individual task’s interval setting. Consider the following Sitecore patch file:


The following is an example of when the various tasks will run if the Sitecore server is started and the scheduler runs for the first time at 09:00.
Time MyTask1 MyTask2 MyTask3
09:00 Start
Last run: never Start
Last run: never Start
Last run: never
09:05 Start
Last run: 09:00
Interval: 00:03:00
More than 3 minutes has passed, so start Do not start
Last run: 09:00
Interval: 00:06:00
Fewer than 6 minutes has passed, so do not start Do not start
Last run: 09:00
Interval: 00:12:00
Fewer than 12 minutes has passed, so do not start
09:10 Start
Last run: 09:05
Interval: 00:03:00
More than 3 minutes has passed, so start Start
Last run: 09:00
Interval: 00:06:00
More than 6 minutes has passed, so start Do not start
Last run: 09:00
Interval: 00:12:00
Fewer than 12 minutes has passed, so do not start
09:15 Start
Last run: 09:10
Interval: 00:03:00
More than 3 minutes has passed, so start Do not start
Last run: 09:10
Interval: 00:06:00
Fewer than 6 minutes has passed, so do not start Start
Last run: 09:00
Interval: 00:12:00
More than 12 minutes has passed, so start
09:20 Start
Last run: 09:15
Interval: 00:03:00
More than 3 minutes has passed, so start Start
Last run: 09:10
Interval: 00:06:00
More than 6 minutes has passed, so start Do not start
Last run: 09:15
Interval: 00:12:00
Fewer than 12 minutes has passed, so do not start
Agents are used to schedule tasks.
• Implementing a Task
• Scheduling Agents using Sitecore Patch Files
• Context
• Logging
• Units Processed
• Performance
• Security
Implementing a Task
A task is a method that is run by an agent. The method must have a specific method signature:
public void Run()
Task methods do not return values and they accept no parameters. In order to pass parameters, use the class constructor or properties.
Scheduling Agents using Sitecore Patch Files
Scheduled tasks can be configured using a Sitecore patch file.
The following is an example of how to schedule a task using a Sitecore patch file.

Parameters can be passed to tasks using dependency injection. For more information on using dependency injection in this section.
When an agent is run, Sitecore calls the specified method. The method is called outside of the standard Sitecore request-handling process. As a result, the Sitecore context is not fully initialized.
One part of the Sitecore context that is initialized is Sitecore.Context.Job. This property provides access to an object that represents the current job.
Task logging is best handled by using the Status property on Sitecore.Context.Job. The following is an example of how to log messages from a task.
public virtual void Run()
Sitecore.Context.Job.Status.LogError(“error message”);
Sitecore.Context.Job.Status.LogInfo(“info message”);
Sitecore.Context.Job.Status.LogException(new Exception(“exception happened”));
Units Processed
If you look in the Sitecore log you will see messages (logged at INFO level) that indicate when a job started and when it stopped.
ManagedPoolThread #15 12:43:28 INFO Scheduling.DatabaseAgent started. Database: master
ManagedPoolThread #15 12:43:28 INFO Job ended: Sitecore.Tasks.DatabaseAgent (units processed: 2)
Some of the “Job ended” messages include a “units processed” count. If you want your task to be able to report this value, use the following code.
Sitecore.Context.Job.Status.Processed = 44;
Agents can cause performance problems on a Sitecore server. It is important to use them appropriately.
Scheduled tasks run as the anonymous user. A security disabler can be used to imitate specific users.
Database Scheduler
Sitecore’s Database Agent allows tasks to be scheduled in a Sitecore database. This means Content Editor can be used to schedule tasks.
• Database Agent
• Commands and Schedules
• Implementing a Command Method
• Defining a Command
• Defining a Schedule
Database Agent
The Database Agent is an agent that comes enabled by default. Just like all other agents, database agents are defined in Web.config or a Sitecore patch file under /configuration/sitecore/scheduling.
Each Sitecore database has its own database scheduler. The following is an example of the database agent for the master database.


The Sitecore.Tasks.DatabaseAgent constructor expects following parameters:
• string databaseName – Name of the Sitecore database that has the scheduled tasks.
• string scheduleRoot – Path to the Schedule items in the Sitecore database.
In addition, Sitecore.Tasks.DatabaseAgent supports the following properties:
• bool LogActivity – The database agent logs basic activity at the INFO level. If true the agent will write to the Sitecore log. If false the agent will not write to the Sitecore log.
Commands and Schedules
A command is a Sitecore item that specifies a type and method that can be run by a database agent.
A schedule is a Sitecore item that specifies when a command should be executed.
Implementing a Command Method
Command methods must have a specific method signature:
public void Run(Sitecore.Data.Items.Item[] items, Sitecore.Tasks.CommandItem command, Sitecore.Tasks.ScheduleItem schedule)
• Sitecore.Data.Items.Item[] items – When a command is scheduled, items can be specified. This parameter represents those items. If no items are specified, this array will be a 0-length array.
• Sitecore.Tasks.CommandItem command – This parameter represents the command item.
• Sitecore.Tasks.ScheduleItem schedule – This parameter represents the schedule that resulted in the command being executed.
Agents can cause performance problems on a Sitecore server. It is important to use them appropriately.
Defining a Command
Commands are defined in the Sitecore client.
1. In Content Editor navigate to /sitecore/system/Tasks/Commands
2. Create a new item using the Command template
3. Specify the Type and Method fields.
Defining a Schedule
The database agent will execute the command based on the settings in the schedule.
1. In Content Editor navigate to /sitecore/system/Tasks/Schedules
2. Create a new item using the Schedule template
3. For the Command field select the Command item you just created
4. If the task applies to specific items, you can identify those items in the Items field. This field supports a couple of formats.
5. For the Schedule field, you identify when the task should run. The value for this field is in a pipe-separated format.
Items field formats
The following are examples of values you can use for the Items field on a Schedule item.
Kind: Single item
Description: a path to the Sitecore item
Example: /sitecore/content/Home
Kind: Multiple items
Description: pipe-delimited set of paths to Sitecore items
Example: /sitecore/content/Home/Item1|/sitecore/content/Home/Item2
Kind: Query
Description: Sitecore Query format, but without the query: prefix
Example: /sitecore/content/Home/*
Schedule field values
The Schedule field on a Schedule item expects a pipe-delimited value make up of the following parts.
Position: 1
Name: Start date/time
Description: The task will not run before this date/time (in ISO format)
Example: 20040720T235900
Position: 2
Name: End date/time
Description: The task will not run after this date/time (in ISO format)
Example: 20060725T235900
Position: 3
Name: Days flag
Description: The days of the week when the task should run. The value is a flag, so the individual values below must be added in order to specify the days:
• Sunday = 1
• Monday = 2
• Tuesday = 4
• Wednesday = 8
• Thursday = 16
• Friday = 32
• Saturday = 64
Example: 127
Position: 4
Name: Interval
Description: How often the task should run, in HH:mm:ss format
Example: 01:00:00
Jobs API
• Starting a Job Programmatically
• Job Status
• Expiration
• Priority
• Events
Starting a Job Programmatically
The following is an example of how to start a job programmatically.
public class JobRunner
public Job CurrentJob { get; set; }

public void StartJob()
var jobName = “job name”;
var jobCategory = “tests”;
var siteName = Sitecore.Context.Site.Name;
var objectWithMethodToRun = this;
var methodName = “Run”;
var methodParameters = new Object[] {};
var options = new Sitecore.Jobs.JobOptions(jobName, jobCategory, siteName,
objectWithMethodToRun, methodName,
this.CurrentJob = Sitecore.Jobs.JobManager.Start(options);

public void Run()
if (this.CurrentJob != null)
//do something
The Sitecore.Jobs.JobOptions instance tells Sitecore what to do. The constructor expects the following parameters:
• string jobName – Name used to identify the job.
• string category – Category used to group similar jobs. This value is arbitrary and can be used for whatever purposes you need. (Sitecore uses it certain cases to ensure that only appropriate tasks are performed. For example, the scheduler uses it to ensure that it only interacts with scheduled jobs.)
• string siteName – Name of the site that Sitecore.Context.Site is initialized with.
• object obj – The object whose method will be run.
• string methodName – The name of the method on the obj parameter that will be run.
• object[] parameters – Parameters that are passed to the method that is run.
Job Status
The Sitecore.Jobs.Job class has a property Status. This property is an instance of the Sitecore.Jobs.JobStatus class. This object is used to indicate the job’s status.
The properties on this object do not change how the job runs, but the values are important for communicating what your code is doing.
Consider setting the job status in your code. This will make it easier to debug problems.
A job runs as a thread, and when the thread returns, the job is finished. Sitecore keeps the job around for a limited amount of time afterwards in case you want to check its status. This is called the “after-life”.
By default the after-life value is 1 minute. It can be changed using the Options property on the job.
var job = Sitecore.Jobs.JobManager.GetJob(“job name”);
if (job != null)
job.Options.AfterLife = new TimeSpan(0, 5, 0);
A job runs as a thread, so it is possible to set the thread priority.
var options = new Sitecore.Jobs.JobOptions(…);
options.Priority = System.Threading.ThreadPriority.Highest;
Do not change the priority of a thread after it has started. This is a standard .NET recommendation.
The following job-related events are available.
Name: job:starting
Description: Raised before a job is placed into the thread pool
Sample handler:
public virtual void OnJobStarting(Object sender, EventArgs e)
Assert.ArgumentNotNull(sender, “sender”);
Assert.ArgumentNotNull(e, “e”);
if (e is SitecoreEventArgs)
var args = Event.ExtractParameter(e, 0);
//do something
Name: job:started
Description: Raised after a job is placed into the thread pool and has been started
Sample handler:
public virtual void OnJobStarted(Object sender, EventArgs e)
Assert.ArgumentNotNull(sender, “sender”);
Assert.ArgumentNotNull(e, “e”);
if (e is SitecoreEventArgs)
var args = Event.ExtractParameter(e, 0);
//do something
Name: job:ended
Description: Raised during the Job_Finished event
Sample handler:
public virtual void OnJobEnded(Object sender, EventArgs e)
Assert.ArgumentNotNull(sender, “sender”);
Assert.ArgumentNotNull(e, “e”);
if (e is SitecoreEventArgs)
var args = Event.ExtractParameter(e, 0);
//do something

Sitecore : 404 Error

This post contains my view to fix the below error which we see frequently when we make a request to SITECORE item.


To troubleshoot this error, first make sure the requested item has presentation components configured or not. To check this, Select that item, go to “Presentation” tab and then choose “Details” button.

If presentation components are not configured, Make sure requested item’s template standard value has presentation component configured. If template standard value has components configured. But the same are not appearing on content item level. It indicates that at item level, configuration has been modified by someone.

To get the presentation component set up on item, if template standard value has it configured, Just RESET that item. RESET action will again pick the presentation component configuration from item’s template standard value to this item.

In most of the scenario, above error arises when requested item does not have presentation component configured.

If components are configured properly and still issue persist, then look for other causes.

SC: Custom field to an Image template

Adding a custom field to an Image template

This post is about adding an extra field let’s say “Caption” to an image template in media library. This caption will display with the image on the site.

A very simple straight forward step is to add the field to the standard image template “/sitecore/templates/System/Media/Versioned/Image”. But the problem here is that this image template will get RESET when we upgrade new version of Sitecore.

To avoid this problem, create a new template(for example Media Image) by inheriting the template “/sitecore/templates/System/Media/Versioned/Image”. And use this new template whenever we need to upload an image.

To make use of this new template by “Upload files” in media library, recommended approach is to create a new .config in app_config/include folder and add below contents to the config file.

<?xml version=”1.0″?>

<configuration xmlns:x=””&gt;




<mediaType name=”Windows Bitmap image” extensions=”bmp”>



<sharedTemplate>system/media/Versioned/Media Image</sharedTemplate>

<versionedTemplate>system/media/Versioned/Media Image</versionedTemplate>

<mediaValidator type=”Sitecore.Resources.Media.ImageValidator” />


<generator type=”Sitecore.Resources.Media.ImageThumbnailGenerator, Sitecore.Kernel”>








<media type=”Sitecore.Resources.Media.ImageMedia, Sitecore.Kernel” />



<mediaType name=”GIF image” extensions=”gif”>



<sharedTemplate>system/media/Versioned/Media Image</sharedTemplate>

<versionedTemplate>system/media/Versioned/Media Image</versionedTemplate>

<mediaValidator type=”Sitecore.Resources.Media.ImageValidator” />


<generator type=”Sitecore.Resources.Media.ImageThumbnailGenerator, Sitecore.Kernel”>








<media type=”Sitecore.Resources.Media.ImageMedia, Sitecore.Kernel” />



<mediaType name=”PNG image” extensions=”png”>



<sharedTemplate>system/media/Versioned/Media Image</sharedTemplate>

<versionedTemplate>system/media/Versioned/Media Image</versionedTemplate>

<mediaValidator type=”Sitecore.Resources.Media.ImageValidator” />


<generator type=”Sitecore.Resources.Media.ImageThumbnailGenerator, Sitecore.Kernel”>








<media type=”Sitecore.Resources.Media.ImageMedia, Sitecore.Kernel” />



<mediaType name=”JPEG image” extensions=”jpg, jpeg”>



<sharedTemplate>system/media/Versioned/Media Image</sharedTemplate>

<versionedTemplate>system/media/Versioned/Media Image</versionedTemplate>

<mediaValidator type=”Sitecore.Resources.Media.ImageValidator” />


<generator type=”Sitecore.Resources.Media.ImageThumbnailGenerator, Sitecore.Kernel”>








<media type=”Sitecore.Resources.Media.ImageMedia, Sitecore.Kernel” />







Now if we upload an image, media library will use our new template Media Image which will give us an extra caption field.

Creating a new config file will not impact pre-existing images to using the old templates.

SC7 : Computed index field for MultiList type field

Computed field is required when we want to process value of an item’s field before adding to Index. Think about fields of type DropLink or MultiList which is generally used to have a target item and we want to index the target item’s name or a target item’s field value. So in this case, we can consider of creating a computed field.

Here in the below example, I am going to create a computed field for a field of type MultiList in an item. By which I am going add its target item’s Name into index.

namespace ABCProduction.ComputedFields


class MoviesByName : IComputedIndexField


public string FieldName { get; set; }

public string ReturnType { get; set; }

public object ComputeFieldValue(IIndexable indexable)


var item = indexable as SitecoreIndexableItem;

if (item == null || item.Item == null) return string.Empty;

if (!item.Item.TemplateID.Equals(IMovieConstants.TemplateId)) return string.Empty;

StringBuilder MovieNameList = new StringBuilder();

IIndexableDataField moviesField = indexable.GetFieldById(IMovieContentConstants.MoviesFieldId);

if (moviesField!= null)


var movies = moviesField.Value.ToString().Split(new[] { ‘|’ }, StringSplitOptions.RemoveEmptyEntries).ToList();

foreach (var movieId in movies)


var movieItem = item.Item.Database.GetItem(new ID(movieId));

if (movieItem != null)

MovieNameList.Append(movieItem.Name.ToString() + “;”);


return MovieNameList;


return null;




In Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config file, add below entry.


<field fieldName=”_moviesbyname” storageType=”yes” indexType=”UNTOKENIZED” vectorType=”NO” boost=”1f” type=”System.String” settingType=”Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider” />



<field fieldName=”_moviesbyname”> ABCProduction.ComputedFields.MoviesByName, ABCProduction </field>


Now build the solution. Go to sitecore and rebuild the index.

The computed value will now be indexed.

Using Sitecore rocks for Presentation Details, Pipeline and Publishing

In this blog post, We’ll get to know that how Sitecore Rocks  is used to know about Presentation Details, Pipeline and Publishing.

Presentation Details:

To know about presentation details about an item, choose a desired item in sitecore content tree and right click on that item, context menu will open. In context menu there will be below two options under “Task” context menu item:

  • Design layout (use Ctrl+U to open the same)
  • Design layout on standard values.( we should select this option when we set presentation information on the standard values item of a template)

Clicking on the any of the above options will open “Design Layout Editor”, in this editor, devices like Default, Print and Feed will be available in the left panel of the editor.

To set a layout, click on “Browse” button placed on the right side of the layout box. “Browse” button click will open a dialog to choose a layout to set.

To add a rendering, Click on “+ Add Rendering” link available on the top of design layout editor.  It will open a “Select Rendering” window to choose a rendering.

Once chose a rendering, we need to set placeholder, to do so, open the property window of chosen rendering. In the property window, look for “place holder key “, click on ellipsis present on “Place holder key”. It will open a dialog displaying all the placeholders for the selected layout.

Pipeline Info:

A pipeline is a set of steps which executes in an order. Actually, Sitecore uses a pipeline to generate and populate the Sitecore.Context class. This context file contains information about current user, current site and the current item being requested.

Through Sitecore Rocks, creating a pipeline is simple. Just follow below steps:

  • Find the place/folder in visual studio solution explorer where pipeline has to create.
  • Right click on that folder and choose an “Addà new Item” option from context menu.
  • From “Add New Item “ window, click on “ pipelines “ link available under sitecore of installed template section.
  • In the right side panel. All pipeline templates will be listed to select.
  • Choose a pipeline template and give a name.
  • Once we hit “ADD”, a cs file will get created with a Process method. And corresponding .config file will also get created under App_Config/Include folder on file system.


To publish an item, Right click on that item and choose “Publishing” option available under “Tools” on the context menu. As we click on Publishing, it will display publishing sub menu in three region.Top region contains the following publishing options for the current item.

Publish Item,

Publish Item and Dependencies

Publish Item and Sub items

Middle region contains Incremental Publish Database, Smart Publish Database, Republish Database and Rebuild Publishing Target Database.

Bottom region contains Advanced Publishing.

Keyboard Shortcuts in Sitecore Rocks

Few shortcuts available in Sitecore Rocks are:

CTRL+SHIFT+SPACE   –commandy to search a command.

CTRL+ U  –to know about presentation detail  or design layout about an item.

CTRL+ALT+D  –to create a duplicate item

CTRL+A  –to create a new item

CTRL+E –to open a template associated with an item

CTRL+L –to locate current item in Sitecore Explorer

CTRL+R –to reload an item opened on visual studio.

CTRL+T –to show template in content tree of the Sitecore Explorer.

Template, Item and Navigation via Sitecore Rocks

Once Sitecore Rocks got installed, we will see a Sitecore menu in visual studio. Click on this Sitecore menu and choose “Sitecore Start Page” from sub menu. Sitecore Start Page will get opened in visual studio IDE.

Sitecore Start Page contains below four sections:

Get Started: We’ll find information links about “how to create a new sitecore website and “setting and configuration in web.config”

Content: We’ll find information links for managing content items and media assets. Also provides links for publishing the content and for viewing information about publishing.

Developing: This section provides information links for Querying, Deployment and Serialization.

System: This section provides information links for maintenance and system activities.

Designing and Using Templates:

To design a new template, First locate the section under “Templates” node available in content tree.

Then right click on that section, choose “New Template” option from context menu.

“Add New Item” pop up will prompt us to enter template name. Just enter a Template name and click ok.

A new .template file will get opened in a new tab in visual studio to design a template.

First this file will ask us to enter Section Name. As we enter section name, it will ask us further to enter fields and field’s details.

On this .template file, we can notice few new features:

Validations Drop down allows us to set field validations.

Data Source and Build Button in a field:  Allow us to write data source query directly into the textbox and save the template.  Sitecore Rocks has given us a facility for constructing data sources using “Build”.  When we click on Build, it will open a Builder to create datasources.

If we do right click on anywhere on this .template file, the context menu will show us below features:

Set Icon: Will open a popup to choose an icon to set on template.

Set Base Template: used to set a template as base template.

Creating, Editing and Deleting Content Items:

–       To create an item, just go to that section where we want to create, Right click on that section, Choose “Add” option available in context Menu.

–       To delete an item, just go to that item which we want to delete, Right click on that, Choose “Delete” option available in context Menu. We can also delete that item just by hitting delete key on keyboard.

–       To edit an item, just go to that item which we want to Edit, Right click on that, Choose “Edit” option available in context Menu.

Sitecore Rocks Basic

Sitecore Rocks:

Is a Visual Studio plug-in.

Designed to maximize the developer productivity.

Reduces the switching between  Visual Studio  and Browser .

Uses “Hard Rock Web Service” to interact with Sitecore’s data tier.

Sitecore Rocks Installation:

Sitecore Rocks can be installed in 2 ways.

1-      Using Visual Studio Extension Manager: In Visual Studio open Tools | Extension Manager and click the Online Gallery tab. In the search box, enter Sitecore Rocks and wait for Sitecore Rocks to appear. Click Download and follow the installation instructions.

2-      By downloading the .vsix file: Download the Sitecore Rocks .vsix file from

Sitecore Rocks Components: below is not a complete list of its components.

  1. Sitecore Explorer is like a Visual Studio Solution Explorer. It helps us in navigating sitecore content tree.
  2. Item Editor allows us to edit sitecore item inside Visual Studio. It also provides support for updating multi items simultaneously.
  3. Query Analyzer is an alternative of XPath Builder available in the browser-based Developer Center.
  4. Template Designer is for creating data templates within Visual Studio.
  5. Media Library allows us to upload media item by using search and drag-and-drop functionality.
  6. Log Manager is used to check Sitecore log files to know what is happening on a Sitecore site
  7. Job Manager is used to check background jobs to know which jobs are running in the background on a Sitecore site.

Sitecore MVC

In this blog post, I will try to highlight about Sitecore MVC, MVC rendering and MVC routing.  I‘ll be adding more to it if I find something important related to sitecore MVC.


Sitecore MVC allows us to use ASP.NET MVC as a first class rendering engine in Sitecore. Both ASP.NET WebForms and MVC are supported and can be mixed, although a single request must be rendered by either WebForms or MVC.The another objective of Sitecore MVC is to provide a powerful, flexible, and extendable API for controlling the rendering process.

MVC View Renderings

MVC uses a different set of controls to render than ASP.NET WebForms. In Sitecore  MVC, the supported rendering types are:

  • Content rendering — static text
  • Controller rendering — executes MVC controller and outputs result
  • Item rendering — executes the renderings specified by the item
  • Method Rendering
  • Url Rendering
  • View Rendering — MVC View
  • Xslt Rendering

WebControl and Sublayout renderings are not supported in sitecore MVC.Usually Sublayouts can be converted to View renderings easily. MVC is reusing the Sitecore Data templates for XSLT, URL, and Method renderings. However, we as a developers  should be aware that the renderer classes in MVC do not inherit from WebControl but inherit from Renderer. 

MVC Routing

MVC Routing means “to map URLs by registering routes in the Global.asax module”.

MVC Routes

Sitecore uses the MVC route table to determine which requests to send to the MVC runtime for processing. The route table is set up in global.asax and Sitecore provides a set of custom route values that can be used to augment the routes with Sitecore specific information. We can add additional routes.

Examples of the Sitecore route extensions include:

// bypasses Sitecore and is handled by the ‘MyController’ custom controller

routes.MapRoute(“example1”, “special/{id}”, new { controller = ” MyController”, });

// matches the item ‘/home/blogPosts/{blogNo}’

routes.MapRoute(“example2”, “blog/{blogNo}”, new { scItemPath =

“/home/blogPosts/{blogNo}”, });

// sets language to {scLanguage} and matches the item ‘/home/{itemName}’

routes.MapRoute(“example3”, “home/{scLanguage}/{itemName}”);

// matches the item ‘/home/{itemName}’

routes.MapRoute(“example4”, “home/{something}/{itemName}”,

new { scKeysToIgnore = “something”, });

// matches the item ‘/home/{itemName}’

routes.MapRoute(“example5”, “home/{something}/{orOther}/{itemName}”,

new { scKeysToIgnore = new[] { “something”, “orOther” }, });

A brief explanation of the custom route keys:

scLanguage — The part of the URL that matches this key is used as the context language for the request.

scItemPath — No matter what the route URL is, the item is resolved by using the value of this element. It can either be hard coded as in the previous example or be a part of the route URL, for example, routes.MapRoute(“myRoute”, “/special/{*scItemPath}”)

scKeysToIgnore — One or more keys of the route URL that should be ignored by Sitecore. If they occur in the route, they are removed before attempting to resolve an item from the URL.

If a controller is not specified in a custom route, the default Sitecore controller handles the request. Likewise, if an action is not specified, the default action ‘Index’ is used.

Note that a default route — {*pathInfo} — should not be set up in global.asax. Sitecore installs a default route in the InitializeRoutes processor, as part of the initialize pipeline. This will cause all routes not matching any of custom routes set up in global.asax to be handled by Sitecore.

It is possible to hook into the route handling by adding processors to the GetPageItem pipeline where the route parsing is done.

Sitecore question and answer Part2


Q1-Which is the usual maintenance process that we must make on a Sitecore server?

The phases of maintenance for a Sitecore server are:

a) The IIS, the System logs and Sitecore must be checked for errors.

b) We must test the response times regarding the capacity problems within ISS logs.

There are other procedures that have to be done monthly to assure that Sitecore functions properly. Here are some of them:

a)    The links database has to be reconstructed if we update the content constantly.

b)    The search indexes have to be reconstructed in the case we use Lucene search and update content constantly.

c)    When moving or deleting much content we must be aware of the fragmentation.

These measures are for the case in which we are always changing content, in rest Sitecore can manage the things alone, and usually we only need to clean the unnecessary files. Other common things that we must consider are:

a)    The logging can be changed to fit our needs for example the initial value is Warn but this level can be increased.

b)    We must assure about the installation of the performance counters.

c)    The cache of Sitecore can be modified to fit the memory installed on the server.

d)    People using version 6.0 should upgrade to 6.1 at least because version 6 makes a lot if useless traffic and it affects the performance very much.


Q2-Can we copy fields if we make new version in Sitecore?

The Shared and Unversioned checkboxes from Sitecore permit us to spread the value of fileds to languages or versions. But can we copy the fields from the initial language into a new one if we put a new version of the language? By default, no but there are some methods:

a)    If we use “Translate” we can obtain the view of two item versions in two sides, being able to makes changes between them, we can’t do the copying automatically but there is the advantage of not having to modify the versions all the time.

b)    There is another method like writing some event handlers to communicate with the Sitecore API. Then the old version values have to be copied to the new version.


Q3-What is the way to get in the settings of Sitecore programmatically?

There is a good way by accessing the code. We can find the settings that we look for in the data folder. We also may see the Sitecore Configuration Settings class with the property of static DataFolder: string dataFloder=Sitecore.Configuration.Settings.DataFloder.


Q4-How can we move, delete or select several items in the content editor of Sitecore 6?

Normally it is impossible, but there are some indirect ways to do this, for batch copying we can copy the Presentation Configuration to several different page links (with the aid of “copy to”) but for many people that doesn’t really work. We are lucky that something new came out:Sitecore Rocks that is available for download. With it we can process several items by hildin Ctrland then use the operations from the context menu.


Q5-In Sitecore 6.4 fast query, is it possible to have relative path beginning with the item that the query is running from?

There isn’t any way of operating fast query from the item context.


Q6-Elaborate on the different ways in which you can support a multi lingual site within Sitecore

  • You expect the candidate to illustrate how important the setup of the content tree is pre-development.
  • You expect them to mention the “Multisite” approach (one site per domain)
  • Using Sitecore’s built in language versioning.

Q7-How can you grab the specific version of an item programmatically?

  • Sitecore.Context.Database.GetItem(id/path, language);

Q8-How do you publish an item programmatically?

  • You will need to reference the parent database and the target databse, e.g
  • You will need a reference to the target/fall back language
  • Use Sitecore.Publishing.PublishManager.PublishIncremental or any appropriate publishing type within the Publishing manager class

Q9-What are workflows, how do you set an instance up within Sitecore

  • The allow you to attach a sequence of events and states to a Sitecore item.
  • They can be setup within the Sitecore system folder

Q10-How do you pass parameters to a workflow action and how can you call a type within your code once a workflow state has been triggered.

  • Use an auto publish action template for the state
  • Pass in the Parameters as key/value pairs in the parameters field.
  • To call a type, provide the fully qualified path of the type in the type string field eg. CompanyName.TS.BusinessLogic.Workflow.Actions.CustomAutoPublishAction, CompanyName.TS

Q11-What are Aliases and how can they be useful?

  • Mostly used by the marketing department, it is useful when you are required to point to an item nested deeply within the content tree, i.e. point “/sitename/News/2013/In Brief/Man on the moon” to The newly setup alias acts as a proxy to the real item.
  • Very experienced Sitecore developers would touch base on how you can extend the functionality for multiple sites
  • Discuss inheritance within Sitecore and state how you have used it in a previous instance of Sitecore
  • Creating common templates, such as a page Meta Data template that will be inherited by all presentation templates.
  • What are the new features of the recommended version of Sitecore that you have used or read about
  • Expect some discussion about DMS, Multi variant targeting, adaptive print studio etc.
  • I have a business requirement that requires an email to be sent when a specific item type is published, how can I accomplish this task
  • Expect the candidate to suggest hooking up into the Pipelines, adapting a type that inherits from the PublishItemProcessor class and manipulating the PublishItemContext context

Q12-I need to perform an operation of an Item within code, I am running into some security issues, and how can I potentially fix this.

Wrap the code around the Sitecore.SecurityModel.SecurityDisabler() context.

Q13- What are the top 8 Concept of the Sitecore ?

We have divided top 8 concept of Sitecore into two subset first is Data and second is presentation. Sitecore is based on MVP patterns and here we separate Data Concepts and Presentation concepts clearly which give advantage of Re-use and better control over the content. This way of programing is contradiction to traditional ASP.NET based programming.

Data Presentation
Data Base Layout
Data Template SubLayout
Fields Rendering
Item PlaceHolder

Q14- What is Database?
Sitecore store its all content / information in relational database available in market. By default Sitecore comes with Microsoft SQL based data base in form of .mdf and .ldf files which you may attach with you MS-SQL Instance. Sitecore also supports Oracle, MySQL, IBM DB2.
By default Sitecore have three database Core, Master and Web. Each have its own purpose and role to play.

Q15- What is Data Template / Template? Why we need to create Data template ?
Data Template in Sitecore have two purpose, first is they define the Data Structure for an Item. Second they also define how data is going to be edited and shown to business users in Sitecore Shell / Sitecore Content editor.
To do comparative study Data Template in Sitecore are similar to SQL Table in traditional programming world of programing where we create SQL Table Structure to store information. So it also means that as many information(Business Entities) we need to store we generally create those many SQL tables in traditional world. So same logic applies in case of Sitecore where we need to create those many data templates as many information we want to store and use in Siecore.
Generally in Sitecore we don’t create SQL Tables.

Q16- What is Fields ?
Fields are equivalent to the Columns\Tuples we create in SQL tables in traditional programming world. So collection of Fields are called Data Templates. Field is the smallest entity which define type of single value stored within the data template.

Q17- What is Field Types ?
When we create / add fields in the Data Template then we need to select the field type which basically define the type of value going to store in that particular field. In case of Sitecore we don’t primitive data types like var char, int, float etc., But here we have field type like ‘Single Line TextBox’, ‘Rich Text Box’, ‘Image’, ‘DropDownList’ etc.,
As you notice these field types not only define what kind of data is allowed in field but how that field is going to render on the content editor.

Q18- Can you have custom field types ?
For most of the general requirement sitecore has already provided enough field types. Still you for your own custom requirement you may create your own field types also.

Q19-What are the types of Data Template is available ?
Sitecore users create items using one of three template types: data templates, branch
templates, and command templates.
Data Templates form the framework around which items are built. They define fields used to control how data is entered and can inherit from other templates to enable reuse.
Branch templates—allow you to create a set of items rather than a single item at a time.
Command Templates—allow you to insert of items according to logic rather than predefined structures.

Q20- In Sitecore Multiple Inheritance of Data Template is possible, can you explain with example ?
A data template inherits the sections and fields defined on its base templates. You can see the base templates associated with a data template in the Inheritance tab in the Template Manager or Content Editor.
A data template can be based on any number of data templates, not just one. Occasionally more than one inherited template will contain the same field or field section. In this case, the UI will merge these fields or field sections to prevent duplication.

Q21- What is Standard Values in Sitecore ?
Standard values are a way of having default or fallback values for fields in Sitecore, meaning that when items are created, you can specify a field value that should be used by default. This does not only account for custom fields you build, but also standard fields in Sitecore such as presentations and insert options. This means that you can specify a value on the standard values, and when you create a new item which inherits from this template, it will by default use the values specified on the standard values.
To read more about standard Value or why masters are discontinued from Sitecore 6.0 onwards please read this great article by Jens Mikkelsen
I personally recommend to go through his complete blog as that is my one of the corner for reading about Sitecore.

Q22- How Data / means Items or other information related to it is exposed by Sitecore to you as Developer?
Sitecore use good things from two different world of Data Sources. Sitecore end of the day store all its information in relational world which is MS-SQL, oracle etc., But at time of exposing the same data it exposes and represent in Sitecore Shell as Hierarchical Data Source. Because of this Developer can use XSL to render the same data or use other XML based technology to navigate the data. Developer can also use the .net based InMemory Object collection of Data which is based on generics in .NET, which you may write normal foreach loop also or modern Linq to get you data.