Salesforce Interview Questions & Answers Book is now available!

Grab Now

Interview questions

What's the content of Trigger.new?

Let's look at one of the frequently asked interview questions - What's the content of Trigger.new?

By Teja, ex-Salesforce engineer · Updated March 28, 2021 · 1 min read

Am sure you would have heard about this question in your interviews. Let's a bit more about it in this post.

In triggers, we have a few context variables like Trigger.new, Trigger.old Trigger.newMap, Trigger.oldMap and etc.

The content of Trigger.new and Trigger.old is going to be List and the content of Trigger.newMap and Trigger.oldMap is going to be a map (as in the same you will be presented the same content but in a different representation).

In fact, we can also use Trigger.new as shown below and it's going to work absolutely fine.

trigger AccountTrigger on Account(before update){

	List[Account] accounts = [Select Id, Name FROM Account WEHRE Id IN: Trigger.new]

}

Trigger.new used in SOQL query

Hope this was helpful!

Learn it by building it

Every course, every code repository, the discussion group and certificates of completion — one subscription.

Keep me in the loop!

Email me when a new episode is published (promise, I will not spam you)

You're signing up to receive emails from Salesforce Casts