function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Garret WallimanGarret Walliman 

Setting SOSL Name Fields

Based on the SOSL documentation it appears that you can limit the searched fields to, among other things, Name Fields. The documentation makes it sound like you can designate certain fields to be Name Fields, but I have not been able to figure out how to do this.

Is it possible to designate an arbitrary field as a Name Field on an object, and if so, how is this done?
Best Answer chosen by Garret Walliman
ClintLeeClintLee
Hi Garret,

Name Fields in the SOSL syntax refers to the actual singular Name field that is on most standard objects and all custom objects.  

There are some additional fields that are searched on standard objects when you use Name Fields in a SOSL search.  You'll find those special cases here - https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_in.htm

Also, here is a page in the docs that describes the isNameField() method and states that "objects can have only one name field..." - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_fields_describe.htm#apex_Schema_DescribeFieldResult_isNameField 

Hope that helps,

Clint

All Answers

ClintLeeClintLee
Hi Garret,

Name Fields in the SOSL syntax refers to the actual singular Name field that is on most standard objects and all custom objects.  

There are some additional fields that are searched on standard objects when you use Name Fields in a SOSL search.  You'll find those special cases here - https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_in.htm

Also, here is a page in the docs that describes the isNameField() method and states that "objects can have only one name field..." - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_fields_describe.htm#apex_Schema_DescribeFieldResult_isNameField 

Hope that helps,

Clint
This was selected as the best answer
Garret WallimanGarret Walliman
Hello Clint,

Well, that clears things up. Thanks for clarifying things.