PDI · Question #73
What should a developer use to obtain the Id and Name of all the Leads. Accounts, and Contacts that hove the company name "Universal Containers"?
The correct answer is A. FIND 'Universal Containers' IN Name Fields RETURNING leadjid, name), accounted, name). To query across multiple objects (Leads, Accounts, Contacts) for a specific company name and retrieve Id and Name fields, a SOSL (Salesforce Object Search Language) query is the appropriate tool.
Question
What should a developer use to obtain the Id and Name of all the Leads. Accounts, and Contacts that hove the company name "Universal Containers"?
Options
- AFIND 'Universal Containers' IN Name Fields RETURNING leadjid, name), accounted, name),
- BFIND Universal Containers' IN CompanyName Fietds RETURNING lead{ld. name), accounted,
- CSELECT lead(id, name). accountOd, name), contacted, name) FROM Lead, Account, Contact
- DSELECT Lead.id. Lead.Name, Account.Id, AccountName, Contacted, Contact.Name FROM
How the community answered
(27 responses)- A89% (24)
- C7% (2)
- D4% (1)
Why each option
To query across multiple objects (Leads, Accounts, Contacts) for a specific company name and retrieve Id and Name fields, a SOSL (Salesforce Object Search Language) query is the appropriate tool.
This is the correct syntax for a SOSL query, which is used to search across multiple standard and custom object fields for a specific text string. The `RETURNING` clause specifies which objects and fields to retrieve when a match is found in `Name Fields`, which typically include the company name for these objects.
The `CompanyName Fields` is not a valid search group in SOSL; `Name Fields` is the appropriate general search group for names and company names on these objects, and it's missing `contact(id, name)`.
This is not valid SOQL or SOSL syntax; SOQL uses `FROM` with a single object (or related objects), and this structure does not exist for searching across multiple unrelated objects.
This is incomplete and invalid SOQL syntax. SOQL queries operate on one primary object at a time unless using relationships, and this syntax attempts to select from multiple unrelated objects directly.
Concept tested: Salesforce Object Search Language (SOSL)
Source: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sfdc_sosl_examples_return_multiple_objects.htm
Topics
Community Discussion
No community discussion yet for this question.