"API name", "Unique name" or "developer name". Sounds familiar? They usually refer to the same thing: a unique piece of string that refers to a piece of metadata in a Salesforce org. You might not be too familiar with it, but every time you create a new custom object, field, record type, approval process, workflow rule, email alert or picklist value you name things in a programmatic way too (most of those - and many others - have also the "label" field, that is what your users see when interacting with those items). The problem is when you do this too quickly and forget to give the API name a proper name.
If you have developed some solution with code in the platform, or even with a little more advanced flows, you have probably worked with those names before. They show up all the time in code and flows. In fact, within the underlying metadata in your org all that matters for Salesforce is the API name. In Apex only the API name is ever used, too.
it is how an administrator names things that the platform glues together to make an application run. API names are part of the fundamental building blocks that allow the platform to be so flexible. API names are ultimately part of the user interface and experience, and the administrator is responsible to build and maintain these in a Salesforce org. Does that convince you? If not, then check the use case below.
And it looks like this in the picklist value list:
And in the Flow Builder experience it looks like this (ignore the fact that the picklist is called "Status"):
Notice that this piece of text has 250 characters. It is well within the limit of characters that Salesforce allows us to use for a picklist value. It is not pretty in the UI, for sure, but it is a requirement for now. When creating this picklist value in Setup Salesforce will create the API name automatically for you with a copy of the label. That's usually how it goes for small values.
Now imagine this 250-character is used in Apex:
The developer working on this might decide to use a global variable in Apex just so it is defined once, possibly adding tech-debt to the org's code:
Or they might assign the value directly wherever it is required. The code will occupy an entire editor's line if assigned directly. Worst case scenario: they might type it by hand and miss a letter or copy and paste it in parts, missing a character too. Anyway, the idea here is that a big API name is much more error-prone than a simpler and smaller value.
... you might be asking. It can and probably will if you not only use a huge text like that, but also if such text contains special characters like parenthesis. Let me explain: when you create a change set or make a deployment using a third-party tool like Gearset, Salesforce exports the metadata definition of your field and its picklist values to a XML file.
When this happens the special characters are HTML-encoded, meaning that the opening and closing parenthesis are replaced with "%28" and "%29" respectively, which are now three characters each. So what happens if you have two groups of parenthesis in your API name? Exactly: now they are not 4 characters, but 12. At 258 characters your picklist API name exceeded the limit and can no longer be deployed.
At this point the Salesforce API will return "Picklist value is too long for the max size of 255" to you.
And yes: this happens only for the API name, because that is the name that is actually saved in the database. Labels are stored elsewhere, for performance reasons. So when you view a record in your browser, the platform does its magic in both Classic and Lightning experiences and first fetches the record from the database with all fields with their "raw" API values.
Then it goes through another procedure where those are mapped to their labels so they can show up in the UI.
This can be easily solved by using - like mentioned before - simpler and shorter API names. Like "OPTION_A", for instance. The same principle applies to everything you create in Salesforce that has a "Developer Name" field. Look at how it is much more readable:
"But Salesforce should fix this, not us!" you might be thinking. But Salesforce themselves already stated in a Known Issue that they won't fix it. So maybe go a bit slower when creating new things in the org, and think more carefully about how they should be named? That might save you a few hours of debugging, code formatting and of course: deployment errors.
Discover how Empaua's partnership with The Delta ecosystem empowers your business with exclusive benefits, discounts, and a collaborative hub for innovation and growth. Learn about the unique advantages of joining The Delta, including the upcoming Delta Campus in Berlin and Cape Town.
This brand refresh marks a significant chapter for Empaua, a step further towards becoming the leading Salesforce consultancy in Europe, as well as a step closer towards our group company, The Delta.
On this International Day of Charity, we share some touching stories from Lynette, Desmond and Carolina behind their favourite organisations and the profound motivations that drive their commitment to give back.
Unleashing Revenue Operations Excellence with Salesforce: A Perspective from our CEO, Steffi Kromer. Read more about this here.
Holding a substantial 19.8% share of the CRM vendor market, Salesforce is a pioneer in adopting AI capabilities and technologies. A tool that helps companies and small businesses track their customer relationships is Salesforce CRM. AI, on the other hand, uses data to make smart predictions and automate tasks.
Ally is a term that gets used a lot in the LGBTQ+ community. However, being an ally is not just a buzzword, it is a commitment that goes beyond a single month of celebration. As we mark PRIDE Month, let's dive deeper into what it means to be an ally and how to show meaningful support for the LGBTQ+ community.