• Björn Wiberg 4
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi , 
I have a report which have 48000  records  , when i run a report using synchronous Approach in apex code , it will only return 2000 records  so in order to overcome this problem i have used filter in report but after returning 4000 records it throw exception " FATAL_ERROR System.LimitException: reports:Too many query rows: 50001 "  . (I can't Use Asynch Approach as i am using this class inside batch class).
In order to Apply Filter i am using Autonumber field and sort them in ascending order, Please have a look to my code and help me to figure out the problem , Thanks to All In Advance.


String reportId='00Of1000004jG5h'; // Report Id
Integer filterNumber=0; // Set Lower Row Limit For Filter 
boolean getAllData=False;
integer count=0;

while(getAllData==false) {
Reports.ReportDescribeResult describe = Reports.ReportManager.describeReport(reportId); // describe report metadata
            Reports.ReportMetadata reportMd = describe.getReportMetadata();
    
                string b =reportMd.getDetailColumns()[0]; //get Filtered Column From Report , it is Autonumber Field
                String column1=b;
                Integer value1=filterNumber;
                String operator1='greaterOrEqual';
    
              Reports.ReportFilter filter = reportMd.getReportFilters()[0];// get Filter and Update filter values in apex
             
            filter.setColumn(column1);
            filter.setValue(string.valueOf(value1));
            filter.setOperator(operator1);
             Integer value2=value1+2000; // Upper Limit for Second Filter
            String operator2='lessOrEqual';
                
             Reports.ReportFilter filter1 =reportMd.getReportFilters()[0]; // Second Filter to report on same column 
            filter1.setColumn(column1);
            filter1.setValue(string.valueOf(value2));
            filter1.setOperator(operator2);
    
        
           // Run a report synchronously
            Reports.reportResults ActiveISOContacts = Reports.ReportManager.runReport(reportId,reportMd, true);
            getAllData=ActiveISOContacts.getAllData();
           system.debug(ActiveISOContacts.getAllData());//this will return true and false .

           // Get the fact map from the report results
            Reports.ReportFactWithDetails factDetails = (Reports.ReportFactWithDetails)ActiveISOContacts.getFactMap().get('T!T');
            //create a list of report rows and populate it with the result rows from fact map
            List<Reports.ReportDetailRow> reportRows = factDetails.getRows();
            filterNumber =filterNumber+reportRows.size();
            count++;
                system.debug(filterNumber);
    system.debug(count);
    }           


 
I get the following error while trying to delete an account:

"Your attempt to delete (Name of Account) could not be completed because it is associated with the following accounts. If the following table is empty, it is because you do not have access to the records restricting the delete."

And the table shows only 1 record, that record is the account I tried to delete (verified by ID).

The account is not associated to itself in any way with a custom lookup or elsewhere. I'm not sure what could be causing this I'm using an Admin user with all of the delete permissions you would normally need.

Hi, 

 

Does anybody has an idea on how to create the whole Approval Process by Apex? I don't mean the Approval request by Apex, I saw few examples of the Approval request by Apex, but they are only effective when the Approval Process for a particular object is already defined. 

 

Any advice will be appreciated. 

 

Regards, 

 

  • April 15, 2010
  • Like
  • 0