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
durga prasad 45durga prasad 45 

populate the filed values

when lookup filed selected then automatically populate text filed with some value. text field must be readonly
srlawr uksrlawr uk
I'm going to first leap to an assumption that you want this field to hold some value FROM the lookup relationship?

If this is the case, then you can add a formula field to the child object to reference values in the object selected in the lookup easily. Just add a formular field and use the "Insert Field" button to pick the one you want.

ie. If you have two objects:
Shelf__c

Shelf_Item__c

and when you populate a lookup from Shelf_Item__c to the Shelf__c it is on... you could add a formula field of type text (which is read only) and put
 
Shelf__r.Colour__c

in there... this would "copy" (visually) the text value of the shelf colour into the Shelf_Item and put it on it's page layouts etc.etc.


IF you just want to populate a field on Shelf__c with any old text - make read only text field on Shelf__c and then add a workflow rule (from Setup -> Create -> workflow & approvals -> workflow rules

Then make a workflow rule on your shelf object and tell it to execute "created, and any time it’s edited to subsequently meet criteria" 

Set the formula to somthing like
AND(
NOT(ISBLANK(Shelf_Lookup__c),
 ISCHANGED(Shelf_Lookup__c) 
)
which means it will fire when you change the lookup field... and then when you have your workflow rule, use a "field update" to set the text field to whatever you want.

You will have to use the field settings to make it read only remember!