2

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?

1 Answer 1

5

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.

2
  • So the recommendation that Salesforce Support provided is false.. compile
    – Kyle
    Commented Jan 12, 2018 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
    Commented Jan 12, 2018 at 21:27

You must log in to answer this question.

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