You need to sign in to do that
Don't have an account?
Warjie
Schedulable Batch Class Help
Hi folks!
I have a batch class that is called from another batch class. As of now, what the job does is doing some system debug to check the records to be processed. For some reason, I cannot see the debug. This prevents me from doing the DMLs (which is the real action in the job) since I'm not sure if it will really execute the DMLs given that a simple debug doesn't show up. I have set the debug to FINEST and I got the below. Can you please help me? Thanks!
Calling of batch
Batch job
Debug
I have a batch class that is called from another batch class. As of now, what the job does is doing some system debug to check the records to be processed. For some reason, I cannot see the debug. This prevents me from doing the DMLs (which is the real action in the job) since I'm not sure if it will really execute the DMLs given that a simple debug doesn't show up. I have set the debug to FINEST and I got the below. Can you please help me? Thanks!
Calling of batch
Datetime sysTime = System.now().addMinutes(2); String chronExpression = sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year(); DeleteAttachmentBatchClass batchjob = new DeleteAttachmentBatchClass(); System.schedule('Delete Attachment', chronExpression, batchjob );
Batch job
global class DeleteAttachmentBatchClass implements Database.Batchable<sObject>, schedulable, Database.Stateful{ public String query; public List<Account> accList = new List<Account>(); public List<Attachment> attachmentList = new List<Attachment>(); public Set<Id> accSet = new Set<Id>(); public Set<String> fileNameSet = new Set<String>(); global DeleteAttachmentBatchClass(){ query = 'SELECT Id, Customer_Number__c, (Select License_Number__c FROM Licenses__r) FROM Account WHERE SentEmailToLicenseContact__c = TRUE AND Attachment_Age__c != null AND Licence_Email__c != null AND Local_Language__c != null'; } global Database.QueryLocator start(Database.BatchableContext BC){ return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<Account> scope){ system.debug('**Scope: ' + scope.size() + ' - ' + scope); for(Account a: scope){ a.SentEmailToLicenseContact__c = False; a.Attachment_Age__c = null; accSet.add(a.Id); for(Licenses__c l: a.Licenses__r){ fileNameSet.add(l.License_Number__c + ' - ' + a.Customer_Number__c + ' - ' + System.Today().year() + '.pdf'); } } attachmentList = [SELECT Id, Name, ParentId FROM Attachment WHERE ParentID IN: accSet AND name IN: fileNameSet]; system.debug('**attachmentList: ' + attachmentList.size() + ' - ' + attachmentList); } global void finish(Database.BatchableContext BC){ } global void execute(SchedulableContext SC){ } }
Debug
36.0 APEX_CODE,FINEST;APEX_PROFILING,FINEST;CALLOUT,INFO;DB,FINEST;SYSTEM,FINEST;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO 13:34:48.0 (97413)|EXECUTION_STARTED 13:34:48.0 (151374)|CODE_UNIT_STARTED|[EXTERNAL]|01p7E00000096wA|Delete Attachment 13:34:48.0 (5874005)|HEAP_ALLOCATE|[72]|Bytes:3 13:34:48.0 (5961992)|HEAP_ALLOCATE|[77]|Bytes:152 13:34:48.0 (5986568)|HEAP_ALLOCATE|[342]|Bytes:408 13:34:48.0 (6007947)|HEAP_ALLOCATE|[355]|Bytes:408 13:34:48.0 (6028580)|HEAP_ALLOCATE|[467]|Bytes:48 13:34:48.0 (6074907)|HEAP_ALLOCATE|[139]|Bytes:6 13:34:48.0 (15380024)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:3 13:34:48.0 (15406931)|SYSTEM_METHOD_ENTRY|[1]|SchedulableContextImpl.SchedulableContextImpl() 13:34:48.0 (15412854)|STATEMENT_EXECUTE|[1] 13:34:48.0 (15432851)|SYSTEM_METHOD_EXIT|[1]|SchedulableContextImpl 13:34:48.0 (15441773)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8 13:34:48.0 (15447416)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 13:34:48.0 (15463447)|VARIABLE_SCOPE_BEGIN|[4]|this|System.SchedulableContextImpl|true|false 13:34:48.0 (15544606)|VARIABLE_ASSIGNMENT|[4]|this|{}|0x77b01072 13:34:48.0 (15552147)|VARIABLE_SCOPE_BEGIN|[4]|triggerId|Id|false|false 13:34:48.0 (15642403)|VARIABLE_ASSIGNMENT|[4]|triggerId|"08e7E000000hGNrQAM" 13:34:48.0 (15840917)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:91 13:34:48.0 (15848470)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:13 13:34:48.0 (15851167)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5 13:34:48.0 (15865363)|METHOD_ENTRY|[1]|01p7E00000096wA|DeleteAttachmentBatchClass.DeleteAttachmentBatchClass() 13:34:48.0 (15869731)|STATEMENT_EXECUTE|[1] 13:34:48.0 (15875934)|STATEMENT_EXECUTE|[1] 13:34:48.0 (15884876)|METHOD_EXIT|[1]|DeleteAttachmentBatchClass 13:34:48.0 (15890596)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:24 13:34:48.0 (15893265)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8 13:34:48.0 (15904090)|VARIABLE_SCOPE_BEGIN|[34]|this|DeleteAttachmentBatchClass|true|false 13:34:48.0 (15949827)|VARIABLE_ASSIGNMENT|[34]|this|{"accList":"0x20f2d544","accSet":"0x79d48f07","attachmentList":"0xe1023cf","fileNameSet":"0x2c1652fb","query":"SELECT Id, Customer_ (198 more) ..."}|0x1a78eac8 13:34:48.0 (15964437)|VARIABLE_SCOPE_BEGIN|[34]|SC|System.SchedulableContext|true|false 13:34:48.0 (16039084)|VARIABLE_ASSIGNMENT|[34]|SC|{"triggerId":"08e7E000000hGNrQAM"}|0x77b01072 13:34:48.0 (16054954)|STATEMENT_EXECUTE|[34] 13:34:48.16 (16073571)|CUMULATIVE_LIMIT_USAGE 13:34:48.16 (16073571)|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 0 out of 100 Number of query rows: 0 out of 50000 Number of SOSL queries: 0 out of 20 Number of DML statements: 0 out of 150 Number of DML rows: 0 out of 10000 Maximum CPU time: 0 out of 10000 Maximum heap size: 0 out of 6000000 Number of callouts: 0 out of 100 Number of Email Invocations: 0 out of 10 Number of future calls: 0 out of 50 Number of queueable jobs added to the queue: 0 out of 50 Number of Mobile Apex push calls: 0 out of 10 13:34:48.16 (16073571)|TOTAL_EMAIL_RECIPIENTS_QUEUED|0 13:34:48.16 (16073571)|STATIC_VARIABLE_LIST| char[]:DigitTens:0 long:serialVersionUID:0 String:_sfdcAdditionalCodeLocations:0 double:MAX_VALUE:0 long:serialVersionUID:0 double:MIN_VALUE:0 int:SIZE:0 double:NEGATIVE_INFINITY:0 int:MAX_VALUE:0 char[]:digits:0 double:NaN:0 String:_sfdcAdditionalCodeLocations:0 String:_sfdcAdditionalCodeLocations:0 int:MIN_VALUE:0 char[]:DigitOnes:0 int:BYTES:0 String:__sfdcParameterizedTypes:0 int:MIN_EXPONENT:0 String:_sfdcSuppressedCodeLocations:0 int[]:sizeTable:0 int:MAX_EXPONENT:0 int:SIZE:0 double:POSITIVE_INFINITY:0 double:MIN_NORMAL:0 int:BYTES:0 13:34:48.16 (16073571)|CUMULATIVE_LIMIT_USAGE_END 13:34:48.0 (16339043)|CODE_UNIT_FINISHED|Delete Attachment 13:34:48.0 (17446531)|EXECUTION_FINISHED 13:34:48.29 (29359753)|CUMULATIVE_PROFILING_BEGIN 13:34:48.29 (29359753)|CUMULATIVE_PROFILING|No profiling information for SOQL operations 13:34:48.29 (29359753)|CUMULATIVE_PROFILING|No profiling information for SOSL operations 13:34:48.29 (29359753)|CUMULATIVE_PROFILING|No profiling information for DML operations 13:34:48.29 (29359753)|CUMULATIVE_PROFILING|method invocations| External entry point: global void execute(System.SchedulableContext): executed 1 time in 0 ms 13:34:48.29 (29359753)|CUMULATIVE_PROFILING_END
You could run the Batch Class Directly instead of Scheduling It:
You could monitior if the batch job had any item to execute in Setup -> Monitor - > Apex Jobs
If you still dont see any thing running then it might be because your start method not returning any records to execute.
Thanks
Shashikant