3

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

  • 1
    Are you just using xmlstarlet unesc to decode url-encoded characters, or do you also use the program to escape xml? – martin Sep 9 '15 at 5:24
  • Thanks, I had another look and I think I've misunderstood what the xmlstarlet is doing in jenkins. We're not using it for this purpose, and it probably wouldn't work either. I'll remove it from the original question. – Nick Cook Sep 9 '15 at 5:55
2

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>
| improve this answer | |
  • That's a really good point. This would mean though that we're back at square one where a long string that is then xml escaped may exceed Salesforce's 255 character limit. I'm assuming it's so unlikely to happen that Salesforce aren't going to spend the time on it. – Nick Cook Sep 9 '15 at 7:01
  • @NickCook actually you are fine with xml-escaped values. They will be converted before the validation. – martin Sep 9 '15 at 7:03

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.