Question:

Deployment fails when deploying picklist fields that contain URL encoded values

Olivia: 5 days ago

I'm trying to deploy a picklist field with long string values. The current limit is 255 characters, which isn't a problem except when the string contains characters that salesforce URL encodes, in which case the Custom_Object__c.object file contains values greater than 255 characters. When deploying, Salesforce errors with Error: Picklist value is too long for the max size of 255

e.g.

Salesforce will change A value, with (extra) URL encoded values to A value%2c with %28extra%29 URL encoded values which contains 6 extra characters. This obviously becomes a problem with strings that are at or close to the 255 character limit.

The solution I'm currently using is to edit the file in notepad++ using the MIME Tools > URL Decode function.

What solutions have other people used to get around this?

This has been raised as a 'known issue': https://success.salesforce.com/issues_view?id=a1p300000008XZeAAM

Answer:
Jade: 5 days ago

Keep in mind though that in some cases you will also have to do an xml-escape after decoding url-encoded characters to avoid this error:

Error parsing file: The content of elements must consist of well-formed character data or markup.

For example, if you have this picklist value:

enter image description here

It will be retrieved in record types as:

<fullName>Not Equal %3C%3E</fullName>

URL decoding would give you:

<fullName>Not Equal <></fullName>

To deploy, you also need to xml-escape:

<fullName>Not Equal &lt;&gt;</fullName>

Although, that being said, I typically keep my picklist values very short, and if I need to display a longer value, I will set that as a translation. We have found it useful when we pull data out of salesforce or integrate with other systems, but it would help in avoiding this type of problem as well.

package.xml

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Account</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>Account-en_US</members>
        <name>CustomObjectTranslation</name>
    </types>
    <version>29.0</version>
</Package>

objects/Account.object

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <fields>
        <fullName>Picklist__c</fullName>
        <externalId>false</externalId>
        <label>Picklist</label>
        <picklist>
            <picklistValues>
                <fullName>NotEqual</fullName>
                <default>false</default>
            </picklistValues>
            <sorted>false</sorted>
        </picklist>
        <trackFeedHistory>false</trackFeedHistory>
        <trackHistory>false</trackHistory>
        <type>Picklist</type>
    </fields>
</CustomObject>

objectTranslations/Account-en_US.objectTranslation

<?xml version="1.0" encoding="UTF-8"?>
<CustomObjectTranslation xmlns="http://soap.sforce.com/2006/04/metadata">
    <fields>
        <label><!-- Picklist --></label>
        <name>Picklist__c</name>
        <picklistValues>
            <masterLabel>NotEqual</masterLabel>
            <translation>Not Equal &lt;&gt;   and whatever else you want to put here, up to 255 characters, with xml escape characters each counting as one.</translation>
        </picklistValues>
    </fields>
</CustomObjectTranslation>