0

I have created a button, using the custom button form, that is supposed to run a certain method, but instead I get the following error:

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/AAAParser}parserMethod, please check the WSDL for the service.', }".

So far no luck with finding other solutions to similar errors.

Any idea what this means??Thanks!

Attaching the OnClick JavaScript:

{!REQUIRESCRIPT("/soap/ajax/36.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/36.0/apex.js")} 
var nxh = '{obj__c.nxh__c}'; 
var obj = '{obj__c.Id}'; 
var str; 
if (nxh == null || nct == '') { 
alert('You can\’t Get Data if the nxh # is empty'); 
}else { 
str = sforce.apex.execute("AAAParser","parserMethod",{"obj":obj,"NXH":nxh}); 
alert(str); 
window.location.reload(); 
}
4

To answer your primary question, your Apex code is incorrect (and not included here). Make sure that the class is global, and the method is a webservice method:

global class AAAParser {
    webservice static String parserMethod(Id obj, String NXH) {
        return 'Some String';
    }
}

Note that webservice methods are cAsE-sEnSiTiVe. If your class name is wrong, or your function name is wrong, or the parameters are wrong, you'll get errors like the one you're describing. Also, make sure that profile you're using has access to the class by checking the profile permissions.

As an aside, I'm assuming that {obj__c.id} is supposed to me a merge field? You should be using JSENCODE, and you must include an "!" at the beginning of the merge field:

var nhx = "{!JSENCODE(Obj__c.NHX__c)}";

Without the exclamation mark, you've just got literal strings in there.

Also, in JavaScript, you don't need to check null and empty string. You can just do this:

if(!nhx) {

Finally, your JavaScript object notation doesn't need quotes. You can write your third parameter like this:

{ obj: obj, NHX: nhx }
  • Thanks a lot for the elaborated answer sfdcfox, but unfortunately it didn't help. I tried everything that you said and it wasn't one of those syntax errors (actually I just copied it incorrectly to here). It seems that the problem is that it just doesn't find the method in the class. Don't understand why. Any other ideas? – Yotam Jul 25 '16 at 8:20
0

I found the problem. The namespace was missing.

This is the original:

str = sforce.apex.execute("AAAParser","parserMethod",{"obj":obj,"NXH":nxh}); 

The fix is:

str = sforce.apex.execute("namespace.AAAParser","parserMethod",{"obj":obj,"NXH":nxh}); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.