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
Arash TeimoupoorArash Teimoupoor 

too many querry rows:50001

II'm getting this error when my trigger calls the following @future class:

Public class projectSettingsChartClass{
    @future
    public Static void ProjectMethods(List<id> PSList){
        Set<id> ProjectIds = new Set<id>();
        for(id PS : PSList){
            ProjectIds.add(PS);   
        }
        
        List<Project_Setting__c> PList = [select id,Name,Parent_Project_Name__c,Covering_Account_Manager__c,Healthplan_Contact__c,PR_Number__c,Line_Of_Business__c,ChartSecure_Account_Manager__r.Name,Requestor__c,Covering_Account_Manager__r.Name,Project_End_Date__c,Project_Start_Date__c,Extended_Project_End_Date__c,Project_Closed__c,Date_Project_Closed__c,Copy_Cost__c,Onsite_Threshold__c,Reporting_Active__c from Project_Setting__c where id In : ProjectIds];
        
        List<charts__c> ChartList = [select id,Project_Name__c,Parent_Project_Name__c,Healthplan_Contact__c,Client_Number__c,Line_of_Business__c,
                                 Healthplan_Account_Manager__c,Healthplan_Requestor__c,Covering_Account_Manager__c,Project_End_Date__c,
                                 Project_Start_Date__c,Extended_Project_End_Date__c,Project_Closed__c,Date_Project_Closed__c,Copy_Cost__c,Onsite_Threshold__c,
                                 Reporting_Active__c from charts__c where Project_Name__c In : ProjectIds];
    
        List<charts__c> UpdateChartList = new List<charts__c>();
    
        for(Project_Setting__c Ps : PList){
            for(charts__c ch : ChartList){        
                if(ch.Project_Name__c == Ps.id){
                    ch.Parent_Project_Name__c = Ps.Parent_Project_Name__c;
                    Ch.Healthplan_Contact__c = Ps.Healthplan_Contact__c;
                    Ch.Client_Number__c = Ps.PR_Number__c;
                    Ch.Line_of_Business__c = Ps.Line_Of_Business__c;
                    Ch.Healthplan_Account_Manager__c = Ps.ChartSecure_Account_Manager__r.Name;
                    Ch.Healthplan_Requestor__c = Ps.Requestor__c;
                    Ch.Covering_Account_Manager__c = Ps.Covering_Account_Manager__c;
                    Ch.Project_End_Date__c = Ps.Project_End_Date__c;
                    Ch.Project_Start_Date__c = Ps.Project_Start_Date__c;
                    Ch.Extended_Project_End_Date__c = Ps.Extended_Project_End_Date__c;
                    Ch.Project_Closed__c = Ps.Project_Closed__c;
                    Ch.Date_Project_Closed__c= Ps.Date_Project_Closed__c;
                    Ch.Copy_Cost__c = Ps.Copy_Cost__c;
                    Ch.Onsite_Threshold__c = Ps.Onsite_Threshold__c;
                    Ch.Reporting_Active__c = Ps.Reporting_Active__c;
                    UpdateChartList.Add(ch);   
                }
            }    
        }
        if(UpdateChartList.size() > 0 ){
            Update UpdateChartList;
        }
    }
}


why my future class cannot return more than 50000 querry rows?
KevinPKevinP
Per this document: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm the max rows returned is 50k regardless of invocation context.
Waqar Hussain SFWaqar Hussain SF
Hi Arash..
In salesforce we can retrieved 50,000 total number of records by SOQL queries .try to use limit in your SOQL Query. LIke
List<Project_Setting__c> PList = [select id,Name,Parent_Project_Name__c,Covering_Account_Manager__c,Healthplan_Contact__c,PR_Number__c,Line_Of_Business__c,ChartSecure_Account_Manager__r.Name,Requestor__c,Covering_Account_Manager__r.Name,Project_End_Date__c,Project_Start_Date__c,Extended_Project_End_Date__c,Project_Closed__c,Date_Project_Closed__c,Copy_Cost__c,Onsite_Threshold__c,Reporting_Active__c from Project_Setting__c where id In : ProjectIds limit 1000];

Let me know If it works.