6

I create an app using sfdx and at one point I convert it as a package using:

  • sfdx force:source:convert --outputdir mdapi_packageName --packagename packageName
  • and installing on a (other) org using sfdx force:mdapi:deploy --deploydir mdapi_packageName --targetusername username.

My package contains custom metatadata type with two String fields and one record. The goal is to let user (System admin) fill the content of this record after installation but those two fields are not accessible in setup.

Metadata definition:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <description>Description</description>
    <label>Label</label>
    <pluralLabel>Descriptions</pluralLabel>
    <visibility>Public</visibility>
</CustomObject>

Record:

<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <label>Record</label>
    <protected>false</protected>
    <values>
        <field>fieldA__c</field>
        <value xsi:type="xsd:string"></value>
    </values>
    <values>
        <field>fieldB__c</field>
        <value xsi:type="xsd:string"></value>
    </values>
</CustomMetadata>

I can't find documentation I read yesterday but it seems that user need a permission (via permission set or profile) to be able to do it (Customize Application if I remember correctly) and it is set but still not working.

Edit: I miss the field definition from other files with sfdx:

Metadata 1:

<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>FieldA__c</fullName>
    <externalId>false</externalId>
    <fieldManageability>SubscriberControlled</fieldManageability>
    <label>Field A</label>
    <length>255</length>
    <required>false</required>
    <type>Text</type>
    <unique>false</unique>
</CustomField>

Metadata 2:

<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>FieldB__c</fullName>
    <externalId>false</externalId>
    <fieldManageability>SubscriberControlled</fieldManageability>
    <label>Field B</label>
    <length>255</length>
    <required>false</required>
    <type>Text</type>
    <unique>false</unique>
</CustomField>
2
  • 1
    To clarify, is the Custom Metadata type available but not its custom fields? Are you accessing Setup as a System Administrator or a user with a smaller suite of permissions?
    – David Reed
    Apr 11 '18 at 11:50
  • 1
    Custom Metadata Type is available but not its custom fields, yes. As System admin
    – Simonp
    Apr 12 '18 at 9:40
2

Seems to me like the metadata file that describes your custom metadata type is missing something.

If you take a look at the Custom Metadata Type documentation (from the metadata api), we do have the ability to specify fields.

In fact, the example xml file given contains a custom field:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
   <fields>
      <fullName>AlphaSort__c</fullName>
      <defaultValue>false</defaultValue>
      <externalId>false</externalId>
      <label>Sorted Alphabetically</label>
      <type>Checkbox</type>
   </fields>
   <label>Reusable Picklist</label>
   <pluralLabel>Reusable Picklist</pluralLabel>
   <visibility>Public</visibility>
</CustomObject>

I don't see any custom fields defined in your metadata file. If your custom setting did not exist in your target org prior to your deployment through sfdx, then I'd expect that the metadata you've provided would create the custom metadata type with no fields.

The bit about needing the Customize Application permission seems to come from the "field manageability" options for fields of custom metadata types.

About the only explanation that I can think of for why your custom metadata type xml file ended up the way it did was that the "source form" for your custom metadata type did not contain the "fields" sub-folder. Alternatively, if you created the custom metadata type in a scratch org, and had the "fields" sub-folder in your .forceignore file, then sfdx force:source:pull would have ignored it and just given you the barest of metadata for the custom metadata type itself.

1
  • Sorry, I forgot to paste the custom field definition (cf. original post). You are right that maybe the fields folder is not pushed, I will double check but nothing is included in the .forceignore.
    – Simonp
    Apr 12 '18 at 10:02
1

Do you possibly mean that the fields do not appear when you try to view or create new records of this Custom Metadata Type? One thing I noticed with Custom Metadata types is, the page layout assignments live on Profiles. So if you deployed this stuff in a new org, its Profiles might have no Page Layout Assignments for this CM type. In which case the create/view/edit pages will have no fields on them.

1
  • Thank you!! This helped me a lot.
    – mchandler
    Jul 2 '19 at 20:35
0

Building upon @CharlesT's answer

The custom metadata type gets sprayed all over your SFDX project:

MDT Aspect SFDX Path What?
fields, views /objects __mdt fields and object definition, customized listViews
layouts /layouts Fields shown in the Setup when editing any MDT
values /customMetaData actual saved-to-org custom records
visibility /profiles/** layout permissions**

** I'm not sure about the 4th one as I double-check my metadata, I may come back and update this answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.