You need to sign in to do that
Don't have an account?
Shawn Low 24
Create a custom button using Javascript to create a Task
However, I keep getting errors.
I am just trying to create a custom button that opens up a task window. Then the person fills things in and then clicks "save" and the task is created.
Here's what I have as Javascript...
{!REQUIRESCRIPT("/soap/ajax/41.0/connection.js")}
var taskToCreate = new sforce.SObject("Task");
taskToCreate.OwnerId = "{!$User.Id}";
taskToCreate.Division__c = "{!User.Division}";
taskToCreate.Task_Type__c = "Community Appointment from NHS";
taskToCreate.Subject = "Community Appointment from NHS";
taskToCreate.WhoId = "{!Lead.Id}";
taskToCreate.Priority = "Normal";
taskToCreate.Status = "Not Started";
result = sforce.connection.create( [ taskToCreate ] );
result[0].success == ("true"){ location.reload()};
Im just learning Javascript so I apologize for missing the obvious thing casuing me to get erros.
Thanks
Shawn
I am just trying to create a custom button that opens up a task window. Then the person fills things in and then clicks "save" and the task is created.
Here's what I have as Javascript...
{!REQUIRESCRIPT("/soap/ajax/41.0/connection.js")}
var taskToCreate = new sforce.SObject("Task");
taskToCreate.OwnerId = "{!$User.Id}";
taskToCreate.Division__c = "{!User.Division}";
taskToCreate.Task_Type__c = "Community Appointment from NHS";
taskToCreate.Subject = "Community Appointment from NHS";
taskToCreate.WhoId = "{!Lead.Id}";
taskToCreate.Priority = "Normal";
taskToCreate.Status = "Not Started";
result = sforce.connection.create( [ taskToCreate ] );
result[0].success == ("true"){ location.reload()};
Im just learning Javascript so I apologize for missing the obvious thing casuing me to get erros.
Thanks
Shawn
All Answers
create a custom button that opens up a task window
What Error you are getting?
I don't think Task has a status called "Not Started"
Can you give me a debug logs pls to check the issue .. ??
I have no idea how to "debug" the code for the button. (disadvantage of just starting to learn how to write code)
The errors are definatly related to the code behind the button.
The current error message looks like this...
I keep goign back through what I have and seeing if I can find the missing symbol like "{" but my inexperience is frustrating.
It seems so simple, all I want is a task screen to open, like it does when you click the "New Task" button on the "Activities" related list. Some of the fields will be populated for the sales people, and some will not. They fill in the blanks, and save the Task.
Should be a piece of cake but its turning into a mess.
What am I missing???
Thanks
Shawn
It now creates a Task, and thats awesome
I need the Task Window to stay open though, so the salesperson can enter in any notes and choose a due date.
Right now, the task is created and saved so there is no opportunity to add info, aside from re-opening the task and then entering in the info.
Is there a way to have the task window stay open instead of closing?
Thank you
On two of the lines, there is a "//" right before the "taskToCreate". Why is that?
Is it becasue they are custom fields?