I have a few custom buttons that we place on our page layouts that are Javascript buttons. These update a few fields on the record. I successfully created some but I am having an issue with the last one not updating records. Any ideas what I could be doing wrong on the button that isn't working? By not working, I mean the records aren't getting updated. I ruled out a workflow stopping it because I essentially created the exact same code in Apex and had it execute anonymously in order to get the same effect and it was successful.
Not working button:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
if (('{!Fee_Adjustment__c.Supervisor_Comments__c}' === '' || '{!Fee_Adjustment__c.Supervisor_Comments__c}' === 'null') && ('{!Fee_Adjustment__c.Reviewer_Notes__c}' === '' || '{!Fee_Adjustment__c.Reviewer_Notes__c}' === 'null'))
{
alert('Reviewer or Manager notes required.');
} else
{
//identify the record
var adjustment = new sforce.SObject("Fee_Adjustment__c");
adjustment.Id = "{!Fee_Adjustment__c.Id}";
//make the field change
adjustment.OwnerId = "{!Fee_Adjustment__c.Originator__c}";
adjustment.Status__c = 'Pending';
adjustment.Status_Detail__c = 'Originator';
//save the change
sforce.connection.update([adjustment]);
//refresh the page
window.location.reload();
}
Working button:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var assessed = parseFloat('{!Fee_Adjustment__c.Total_Fees_Assessed__c}'.replace('$', ''));
var desired = parseFloat('{!Fee_Adjustment__c.Total_Fees_Desired__c}'.replace('$', ''));
if (assessed == 0 || assessed == desired)
{
alert('Fees must be entered in Detail before submitting adjustment request');
} else
{
// identify the record
var adjustment = new sforce.SObject("Fee_Adjustment__c");
adjustment.Id = "{!Fee_Adjustment__c.Id}";
// make the field change
adjustment.OwnerId = "{!Fee_Adjustment__c.SupervisorId__c}";
adjustment.Status__c = 'Pending';
adjustment.Status_Detail__c = 'Supervisor';
// save the change
sforce.connection.update([adjustment]);
//refresh the page
window.location.reload();
}