function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Monishan MMonishan M 

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,,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\'');  
                         return Database.getQueryLocator(query);

Can anyone please help me in this?
ShirishaShirisha (Salesforce Developers) 
Hi Monishan,


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
Pawel BorysPawel Borys
Hi Monishan,

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