Tuesday 22 July 2014

Disable Schedule Email Reminder Task for multiple items in Sitecore

3 comments
Today I have noticed a post in Sitecore SDN forum regarding how to disable Schedule Email Reminder task for multiple items in Sitecore. I thought it'd be better to turn it into a Blog post with more detail. It might come useful to someone. :)

Occasionally an author may wish to be reminded of something regarding the item he is working on. Sitecore Reminders are made just for that. They also make the Administrator's work easier, by providing a suitable way of notifying Editors and other staff members about changes needed to be made. Reminder settings for an item are set in the Tasks section:
You can also set reminder settings for an item by clicking on Set Reminder in Review Strip of Sitecore Content Editor Ribbon.

Disabling Schedule Email Reminder task

Schedule Email Reminder task for Sitecore item can be disabled by following ways:
  1. Using Sitecore Content Editor: You can disable reminder settings for an item by clicking on Clear Reminder in Review Strip of Sitecore Content Editor Ribbon.
    You can also disable reminder settings for an Item by clicking on Clear link in the Tasks section.
    This approach will work only for one item at a time.
  2. Updating tasks table of Core Database: You can disable EmailReminderTask for multiple items by modifying tasks table of Core database using below SQL query:
    Update [Tasks] set Disabled=1 where taskType='Sitecore.Tasks.EmailReminderTask,Sitecore.Kernel'
    Take a backup of Core db before executing this query.
  3. Disabling TaskDatabaseAgent in web.config: In web.config, you will find below entry related to TaskDatabaseAgent
      <!-- Agent to process tasks from the task database (TaskDatabase) -->
          <agent type="Sitecore.Tasks.TaskDatabaseAgent" method="Run" interval="00:10:00" />
    
    TaskDatabaseAgent gets all pending tasks ( for example: EmailReminderTask, ArchiveItem, ArchiveVersion) from the tasks table of Core db and executes them one by one. So basically TaskDatabaseAgent runs scheduled tasks from the Core database.
    So in order to suspend EmailReminderTask you have to disable TaskDatabaseAgent by setting its value to 00:00:00 ( 00:00:00 means that Agent/Job is disabled).
    Disabling TaskDatabaseAgent will also suspend execution of other pending tasks like ArchiveItem or ArchiveVersion.
  4. Using Custom Code: Below function ClearReminder(Item item) takes Sitecore item as input parameter and clear reminder for specific item. Call this function iteratively for multiple items.
  5. Item item = Sitecore.Data.Database.GetDatabase("master").GetItem(new ID("{D833E825-4948-4264-9D77-68CE50C72F94}"));
                ClearReminder(item);
    public void ClearReminder(Item item)
            {
                if (item[FieldIDs.ReminderText].Length > 0 || item[FieldIDs.ReminderRecipients].Length > 0 || item[FieldIDs.ReminderDate].Length > 0)
                {
                    using (new Sitecore.SecurityModel.SecurityDisabler())
                    {
                        item.Editing.BeginEdit();
                        item[FieldIDs.ReminderText] = string.Empty;
                        item[FieldIDs.ReminderRecipients] = string.Empty;
                        item[FieldIDs.ReminderDate] = string.Empty;
                        item.Editing.EndEdit();
                        string[] strArrays = new string[] { AuditFormatter.FormatItem(item) };
                        Log.Audit(this, "Clear reminder: {0}", strArrays);
                    }
                }
            }
    
Comments and suggestions are most welcome. Happy coding!

3 comments :

  1. Thanks, this guide has really helped me to understand SSL in a load balancing context. The problem I'm having right now is getting this HTTP_X_FORWARDED_PROTO header to be forwarded to the nodes from ARR. I have my own custom inbound rule, do I need to add a server variable there?

    ReplyDelete
  2. Congratulations for the great post! The official documentation is not exactly straight-forward and you made a good job summarizing everything we need to change to make the Active Directory module works.


    In the other hand I've never been a big fan of changing the Web.config: you can easily lose track of your changes and a Sitecore upgrade would become harder. Also, turning the module off is also harder, so I decided to take another approach of isolating the configs on include files.

    Please check my solution and let me know what you think:
    http://blog.peplau.com.br/en_US/best-way-to-setup-active-directory-module-in-a-sitecore-solution/

    ReplyDelete
  3. Nice approach. Thanks for sharing your solution Rodrigo. Cheers! :)

    ReplyDelete