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.
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.
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(){}
}
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
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 :)
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.
When you expand symbol and then expand Methods in it.You find all the methods of the apex class.
Hope this will be useful.
Example:
Hope this helps :)
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
If yes can you please let me know how you did this?
If yes please let me know ?