2

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"/>
1

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.

| improve this answer | |
  • 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 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 at 16:33

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.