You need to sign in to do that
Don't have an account?
lodoss118
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 :(....
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 :(....
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????
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.