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

Create a button to update fields on Custom Object

Good afternoon,

I'm looking to create a button on a custom object that updates the owner and status of the record on the object (Sales_Order__c).  So on button click, the owner changes to a specific queue, and the status updates to "Sales Order Submitted".  What i have below so far:


var sor = new sforce.SObject("Sales_Order__c");

sor.Id = '{!Sales_Order__c.Id}';
sor.OwnerId = '00Ge0000000XKF0';
sor.Status__c = "Sales Order Submitted";
var result = sforce.connection.update([sor]);

but when i click the button, nothing happens.  Can someone take a look and let me know where i went wrong (no error message, screen just refreshes but changes aren't made).
Varun VatsaVarun Vatsa
Please try to use browser's logger to find any error messages, this seems related to JS and I feel it must be because of Double Quotes used on line sor.Status__c = "Sales Order Submitted";
Change your code from

sor.Status__c = "Sales Order Submitted";


sor.Status__c = 'Sales Order Submitted';
thanks for your help Varun and Vinit, looks like it was the Ownerid line, i removed it (and had that piece operate through a workflow) and the button works now. Appreciate your feedback.