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

What is Revenue Cloud?

Quote and Order·Admin

"sObject type is not supported": A Trigger That Blocks Every Quote

Suddenly no quote would save, except for admins. A trigger was reading an object new users had no access to, and then fields they couldn't see.

Nathan Altmann · Revenue Cloud consultant at Meir IT

Published 4 min read

In 3 linesfor leadership

  1. One morning, no user other than administrators could save a quote or an order anymore.
  2. New profiles had no access to a custom pricing-rules module that every quote checked on save.
  3. Read access was granted to the whole module; from then on, ask for each release to be tested as a non-admin.
In this article (5 sections)
  1. The error, and what had changed
  2. Why every quote failed
  3. Open the whole module, read-only
  4. Two days later: the fields
  5. In practice

Stage: saving the quote. On every save, a trigger on the quote read the objects of a pricing rules module built for the client. One morning, no user except admins could save a quote, or an order, or anything that touches the Quote object. The day before, everything worked.

The error, and what had changed

This was the error that came back:

Code
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: QuoteAfterUpdate: execution of AfterUpdate
caused by: System.QueryException: sObject type 'Rate_Offer__c' is not supported

(Trigger and object names changed.)

Nothing had been deployed recently: the failing code had been running in production for weeks. What had changed was the users. New profiles had just been added, with no access at all to the custom object that holds the pricing rule configuration.

Why every quote failed

People often say Apex runs in system mode and ignores the user's permissions. Here, that didn't protect the query. For a user with no access to the object, not even read, the query naming it didn't return zero rows. It threw an exception, and the whole save failed. I didn't pin down why this particular code wasn't getting system mode. The first thing to look for is a query running in user mode somewhere in the classes it calls.

That left the question of why every quote was affected, not just the ones that use those rules. The after-save trigger queried the configuration object on every save, to find out whether there was anything to calculate. It asked "is there a rule for this quote?" before knowing whether the quote was in scope. So a module added for a handful of offers had become something every quote in the org depended on, including tens of thousands of older quotes that never use it.

Open the whole module, read-only

The client's first move was to grant access to the object named in the error. That wasn't enough: the trigger and the classes it calls read six objects from the same module (the offer, the rules, their conditions, their inputs, the linked products and the rate tables). Unblocking the first one moved the error to the second, as soon as a quote actually went through the calculation.

So the project team listed every query in the call tree and granted the whole module, read-only, in a permission set assigned broadly. Profiles weren't touched: a permission set is easy to read, audit and remove, and it doesn't depend on whatever profiles get created later. To assign it to new users automatically, User Access Policies handle that out of the box.

Two days later: the fields

A business user who did have access to all six objects reported a different error:

Code
No such column 'Override_Allowed__c' on entity 'Pricing_Rule__c'

The field existed: deployed, and referenced in the class. But it wasn't visible to that user, and the query naming it threw an exception, just like the object. So "No such column" meant this user couldn't see the column, not that it was missing.

For a configuration object read by code, the team chose to grant View All Fields in the permission set. The code reads fields no page shows, and that list grows with every new feature.

In practice

The code worked for the admin who deployed it and broke for the first user without access. The gap between the two is however long it takes a non-admin to open a quote. Hence these habits:

  • In the release that adds an object or field read by a shared trigger, add read access to it in the permission set. Permissions ship with the code, never after.
  • Before every release, save a quote that has nothing to do with the new feature, using a non-admin account.
  • When the error names an object, list every query in the call tree and open every object they read, not just the one in the message.
  • In the trigger, check that the quote is in scope before querying the module.
  • When you see "No such column" on a field that exists, check that user's field-level security before suspecting the metadata.
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.