Running into an error where dependent classes are invalid and need recompilation because no such column 'BillingAddress' on entity 'Account' exists. One recommendation was to create a class that pulls the information with a name that starts with aaa (so it appears first alphabetically).

Does Compile all classes run alphabetically? If not, how is the order determined?


Classes are compiled based on dependency, just like they would be in C++, Java, or other compiled languages. Adding a class that's "first" won't help resolve the error. You need to fix the class that's failing, then recompile all of the classes. Most likely, the class that's failing is using an older API version, so you might try updating it to a newer version.

For example, if you consider the following code:

public class A {
  public B value;

public class B {
  public A value;

If classes were strictly compiled alphabetically, then this code could not compile. Instead, the compiler is smart enough to start compiling one of the classes (A or B, doesn't matter), pause with the partial definition of that class, then move to the other class, referring to the partial definition of the first. Renaming these classes won't change anything.

Edit: Just confirmed, the Address data type (for BillingAddress, MailingAddress, etc) was introduced in v30.0 of the API. The class, and any class that depends on it, must be version 30.0 or higher, or you'll get this error.

  • So the recommendation that Salesforce Support provided is false.. compile
    – Kyle
    Jan 12 '18 at 21:25
  • 1
    @Kyle Support, while skilled, are not definitely not infallible. There's no evidence that the classes are compiled (strictly) alphabetically. I suspect that the Compile All Classes probably starts from the top alphabetically, but the files are parsed in dependency order, so the class that's causing the problem needs to be fixed directly.
    – sfdcfox
    Jan 12 '18 at 21:27

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.