3 个回答
Hi Shalini,As per the best practices if we want to update on the same record we need to use Before events only.If we use after update here DML events count will happen.so governor limits will be reduced.lead ld = new lead(id = l.id,rating = 'cold');here we are adding again leadid and again we are updating samereocrd.This is not best a best practices. Trigger events best practices : Use Before Trigger:In the case of validation check in the same object.Insert or update the same object.Use After Trigger:Insert/Update related object, not the same object.Notification email.We cannot use After trigger if we want to update a record because it causes read only error. This is because, after inserting or updating, we cannot update a record.So in the above triggers, you need to use before update only.Hope it helps you.ThanksVaraprasad