function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MLamb2005MLamb2005 

Removing Task Reminder with javascript

Hey all,
 
We've got a custom button on our Tasks and Events called 'Mark Complete' that executes the code below.  Is there a way to also remove or disable the reminder for the task at the same time?
 
Thanks!
Matt
 
Code:
{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")} 

var newRecords = []; 

var c = new sforce.SObject("Task"); 

c.id ="{!Task.Id}"; 
c.Status= "Complete"; 

// Reminder added by matt... 
//c.Reminder = 0; 

newRecords.push(c); 

result = sforce.connection.update(newRecords); 

window.location.reload();

 
 
Best Answer chosen by Admin (Salesforce Developers) 
MLamb2005MLamb2005

Good catch!  It should mark the item as "Completed" and not "Complete".  That will actually Close the item and drive it into the Activity History.  The updated code is below...

As far as making it a link, I'm not sure how you would accomplis this.  Maybe try overriding the 'Close' button?

Best of luck,

Matt

Code:
{!REQUIRESCRIPT("/soap/ajax/12.0/connection.js")} 

var newRecords = []; 

var c = new sforce.SObject("Task"); 

c.id ="{!Task.Id}"; 
c.Status= "Completed"; 
c.IsReminderSet = false 
newRecords.push(c); 

result = sforce.connection.update(newRecords); 

window.location.reload();

 

All Answers

sfdcfoxsfdcfox
Sure, just add this one line of code:
 
Code:
 
{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")} 

var newRecords = []; 

var c = new sforce.SObject("Task"); 

c.id ="{!Task.Id}"; 
c.Status= "Complete"; 

// Reminder added by matt... 
//c.Reminder = 0;
c.IsReminderSet = false; newRecords.push(c); result = sforce.connection.update(newRecords); window.location.reload();
 

There goes the reminder!
 
Edit: As a side note, upgrade to version 12.0 of the API by changing the first line. I can't remember which API version reminders came out on, but there's no reason to limit yourself to version 8.0 when 12.0 is 100% compatiable from a scripting point of view.


Message Edited by sfdcfox on 04-03-2008 04:54 PM
MLamb2005MLamb2005
Awesome, thanks!
 
Good catch on the API version.
CrmzepherCrmzepher
Hello Gentlemen,
 
First off, great work on putting this code together. I especially like that it removes the reminder when you mark the Task complete. For me this is one of the major programming oversites with SF and the Task section. We are constantly after users to mark tasks as complete or to clean up the Reminder Popup using the dismiss checkbox.
 
One problem that I have noticed  . . . your code will mark the task "Complete" in the status field but it will not "Close" the task. It still appears in the Open Activities section of the Leads Tab when if the task is "Complete" it should be closed and appear the Activity History section. How can that be fixed?
 
Also an idea,,,, Is the anyway to make this a "link" hyper link button that would act like the "Cls" hyperlink button that is found in teh Open Activites section next to the Task. Many times our users have tasks that they do not have to look at the contents again (loading a new page, etc . . ) because the are are aware of the task already or the Subject line explains everything they need to know. Having a quick hyperlink button that closed the task and removed the reminder would a great time saver.
 
Is it possible to put this type of hyperlink next to the Task subject in Professional version? Could you help me try to accomplish it.
 
Thanks again.
 
crmzepher
MLamb2005MLamb2005

Good catch!  It should mark the item as "Completed" and not "Complete".  That will actually Close the item and drive it into the Activity History.  The updated code is below...

As far as making it a link, I'm not sure how you would accomplis this.  Maybe try overriding the 'Close' button?

Best of luck,

Matt

Code:
{!REQUIRESCRIPT("/soap/ajax/12.0/connection.js")} 

var newRecords = []; 

var c = new sforce.SObject("Task"); 

c.id ="{!Task.Id}"; 
c.Status= "Completed"; 
c.IsReminderSet = false 
newRecords.push(c); 

result = sforce.connection.update(newRecords); 

window.location.reload();

 
This was selected as the best answer