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
sachin shuklasachin shukla 

Name field of Contact not present in FieldPermission

Hi All,
I am trying to identify field access of an object and used SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit FROM FieldPermissions where SObjectType='Contact' this SOQL query. But Name field is missing in the result.
Can somebody help me to identify root cause for the above issue?

Thanks,
Sachin
Linga_RaminLinga_Ramin
Hi Sachin,
 You can try below SOQL Query

SELECT Assignee.Name, PermissionSet.Id, PermissionSet.isOwnedByProfile, PermissionSet.Profile.Name, PermissionSet.Label
FROM PermissionSetAssignment
WHERE PermissionSetId
IN (SELECT ParentId
FROM ObjectPermissions
WHERE SObjectType = 'Account' AND
PermissionsRead = true)
Linga_RaminLinga_Ramin
In place of 'Account' you can put 'Contact'
 
sachin shuklasachin shukla
Thanks PMPR72 for the response!
I am looking out for the query which will give me field access information like Read Only, Hidden or Editable.
SELECT Id, Field, SObjectType, PermissionsRead, PermissionsEdit FROM FieldPermissions where SObjectType='Contact'
Above query giving me the output which i wanted, but Name field Contact Object is missing.

Thanks,
Sachin
Matt P McMatt P Mc
That's because it won't show system fields that Salesforce sets access to - you can't adjust Name so you won't see it in FieldPermissions. If you were to open the Workbench and get into the REST Explorer, you'd be able to track down which fields this is specifically by looking for the following:
User-added image

Fields like Id, Name, CreatedById have this restriction.
Matt P McMatt P Mc
Review the following link (https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_fieldpermissions.htm).

The following field types don’t return a FieldPermissions record because they are assumed to always be readable.
  • Id
  • CreatedById
  • CreatedDate
  • IsDeleted
  • LastModifiedById
  • LastModifiedDate
  • SystemModStamp

The following field types don’t return a FieldPermissions record because they are assumed to always be readable and writable.
  • OwnerId
  • Master-detail custom (relationship) fields
  • Universally required custom fields