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
SimrinSimrin 

creating lookup to custom object of other field

Hello,

I want to create a lookup to text.

Obj 1
 - name1 (lookup to obj2.name)

Obj2
 -name2 (text, unique)

I am able to crete look up tp obj2.
But I want to create a lookup to text field of Obj2 (name2)

If i create lookup to Obj2 (type text) one fucntionality is met, that i can make lookup to text field. But i cant make it unique, hence i add other text field. Also, i want that this custom field should be displayed when i create lookup.
Best Answer chosen by Simrin
sfdcdevsfdcdev
Change the Search Layouts for the Object2.

Go to the Object2 Definition Detail Page(Create->Objects->Object2) and scroll down to "Search Layouts" section, click Edit on Lookup Dialogs and select Name from Available Fields;add it to the Selected Fields and Save.

All Answers

SonamSonam (Salesforce Developers) 
If I understand this correctly - you wish to copy the field from Obj 1 to obj 2 which is the reaosn you are creating the lookup ..right?
You can do the same using triggers such that you can do this field update using only the fields required..pls correct me if I haven't understood the requirement:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers.htm
SimrinSimrin

Hi Sonam, 

This is not really what i need.

I try to reexplain.

What is working at the moment:
-I have created a new object1 of type Text.
-I create a lookup to this object1 from otther object2.
All is good until now.
Drawbaks of this approach is
-The text field of this object1 is not unique, hence when a user on Object2 page goes for lookup, he can find TEST01, TEST01, TEST02, TEST02.
- To resolve above issue, I added anoter textfield called 'name' in Object2 and made it uique and also i changed the Object2 type to Autonumber.  This solves my issue fucntionally but it arises to new issue that, When usr clicks on lookup  he finds the the Autonumber but not the name entered.

It would solve my issue, if i could disply the name instead of Autonumber when a lookup is clicked
 

sfdcdevsfdcdev
Change the Search Layouts for the Object2.

Go to the Object2 Definition Detail Page(Create->Objects->Object2) and scroll down to "Search Layouts" section, click Edit on Lookup Dialogs and select Name from Available Fields;add it to the Selected Fields and Save.
This was selected as the best answer