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
BritishBoyinDCBritishBoyinDC 

How to Deploy when a Query will return more than 500 rows in Production..

Part of my code returns a list of opportunities that will often return > 500 rows. Not a problem, except when Itry to deploy the code, and the function is called in the test script, it fails because it breaks the test governor limits.

 

To avoid this seems to require a messy coding exercise to check if the code is running in a test scenario, and limit accordingly - is there an easier way I am missing to get past this problem?

Steve MaxSteve Max

I have the same problem.  If anyone can product the same result by batching, please let me know.

 

    private void RetrieveUserKPIData()
    {      
        //Retrieve the collection of USER_KPI Records
        for (   User_Month_KPI__c[] UserKPIs :
                                            [
                                            select 
                                                u.OwnerId,
                                                u.active_accounts_actual__c,
                                                u.APNrent_month_revenue_actual__c,
                                                u.revenue_new_accounts_actual__c,
                                                u.new_accounts_signed_actual__c,
                                                u.APN_Month__c,
                                                u.APN_Year__c,
                                                u.Month_Start_date__c,
                                                u.Month_End_date__c,
                                                u.avg_rev_per_account_actual__c,
                                                u.IPI_bookings_count__c,
                                                u.Id
                                            from    User_Month_KPI__c u
                                            where   u.APN_Year__c = :APNYear
                                            and     u.APN_Month__c = :APNMonth
                                            ] )
        {
            for (User_Month_KPI__c UserKPI : UserKPIs)
            {
                this.getCurrentSet().put(UserKPI.OwnerId,UserKPI);
                UserKPI.Month_Start_date__c = APNMonthStartDate;
                UserKPI.Month_End_date__c = APNMonthEndDate;
               
                Records++;
            }
        }
       
        CurrentSet=0;
    }