3

We want to use some of Product object standard fields and just change field labels to make them more tailored for our organization.

For example: Product Code -> EAN Code

This can be achieved by going to Rename Tabs and Labels but since we are using pipelines and have many developer orgs we want to avoid manual steps.

The question is: how to retrieve and deploy this using mdapi of sfdx?

What I tried was:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Product2-en_US</members>
        <name>CustomObjectTranslation</name>
    </types>
    <types>
        <members>Product2</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>Product2.ProductCode</members>
        <name>CustomField</name>
    </types>
    <types>
        <members>Product2.ProductCode</members>
        <name>CustomFieldTranslation</name>
    </types>
    <version>48.0</version>
</Package>

But this retrieves the field without the label.

When adding it manually to CustomField metadata file I get following error: Cannot specify label on standard field (3:13)

I also tried retrieving just the Product2's CustomObjectTranslation using following package.xml:

<types>
    <members>Product2-en_US</members>
    <name>CustomObjectTranslation</name>
</types>

And this returns empty file:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObjectTranslation xmlns="http://soap.sforce.com/2006/04/metadata"/>

2 Answers 2

3

As per pointed out by Salesforce Support when I asked them directly,

You should add the following extract to your package.xml file:

<types>
        <members>Product-en_US</members>
        <name>CustomObjectTranslation</name>
</types>

Hope this helps someone in the future.

Edit for clarity: Notice there's no "2" in the line

<members>Product-en_US</members>
2

The metadata you want is the CustomObjectTranslation.

It'll include metadata similar to this example (from a renaming of the Account object to Organization, and similar renamings at the field level):

    <fields>
        <caseValues>
            <plural>false</plural>
            <value>Organization Number</value>
        </caseValues>
        <name>account_number</name>
        <startsWith>Vowel</startsWith>
    </fields>

The CustomObject and CustomField metadata won't change, because you cannot actually alter the label of the standard field. Your renaming is encapsulated in the CustomObjectTranslation, and you can deploy it into other orgs via that vehicle.

4
  • Thanks David for your comment. Tried this with no success - empty file is returned. I will update my question to note that
    – neff
    Feb 18, 2020 at 16:24
  • I think CustomObjectTranslation works similiar to profiles - retrieves just the translations for other members in the package xml - at least this is how it works for custom fields.
    – neff
    Feb 18, 2020 at 16:33
  • I am able to retrieve via below with VS Code but can't deploy, any thoughts? <types> <members>*</members> <name>CustomObjectTranslation</name></types>
    – Usman
    May 26, 2021 at 10:51
  • @Usman Please open a new question.
    – David Reed
    May 26, 2021 at 13:09

You must log in to answer this question.

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