Length of “Name” field in “List” setting type custom settings

I’m using a List Custom Setting to allow some attributes used in Apex code to be configured for each picklist entry of a field. So it is natural to make the “Name” of the setting correspond to one of the picklist entries, and then add custom fields to hold the attributes. But a gotcha with this approach is the length of what can be stored in the “Name” field.

First of all the “Name” field reports its length in e.g. the schema browser in Eclipse as 38 characters. But if you hard code that assumption – e.g. truncate any field you are trying to match to 38 characters – you are still at risk of a second problem. That second problem is that the length limit applies to the URL encoded form of the text being entered for the “Name” (confirmed by Salesforce support).

For example this 7 character string:

A/B 'C'

consumes 13 of the available 38 characters in its URL encoded form:


Note that apart from the length problem this encoding is not visible to code using the custom setting i.e. Apex code always sees the unencoded form.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s