+ Start a Discussion
Anthony PenkethAnthony Penketh 

Issues with custom buttons on the lead page.

Hi All,

I am trying to create a custom button ("LVM") on the lead object that will create a task, applied the current date and sets the status to complete.

Here's what I have so far:

{!REQUIRESCRIPT("/soap/ajax/17.0/connection.js" )} 

var t1= new sforce.SObject("Task"); 
t1.Subject = "LVM";
t1.Status = "Completed"; 
t1.Priority = "Normal"; 
t1.OwnerId = "{!User.Id}";
t1.ActivityDate =  new Date();
 
result = sforce.connection.create([t1]);

  if(result[0].success=='true'){
      alert('Your Left voice mail (LVM) task has been created.');
      location.reload();
  }
else
{
alert(result[0]);
}

This currently delivers the alert but does not create the task.

Origionally we used the following:
 
t1.WhatId = "{!Lead.Id}"; 

But received and error message upon pressing the button.

Any help would be much appreciated!

Thanks,

Anthony
Best Answer chosen by Anthony Penketh
Jai ChaturvediJai Chaturvedi
Hi,

Use this:

t1.WhoId  = LeadId;

And what the error you are getting?

Mark this as solution if works.

All Answers

Jai ChaturvediJai Chaturvedi
Hi,

Use this:

t1.WhoId  = LeadId;

And what the error you are getting?

Mark this as solution if works.
This was selected as the best answer
Anthony PenkethAnthony Penketh
Hi Jai, this worked. Thanks a lot.