Apex Triggers in salesforce

Apex Triggers in salesforce,sfdcpanda, sfdc panda, salesforce basics, basics of salesforce, apex triggers, salesforce examples, apex example, visualforce examples, apex visualforce, salesforce training, online training salesforce, salesforce job market

Apex Triggers in salesforce

A trigger is Apex code that executes before or after the following types of operations:

  • insert
  • update
  • delete
  • merge
  • upsert
  • undelete

Trigger Syntax:-

Trigger triggerName on object(Trigger Event handlers)

{

Business Logic

}

Types of Trigger :-

  • Before Trigger ( It will be fired before records saving into database)
  • After Trigger ( It will be fired after records saving into database but still not committed)

When to use Before-Triggers?

Before trigger events occur before a records changes are committed to the database. This particular event is ideal for performing data validation, setting default values, or performing additional logic or calculations.

Please keep in mind that in the case of before insert events, because the event is executed before the record is committed to the database it will not have a record id.

When to use After-Triggers?

After trigger events occur after a record has been committed to the database, which means that records being inserted will have a record id available.

This particular event is ideal for working with data that is external to the record itself such as referenced objects or creating records based on information from the triggered object.

Be the first to comment

Leave a Reply

Your email address will not be published.


*