You need to sign in to do that
Don't have an account?
ManojKumar Muthu
system.QueryException
Here I am trying to get value dynamically from few different fields include, Account, Status, Tracker, Priority, ContactEmail and list down the list of case that matchs the criteria.
When I execute the below code I am getting system.QueryException: invalid ID field: null
@RestResource(urlMapping='/QueryFilterStatus/*')
global with sharing class QueryFilterStatus{
@HttpPost
global static List<Case> dopostCase(String accountid,String tracker,String priority,String contactEmail,String status,String CStatus,String subject, String Keyword, String accid) {
List<Case> caseList = new List<Case>();
String str='Select id, 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 from Case where accountid =\''+ null +'\'';
if(String.isBlank(accid))
{
str+=' AND AccountId=\''+ accid+'\'';
}
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(Keyword))
{
str+=' AND (Subject Like\''+ Keyword+'\'';
str+=' OR CaseNumber Like \'%'+ Keyword+'%\')';
}
System.debug(str);
caseList=Database.query(str);
return caseList;
}
}
When I execute the below code I am getting system.QueryException: invalid ID field: null
@RestResource(urlMapping='/QueryFilterStatus/*')
global with sharing class QueryFilterStatus{
@HttpPost
global static List<Case> dopostCase(String accountid,String tracker,String priority,String contactEmail,String status,String CStatus,String subject, String Keyword, String accid) {
List<Case> caseList = new List<Case>();
String str='Select id, 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 from Case where accountid =\''+ null +'\'';
if(String.isBlank(accid))
{
str+=' AND AccountId=\''+ accid+'\'';
}
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(Keyword))
{
str+=' AND (Subject Like\''+ Keyword+'\'';
str+=' OR CaseNumber Like \'%'+ Keyword+'%\')';
}
System.debug(str);
caseList=Database.query(str);
return caseList;
}
}
Please change method from String.isBlank(accid) to String.isNotBlank(accid)
Please let me know if it helps!