You need to sign in to do that
Don't have an account?
choppen5
Apex class vs Trigger
I have a requirement to create a new custom child object for Opportunities. Looks like I can create an APEX class to to do that and call it with a trigger on Opportunity... or just include in the trigger the code to create the new object.
Is there a compelling reason to do it via apex class, or trigger would be the best?
Best Answer chosen by Admin (Salesforce Developers)
Harmpie
In general, APEX classes should contain re-usable code. So if this piece of logic is used in other situations as well, put it in a class. If not, you can add it to the trigger. Sometimes you may prefer adding non-re-used code to classes as well, purely to keep a trigger clean, in case of a lot of code (triggers are also limited to 500 lines).