123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Business >> View Article

What Is Apex Trigger In Salesforce?

Profile Picture
By Author: Chitiz Agrawal
Total Articles: 4
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

Apex is a powerful object-oriented programming language used for development within Salesforce.com. it allows developers to perform specific processes, such as executing flows, creating object relationships, executing transaction control statements on the platform of Force.com, a PaaS platform for simplified development.
Apex makes use of Java-like syntax to enable developers to add suitable business logic to specific system events like button clicks, updates of related records, and Visualforce pages.

What Is Apex Trigger?

Developers can perform specific actions within Salesforce.com with the help of Apex triggers. An Apex trigger allows you to perform customized actions before or after specific events to records within the Salesforce environment, such as making insertions, deletions, or updates. Apex provides developers with trigger support which is similar to the triggers supported by database systems.

An Apex trigger is generally used to perform activities that are based on specific conditions, for modifying related records within the database, or for restricting specific operations from taking ...
... place. Developers can use these triggers for performing all activities within Apex, including the execution of SOQL and DML operations and calling custom Apex methods.

It is advisable to use Apex triggers for performing activities that cannot be carried out using the point-and-click tools available on the Salesforce platform. Apex trigger examples will not include activities like updating a field on a record or validating a field value. You can use validation and workflow rules for carrying out these processes.

An Apex trigger is fired before or after the following major operations:
insert
delete
update
upsert
merge
undelete
Types Of Triggers

There are two different types of Apex triggers in Salesforce - before triggers and after triggers.

Before triggers are fired for updating and validating record values before they are saved to the database. On the other hand, after triggers are fired for accessing field values that are set by the system and for affecting changes in other records. The records firing the after triggers are read-only records.

Trigger Context Variables

All Apex triggers define specific variables contained in the System.Trigger class that allows developers to access run-time context.
Here are some of the major Apex trigger context variables and their functions:

Trigger.isExecuting – It returns true if the current context for the Apex code is a trigger instead of an Apex page, a web service, or an executeanonymous () API call.
Trigger.isInsert – It returns true if the trigger was fired from the Salesforce user interface, Apex, or the API for an insert operation.
Trigger.isDelete – It returns true if the trigger was fired for the purpose fo a delete operation from the Salesforce user interface, Apex, or the API.
Trigger.isUpdate – It returns true if the trigger was fired for the purpose of an update operation from the Salesforce user interface, Apex, or the API.
Trigger.isBefore – It returns true if the trigger is fired before a record was saved.
Trigger.isAfter – It returns true if the trigger is fired after all the records were saved.
Trigger.isUndelete – It returns true if the trigger was fired after a record being discovered from the recycle bin.
Trigger.new – It returns with a list of new versions of the Salesforce object records. This list is only available in insert, undelete, and update triggers and these triggers can only be modified in before triggers.

Trigger.old – It returns with a list of the old versions of the Salesforce object records. This list is available only in update and delete triggers.

The scope for using Apex triggers in Salesforce is huge. It allows developers to customize the platform according to the specific needs of the organization and leverage the use of the customer database.

Total Views: 813Word Count: 587See All articles From Author

Add Comment

Business Articles

1. Etsy Data Scraping Api — Real-time Listing, Shop & Sales Data | Real Data Api
Author: Acto96

2. Simple Guide To Takshak, Mahapadma And Vasuki Kaal Sarp Dosh
Author: Pandit Rakesh Guruji

3. Replace Spreadsheet-based Processes With Erp Supply Chain Software
Author: emathew

4. Kaal Sarp Dosh Effects On Career With Nivaran Procedure Guide
Author: Vidyanand Guruji

5. Kayali Perfume For Everyday Confidence And Style
Author: Kayali perfume

6. Difference Between 2 Bhk And 3 Bhk: Which Is Better?
Author: Dharmendra

7. How Ai Is Changing Search Engine Optimization
Author: bharathi

8. Benefits Of Professional Mosquito Control Services In Chennai
Author: Nandini

9. Comparing Bond Types Based On Risk And Return Potential
Author: Ravi Fernandes

10. How Winter Weather Causes Hidden Damage To Commercial Buildings
Author: Michael

11. Target Data Scraping Api — Real-time Product, Price & Store Inventory Data | Real Data Api
Author: Acto96

12. Cleaning Solutions For Airports, Metro Stations, And Large Facilities
Author: Steve Smith

13. Monel 400 Scrap Exporters In Mumbai
Author: Akshit shah

14. Chromium Carbide Plates Manufacturers In India
Author: Mukesh Chhajed

15. Kaal Sarp Puja In Nashik – Simple Guide, Benefits And Trimbakeshwar Puja
Author: Devansh Guruji

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: