You need to sign in to do that
Don't have an account?

Hi, I am receiving unexpected token error while executing my code in dev console
Error: FATAL_ERROR System.QueryException: unexpected token: AZ_lyn_prescription_AZ_JP__c
global Database.QueryLocator start(Database.BatchableContext BC) {
// Fetch last run from Cutom setting
AZM_Settings_AZ_JP__c objSetting = AZM_Settings_AZ_JP__c.getOrgDefaults();
Datetime lastSync = objSetting.Clear_Suggetsions_Last_Run_time_AZ_JP__c;
if(lastSync == null ){
lastSync = System.Now();
}
String query = 'SELECT Id,AZ_Product_Catalog_AZ_JP__c,AZ_lyn_prescription_AZ_JP__c,AZ_Product_Catalog_AZ_JP__c,Delete_AZ_JP__c,Recordtype.name,Dose_Status_AZ_JP__c,AZ_HCP_AZ_JP__c,CreatedDate,Lastmodifieddate FROM AZ_Patient_Information_AZ_JP__c' +
'WHERE AZ_lyn_prescription_AZ_JP__c = \'Yes\'' +
'AND Lastmodifieddate >= '+lastSync.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
System.debug(query);
return Database.getQueryLocator(query);
}
Can anyone please help me in this?
global Database.QueryLocator start(Database.BatchableContext BC) {
// Fetch last run from Cutom setting
AZM_Settings_AZ_JP__c objSetting = AZM_Settings_AZ_JP__c.getOrgDefaults();
Datetime lastSync = objSetting.Clear_Suggetsions_Last_Run_time_AZ_JP__c;
if(lastSync == null ){
lastSync = System.Now();
}
String query = 'SELECT Id,AZ_Product_Catalog_AZ_JP__c,AZ_lyn_prescription_AZ_JP__c,AZ_Product_Catalog_AZ_JP__c,Delete_AZ_JP__c,Recordtype.name,Dose_Status_AZ_JP__c,AZ_HCP_AZ_JP__c,CreatedDate,Lastmodifieddate FROM AZ_Patient_Information_AZ_JP__c' +
'WHERE AZ_lyn_prescription_AZ_JP__c = \'Yes\'' +
'AND Lastmodifieddate >= '+lastSync.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
System.debug(query);
return Database.getQueryLocator(query);
}
Can anyone please help me in this?
Greetings!
Can you please double check the API name of the field which you are trying to query on the Object "AZ_Patient_Information_AZ_JP__c".
Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
I believe it's because you're missing spaces between the lines of the query. So when executed it looks like this
FROM AZ_Patient_Information_AZ_JP__cWHERE AZ_lyn_prescription_AZ_JP__c = 'Yes'AND Lastmodifieddate