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
Sameer VitsSameer Vits 

Copy text from custom text field to custom lookup field.

I have 2 fields, one is custom text field A and second is PAP lookup field. Both fields are under Contacts. Is there a way to copy text from text field 'A' to lookup field 'PAP'? PAP lookup field is looking up to Account Name.
Sandra WicketSandra Wicket

Hello Sammer, 
what is the content of the field A ? You always need a Id for a lookup field.
 

Greetings Sandra

Sameer VitsSameer Vits
Hello Sandra, 

It's text type. I am actually bringing values from a picklist into this text box. 

Sameer
Sandra WicketSandra Wicket
Hi Sameer,
a lookup relation always needs an Id. You can cast a string to a id in apex. 
Id i = Id.valueOf(field a);
Sameer VitsSameer Vits
Hello Sandra, 

It's not working. 
Sandra WicketSandra Wicket
Could you provide the code an a example value of both fields ?