Oops! I Didn’t Want to Dismiss All

The infamous Matt Brown threw out a question the other day

After some back and forth with Matt it turned out there are many questions on the Salesforce.com Answers forums related to getting reminders back after a user clicks ‘Dismiss All’ on the reminders pop up. I decided to give this a stab and the following is the result.

I created a Visualforce Page that simply has a button on it along with a disclaimer of what the button will do.

<apex:page controller="resetReminderController" sidebar="false">
    <apex:form >
        <apex:panelGrid columns="2">
            <apex:outputPanel >
                <apex:outputText >
                    To reset all of your <b>open</b> task and <b>future</b> event reminders click the button.<br/>
                    Any open tasks and any future events will have the reminders turned on. <br/><br/>
            <apex:commandButton value="Reset Reminders" action="{!processItems}"/>

    <apex:outputText value="No tasks or events processed" rendered="{!noRecords}" style="color:red"/>

    <apex:pageBlock title="Updated Tasks" tabStyle="Task" rendered="{!RenderTasks}" id="theTasks">
        <apex:pageBlockTable value="{!updateTaskList}" var="ut">
            <apex:column value="{!ut.Subject}"/>
            <apex:column value="{!ut.ActivityDate}"/>
            <apex:column value="{!ut.IsReminderSet}"/>
            <apex:column value="{!ut.ReminderDateTime}"/>
            <apex:column value="{!ut.whoId}"/>
            <apex:column value="{!ut.whatId}"/>

    <apex:pageBlock title="Updated Events" tabStyle="Event" rendered="{!RenderEvents}" id="theEvents">
        <apex:pageBlockTable value="{!updateEventList}" var="ue">
            <apex:column value="{!ue.Subject}"/>
            <apex:column value="{!ue.ActivityDate}"/>
            <apex:column value="{!ue.IsReminderSet}"/>
            <apex:column value="{!ue.ReminderDateTime}"/>
            <apex:column value="{!ue.whoId}"/>
            <apex:column value="{!ue.whatId}"/>

The main purpose of the controller is to query for all open tasks and future events owned by the current user and set the reminder flag to true, allowing them to show up in the reminder pop-up when logging in. The controller will not set the reminder flag for any Tasks that never had a reminder set.  We know this because the Reminder Date is null.  Had it been set previously, it would still be set; the reminder flag was just unchecked.

public with sharing class resetReminderController {

    public List&lt;Task&gt; updateTaskList {get;set;}
    public List&lt;Event&gt; updateEventList {get;set;}
    public Boolean noRecords {get;set;}

    //This is our constructor. initialize the lists and noRecords
    public resetReminderController(){
        updateTaskList = new List&lt;Task&gt;();
        updateEventList = new List&lt;Event&gt;();

    public boolean getRenderTasks(){
        return !updateTaskList.IsEmpty();

    public boolean getRenderEvents(){
        return !updateEventList.IsEmpty();

    public void processItems(){
        //make sure the lists are clear

        //if there are no records, we want to display that message to the user

        //loop though users open tasks and update any task with no reminder.  if reminder date is null, then reminder was never set in the first place
        for(Task t : [select Id, Subject, ActivityDate, ReminderDateTime, IsReminderSet, whoId, whatId from Task where OwnerId = :UserInfo.getUserId() and IsClosed=false]){
            if(!t.IsReminderSet &amp;&amp; t.ReminderDateTime &lt;&gt; null){
                t.IsReminderSet = true;

       //loop through all future events and turn on the reminder.  since reminder for events is a picklist, it won't be null. no need to account for that
       for(Event e : [select Id, Subject, ActivityDate, ReminderDateTime, IsReminderSet, whoId, whatId from Event where OwnerId = :UserInfo.getUserId() AND (ActivityDateTime &gt;= :DateTime.now() OR ActivityDate &gt;= :Date.Today()) ]){
                e.IsReminderSet = true;

        //update any tasks that were changed
            update updateTaskList;

        //update any events that were changed
            update updateEventList;

Finally, I created a very simply home page component with a link to the visualforce page. The component name is “Reset Reminders For My Open Tasks and Event” and the html (be sure to check the ‘show html’ checkbox) is:

&lt;a href=&quot;/apex/resetReminders&quot;&gt;Click here&lt;/a&gt; to reset the reminders for tasks and events.&lt;div&gt;&lt;br&gt;&lt;/div&gt;

I figured the easiest way to show the functionality was with a quick demo.

Finally, you can install an unmanaged package of the home page component (don’t forget to add it to a page layout), visualforce page, controller and test method with this link:
*Remember, you can change the path to https://test.salesforce.com&#8230; to install to a sandbox.

    • Akhil
    • June 1st, 2012

    That is some good work .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: