Custom metadata type entity/field definition relationships not rendered properly into the OST

Issue #1414 resolved
Scott Wells repo owner created an issue

This issue is based on a discussion in this group thread:

https://groups.google.com/a/illuminatedcloud.com/d/msg/qanda/ONGwmr_Nfgo/5gt7-FVkBAAJ

It appears that when you create a relationship field in a custom metadata type against an entity or field definition, the field is not treated as a relationship properly. Only the ID portion of the relationship field is rendered into the OST and not the actual relationship part.

Comments (3)

  1. Scott Wells reporter

    The main issue is that these relationship fields aren't reported as being relationships directly. The field type is STRING instead of REFERENCE. It does appear that the field carries some indication of it being more than just a string, though, in the form of its extraTypeInfo which has a value of externallookup. I'll need to use that to render this properly into the OST.

  2. Scott Wells reporter

    Okay, I've fixed this for the next build. Here's the result of an OST generation for a custom MDT with entity and field definition relationships:

    Custom MDT

    /**
     * <h3>Parent MDT</h3>
     */
    global class Parent_MDT__mdt extends SObject 
    {
        ...
        /**
         * <h3>Entity Definition Link</h3>
         * <h3>Field Attributes</h3>
         * <table border="0" valign="top">
         * <tr><td><b>Data Type:</b></td><td>Metadata Relationship</td></tr>
         * <tr><td><b>Required:</b></td><td>false</td></tr>
         * <tr><td><b>Unique:</b></td><td>false</td></tr>
         * <tr><td><b>External ID:</b></td><td>false</td></tr>
         * </table>
         */
        global Id Entity_Definition_Link__c;
        /**
         * <h3>Entity Definition Link</h3>
         * <h3>Field Attributes</h3>
         * <table border="0" valign="top">
         * <tr><td><b>Data Type:</b></td><td>Metadata Relationship</td></tr>
         * <tr><td><b>Required:</b></td><td>false</td></tr>
         * <tr><td><b>Unique:</b></td><td>false</td></tr>
         * <tr><td><b>External ID:</b></td><td>false</td></tr>
         * </table>
         */
        global EntityDefinition Entity_Definition_Link__r;
        /**
         * <h3>Field Definition Link</h3>
         * <h3>Field Attributes</h3>
         * <table border="0" valign="top">
         * <tr><td><b>Data Type:</b></td><td>Metadata Relationship</td></tr>
         * <tr><td><b>Required:</b></td><td>false</td></tr>
         * <tr><td><b>Unique:</b></td><td>false</td></tr>
         * <tr><td><b>External ID:</b></td><td>false</td></tr>
         * </table>
         */
        global Id Field_Definition_Link__c;
        /**
         * <h3>Field Definition Link</h3>
         * <h3>Field Attributes</h3>
         * <table border="0" valign="top">
         * <tr><td><b>Data Type:</b></td><td>Metadata Relationship</td></tr>
         * <tr><td><b>Required:</b></td><td>false</td></tr>
         * <tr><td><b>Unique:</b></td><td>false</td></tr>
         * <tr><td><b>External ID:</b></td><td>false</td></tr>
         * </table>
         */
        global FieldDefinition Field_Definition_Link__r;
        ...
    
        global Parent_MDT__mdt()
        {
        }
    }
    

    EntityDefinition

    global class EntityDefinition extends SObject 
    {
        ...
        /**
         * The reciprocal relationship for <a href="psi_element://Parent_MDT__mdt.Entity_Definition_Link__c"><code>Parent_MDT__mdt.Entity_Definition_Link__c</code></a>.
         */
        global List<Parent_MDT__mdt> Parent_MDTs__r;
        ...
    
        global EntityDefinition()
        {
        }
    }
    

    FieldDefinition

    global class FieldDefinition extends SObject 
    {
        ...
        /**
         * The reciprocal relationship for <a href="psi_element://Parent_MDT__mdt.Field_Definition_Link__c"><code>Parent_MDT__mdt.Field_Definition_Link__c</code></a>.
         */
        global List<Parent_MDT__mdt> Parent_MDTs__r;
        ...
    
        global FieldDefinition()
        {
        }
    }
    

    Hopefully that will put this to rest. Thanks again for the input!

  3. Log in to comment