You need to sign in to do that
Don't have an account?

before insert and before update
what is the best real time scnerio for before insert and before update for interview purpose ?
can u say ?
thank u .
You need to sign in to do that
Don't have an account?
what is the best real time scnerio for before insert and before update for interview purpose ?
can u say ?
thank u .
if we want to assign a field to a specific value in a record before we write the data to the database we can use before insert
in a trigger ,
if we wanto to update the field a specific value before updating the record we can user before update in the trigger
Thumb rule :
Before triggers are used if you are performing the update/insert on the object you are writing the trigger(in this case you do not need to use the update/insert keywords explicitly). If you are doing the update/insert on a related object use after trigger.
Also if you need to say validate the data or do some data checks use before triggers nad for operations eg send an email you can use after triggers.
Mark this as solution if helps and hit kudos
Cheers!
Before insert: fires trigger before the record is inserted (for the first time, fires only once for one record)
before update: fires trigger before record is updated(every time the record is updated, the trigger will fire)