You need to sign in to do that
Don't have an account?
fiona gentry
How To Make IsProcessed Flag Is Set To True for records whenever a batch Job is executed ?
Hi Gurus,
In my custom object ERT_Case_Type__c, i have a check box IsProcessed which is by default false
Now I need to make this IsProcessed Flag set to True whenever a batch Job is executed ,here is Pseudo code now what i am looking is
what exact changes do i need to make in below batch apex code to make this code work with IsProcessed Flag
Your help is higly appreciated
Thanks and Regards,
In my custom object ERT_Case_Type__c, i have a check box IsProcessed which is by default false
Now I need to make this IsProcessed Flag set to True whenever a batch Job is executed ,here is Pseudo code now what i am looking is
what exact changes do i need to make in below batch apex code to make this code work with IsProcessed Flag
global class copyertbatch6am implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { // collect the batches of records or objects to be passed to execute String query = 'select Case__c, Level_1__c, Level_2__c,Level_3__c FROM ERT_Case_Type__c where createddate = today and IsProcessed Flag = False'; System.debug('ERT Case No is =====>' +query); return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<ERT_Case_Type__c> exeList) { // process each batch of records List<Case_Type__c> listCTD = new List<Case_Type__c>(); System.debug('ERT Case No is =====>' +exeList); for(ERT_Case_Type__c exe : exeList) { listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c)); IsProcessed Flag = True } try { System.debug('ERT Case No is =====>' +listCTD); insert listCTD; } catch(Exception e) { System.debug(e); } } global void finish(Database.BatchableContext BC) { // execute any post-processing operations } }
Your help is higly appreciated
Thanks and Regards,
Can you try the below code once:
I have highlighted the changes in bold for understanding.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.