0

We're migrating to Salesforce and the question has come up whether API name capitalization matters or not. I know SOQL queries are case-insensitive. Where would the capitalization of API names make a difference?

2 Answers 2

3

As a general rule, for XML- and JavaScript-based features, the API names are case-sensitive, and for JSON-, Apex-, and Visualforce-based features, it is case-insensitive, as well as basic features like SOQL, SOSL, and Formula Fields.

Aside from programming in Lightning, you'll find that most of your day-to-day work is case-insensitive. Apex and Visualforce are case-insensitive both in query execution and accessing the data (aside from Visualforce's Remote Objects, which is JavaScript-based), and queries you perform in the Developer Console or most popular query tools are all case-insensitive as well.

When you get down to using things like Salesforce DX or the Ant Migration Toolkit, as well as writing Aura and LWC-based components and applications, everything is then case-sensitive. This is because these tools are based on XML and JavaScript, respectively, both of which are case-sensitive by definition, not just for API names, but also command names, function calls, etc.

It sounds a bit daunting, but just remember the rules from the first paragraph, and that should cover you 99% of the time. I prefer to always be case-correct anyways, as I feel it's easier to read, but you can choose to come up with your own rules within the limits.

3

The Apex language is case-insensitive, but having a consistent casing pattern in your code base is a simple way to make your code easier to understand by people. The most significant convention is to distinguish between class names and method and property names.

See:

  • Naming Conventions which is the convention used in Salesforce platform API documentation.
  • But watch out for Name Shadowing that is a bigger problem in Apex than in case-sensitive languages.
2
  • By api names I meant the api names of fields. Was that clear?
    – sFishman
    Jan 11, 2021 at 14:40
  • Hi @sFishman, Not to me. Note that field names are case-sensitive in JavaScript code. Plus the consistency argument also applies for people looking at the code.
    – Keith C
    Jan 11, 2021 at 17:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .