Activity Forums Salesforce® Discussions What are the best practices of using insert option in Salesforce trigger?

  • Mohit

    Member
    September 29, 2016 at 5:58 am

    Hi Pranav,

    The Best Practices of using insert option in trigger are

    Before Insert:-

    1) We can use this during change fields using trigger.new

    2)You cannot update or delete original object using an update or delete DML operation because the original object has not been created; nothing can reference it, so nothing can update it.

    After Insert:-

    1) We cannot use  change fields using trigger.new because  a runtime error is thrown, as trigger.new is already saved.

    2)We can use after insert during update or delete original object using an update or delete DML operation. But in case of delete it is not necessary to use because the object is deleted immediately after being inserted.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos