0

We have some picklist values (in various places both as part of a custom field and as a global picklist value set) that look something like this:

<customValue>
    <fullName>1</fullName>
    <default>false</default>
    <label>Choose this</label>
</customValue>
<customValue>
    <fullName>2</fullName>
    <default>false</default>
    <label>Choose the other thing</label>
</customValue>
...

This is just an example, but we have several places where we would like to change the API name to be that of the displayed label.

We would like to change the fullName to match the label.
So naturally we try that in SFDX, but whenever we do we get an error Duplicate label: Choose this.

How do I fix this?

0

Whenever you add picklist values then when changing the API Name they will be added as new labels and any deactivation of existing labels is done so after validating the deployment, this is why you get the error of Duplicate label.

Considering the below metadata, where I want to align the label and API Name of the "Finish A Lot" labelled item.

        <valueSetDefinition>
        <sorted>false</sorted>
        <value>
            <fullName>Start</fullName>
            <default>false</default>
            <label>Start</label>
        </value>
        <value>
            <fullName>Execute</fullName>
            <default>false</default>
            <label>Execute</label>
        </value>
        <value>
            <fullName>Finish</fullName>
            <default>false</default>
            <label>Finish</label>
        </value>
        <value>
            <fullName>Finish A</fullName>
            <default>false</default>
            <label>Finish A Lot</label>
        </value>
    </valueSetDefinition>

enter image description here

If you remove the picklist value from your metadata and deploy it then it moves to an inactive value. Doing this also aligns the label to that of the API Name (not sure why).

        <valueSetDefinition>
        <sorted>false</sorted>
        <value>
            <fullName>Start</fullName>
            <default>false</default>
            <label>Start</label>
        </value>
        <value>
            <fullName>Execute</fullName>
            <default>false</default>
            <label>Execute</label>
        </value>
        <value>
            <fullName>Finish</fullName>
            <default>false</default>
            <label>Finish</label>
        </value>
    </valueSetDefinition>

enter image description here

Once inactive then you can add the picklist value and do a secondary deploy.

enter image description here

In doing so you will then need to manually delete the inactive picklist value and replace values with your new picklist value (this is because the inactivation caused the label to be changed and so your records will refer to that now inactive label)

0

So what I ended up doing was two steps via SFDX:

  1. Delete all existing values while creating a new one (so the picklist isn't empty).
  2. Delete the dummy value while creating the old values with new lables.

Like so:
Stage 1

<!--<customValue>
    <fullName>1</fullName>
    <default>false</default>
    <label>Choose this</label>
</customValue>
<customValue>
    <fullName>2</fullName>
    <default>false</default>
    <label>Choose the other thing</label>
</customValue>
...-->
<customValue>
    <fullName>DeleteMe</fullName>
    <default>false</default>
    <label>DeleteMe</label>
</customValue>

Stage 2

<customValue>
    <fullName>Choose this</fullName>
    <default>false</default>
    <label>Choose this</label>
</customValue>
<customValue>
    <fullName>Choose the other thing</fullName>
    <default>false</default>
    <label>Choose the other thing</label>
</customValue>
...
<!--<customValue>
    <fullName>DeleteMe</fullName>
    <default>false</default>
    <label>DeleteMe</label>
</customValue>-->

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.