Error:
You may get a following error, when you call an apex method from custom button.
{faultcode:'soapenv:Client', faultstring:'No service
available for class ‘MetaDataSOQLController’ }
Class:
- global class MetaDataSOQLController{
- webService static string getName(){
- return ‘Hi….!’;
- }
- }
Button:
- {!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
- {!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")}
- var res = sforce.apex.execute("MetaDataSOQLController","getName",{ });
- alert(res);
Solution:
Referred class in a button is a Managed
Package Class or your organization is enabled a namespace prefix.
To know to namespace prefix of the class. Go to Apex Classes,
in the list view you can find the Namespace Prefix near by class name.
Copy the namespace prefix and change the sforce.apex.execute
line as follows,
In my case, I have enabled a namespace prefix and consider my org namespace is “sfkings”
Syntax:
sforce.apex.execute("NameSpacePrefix/ClassName","MethodName",
“{Parameter 1, Parameter 2}”);
var res = sforce.apex.execute("sfkings/MetaDataSOQLController","getName",{
});
No comments:
Post a Comment