You need to sign in to do that
Don't have an account?
Ivan Winzer
Is batch job updating records
So i was in need of scheduling a Apex job to run on scheduler. Few folks helped me out and i got the classes to work. But now im wondering if they are actually updating records. I ask becasue the class below is to update a checkbox on the object each time its run, but when i check my history i dont see any changes. And i should see it becaue once the class checks the box i have a work flow to uncheck it but im not seeing any of this in the history, yet the job keeps completing and saying it batched 61 batches. Is there a way i can see a log of whats being updated or does the code below not actually update anything?
global class WineClubCronJobBatch implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { String query ='Select Id, Tenure_Cron_Job_Schedule__c From Wineclub_Membership__c Where Active__c=True'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<sObject> scope) { List<Wineclub_Membership__c> listToUpdate = new List<Wineclub_Membership__c>(); for( Wineclub_Membership__c a: (List<Wineclub_Membership__c> ) scope) { if(a.Tenure_Cron_Job_Schedule__c = False ) { a.Tenure_Cron_Job_Schedule__c = True; listToUpdate.add(a); } } if(listToUpdate.size() > 0) { update(listToUpdate); } } global void finish(Database.BatchableContext BC){ } }
// You need two equal signs (==) to test equality
NOTE == is used to check equality
and = is used to assign the value.
Please let us know if this will help you.
Thanks
Amit Chaudhary
All Answers
system.debug('Wineclub_Membership__c='+a);
and it should put a log entry in your log, with the values of all the fields selected for the object.
I would also look at line 16 - I think the syntax should be ... if(a.Tenure_Cron_Job_Schedule__c == false) ....
One question i have is you mentioned that line 16 should have == but doesnt that mean not equal or does that men equal and should i also update line 18 as well for the make true?
// You need two equal signs (==) to test equality
NOTE == is used to check equality
and = is used to assign the value.
Please let us know if this will help you.
Thanks
Amit Chaudhary
You guys are awesome thanks for your help.
Ivan