Revenue Cloud project notebook, written by two Meir IT consultants who implement it.

What is Revenue Cloud?

Projects and Integration·Admin

“No Such Column”: An API Version Problem

Stage: tax calculation on invoice lines. An Apex class saved on an older API version can't see fields added in a later one, even through dynamic SOQL.

Nathan Altmann · Revenue Cloud consultant at Meir IT

Published 2 min read

In 3 linesfor leadership

  1. The tax calculation code couldn't find a field that clearly existed and held data.
  2. The code was saved on an old API version, which doesn't see fields added later.
  3. Raising that version fixed it; do the same whenever code starts using newer fields.
In this article (4 sections)
  1. The first fix tried
  2. Why the class can't see the field
  3. In practice
  4. Sources

Stage: tax calculation on invoice lines. The project was building an Apex tax engine adapter that looked up the rate for a postal code and a product code. Both fields existed on the rate object, with data in them, visible in the UI and in the object describe. The query inside the class kept answering No such column.

The first fix tried

The obvious suspect is the query. The next step is usually to rebuild it as a string, with dynamic SOQL, to get around whatever the compiler dislikes. It changes nothing, and that's what makes this one expensive: two attempts, the same error, and a field that clearly exists.

Why the class can't see the field

Every Apex class is saved with an API version, and it sees the data model as it was in that version. Those two fields exist from API 66.0 onward. For a class saved on an earlier version, they don't exist, whatever the org shows elsewhere. Dynamic SOQL runs under the same class, so it gets the same answer. The fix was to save the class on API 66.0 or later.

The signal to recognize is a field that exists everywhere except inside one class. The same error has a second common cause: a freshly deployed custom field stays invisible to SOQL and Apex until field-level security is granted, which looks just like a failed deployment.

In practice

  • When a field is visible everywhere except in the code, open the class's metadata and check its API version before touching the query.
  • Grant field-level security right after deploying a field, before testing any query.
  • When a class starts using newer fields, raise its API version in the same change, and rerun its tests.

Sources

  1. TaxRate
A technical question about this article?

A question about this article? I reply within 48 hours.

Something unclear, a mistake, or different behavior in your Salesforce org? Write to me.

Prefer email? Write to nathan@meir-it.com

Get notified of new articles

Type at least two letters.