You need to sign in to do that
Don't have an account?
DeLi
OnClick Javascript custom button creating Tasks
On a custom object, I have created a simple javascript button which creates tasks on the click.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var t = new sforce.SObject("Task");
t.OwnerId = '{!Custome_Object.User_Id}';
t.Subject = "Task With Jscript";
...
t.What = '{!Custome_Object.Id}';
var result = sforce.connection.create([t]);
if(result[0].getBoolean("success")){
window.location = "/" + result[0].id;
}else{
alert('Could not create record '+result);
}
I can't figure out how to set the t.What (Related To) field. I get the following error:
{errors:{message:'The external foreign key reference does not reference a valid entity: What', statusCode:'INVALID_FIELD', }, id:null, success:'false', }
My searches tuned out nothing. :(
Any suggestion would be appreciated.
btw, I don't want to use the URL hack or the URLFOR function.
Thank you
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var t = new sforce.SObject("Task");
t.OwnerId = '{!Custome_Object.User_Id}';
t.Subject = "Task With Jscript";
...
t.What = '{!Custome_Object.Id}';
var result = sforce.connection.create([t]);
if(result[0].getBoolean("success")){
window.location = "/" + result[0].id;
}else{
alert('Could not create record '+result);
}
I can't figure out how to set the t.What (Related To) field. I get the following error:
{errors:{message:'The external foreign key reference does not reference a valid entity: What', statusCode:'INVALID_FIELD', }, id:null, success:'false', }
My searches tuned out nothing. :(
Any suggestion would be appreciated.
btw, I don't want to use the URL hack or the URLFOR function.
Thank you
All Answers
I tried "what_id" and didn't work, then used the "insert field" dropdown and it insterted {!Task.What}. Never thought to use WhatId.
Thank you again