You need to sign in to do that
Don't have an account?
Vinu Varghese
How to pass Object Name as a parameter to a Class
I wanted to create a trigger which pass trigger.new to class where it perform some validation. But my poblem here is I wanted to use the same Class for other objects's trigger too. example I have an Account trigger which pass trigger new to a class called Validation Class with the following :
Public class validationClass {
Public static void validation(List<Account> triggerList){ }
I would like to use the same class for Contact Object too. i.e.
Public static void validation(List<Contact> triggerList){ }
Is there any way I can pass Object Name as variable?
Public class validationClass {
Public static void validation(List<Account> triggerList){ }
I would like to use the same class for Contact Object too. i.e.
Public static void validation(List<Contact> triggerList){ }
Is there any way I can pass Object Name as variable?
https://salesforce.stackexchange.com/questions/64988/apex-cast-sobject-list-dynamically-to-a-specific-sobject-type
The above link has a similar use case that you can try checking, can you try checking this once?
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
you can try like following. you can set sobject instead of Account,Contact object.
for Example ==> instead of list<Account> you can try list<sobject>.
sobject store all type of object's records like all custom or standard object's records.
let me know if it's helps you and close your query by marking as solved.
Thank you