Activity Forums Salesforce® Discussions In Salesforce,How to pass the context variables in handler in triggers ?

  • MOHIT

    Member
    February 20, 2020 at 2:25 pm

    It is always a best practice to write a single trigger on object and process all operation in apex class (we called it as handler) instead of
    writing logic in trigger. In handler you can specify the order of event based on different context variables. If you write many triggers in on object,
    then you cannot control the order in which triggers gets executed.

    For best practice, use below suggestion:

    1. Pass all trigger context variables to static method (say "OperationManager")in handler class.
    2. Create different static methods for different operations which you need to perform.
    3. Control the order of different operation in "OperationManager" static method based on context variables.
    4. Also you can create different apex classes and call them from "OperationManager" static method.

  • Ratnesh

    Member
    February 24, 2020 at 5:38 am

    Fundamentally, to contrast old field estimation of record and the new incentive in trigger we have to get to trigger.oldmap and trigger.newmap. Salesforce gives trigger.oldmap wherein all the old records are put away in map with keyset as their id's. We can contrast the old qualities and new qualities as in the beneath model. Let's see how we can actualize such information approval by getting old incentives in triggers.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos