I built a custom button that should run some JavaScript to update a field value if certain conditions are met. However, when I test the button, the else clause always runs.
Any help on what is wrong with the javascript would be much appreciated:
{
!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")
}
var agmt = new sforce.SObject("Apttus__APTS_Agreement__c");
agmt.Id = '{!Apttus__APTS_Agreement__c.Id}';
if ('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Internal Review') {
agmt.Apttus__Status__c = 'Other Party Review';
result = sforce.connection.update([agmt]);
window.location.reload();
} else if ('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Other Party Review') {
alert('This agreement has already been sent for review');
} else if ('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Activated' || '{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Fully Signed') {
alert('This agreement is fully signed');
} else {
alert('This agreement must first be sent for legal review');
}
{!Apttus__APTS_Agreement__c.Apttus__Status__c}
is evaluated asInternal Review
? Check in JS console.