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
lodoss118lodoss118 

Using Cron Job tool to update records?

Hi i am using the CronJob tool from the appxexchange and i am getting the error too many dml rows 101 here is the code that the batch run trigger runs

public class SalesOrderBatchRun
{
    private static final List<SCRB_SalesOrder__c> findOrders = new List<SCRB_SalesOrder__c>([Select
           Id, Name, Description__c, Approved_Date__c, StatusCode__c From SCRB_SalesOrder__c
               Limit 100]);
              
    public static String updateOrderDescription()
    {
        String orderId = '';
       
        try
        {       
            for(SCRB_SalesOrder__c batch : findOrders)
            {
                batch.Description__c = '---- UPDATED IN APEX SCRIPT FROM BATCH SCHEDULER ----';
                orderId = batch.Id;
            }
           
            update findOrders;
           
        }catch(System.DmlException e)
        {
            System.debug('#### DML EXCEPTION ####:' + e.getMessage());
            return 'Updated Description: FAILED';
        }
       
        return 'Updated Description: SUCCESS' + ': ' + orderId;
    }
}

And in the batch script i put this

 if (batchRun.cron__Batch_Job_Name__c == 'Update Order Description') {
                error = false;
                results = ''
                SalesOrderBatchRun.updateOrderDescription();
    }


why is this happening, this sucks :(....



TehNrdTehNrd
Do you have any triggers on the SCRB_SalesOrder__c obejct?
lodoss118lodoss118

i have but they should be disabled? i really like apex but i keep encountering these limits which makes me go gagagagsahgshasga,

i really need a solution that i am able to update mass records and do batches more easily????

TehNrdTehNrd

lodoss118 wrote:

i have but they should be disabled?


Is this a statement or a question? It looks like the triggers on this object may not be written for bulk processing. If you have any DML statements inside for loops they need to be taken out.
lodoss118lodoss118
they have been disabled so i am not sure why i am getting the error?