Sitecore provides you with the database task feature to schedule tasks, which comes with many advantages over scheduling agents. To make this recipe shorter, we will configure database task to reset layout details.
We will first implement a task to reset layout details, which we already implemented while creating jobs:
In the
SitecoreCookbook
project, create aResetLayoutTask
class in theTasks
folder and implement theExecute()
method. Database task expects a specific signature for this method as follows:public void Execute(Item[] items, CommandItem command, ScheduleItem schedule) { foreach(Item rootItem in items) { ResetLayoutDetails(rootItem); } }
Create the
ResetLayoutDetails()
method to reset layout details, which we already implemented while creating a job. You can also get the code from the code bundle provided with this book.From the content editor, select the
/sitecore/system/Tasks/Commands
item. In this...