[SalesForce] Custom Button Javascript….Webservice is not called

Return value from Apex method to Javascript in Salesforce using a custom button.For that i have controller :

global class web
{
    Webservice static String fetch(Id localId)
    {
        return localId;
    }
}

And Custom Button Javascript:

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

var r = confirm("Are you sure want to fetch?");

if(r == true)
{
    var a = sforce.apex.execute("web","fetch",{ID:"{!Account.Id}"});
    alert(a);
}
else
{
    alert('Operation aborted');
}

When i clicked on custom Button one alert box appeared "Are you sure want to fetch?" that's ok after that second alert box give me the Error.Error is

A problem with the OnClick JavaScript for this button or link was encountered:

{faultcode:'soapenv:Client', faultstring:'No operation available for request {http://soap.sforce.com/schemas/package/web}fetch, please check the WSDL for the service.', }

So what can i do to solved the above problem…Please help me….

Snapshot of the Problem….

image

Best Answer

Do you have a namespace for your org you are working in? Say, if the namespace of the org is "abc", try the following code:

var a = sforce.apex.execute('abc.web', 'fetch', {localId:'{!Account.Id}'});

Related Topic