0

How can I find standard fields in standard objects are Case Sensitive ? What's the default value Case Sensitive or Case Insensitive ?

  • 1
    are you talking about field API or field values? – Santanu Boral Aug 22 '17 at 14:08
3

All field API names in Salesforce, standard and custom, are case insensitive. That's the case when you're using Apex, at least.

There doesn't appear to be any official documentation to corroborate that, but it's easy enough to verify for yourself.

// Demonstrating that fields in SOQL queries are case-insensitive
// You'll need to replace my custom Account_Status__c field with a custom field
//   of your own.
List<Account> acctsList = [SELECT Id, Type, AcCoUnT_sTaTuS__c FROM Account LIMIT 1];
acctsList = [SELECT iD, TYPE, account_status__C FROM Account LIMIT 1];

// The order I debug the different possibilities in might look weird, but
//   there is a pattern to it.
// Only 1 letter changes its capitalization state from one line to the next.
// There isn't really much point to it here, it was just a good mental exercise.
// In boolean logic, doing this allows you to create a Karnaugh Map, which can
//   be used to simplify boolean logic.
system.debug(acctsList[0].id);
system.debug(acctsList[0].Id);
system.debug(acctsList[0].ID);
system.debug(acctsList[0].iD);

system.debug(acctsList[0].type);
system.debug(acctsList[0].Type);
system.debug(acctsList[0].TYpe);
system.debug(acctsList[0].tYpe);
system.debug(acctsList[0].tYPe);
system.debug(acctsList[0].TYPe);
system.debug(acctsList[0].TYPE);
system.debug(acctsList[0].tYPE);
system.debug(acctsList[0].tYpE);
system.debug(acctsList[0].TYpE);
system.debug(acctsList[0].TypE);
system.debug(acctsList[0].typE);
system.debug(acctsList[0].tyPE);
system.debug(acctsList[0].TyPE);
system.debug(acctsList[0].TyPe);
system.debug(acctsList[0].tyPe);

// I'm not so masochistic as to type out all the possibilities for my custom field,
// nor so sadistic to make you read it all.
system.debug(acctsList[0].ACCOUNT_STATUS__c);
system.debug(acctsList[0].account_StatuS__C);

SObject names, Type names, Class names, method names, and variable names are also case-insensitive in Apex.

List<Account> acctsList = new LiSt<ACcoUNt>();
AcCtSlIsT = new liST<ACCOUNT>();
ACCTSList = [SELECT iD, TYPE, Account_STATUS__C FROM AccounT LIMIT 1];

system.debug(acctsList.SiZe());

That said, just because you can use any combination of cases doesn't mean that you should. Picking a standard casing scheme, like

  • SObject and class names start with a capital letter
  • Method names and variable names start with a lower-case letter and useCamelCasing
  • SObject fields are Title_Case_With_Underscores__c

and sticking to it make it easier to read/write your code (and also prevent you from getting lazy and running into trouble with other programming languages).

| improve this answer | |

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.