
I Tried this Code for 'status from Active to Suspend on 1st click'
{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}
var objdeal = new sforce.SObject("Deals__c");
objdeal.Id = "{!Deals__c.Id}";
if(objdeal.Status__c = "ACTIVE")
{
objdeal.Status__c = "SUSPEND";
}
var result = sforce.connection.update([objdeal]);
if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
location.reload(true);
}
답변 7개
Sorry! I misread the question. Give this a shot:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
try{
var dealToUpdate = new sforce . SObject ("Deals__c");
dealToUpdate.Id = "{!Deals__c. Id }";
if("{!Deals__c. Status__c }" == "ACTIVE")
dealToUpdate.Status__c = "SUSPEND";
else
dealToUpdate.Status__c = "ACTIVE";
var result = sforce. connection . update ([dealToUpdate]);
if(result[0].success == "false")
alert("An Error has Occurred. Error:" + result[0].errors.message);
else
location. reload ( true );
}
catch(e){
alert("An Error has Occurred: Error: " + e);
}