Is it possible to call remote action in javascript button without using visual force page.

i have tried using

sforce.apex.execute("mycontroller","method",{parameters} ); 

But of no use.can any one suggest solution

  • What error do you get. Do the methods have to be marked as webservice. I do not remember
    – Eric
    Commented May 18, 2016 at 6:56
  • sforce.apex.execute() method call webservice method. This method is part of Global class. Parameter part is optional, you only write it if your method receive parameters. See my comment below. Commented May 18, 2016 at 7:40

3 Answers 3


you will have to write a webservice method in a global class.

In you javascript button write following

    // call apex webservice method
    sforce.apex.execute("ClassName", "MethodName", {MethodParam:'value'});

Refer Davin Casey's answer in this thread

You need to include js files also in your script to make it work and as Sneha has answered you have to declare the class as webservice.

For eg.


var retStr; 
retStr = sforce.apex.execute("ApexClassName", "MyWebServiceMethodName", {Id:'{!Account.Id}'}); 

alert('The method returned: ' + retStr); 

document.location = '/{!Account.Id}'; 

You will call webservice method from Javascript but for this you need to make a class Global. You can use below code if you want to achieve this: global class GlobalClass { webservice static void WebMethod() { // Do something } } You need to include below code in VF page: {!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}

Now on js button click, call one js method and inside the method use below code: sforce.apex.execute("GlobalClass","WebMethod",{}"}); Hope it helps you. But as mentioned earlier, you need to make class Global for it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .