You need to sign in to do that
Don't have an account?

Onclick Javascript Custom Button "Follow-up Task" button for Opportunity page
I created a custom button for the "leads" page so that our sales team can have a one-click follow-up created for various lengths of time. The below button is for a 1 week follow-up and works just fine on the leads page:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var myTask = new sforce.SObject("Task");
myTask.WhoId = "{!Lead.Id}";
myTask.Subject = "{!Lead.LastName} 1 Month Follow-up";
myTask.status = "Not Started"
myTask.ActivityDate = "{!SUBSTITUTE(TEXT(TODAY()+30), "/", "-")}"
sforce.connection.create([myTask]);
window.location.reload();
I would like to do something similar on our Opportunity and Case pages. I would expect that I could just swap out Lead.ID for Opportunity.ID and Lead.Lastname for the Opportunity.Subject and it should work. Unfortunatly, I'm just getting a page refresh and no task. Please help!
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var myTask = new sforce.SObject("Task");
myTask.WhoId = "{!Lead.Id}";
myTask.Subject = "{!Lead.LastName} 1 Month Follow-up";
myTask.status = "Not Started"
myTask.ActivityDate = "{!SUBSTITUTE(TEXT(TODAY()+30), "/", "-")}"
sforce.connection.create([myTask]);
window.location.reload();
I would like to do something similar on our Opportunity and Case pages. I would expect that I could just swap out Lead.ID for Opportunity.ID and Lead.Lastname for the Opportunity.Subject and it should work. Unfortunatly, I'm just getting a page refresh and no task. Please help!
For Opportunitty you ca try below code.
For Case you ca try below code.
Please let me know if this helps you.
Best Regards,
-Vivek
All Answers
it should be - myTask.WhatId = "{Opportunity.Id}";
Thanks,
Kaustav
For Opportunitty you ca try below code.
For Case you ca try below code.
Please let me know if this helps you.
Best Regards,
-Vivek