Saturday, September 12, 2015

how to call apex call from custom button to pass the values from custome button

Custom Button code:

  {!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}

var meetingID = '{!nnr__c.Id}';
var agree = confirm("Are you sure you want to proceed ");
if(agree){
   

    var result = sforce.apex.execute("YourClassName ","Methodname",{meetingID: meetingID});
   
    alert(result);
   
    }

=======================
Apex Class code

*************************
global class YourClassName
{
webservice static OppResult Methodname(ID meetingID) // you can pass parameters
    {
        OppResult res = new OppResult();

            
         
           res.errorMsg = 'oh no something broke';

            res.oppId = '01pW00000000000';

            

            system.debug(res);

            return res;
    }
    global class OppResult{

           webservice String errorMsg;

           webservice Id oppId;

       }
   
}

No comments:

Post a Comment