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
Big EarsBig Ears 

Read-only "Look-up" field. Is it possible?

I want to have a read-only look-up field in my instance of Salesforce. However, whenever I build one, they either seem to be invisible to all, or editable.
 
I want a Read-Only Look-up field is so I can update it later using some behind-the-scenes APEX coding as part of the sales & contracting process. I just don't want people to be putting information in that field before they're supposed to.
 
Does anybody know if Salesforce doesn't allow for Read-Only Look-ups? I'd understand why.
 
Thanks for your help!
 
Andy
Nathan CrosbyNathan Crosby
You can have read-only lookups on an object. You can control this either through field-level security or on the page layout itself.

To use field-level security, click on the field name within the object settings and click the Set Field-Level Security button. Here you will be able to control by profile who can view the field, and for those who can view it, control if the field is read-only or not.

You also have the ability to make a field read-only on page layouts. From the page layout edit screen, double-click the field you want to make read-only and there will be a read-only option via a checkbox.

You'll be able to control these lookups via an APEX trigger in the background - sounds like what you're after.
Marc C.Marc C.

"You also have the ability to make a field read-only on page layouts. From the page layout edit screen, double-click the field you want to make read-only and there will be a read-only option via a checkbox."

 

The read-only checkbox is greyed out on lookup fields inside the layout. Is this maybe because the field is mandatory? We'd like to have the field set only by the system once at creation (to make a multi-level master-detail relationship) but not changed.

James BengelJames Bengel
Have you explored using a formula field to handle the display chores, rather than trying to use the lookup field itself on the page?  Formulas are by definition read-only, so it seems like it would do what you're after.
Shraddha D GuptaShraddha D Gupta
Hi James,
I do have sort of similar requirement. There is lookup field on Opportunity called Territory(lookup to Territory Object), on this the Read Only inside the Set field level security is greyed out and I do want to restrict the edit permissions on specific profils. I know this can be achieved at the page layout level but the thing is that the Page Layouts are shared between profiles(some need edit access and some do not) so I would like to achive this without creating multiple page layouts. 

So is there any way to edit the Read only for this field? 
Thanks!