Is there a possible way to search the name of a lookup fields using the search.query using apex in salesforce?

Viewed 429

I had a lookup field on my object and I want to search the name of the lookup using search.query in apex, how can I do this?. In my debug, I am returning nothing. Below is my sample code.

String query = 'FIND \'Sonny McNeil\' IN ALL FIELDS RETURNING ASPHPP__ASPayment_Source__c (Id, Name,ASPHPP__PPContact__r.Name), Contact';
    System.debug('query '+query);

    List<List<sObject>> searchRecords = Search.Query(query);
    System.debug('searchRecords '+searchRecords);

    return searchRecords.get(0);
1 Answers

I've found a solution to my problem, it's not possible to use SOQL to search such certain name of a lookup field, all I do is use a sample SQL and add some LIKE condition on my sql and query it to the database and return

Related