• martinjh
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

Hi folks,

 

I've inherited a series of Visualforce pages and up until yesterday they were working but now all of a sudden I'm getting the following error:

 

Too many query rows: 50001 

 

An unexpected error has occurred. Your development organization has been notified.

 

I've used the Developer Console and it's pin pointed the FATAL_ERROR in the Execution Log to the following method:

 

global class mForceSupportCustCaseRptGeneratorCtrl {

    String customerID;
    String reportMonth;    
    String reportYear;
    
    public PageReference generateReport() {
        PageReference reportPage = Page.mForceSupportCustCaseReport;
        reportPage.setRedirect(true);
        reportPage .getParameters().put('m', reportMonth);
        reportPage .getParameters().put('y',  reportYear);
        reportPage .getParameters().put('acc', customerID);
        return reportPage ;
    }
    
    public List<SelectOption> getListcustomeroptions() {

        List<AggregateResult> customerlist = [Select Account.Name accname, Accountid , count(createddate) FROM Case group by Account.Name, Accountid order by Account.Name limit 25000];

        List<SelectOption> options = new List<SelectOption>();
        
        Map<string,string> accountmap = new Map<string,string>();
        
        for (AggregateResult ar : customerlist ) {
            if (ar.get('expr0')!=null && ar.get('accname')!= null)
                accountmap.put(string.valueof(ar.get('Accountid')),string.valueof(ar.get('accname')));
        }
 
        for(String accid: accountmap.keyset()) {
            options.add(new SelectOption(accid, accountmap.get(accid)));
        }

        return QuickSort.sortOptionList(options);
    }
 
    public String getCustomerID() {
        return customerID;
    }
 
    public void setCustomerID(String customerID) {
        this.customerID = customerID;
    }    

    public List<SelectOption> getlistmonthoptions() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('1', 'January'));
        options.add(new SelectOption('2', 'February'));
        options.add(new SelectOption('3','March'));
        options.add(new SelectOption('4','April'));
        options.add(new SelectOption('5','May'));
        options.add(new SelectOption('6','June'));
        options.add(new SelectOption('7','July'));
        options.add(new SelectOption('8','August'));
        options.add(new SelectOption('9','September'));
        options.add(new SelectOption('10','October'));
        options.add(new SelectOption('11','November'));
        options.add(new SelectOption('12','December'));
        return options;
    }
 
    public String getReportMonth() {
        return reportMonth;
    }
 
    public void setReportMonth(String reportMonth) {
        this.reportMonth= reportMonth;
    }    

    public List<SelectOption> getlistyearoptions() {

        //List<AggregateResult> minmaxdates = [Select MIN(createddate) mindate, MAX(createddate) maxdate FROM Case limit 25000];
        //Integer minyear = datetime.valueof(minmaxdates.get(0).get('mindate')).year();
        //Integer maxyear = datetime.valueof(minmaxdates.get(0).get('maxdate')).year();

        List<SelectOption> options = new List<SelectOption>();
        
        for (Integer i = datetime.now().year() ; i>= 2009 ;i--) {
            options.add(new SelectOption(string.valueof(i),string.valueof(i)));
        }
        return options;
    }
 
    public String getReportYear() {
        return reportMonth;
    }
 
    public void setReportYear (String reportYear) {
        this.reportYear= reportYear;
    }    

}

 Looking at the Execution Log within the Developer Console I can see the (one and only) SOQL statement in the method being executed:

 

List<AggregateResult> customerlist = [Select Account.Name accname, Accountid , count(createddate) FROM Case group by Account.Name, Accountid order by Account.Name limit 25000];

 This obviously has the "limit" keyword on it so should be limiting the resultset, plus in the Developer Console I can see SOQL_EXECUTE_END [18] Rows:105

 

So I'm more than a little confused as to why it thinks the limit has been exceeded and any help would be much appreciated.

 

Thanks,

Martin

 

Hi folks,

 

I've inherited a series of Visualforce pages and up until yesterday they were working but now all of a sudden I'm getting the following error:

 

Too many query rows: 50001 

 

An unexpected error has occurred. Your development organization has been notified.

 

I've used the Developer Console and it's pin pointed the FATAL_ERROR in the Execution Log to the following method:

 

global class mForceSupportCustCaseRptGeneratorCtrl {

    String customerID;
    String reportMonth;    
    String reportYear;
    
    public PageReference generateReport() {
        PageReference reportPage = Page.mForceSupportCustCaseReport;
        reportPage.setRedirect(true);
        reportPage .getParameters().put('m', reportMonth);
        reportPage .getParameters().put('y',  reportYear);
        reportPage .getParameters().put('acc', customerID);
        return reportPage ;
    }
    
    public List<SelectOption> getListcustomeroptions() {

        List<AggregateResult> customerlist = [Select Account.Name accname, Accountid , count(createddate) FROM Case group by Account.Name, Accountid order by Account.Name limit 25000];

        List<SelectOption> options = new List<SelectOption>();
        
        Map<string,string> accountmap = new Map<string,string>();
        
        for (AggregateResult ar : customerlist ) {
            if (ar.get('expr0')!=null && ar.get('accname')!= null)
                accountmap.put(string.valueof(ar.get('Accountid')),string.valueof(ar.get('accname')));
        }
 
        for(String accid: accountmap.keyset()) {
            options.add(new SelectOption(accid, accountmap.get(accid)));
        }

        return QuickSort.sortOptionList(options);
    }
 
    public String getCustomerID() {
        return customerID;
    }
 
    public void setCustomerID(String customerID) {
        this.customerID = customerID;
    }    

    public List<SelectOption> getlistmonthoptions() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('1', 'January'));
        options.add(new SelectOption('2', 'February'));
        options.add(new SelectOption('3','March'));
        options.add(new SelectOption('4','April'));
        options.add(new SelectOption('5','May'));
        options.add(new SelectOption('6','June'));
        options.add(new SelectOption('7','July'));
        options.add(new SelectOption('8','August'));
        options.add(new SelectOption('9','September'));
        options.add(new SelectOption('10','October'));
        options.add(new SelectOption('11','November'));
        options.add(new SelectOption('12','December'));
        return options;
    }
 
    public String getReportMonth() {
        return reportMonth;
    }
 
    public void setReportMonth(String reportMonth) {
        this.reportMonth= reportMonth;
    }    

    public List<SelectOption> getlistyearoptions() {

        //List<AggregateResult> minmaxdates = [Select MIN(createddate) mindate, MAX(createddate) maxdate FROM Case limit 25000];
        //Integer minyear = datetime.valueof(minmaxdates.get(0).get('mindate')).year();
        //Integer maxyear = datetime.valueof(minmaxdates.get(0).get('maxdate')).year();

        List<SelectOption> options = new List<SelectOption>();
        
        for (Integer i = datetime.now().year() ; i>= 2009 ;i--) {
            options.add(new SelectOption(string.valueof(i),string.valueof(i)));
        }
        return options;
    }
 
    public String getReportYear() {
        return reportMonth;
    }
 
    public void setReportYear (String reportYear) {
        this.reportYear= reportYear;
    }    

}

 Looking at the Execution Log within the Developer Console I can see the (one and only) SOQL statement in the method being executed:

 

List<AggregateResult> customerlist = [Select Account.Name accname, Accountid , count(createddate) FROM Case group by Account.Name, Accountid order by Account.Name limit 25000];

 This obviously has the "limit" keyword on it so should be limiting the resultset, plus in the Developer Console I can see SOQL_EXECUTE_END [18] Rows:105

 

So I'm more than a little confused as to why it thinks the limit has been exceeded and any help would be much appreciated.

 

Thanks,

Martin