Below my code, I want to pass date value as a parameter but I facing an error as below, message: System.QueryException: value of filter criterion for field 'CreatedDate' must be of type dateTime and should not be enclosed in quotes Class.QueryFilterStatus.dopostCase: line 85, column 1
@RestResource(urlMapping='/QueryFilterStatus/*') global with sharing class QueryFilterStatus{
@HttpPost
global static List<Case> dopostCase(String CreateDate,String Owneremail, String Bugis, String Version, String accountid,String tracker,String priority,String contactEmail,String status,String CStatus,String subject, String Keyword, String Product, String Name, String OwnerName) {
List<Case> caseList = new List<Case>();
String str='Select id, CreatedDate, Case_Owner_Name__c, OwneEmail__c, Description, Subject, Case_Type__c, Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail, ContactId, OwnerId, CaseNumber, CSM_ID__c, CUP_Phone__c, Call_Type__c, IsClosed, Product_Type__c, ContactName__c, GS_Account__c from Case where accountid =\''+ accountid +'\'';
if(String.isNotBlank(Owneremail))
{
str+=' AND OwneEmail__c=\''+ Owneremail+'\'';
}
if(String.isNotBlank(Bugis))
{
str+=' AND BugIs__c=\''+ Bugis+'\'';
}
if(String.isNotBlank(Version))
{
str+=' AND Version__c=\''+ Version+'\'';
}
if(String.isNotBlank(tracker))
{
str+=' AND Tracker__c =\''+ tracker+'\'';
}
// if(String.isNotBlank(priority))
// { // str+=' AND Priority=\''+ priority+'\''; // } if(String.isNotBlank(contactEmail)) { str+=' AND ContactEmail=\''+ contactEmail+'\''; } if(String.isNotBlank(status)) { str+=' AND Status =\''+ status+'\''; }
if(String.isNotBlank(CStatus))
{
str+=' AND CStatus__c=\''+ CStatus+'\'';
}
if(String.isNotBlank(Product))
{
str+=' AND Product_Type__c=\''+ Product+'\'';
}
if(String.isNotBlank(Name))
{
str+=' AND ContactName__c Like \'%'+ Name+'%\'';
}
if(String.isNotBlank(OwnerName))
{
str+=' AND Case_Owner_Name__c Like \'%'+ OwnerName+'%\'';
}
if(String.isNotBlank(priority))
{
for(string pstring : priority.split(',')){
str+=' AND Priority=\''+ pstring +'\'';
}
}
if(String.isNotBlank(CreateDate))
{
str+=' AND CreatedDate = \''+ CreateDate+'\'';
}
if(String.isNotBlank(Keyword))
{
str+=' AND (Subject Like\'%'+ Keyword+'%\'';
str+=' OR CaseNumber Like \'%'+ Keyword+'%\')';
}
System.debug(str);
caseList=Database.query(str);
return caseList;
} }