function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jake JeonJake Jeon 

Examples of Trigger.New.size() > 1

Hi all,

I’m a middle of make some trigger classes and found that trigger.new return list of sobject
What kind of situation would return size 2?
it would be much appreciated if someone give any examples of that

Thanks!
Best Answer chosen by Jake Jeon
SecondID PatelSecondID Patel
Hi Jake,
When someone tries to update the number of records using inline editing then the number of records involved in the update operation becomes the size of Trigger.New.Size()...So in the same way when someone tries to update the two records using inline editing then the Trigger.New.Size() becomes 2.

Thanks 
Beenal

All Answers

SecondID PatelSecondID Patel
Hi Jake,
When someone tries to update the number of records using inline editing then the number of records involved in the update operation becomes the size of Trigger.New.Size()...So in the same way when someone tries to update the two records using inline editing then the Trigger.New.Size() becomes 2.

Thanks 
Beenal
This was selected as the best answer
Naren9Naren9
Hi Jake,
Trigger.New is a List Collection Type. On List Collection we can do a Size method.
When you do a Insert or Update one record at a time, then the size will be 1. But when you try to do a Bulk update or bulk Import, the Trigger.Size will be >1. Normally when you write a Trigger will consider the both scenarios like Single record Updates/Insert or Multiple records Updates/Insert.
I hope this will help.

Thanks,
Narendar
Ashish BurnwalAshish Burnwal
Hi Jake, Narendra's explanation is enough to understand it. You can refer https://www.youtube.com/watch?v=EaWPI0LCQDM this video to know more about inline editing.