How to know if a field is part of a compound address field and thus is not permissionable

There is an easy way to determine if field is a real field or a part of compound field.

There are two tables in Salesforce which correspond to compound fields and its components.

If a field can be found in FieldDefinition table, it is a real (permissionable) field. If a field cannot be found in FieldDefinition table, but can be found in EntityParticle table, it is a part of compound field and not a separate independent field.

So, you can easily detect if field is part of compound field by making a query.

SELECT BusinessOwnerId,BusinessStatus,ControllingFieldDefinitionId,DataType,Description,DeveloperName,DurableId,EntityDefinitionId,ExtraTypeInfo,Id,IsApiFilterable,IsApiGroupable,IsApiSortable,IsCalculated,IsCompactLayoutable,IsCompound,IsFieldHistoryTracked,IsHighScaleNumber,IsHtmlFormatted,IsIndexed,IsListFilterable,IsListSortable,IsListVisible,IsNameField,IsNillable,IsPolymorphicForeignKey,IsSearchPrefilterable,IsWorkflowFilterable,Label,LastModifiedById,LastModifiedDate,Length,MasterLabel,NamespacePrefix,Precision,PublisherId,QualifiedApiName,ReferenceTargetField,ReferenceTo,RelationshipName,RunningUserFieldAccessId,Scale,SecurityClassification,ServiceDataTypeId,ValueTypeId FROM FieldDefinition where DurableId = 'Contact.MailingStreet'

or, simply put,

SELECT DeveloperName,DurableId,EntityDefinitionId FROM FieldDefinition where DurableId = 'Contact.MailingStreet'

Since this query returns zero results,

enter image description here

this means that there is no definition of field with name MailingStreet on Contact.

To be sure that there is no such field if you would try to adopt this logic for custom fields, you can change the filter criteria to include QualifiedApiName

SELECT DurableId FROM FieldDefinition where EntityDefinitionId = 'Contact' AND QualifiedApiName = 'MailingStreet'

enter image description here

While for real field like Mailing Address, the similar query would return result

enter image description here

To find all field parts of compound fields, query EntityParticle table.

SELECT ByteLength,DataType,DefaultValueFormula,DeveloperName,Digits,DurableId,EntityDefinitionId,ExtraTypeInfo,FieldDefinitionId,Id,InlineHelpText,IsApiFilterable,IsApiGroupable,IsApiSortable,IsAutonumber,IsCalculated,IsCaseSensitive,IsCompactLayoutable,IsComponent,IsCompound,IsCreatable,IsDefaultedOnCreate,IsDependentPicklist,IsDeprecatedAndHidden,IsDisplayLocationInDecimal,IsEncrypted,IsFieldHistoryTracked,IsHighScaleNumber,IsHtmlFormatted,IsIdLookup,IsLayoutable,IsListVisible,IsNameField,IsNamePointing,IsNillable,IsPermissionable,IsUnique,IsUpdatable,IsWorkflowFilterable,IsWriteRequiresMasterRead,Label,Length,Mask,MaskType,MasterLabel,Name,NamespacePrefix,Precision,QualifiedApiName,ReferenceTargetField,ReferenceTo,RelationshipName,RelationshipOrder,Scale,ServiceDataTypeId,ValueTypeId FROM EntityParticle where EntityDefinitionId = 'Contact' and IsCompound = false AND FieldDefinitionId IN (
SELECT DurableId FROM 
FieldDefinition
where IsCompound = true)

Since you can find MailingStreet record in these results, you can confirm that it is truly part of compound field. enter image description here

I think even better to check `IsComponent' property alone.

SELECT DataType,DeveloperName,DurableId,EntityDefinitionId,FieldDefinitionId,IsComponent,IsCompound,Label,Name,QualifiedApiName
FROM EntityParticle
where EntityDefinitionId = 'Contact' and IsComponent = true

So this query is simpler and returns the same 23 results.

enter image description here

Even it is possible to execute query to return this record without knowing its DurableId filtering by QualifiedApiName, Name or Label like this:

SELECT DataType,DeveloperName,DurableId,EntityDefinitionId,FieldDefinitionId,IsComponent,IsCompound,Label,Name,QualifiedApiName
FROM EntityParticle
where EntityDefinitionId = 'Contact' AND QualifiedApiName = 'MailingStreet'

enter image description here

Also, another way to find out if field is a component of a compound field without making SOQL queries is to check getCompoundFieldName() method on fieldDescribe result. It returns a name of Compound Field for a component of a compound field and returns null in other cases.

System.debug(LoggingLevel.ERROR, '@@@ v: ' + Test__c.Geolocation__Latitude__s.getDescribe().getCompoundFieldName() );
System.debug(LoggingLevel.ERROR, '@@@ v: ' + Test__c.Geolocation__c.getDescribe().getCompoundFieldName() );
System.debug(LoggingLevel.ERROR, '@@@ v: ' + Contact.MailingStreet.getDescribe().getCompoundFieldName() );
System.debug(LoggingLevel.ERROR, '@@@ v: ' + Contact.MailingAddress.getDescribe().getCompoundFieldName() );

enter image description here

So instead of checking Contact.MailingStreet.getDescribe().isPermissionable() you can check Contact.MailingStreet.getDescribe().isPermissionable() && Contact.MailingStreet.getDescribe().getCompoundFieldName() == null