+ Start a Discussion
Learning_fastLearning_fast 

creating a custom button to create task

Hey there. Your help on this one will be greatly appreciated. I am trying to create a custom button on my contact pages  to do the following:

1. Create new task to process members cc information
2. The task will have basic contact information already populated from contact record
3. An important custom field that must be autopopulated is our "membername" field.
4. Fields that Sales Managers input cc information (it is not necessary to store the cc)
5. The task is assigned to me with email notification to process cc.

I hope this makes sense. I am looking to see if someone could help me with the syntax on this one or maybe someone has written something similiar that I can customize.

Thank you in advance for your help on this. Go Sales Force!

Matt




Jeff TalbotJeff Talbot
You might be able to keep it as simple as a custom URL button. A "create new task" URL will often look something like this:
 
You will use a formula to insert the who_id, what_id, and retURL from the current record.
 
Here's some additional info I've gathered through trial and error on acceptable parameters for the "new task" URL:
tsk1=Assigned To
tsk2=Name
tsk3=Related To
tsk4=Due Date
tsk5=Subject
tsk6=Comments
tsk9=Activity Currency
tsk10=Type
 
including the "followup=1" parameter in your URL makes four things happen:
1) Status is set to Completed (vs. Not Started) and is not editable
2) Due Date is auto populated with today's date
3) Reminder is not offered for completed task
4) Schedule a followup task and reminder are offered
Learning_fastLearning_fast
Ta,


Thanks for the advice. I will look into this!


Navin SoniNavin Soni
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}

try{
    var taskToCreate = new sforce.SObject("Task");

    taskToCreate.OwnerId = "{!$User.Id}";
    taskToCreate.WhoId = "{!Lead.Id}";
    taskToCreate.Subject = "Outbound Call";
    taskToCreate.ActivityDate = new Date();

    taskToCreate.Priority = "Normal";
    taskToCreate.Status = "Completed";

    taskToCreate.CallType__c = "Left Voicemail";
    taskToCreate.Short_Call_Notes__c = "Left Voice Mail";

    result = sforce.connection.create([taskToCreate]);

    if(result[0].success == "true"){
        location.reload();
    }
    else{
        alert(
            "An Error has Occurred. Error: \r\n" +
            result[0].errors.message
        );
    }
}
catch(e){
    alert("An Un-expected Error has Occurred. Error: \r\n" +e);
}