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

What is Revenue Cloud?

Quote and Order·Admin

Context Definitions: One Unknown Attribute Drops the Whole Update

In the configurator, every line showed quantity 1 and list price, while the call reported success. The cause was one attribute missing from the production context.

Nathan Altmann · Revenue Cloud consultant at Meir IT

Published 4 min read

In 3 linesfor leadership

  1. For two months, the configurator showed wrong quantities and prices, with no error message.
  2. One attribute known in the sandbox but missing in production made the whole update get dropped.
  3. The code now sends only what production declares, and the right prices show on screen.
In this article (5 sections)
  1. Right on save, wrong in the configurator
  2. One unknown name rejects the whole batch
  3. Proof in two runs
  4. Send the attribute only if the context declares it
  5. In practice

Stage: instant pricing in the configurator, while the rep builds the quote. On this project, every line in the configurator showed a quantity of 1 and the list price, with no error message. Yet the same quote, once saved, had the right quantities and the right amounts. The problem lasted two months.

Right on save, wrong in the configurator

The rep filled in the parameters and ran instant pricing. Every line came back with a quantity of 1 and the list price. Nothing in the logs looked like a failure. When the quote was saved outside the configurator, with the same code and the same rules, quantities and amounts were right.

The project team ruled out thirteen leads one at a time, including the Procedure Plan, permissions, the configurator cache, an inactive procedure version, execution order and how instant pricing was wired. None of them explained why the same calculation gave two results depending on the path.

(If your bundle quantities stay at 1 only on the first save, the cause is probably something else: see Revenue Cloud Bundle Quantities Wrong on the First Save.)

One unknown name rejects the whole batch

An Apex hook, meaning code that runs before pricing, sent a small batch of attributes back to the configurator for each line, through updateContextAttributes. The batch held two names. The first carried the calculated quantity. The second was left over from a sandbox experiment: it was declared in the sandbox's context definition, not in production's. The field itself existed on the quote line in both orgs.

The context handles the batch as a whole. One name it doesn't know, and the entire batch is rejected, including the quantity, which was perfectly valid. The call still returns isSuccess: true. So the configurator got nothing to apply: it kept the quantity of 1 and the list price that goes with it, while the code and the logs reported success.

The cause took a long time to find because no error pointed to it, and attention went to the attribute that wasn't applied, the quantity, when the culprit was the one next to it. Above all, comparing objects between sandbox and production showed nothing, because the field existed on both sides. The difference was in the context definition's attributes, a layer people rarely compare between two orgs.

Proof in two runs

On a bug that has already survived thirteen theories, I don't trust an idea until it's tested. The team ran two passes with exactly one change between them:

  • batch unchanged, with both attributes: quantity 1, list price;
  • batch without the suspect name: right quantities and right prices, on screen.

Send the attribute only if the context declares it

Deleting the attribute wasn't an option, since the sandbox still needed it. The code now sends it only if the org's context declares it. The hook already has that information, because it reads the node's attribute values.

Code
// generic names
private static Boolean contextKnowsAttribute = false;
...
if (nodeValues.containsKey('Sandbox_Attribute__c')) {
    contextKnowsAttribute = true;
}
...
attributes.add(/* calculated quantity, always declared */);
if (contextKnowsAttribute) {
    attributes.add(/* the attribute only the sandbox declares */);
}

An "am I in a sandbox?" check was ruled out. With this version, if the attribute is ever added to the production context, the code will send it again without anyone touching it.

This fix had been tried that same morning in its blunt form, removing the attribute, then rolled back because two unit tests failed. Those tests built fake nodes without the attribute, so they were checking exactly the behavior that had just changed. That cost the bug another half day. Both tests were rewritten to declare the attribute, and they now describe the sandbox case.

In practice

  • After writing to the context, read the value back in the same test. isSuccess: true means the call went out, not that the value landed.
  • Retrieve the context definition from sandbox and production as metadata, and compare the two files attribute by attribute, on top of the object fields.
  • In code, send only the attributes the node declares, checking it the way the example above does.
  • When a unit test fails on a fix, read what it checks before rolling the fix back.
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.