You need to sign in to do that
Don't have an account?
Malik Butler 5
Issues with ParentRecordType in apex class
I have an issue in the debug section it's saying that the ParentRecordType is an unexpected token for service appointments.
global class ServiceAppointmentCancel implements Database.Batchable<SObject>, Schedulable { global Database.QueryLocator start(Database.BatchableContext BC) { String subject = 'Reload,Pre-Trip report,Post-Trip report'; String status = 'O'; Date SchedEndTime = Date.today(); String ParentRecordType = 'Work Order'; String ID = 'WorkOrder.ID'; String query = 'SELECT Subject,Status,SchedEndTime FROM ServiceAppointment WHERE subject = :subject AND status = :status AND SchedEndTime < :SchedEndTime' + 'SELECT ParentRecordType, FROM ServiceAppointment WHERE ParentRecordType = :ParentRecordType AND ID = ID'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<WorkOrder> serviceAppointments) { // Loop to iterate over the service appointments for(WorkOrder service : serviceAppointments) { service.status = 'C'; } for(WorkOrder work : serviceAppointments) { work.status = 'C'; } // Preforming the DML operation update serviceAppointments; } global void finish(Database.BatchableContext BC) { } global void execute(System.SchedulableContext SC) { Database.executeBatch(new ServiceAppointmentCancel(), 200); } }
In this query, no need to concat 2 soql.
'SELECT Subject,Status,SchedEndTime FROM ServiceAppointment WHERE subject = :subject AND status = :status AND SchedEndTime < :SchedEndTime' + 'SELECT ParentRecordType, FROM ServiceAppointment WHERE ParentRecordType = :ParentRecordType AND ID = ID';
Instead add all the conditions in same soql:
Thanks,
Dhanya
All Answers
In this query, no need to concat 2 soql.
'SELECT Subject,Status,SchedEndTime FROM ServiceAppointment WHERE subject = :subject AND status = :status AND SchedEndTime < :SchedEndTime' + 'SELECT ParentRecordType, FROM ServiceAppointment WHERE ParentRecordType = :ParentRecordType AND ID = ID';
Instead add all the conditions in same soql:
Thanks,
Dhanya