PDI · Question #225
PDI Question #225: Real Exam Question with Answer & Explanation
The correct answer is B: List<List <sObject>> searchList = [FIND '*ACME*" IN ALL FIELDS RETURNING Contact, Lead];. This question asks for an Apex statement that performs a full-text search across multiple Salesforce objects (Leads and Contacts) for a specific phrase.
Question
Which statement generates a list of Leads and Contacts that have a field with the phrase 'ACME'?
Options
- AList<List <sObject>> searchList = [SELECT Name, ID FROM Contact, Lead WHERE Name like
- BList<List <sObject>> searchList = [FIND '*ACME*" IN ALL FIELDS RETURNING Contact, Lead];
- CMap <sObject> searchList = [FIND '*ACME*' IN ALL FIELDS RETURNING Contact, Lead];
- DList <sObject> searchList = [FIND '*ACME*' IN ALL FIELDS RETURNING Contact, Lead];
Explanation
This question asks for an Apex statement that performs a full-text search across multiple Salesforce objects (Leads and Contacts) for a specific phrase.
Common mistakes.
- A. This is an invalid SOQL query syntax; SOQL cannot query multiple unrelated objects in a single
FROMclause like this, nor is it designed for full-text searches across all fields. - C. While using SOSL is correct for the search, the return type for a multi-object SOSL query is
List<List<sObject>>, notMap<sObject>. - D. While using SOSL is correct for the search, the return type for a multi-object SOSL query is
List<List<sObject>>, not a flatList<sObject>.
Concept tested. SOSL syntax for multi-object search
Reference. https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl.htm
Topics
Community Discussion
No community discussion yet for this question.