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
hikiran rajuhikiran raju 

How to retrive more than 50000 records using triggers

Hi all,

can anyone let how we can retrive more than  50000 records using salesforce.

Thanks in advance,
you can opt for a batch in that case
call batch from trigger
Rajesh Varma MudunuriRajesh Varma Mudunuri

Please invoke a batch class from apex trigger and use Database.QueryLocator.

 If you use a QueryLocator object, the governor limit for the total number of records retrieved by SOQL queries is bypassed. For example, a batch Apex job for the Account object can return a QueryLocatorfor all account records (up to 50 million records) in an org. Another example is a sharing recalculation for the Contact object that returns a QueryLocator for all account records in an org.

Please refer to the below link to learn more about batch apex