When creating Custom Metadata entries (especially via API) with relationship fields into other objects, you are limited to certain SObjects that can be used.

The Custom Metadata implementation guide mentions:

The value of a relationship field with the EntityDefinition domain is a custom or standard object that:
• Supports custom fields
• Supports Apex triggers
• Supports custom layouts
• Is not a type of activity, such as a Task or Event
• Is not the User object
• Is not a Trialforce object, such as a SignupRequest

Here I'm asking what is a programmatic way whether an arbitrary SObject is useable in that relationship. The first three requirements doesn't seem to hold water:

        QualifiedApiName IN ('Territory2')

Returns true for all fields, but is not valid value. I get INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST: (SObject__c) SObject: bad value for restricted picklist field: Territory2 when deploying via API and it's not available when creating record from UI.

So the question is what other attributes define whether field is relatable?

My code right now is:

@AuraEnabled public static Boolean isObjectRelatable(String sobjectName){
    if(String.isEmpty(sobjectName) || sobjectName == 'User' || sobjectName == 'Event' || sobjectName == 'Task'){
        return false;
    Integer count = [SELECT
            QualifiedApiName =: sobjectName
            AND IsLayoutable = TRUE
            AND IsCustomizable = TRUE
            AND IsApexTriggerable = TRUE
    return count != 0;

I'm not too worried about Trialforce objects at the moment.

  • n.b. the only hole in my theory is IsCustomizable field which someone else in this site correlated with Supports custom fields - I am not 100% sure whether that is true.
    – dzh
    Apr 9, 2020 at 10:27

1 Answer 1


Aha, yes, the docs need some clarification here. The bullet point "is not the User object" is incomplete.

You can't point EntityDefinition relationships to any entity that is on the "mixed DML" list - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects.htm.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .