I have created a custom object with several fields in which one of the field is of type lookup to the reference to the User object. When I created a tab to add records to this object, I can only see all the other custom fields except this User lookup field. I ma logged in as System Administrator which should have access to that User object.
2 Answers
Check your Field visibility and after that, if that field is added on the corresponding page layout!!!!
I'm not 100% sure if this is how things work (because I haven't used sfdx in this capacity), but...
When you create a new field on an SObject, and deploy that field to another org, the permissions for that field are generally not transferred to the receiving org.
Long story short, unless you know for a fact that you're deploying profile data too1, you'll need to at the bare minimum set the Field Level Security (FLS) for the new field in your receiving org.
By default, a field2 deployed to a new org has the FLS set to disallow everyone (even sysadmins) from reading or writing the field. You'll be able to see the field in the object manager (in the setup menu) but not be able to see it on layouts (or even query it, for that matter).
I have a feeling that this also applies to fields created in a scratch org and then deployed to another org, as well as fields created "directly" as xml files in an SFDX project (if you're crazy enough to do that).
One more time for clarity:
- If you create a field via the web UI of Salesforce, you have the chance to set FLS when you create the field
- If you deploy a field to an org, setting the FLS is something you need to do as well (and is typically a separate step from deploying the field)
1: or a PermissionSet, and you've already assigned the permission set to users in the receiving org
2: With the possible exception of formula fields
-
My object is a brand new custom object which was created through web UI only with 6 fields in which one of it is a lookup field which is reference to User object. When I create a tab for this custom object to insert data, I am able to see only 5 fields as shown in the above image, but the lookup field which is referencing User object is not rendered in the form. Hence I cannot proceed with creating data. This is all happening in single org. There is no context of multiple orgs here. Commented Jul 28, 2020 at 20:05
CreatedById
orLastModifiedById
), or is it a custom field (with an API name ending in__c
)? If it's a custom field, is this issue something you see in the org that you created the custom field in, or in an org that you deployed this custom field to?