Activity Forums Salesforce® Discussions Where to use before update and after update in Salesforce?

  • Saurabh

    Member
    May 15, 2017 at 7:23 am

    Hi Suraj

    You can find the info on this Apex documentation.

    For Before update

    Triggerevent -Event Can change fields usingtrigger.new

    Allowed.

    Triggerevent- Can update original object using an update DML operation

    Not allowed. A runtime error is thrown.

    Triggerevent-Can delete original object using a delete DML operation

    Not allowed. A runtime error is thrown.

    For After Update

    Triggerevent -Event Can change fields usingtrigger.new

    Not allowed. A runtime error is thrown, astrigger.new is already saved.

    Triggerevent- Can update original object using an update DML operation

    Allowed. Even though a bad script could cause an infinite recursion doing this incorrectly, the error would be found by the governor limits.

    Triggerevent-Can delete original object using a delete DML operation

    Allowed. The updates are saved before the object is deleted, so if the object is undeleted, the updatesbecome visible.

    Hope it may help you

     

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos