Is there any way I can call apex method from class if both class name and method are stored in the string.
String strClass = 'BatchUtil';
String strMethod = 'updateAccounts'
now I want to call above method.. is it possible ?
I was doing research and came across following – (not sure how this works and how to call it from salesforce)
ExecuteAnonymousResult[] = binding.executeanonymous(string apexcode);
http://www.salesforce.com/us/developer/docs/apexcode/Content/sforce_api_calls_executeanonymous.htm
Best Answer
With the Callable interface that was introduced in Winter '19 you can now build a light weight interface for the methods you want to dynamically call from a class.
The example below is from the docs (tweaked to show dynamic method naming):
Example class you want to dynamically call
Unit test demonstrating the dynamic calling