+ Start a Discussion
Prema -Prema - 

How to fetch all method names of any particular class Please help

Mohammed MohiddinMohammed Mohiddin
Hello Prerna,
    Go to your Developer Console and open your class. Inside your class write your class name followed by a dot and then press ctrl+space. You will get all the methods and variables associated with it.

If this helped you, mark it as solved :)

 
Bhargavi TunuguntlaBhargavi Tunuguntla
Hi prema,

You can get all the methods of a Class using 'ApexClass' object .
In Workbench - REST Explorer:

/services/data/v36.0/tooling/query/?q=Select+Id,Name,SymbolTable+From+ApexClass+where+Id='apexclassid'

You would then need to parse the SymbolTable out of the REST Response. 

User-added image
When you expand symbol and then expand Methods in it.You find all the methods of the apex class.

Hope this will be useful.
Prema -Prema -
Thanks for the reply but my requirement is I want a picklist value where all the selected class's method will be there and when I click on any method it should get executed. But m not able to fetch the method name inside the picklist because I don't know how to get all the methods of a class in any list. What is that object called.
Prema -Prema -
How to get only the methods inside a list according to your concept.pls help
Mohammed MohiddinMohammed Mohiddin
I am not sure if this is the best solution but you can do one thing. In your visualforce page store the picklist value(which has all the method name)  in a variable and declare it in your class as get; set; Then add one method that will use if-else conditions and execute the required method.

Example:
 
//Controller

public class test{

public string picklistValue {get;set;}

public void MainMethod()
{
   If(picklistValue == 'method1')
       method1();
   else If(picklistValue == 'method2')
       method2();
  else
       method3();
}

public void method1(){}

public void method2(){}

public void method3(){}

}

Hope this helps :)
Prema -Prema -
Thanks for the resolution @
Mohammed Mohiddin but it won't work because I need it dynamically not hard coded. Otherwise it would be really difficult to hardcode the method name for every class thoroughout the organization
Prema -Prema -
@Bhargavi Tunuguntla , Could you please let me know how can I get the method table inside my apex class please?