You need to sign in to do that
Don't have an account?
Akshay Gupta
System.QueryException: unexpected token: WHERE
String strObjProsPrefix = Schema.MCPM_Prospect__c.getSobjectType().getDescribe().getKeyPrefix();
String strQuery = 'Select Id, MCPM_Email_Reminder_Interaction__c, MCPM_Prospect_Email_For_Reminder__c, '+
'MCPM_Premise_Lookup__c, MCPM_Prospect__c'+
'from MCPM_Interaction__c where ';
if(strRecordId.startsWith(strObjProsPrefix)){
strQuery += 'MCPM_Prospect__c= \''+String.escapeSingleQuotes(strRecordId)+'\' and '+
'MCPM_Email_Reminder_Interaction__c = true ' +
'ORDER BY CreatedDate DESC LIMIT 1 ';
}
else{
strQuery += 'MCPM_Premise_Lookup__c= \''+String.escapeSingleQuotes(strRecordId)+'\' and ' +
'MCPM_Email_Reminder_Interaction__c = true'+
'ORDER BY CreatedDate DESC LIMIT 1 ';
}
List<MCPM_Interaction__c> objInterction = Database.query(strQuery);
Hi I am getting above error, tried many thing don't know what's going wrong.
Please help,
String strQuery = 'Select Id, MCPM_Email_Reminder_Interaction__c, MCPM_Prospect_Email_For_Reminder__c, '+
'MCPM_Premise_Lookup__c, MCPM_Prospect__c'+
'from MCPM_Interaction__c where ';
if(strRecordId.startsWith(strObjProsPrefix)){
strQuery += 'MCPM_Prospect__c= \''+String.escapeSingleQuotes(strRecordId)+'\' and '+
'MCPM_Email_Reminder_Interaction__c = true ' +
'ORDER BY CreatedDate DESC LIMIT 1 ';
}
else{
strQuery += 'MCPM_Premise_Lookup__c= \''+String.escapeSingleQuotes(strRecordId)+'\' and ' +
'MCPM_Email_Reminder_Interaction__c = true'+
'ORDER BY CreatedDate DESC LIMIT 1 ';
}
List<MCPM_Interaction__c> objInterction = Database.query(strQuery);
Hi I am getting above error, tried many thing don't know what's going wrong.
Please help,
Also, make sure proper spaces are put in between the literals. as a check put a print out your query to know what actually you dynamic query looks like,
All Answers
Let us know if this will help you
Also, make sure proper spaces are put in between the literals. as a check put a print out your query to know what actually you dynamic query looks like,
Thank you for helping my and giving a working query.
@ Vineeth thanks for explanation