Skip to main content
Vivekh R が「#Data Management」で質問
I need to change the status from Active to Suspend on 1st click and then Suspend to Active on Second Click. whether this Logic is possible in a Single button.

 

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 件の回答
  1. 2014年1月13日 12:59

    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);

     

    }
0/9000