Find your content:

Search form

You are here

Look up search on 2 custom fields instead standard name field


I have a custom object Country with two fields Country Code which is salesforce standard name field and country name which is text field. I have a look up field to this country object. Now when user searches for a country it only matches against country code and not country name. I want both fields searchable. Sometimes users dont know country code of a country but they know country name.

Attribution to: doga

Possible Suggestion/Solution #1

You can't do this using the standard lookup functionality, when searching for custom objects only the "Name" field is searched. To achieve that you will need to develop your own custom search (VF component).

Attribution to: PepeFloyd

Possible Suggestion/Solution #2

I do not think this is possible from the interface. I would recommend one of the following ideas:

  1. Switching the fields around, so that your users can search on the common field (preferred). You could then use a formula to pull in the related object's country code for use.
  2. Provide a cheat sheet for your users, that maps country codes to country names. If you are using the standard ISO codes then a link to Wikipedia might be sufficient.
  3. At worst, the users could go to a Countries tab and look there first, to find the object and its code.

Attribution to: Mike Chale

Possible Suggestion/Solution #3

Use a new custom field for Country Code, and make the standard Name field a concatenation of Code and Country Name. E.g. Country_Code__c = 'US', Country_Name__c = 'United States', Name="US - United States'. People can then search on any part of the code or name. You can then use the Country Code and Country Name values separately wherever you need those things.

Attribution to: Jeremy Nottingham
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content