Skip to main content
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??

 
3 件の回答
  1. 2018年11月16日 11:25
    Hi Manoj,

    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:

     

    @RestResource(urlMapping='/Casequery/*')

    global with sharing class CaseQuery {

    @HttpGet

    global static List<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;

    }

    }

    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
0/9000