When to use triggers in Salesforce

Triggers are used to perform immediate actions based on previous action.

Example: field update.

     A trigger is Apex code that executes before or after specific Data Manipulation Language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted.


trigger triggerName on ObjectName (trigger_events)

where trigger_events can be a comma-separated list of one or more of the following events:
  1. before insert
  2. before update
  3. before delete
  4. after insert
  5. after update
  6. after delete
  7. after undelete

No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit