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
Sean TisdaleSean Tisdale 

JavaScript Button generates no errors

I am not a JS developer so I'm struggling to get my head around this.  

I am bulding a JS OnClick button that updates the Owner field in a custom object to a queue.  

Here's the code:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

var SupportRequestObj = new sforce.SObject("SupportRequest__c"); 
SupportRequestObj.Id = '{!SupportRequest__c.Name}'; 
SupportRequestObj.OwnerId = '00G50000001dv2s'; 
var result = sforce.connection.update([SupportRequestObj]); 
window.location.href=window.location.href;

The custom object's API name is SupportRequest__c and the Object Name is SupportRequest.

The Syntax comes back clean but when the button is clicked there's nothing. No error. No update to the owner field.  

What am I doing wrong?
Apoorv Saxena 4Apoorv Saxena 4
Hi Sean,

Update your button code to the code provided below:
 
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

var SupportRequestObj = new sforce.SObject("SupportRequest__c"); 
SupportRequestObj.Id = '{!SupportRequest__c.Id}'; 
SupportRequestObj.OwnerId = '00G50000001dv2s'; 
var result = sforce.connection.update([SupportRequestObj]); 
window.location.href=window.location.href;

Please mark this question as Solved if this works for you.

Thanks,
Apoorv