You need to sign in to do that
Don't have an account?
Monin Savant
Assign Type dynamically and passing it to a method
I want to create a class object knowing only its name. This object belongs to Batch, but I don't know which one. So i have to run it by name only. i get error when i pass sObject to executeBatch.
Thanks in advance.
@AuraEnabled public static void run(String batchName){ sObject newObject = (sObject)Type.forName(batchName).newInstance(); Database.executeBatch(newObject); }How to bypass it.
Thanks in advance.
The key is to use the right Type cast which is Database.Batchable<sObject>
You can use the code like this:
Thanks
Gulshan Raj (https://forceblazer.com/)