function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ahmed MediouniAhmed Mediouni 

apex trigger for variable sobject

Hello Community,
I was working on an apex trigger for the account object and opportunity object but there are other objects left for me to create an apex trigger on them, is there any way I can make one single apex trigger that works on all objects?

thanks
Best Answer chosen by Ahmed Mediouni
SwethaSwetha (Salesforce Developers) 
HI Ahmed,
>I understand your requirement but you have to create Triggers for each Object, you cannot create just one Trigger for multiple objects. Salesforce only supports “One Trigger per Object” design pattern as a best practice(See https://www.sfdc99.com/2015/01/19/the-one-trigger-per-object-design-pattern/)
 
>Salesforce permits you to can create a Trigger Handler which each Trigger would invoke and use Dynamic Apex / SObjects to perform generic logic at run-Time.
 
Also, see https://developer.salesforce.com/forums/?id=906F0000000DBl8IAG

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you