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

setting Related To object in javascript in button to open new task

I have a custom button on my activity related list of a custom object named member. I'm converting it from using the URL hack method to the javascript method. That button executes the following javascript when clicked:


var taskObj = new sforce.SObject("Task");
taskObj.Subject ='Received DNE call';
tskObject.tsk3 = 'Member'

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

if (result[0].success=='false') {
} else {
var newURL = '/' + result[0].id + '/e';,"_self");

Without the line
tskObject.tsk3 = 'Member'
in the code, this works great. However, I need to set the Related To object to my custom object Member, otherwise it defaults to Opportunity. Using the URL hacking method to open a new task, I can pass the object reference via the tsk3_mlktp=a07 (with a07 being the ID of my custom Member object), but that doesn't work in the javascript method. 

I've tried the following lines of code, all of which give me an error of tskObject is not defined
tskObject.What = 'Member'
tskObject.What = 'a07'
tskObject.tsk3_mlktp = 'Member'
tskObject.tsk3_mlktp = 'a07'
tskObject.tsk3 = 'Member'
tskObject.tsk3 = 'a07'

Any ideas out there on how to pass the object ID/name to get the Related To drop-down to default to the correct object?
Best Answer chosen by megmooPDX
I have found that using Publisher Actions is a better solution than URL hacking or a javaScript button. Publisher Actions have their limits (see my Idea ( on the Idea Exchange for an enhancment), but so far, they're much better.