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

Create Task not happening

Trying to create a new task associated with a lead in an s-control and the code executes ok but it doesnt create the associated record in the task is the code below - I also use the same method to add a note to a lead which works fine.

function UpdateTask() {
var addr = new sforce.StringBuffer();
var usr = "Lead sent-forwarded by: " + "{!User.Name}" + " to the following addresse(s): " + addr.append(document.getElementById("to_address").value);
var lead = "{!Lead.Id}";
var user = sforce.connection.getUserInfo().userEmail;

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

updateTask.WhoId = lead;
updateTask.Subject = "Lead Sent-Forwarded";
updateTask.Description = usr;
updateTask.IsClosed = "true";
updateTask.Status = "Completed";
updateTask.Type = "Email";
updateTask.Priority = "Normal";

var result = sforce.connection.create([UpdateTask]);


Did you check to see what error you're getting?  Run it with Firebug to see.

My guess would be that it doesn't like that you're setting IsClosed, which is a derived field (it's derived from the Status field).