You need to sign in to do that
Don't have an account?
symantecAP
Too many DML rows
I am getting the error given below... I am trying to use @ future and it is not allowing me. Kindly help
global class schedulePMWorkOrderCreation implements Schedulable{ public static String CRON_EXP = '0 0 0 3 9 ? 2022' public date periodStart; public date periodEnd; //Override 'execute' method of Schedulable interface global void execute(SchedulableContext sc) { //Get Current Date date currentDate = Date.today(); //periodStart = Date.today()-1; //****Calculate Period Start and End Dates if(currentDate.month() == 12) periodStart = date.newInstance(currentDate.year()+1, 1, 1); else periodStart = date.newInstance(currentDate.year(), currentDate.month()+1, 1); periodEnd = periodStart.addMonths(1) - 1; System.debug('**************Period End: '+periodEnd); /****Create a query for retrieving all the fields required for creating a work order using the conditions Next_PM_Date__c is between Period Start and End Dates and Asset is active?*/ //String returnQuery = 'Select id, Facility__c, Primary_FSE__c, PM_Plan__c, Next_PM_Date__c, Effective_PM_Frequency__c, Last_Completed_PM_Date__c, Last_Scheduled_PM_Date__c, Facility__r.OwnerId from MVS_Asset__c where (Next_PM_Date__c >= :periodStart and Next_PM_Date__c <= :periodEnd ) and Status__c = \'Active\' and Outstanding_PM_Work_Order__c = false'; //String returnQuery = 'Select id, Facility__c, Primary_FSE__c, PM_Plan__c, Next_PM_Date__c, Effective_PM_Schedule_Type__c, Effective_PM_Frequency__c, Last_Completed_PM_Date__c, Last_Scheduled_PM_Date__c, Facility__r.OwnerId from MVS_Asset__c where Next_PM_Date__c <= :periodEnd and Status__c in (\'Active\',\'Reactivated\') and Outstanding_PM_Work_Order__c = false'; //Updated 2010-11-23 to add filter on Effective_PM_Frequency__c <> 'Not Required' String returnQuery = 'Select id, Facility__c, Primary_FSE__c, PM_Plan__c, Next_PM_Date__c, Effective_PM_Schedule_Type__c, Effective_PM_Frequency__c, Last_Completed_PM_Date__c, Last_Scheduled_PM_Date__c, Facility__r.OwnerId from MVS_Asset__c where Next_PM_Date__c <= :periodEnd and Status__c in (\'Active\',\'Reactivated\') and Outstanding_PM_Work_Order__c = false and Effective_PM_Frequency__c <> \'Not Required\''; //Create an object for createPMWorkOrder class used to create work orders. createPMWorkOrder b = new createPMWorkOrder (); b.query = returnQuery; //Use executeBatch method to perform the DML operations in batches Database.executeBatch(b); } }
I believe the error is occuring in your class, "CreatePMWorkOrder". We'll have to see that in order to solve your problem.
Sure here is "CreatePMWorkorder" code
any updates please
I don't see anything out of the ordinary in your batch apex. It looks like you are creating a Case and updating the MVS_Asset. As far as I can tell you should have a max of 400 DML rows(200 for the update and 200 for the cases), which is well below the 10k limit.
Have you tried dumping mvsAssetList.size() and pmWorkOrders.size() to the debug log and watching the debug log as it excutes to insure that they aren't over 10k combined?
You can also use Limits.getDMLRows() to keep track where you are in relation to the governor limit.
Here's more info on Limits Methods,
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_methods_system_limits.htm?SearchType=Stem
Wish I could be more help. Good luck!