Sure you can. You'll need to follow a few simple steps, though:
1. Mark you class as global 2. Mark the method that you want to use with webservice and static keywords 3. In javascript use the function sforce.apex.execute('Your_class_name' , 'your_method_name', {arg1: <<ar1_value>>, arg2: <<arg2_value>>});
Here is an example:
Code:
global class MyWSClass{
webService static string foo(Integer arg1, String arg2){ //your logic here return 'Hello World'; }
}
Have you set a developer namespace for your login? (to use managed packaging for example). If so that'll affect the fully qualified name of the class that you need to specify in the javascript. (myNamespace.myClass instead of myClass)
1. Mark you class as global
2. Mark the method that you want to use with webservice and static keywords
3. In javascript use the function sforce.apex.execute('Your_class_name' ,
'your_method_name', {arg1: <<ar1_value>>, arg2: <<arg2_value>>});
Here is an example:
Thanks Shamil
I tried that but I get
sforce.apex has no properties
Message Edited by MDXHiker on 11-13-2008 03:31 PM
1. you have created apex class called MyWSClass with the code from my previous post
2. in javascript you included
Setup -> Develop -> Apex Classes -> click 'WSDL' link next to your class name.
It would be very helpful if you could post your code here.