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
Patrick ConnerPatrick Conner 

Redirect to "Related To:" link from custom "Completed" button on task

I've created a custom button on tasks which will complete the task. However I'd like it to then redirect to the related to: value (usually account page or custom object page).

var TskObj = new sforce.SObject("Task");
TskObj.Id = '{!Task.Id}';
TskObj.Status = 'completed';
var result = sforce.connection.update([TskObj]);

Code snippet pasting was causing troubles posting for me so I've pasted in txt above. I've attempted to use window.location.href to load a task.WhatId variable addended to my instances URL unsuccessfully. Any ideas how to pull this off without using triggers? I'm sure it's a simple solution. Thank you.
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri

window.location.href = '/';

Not sure what you are asking about