+ Start a Discussion
lopezclopezc 

Problem with Onclick JavaScript 'No operation available for request...'

Hi,

 

Please help!

I’ve created a veeeeery simple APEX class:

 

 

public class test { public boolean testMethod(){ return true; } }

 


 

The testMethod needs to be called when I press a button (custom button) with JavaScript Behaviour:

 

{!requireScript("/js/functions.js")}
{!requireScript("/soap/ajax/13.0/connection.js")}
{!requireScript("/soap/ajax/13.0/apex.js")}
var answer = confirm("Are you sure you want get Open Positions for this epic?")
if (answer){
alert(sforce.apex.execute("test","test", {}));
} else {}

 

But I have got the following error:

 

 

No operation available for request

{http://soap.sforce.com/schemas/class/test}testMethod.

 

 


 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
if your namespace is bob, then you'd specify bob.test as the class name instead of just test when you call execute

All Answers

SuperfellSuperfell
If you're in a DE org with a namespace set, you need to include the namespace in the classname part of the execute call.
lopezclopezc
Sorry, could you specify a little more.. I don't understand what I have to do..
SuperfellSuperfell
if your namespace is bob, then you'd specify bob.test as the class name instead of just test when you call execute
This was selected as the best answer
lopezclopezc
But I don't know what is my namespace or if I have got one at all.. What is that namespace thing?
cheenathcheenath

setup->create-apps

 

select your custom managed app.

 

This will display the "Namespace Prefix".

 

 

micwamicwa

The problem is that your method is called "testMethod" but you're calling method "test". Try this:

alert(sforce.apex.execute("test","testMethod", {}));

 

 
lopezclopezc

yes sorry, I am using testMethod, it was an error I committed when I posted the code here.

 

I went to Setup --> Create-Apps to see the details of my app and it doesn't have a "Namespace Prefix" label.

 

I am wondering if there might be something wrong with the import of my libraries? Could it be that the version of the libraries is not the correct one? But which one should I be using?

 

Thanks for you help

 

Message Edited by lopezc on 08-05-2009 01:40 AM
ankitjainankitjain

Please check the access modifier for the class and method.

It should be something like this:

 

global class test {
Webservice static boolean testMethod(){
return true;
}
}

Note that you are not creating any instance of the class, so the method should be static.

doug@kosmojo.comdoug@kosmojo.com

How do I know what my name space is?