Apex Trigger Basic

instagram | bugendaitech  Twitter | bugendaitech  Linkedin | bugendaitech

Apex Trigger is a stored procedure or 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 chain of events

When we use Trigger:

1.We basically use triggers to do operations that cannot be done by point and click tools provided in salesforce.

2.Using Trigger We can do things that we can do through Apex, along with executing SOQL and DML or calling custom methods.

3.Triggers can be created for both standard and custom objects.

4.Triggers are active by default when created and salesforce automatically fires active triggers when a specified database event occurs.

Trigger Syntax:

Trigger Syntax

Types of Apex Triggers:

  • Before Trigger
  • After Trigger

When to use Before Trigger:

1.Wanted to update the same record before saving into the database and saving the DML.

2.when you have to perform some complicated validation and can not be achieved by validation rule.

When to use After Trigger:

1.When there is a need to read the System generated Fields like CreatedById, Record Id, Created Date, etc.

2.When you wanted to make some callouts on the same records which are being inserted into the salesforce database.

Triggers flow before and after

In the salesforce automation, Trigger is one of the most important tools which help us to automate the business processes.If you want to explore more about Trigger then explore this link-Trigger.

Article Name
Apex Trigger Basic
What is an Apex trigger? When can you use it,its type and its syntax, know all of it here. Implement it through Salesforce professional services into your business.
Publisher Name
BugendaiTech Pvt Ltd
Publisher Logo
Spread the updates
April 29, 2021

Leave a reply