System.LimitException: Too many query rows: 50001 error in t



我在Apex触发器中有soql,因为它正在获取测试对象的所有记录。SOQl正在获取超过50000条记录,所以当我更新记录时,我正面临这个总督限制错误。请告诉我如何解决这个错误。

List<test__c> ocrInformation = new List<test__c>();
Map<String,String> Opporgcode=new Map<String,String>();
ocrInformation= [select id,Team__c,Org__c from test__c];//facing an error here
for(test__c oct: ocrInformation){
    Opporgcode.put(oct.Org__c,oct.Team__c);
}

这是Salesforce的标准限制

SOQL查询检索到的记录总数= 50,000

你真的需要选择所有的test__c记录吗?在wherelimit条件的帮助下,您可能会减少检索的数据量。如果没有,您可以尝试使用Batch Apex。它允许每次批处理执行50k个限制计数。

最新更新