SAVE UP to ₹4999/- OFF On All Salesforce Courses Claim Offer

9

Trigger.new in Salesforce| Context Variables in Apex Triggers

Trigger.new in Salesforce returns a list of the new version of sObject records, and is available in insert, update, and undelete triggers.

Trigger.new in Salesforce Example:

trigger AccountTrigger on Account (before insert) {
    for (Account acc: Trigger.new) {
        acc.NumberOfEmployees = 100;
    }
}

In this example, Trigger.new allows us to modify the NumberOfEmployees field before the record is inserted into the database.

trigger ApexTrigger on Account(before insert) {
    for (Account acc: Trigger.new) {
        acc.NumberOfEmployees = 100;
    }
}
LWC Training
Next Topic

Need more support?

Get a head start with our FREE study notes!

Learn more and get all the answers you need at zero cost. Improve your skills using our detailed notes prepared by industry experts to help you excel.

-9++

Book A 15-Minutes Free Career Counselling Today!