Thursday, August 1, 2013

Salesforce names: what's not to use

To developers what matters are the API names because they're referenced in code, have strict rules on the composition, and harder to change.  That's why API names often automatically created for you when things are set up via the UI, and you have limited choices in what you can put in the API names.  However there are things in that don't really have the distinction between names (labels) and API names - they're one and the same.  For instance, workflow rules, layout, and profiles don't really have a separate API name.  Since they're plain names, Salesforce doesn't really restrict what characters you can use for them like API names.  That is fine most of the time, but could get you in trouble when migrating changes using SFMT, the ANT based tool.

The problem is with how ANT retrieve entities.  For things that will occupy its own file, such as profiles, their names become the files name.  If you use some character in entity name that's not compatible with file names (such as /), ANT won't complain but simply URL encode the character, so / becomes %2F.  This breaks the match between file names and your package.xml, which renders the whole thing undeployable.  For some reason ANT also does this to characters like period, which isn't even incompatible with file names.

So the advice is to stay safe with just letters, numbers, and underscore, so you know you can script deployment without worries.

No comments:

Post a Comment