You need to sign in to do that
Don't have an account?
Sunny Solanki 11
Batch fail with caused by: System.QueryException: Variable does not exist: Label.CustomObject_Record_Type
Hi Gurus,
I have a batch class where I am using the custom label to limit result by record type and doing a blank update on the result. Batch class has been scheduled and failing with: Source organization: ****************8(null) Failed to process batch for class 'BatchBlankUpdateCompliance' for job id '7074D00000LzJIL'. Please, can anyone assist me the correct this error?
caused by: System.QueryException: Variable does not exist: Label.PSG_Compliance_Record_Type
Class.BatchBlankUpdateCompliance.start: line 7, column 1
global class BatchBlankUpdateCompliance implements
Database.Batchable<sObject>, Database.Stateful {
// instance member to retain state across transactions
global Integer recordsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(
'SELECT ID FROM Compliance__c ' +
'Where RecordTypeId =: Label.CustomObject_Record_Type'
);
}
global void execute(Database.BatchableContext bc, List<Compliance__c> scope){
// process each batch of records
List<Compliance__c> compList = New List<Compliance__c>();
for (Compliance__c comp : scope) {
compList.add(comp);
recordsProcessed = recordsProcessed + 1;
}
update compList;
}
global void finish(Database.BatchableContext bc){
System.debug(recordsProcessed + ' records processed. Shazam!');
I have a batch class where I am using the custom label to limit result by record type and doing a blank update on the result. Batch class has been scheduled and failing with: Source organization: ****************8(null) Failed to process batch for class 'BatchBlankUpdateCompliance' for job id '7074D00000LzJIL'. Please, can anyone assist me the correct this error?
caused by: System.QueryException: Variable does not exist: Label.PSG_Compliance_Record_Type
Class.BatchBlankUpdateCompliance.start: line 7, column 1
global class BatchBlankUpdateCompliance implements
Database.Batchable<sObject>, Database.Stateful {
// instance member to retain state across transactions
global Integer recordsProcessed = 0;
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(
'SELECT ID FROM Compliance__c ' +
'Where RecordTypeId =: Label.CustomObject_Record_Type'
);
}
global void execute(Database.BatchableContext bc, List<Compliance__c> scope){
// process each batch of records
List<Compliance__c> compList = New List<Compliance__c>();
for (Compliance__c comp : scope) {
compList.add(comp);
recordsProcessed = recordsProcessed + 1;
}
update compList;
}
global void finish(Database.BatchableContext bc){
System.debug(recordsProcessed + ' records processed. Shazam!');
Complete Code
All Answers
Complete Code
// instance member to retain state across transactions
05 global Integer recordsProcessed = 0;
//added line:
String abc = Label.CustomObject_Record_Type;
06 global Database.QueryLocator start(Database.BatchableContext bc) {
07 return Database.getQueryLocator(
08 'SELECT ID FROM Compliance__c ' +
09 'Where RecordTypeId =abc'
10 );