0

I saw the following example in the Salesforce Docs for creating fields using the metadata api: My question is - How does the system know to create a field on the account standard object? I cannot find anything that indicates that this xml file will deploy the fields onto the Account Standard object? I think I just do not understand how the file structure of these xml files works.

The following is the definition for two fields on the Account standard object—a custom field (MyCustomAccountField__c), and a standard field (Phone) that has history tracking enabled.

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <fields>
        <fullName>MyCustomAccountField__c</fullName>
        <description>A custom field on the Account standard object.</description>
        <externalId>false</externalId>
        <inlineHelpText>Some help text.</inlineHelpText>
        <label>MyCustomAccountField</label>
        <length>100</length>
        <required>false</required>
        <trackFeedHistory>false</trackFeedHistory>
        <trackHistory>false</trackHistory>
        <type>Text</type>
        <unique>false</unique>
    </fields>
    <fields>
        <fullName>Phone</fullName>
        <trackFeedHistory>false</trackFeedHistory>
        <trackHistory>true</trackHistory>
    </fields>
</CustomObject>

1 Answer 1

4

In the provided example, the core thing to bound this field to account is naming of .xml file.

It will be Account.object-meta.xml. Therefore, the fields in xml with such name will be added to Account.

It is also very important to deploy your archived xml files with proper names, so the organization understands what you want from it.

8
  • I have a custom object called "Top of the Funnel Trending" with the developer name "Top_of_the_Funnel_Trending__c" - would this be Top_of_the_Funnel_Trending__c.Object-meta.xml? Commented Oct 17, 2019 at 14:01
  • Yes, you are right, except for object in the lower case. Commented Oct 17, 2019 at 14:02
  • So what would the zip file look like? Just a zip with - Top_of_the_Funnel_Trending__c.object-meta.xml? Commented Oct 17, 2019 at 14:03
  • 1
    @MatthewMetros You would have a package.xml that names the Account CustomObject (standard objects are also named as custom objects in the Metadata API), a folder called objects, and a Account.object-meta.xml file in the objects folder.
    – sfdcfox
    Commented Oct 17, 2019 at 14:06
  • @MatthewMetros The comment above clearly describes the process. However, you can use sfdx commands to simplify the process. Open the terminal, go to the folder with your project. 1) mkdir mdapi 2) sfdx force:source:convert -d mdapi/ 3) sfdx force:mdapi:deploy -d mdapi/ -u [email protected] Commented Oct 17, 2019 at 14:09

You must log in to answer this question.

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