+ Start a Discussion
khillan bhardwajkhillan bhardwaj 

Dynamically calling static method of apex class

Hi, 

I want to call static method dynamically.class or static method present in org should not checked when code is save .It should check at runtime.
we can check whether class present of not  dynamicallylike below:

 Type t = Type.forName('classname');

But I have not found way to execute staic method at run time.

If someone have idea please let me know.Help is really appreciated.

Thanks
Khillan 
Best Answer chosen by khillan bhardwaj
khillan bhardwajkhillan bhardwaj
I have done it by running anonimous code from apex class using metadata APi or tooling Api

All Answers

Pavan AnnaldasPavan Annaldas
Hi Khilan,

Hope this helps,
https://developer.salesforce.com/page/Apex_Design_Patterns#Strategy

Regards,
Pavan
khillan bhardwajkhillan bhardwaj
Hi Pavan,

Thanks you for replying,
My requirement is as below:

i have create new package x .In the class of this package x, i have called static method of class in other pachage y.when i adding class then class from manage package y is automethically added in the my package.
When i insalled it in new org then it say "Require package is missing""package y version XXX must be installed first".

Now what i need to remove class referance that i have call from our code.it shoud be checked at run time.

Thanks
khillan bhardwajkhillan bhardwaj
I have done it by running anonimous code from apex class using metadata APi or tooling Api
This was selected as the best answer