You need to sign in to do that
Don't have an account?
ManojKumar Muthu
Illegal conversion from List<List<Case>> to List<Case>
Hi,
I am trying to query across all field with an object(case), just like the search bar so that whatever keyword I enter it should query all field and throw back list of record that matach the keyword,
below the code I use,
@RestResource(urlMapping='/Casequery/*')
global with sharing class CaseQuery {
@HttpGet
global static List<Case> getCase() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
List<List<Case>> results = [FIND 'map*' IN ALL FIELDS RETURNING Case (id, Call_Back_Type__c, IsEscalated,
Case_Owner_Name__c, OwneEmail__c, subject, Case_Type__c,
Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail,
ContactId, OwnerId, CaseNumber)];
return results;
}
}
and geting an error:Illegal conversion from List<List<Case>> to List<Case>
Any thought on this??
I am trying to query across all field with an object(case), just like the search bar so that whatever keyword I enter it should query all field and throw back list of record that matach the keyword,
below the code I use,
@RestResource(urlMapping='/Casequery/*')
global with sharing class CaseQuery {
@HttpGet
global static List<Case> getCase() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String Id = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
List<List<Case>> results = [FIND 'map*' IN ALL FIELDS RETURNING Case (id, Call_Back_Type__c, IsEscalated,
Case_Owner_Name__c, OwneEmail__c, subject, Case_Type__c,
Code__c, Tracker__c, status, Version__c, type, priority, ContactEmail,
ContactId, OwnerId, CaseNumber)];
return results;
}
}
and geting an error:Illegal conversion from List<List<Case>> to List<Case>
Any thought on this??
Greetings to you!
In your code, you are using List<Case> as return type but the SOSL always return the List of List of sobjects like List<List<Case>>
If you will change the return type to List<List<Case>> in your code that will work.
global static List<List<Case>> getCase() { ... }
Try below code:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
In your code, you are using List<Case> as return type but the SOSL always return the List of List of sobjects like List<List<Case>>
If you will change the return type to List<List<Case>> in your code that will work.
global static List<List<Case>> getCase() { ... }
Try below code:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Thanks for the timely help,
Yeah its works fine now, by the way I am trying to create a search bar just mentioned above, where I enter a keywords and query will list of all the records mataching that keyword. Is there a way to achive this?