In this article (4 sections)
Stage: the quote PDF, and the pricing run that comes before it. The client's ask: don't print $0 lines, unless the rep wants to show the customer a concession, like free maintenance. Choosing where that rule should live ended up touching the pricing procedure, and breaking amendments.
An editable checkbox instead of a formula
A formula field checked whenever the price isn't zero handled the general case. But a formula can't be edited by hand, so a rep couldn't have shown free maintenance to let the customer see the discount. It needed a real checkbox on the quote line, and a rule that checks it automatically when the line has a price.
Three places the rule could live
- A flow on the quote line. Ruled out. Revenue Cloud's line editor saves through its own API, and a flow updating the same line at the same moment caused save conflicts on this project (seen on this one project only).
- An Apex hook, code plugged into pricing. Doable, but it means creating a Procedure Plan and changing how all pricing gets invoked, which is way too much for a checkbox.
- A step in the pricing procedure. Chosen. The field is declared in the transaction context (the in-memory picture of the quote the procedure works on), and an assignment step checks it when the net price is positive.
The rule checks the box but never unchecks it. A $0 line checked by hand stays checked; a priced line unchecked by hand gets checked again on the next calculation. So reps can show a $0 line, but they can't hide a paid one.
Why amendments broke
A few days later, asset amendments started failing. By putting the rule in the pricing procedure, it had become a pricing step, run on every path, including the ones where a line doesn't have a price yet. That's the case during an amendment. The "net price greater than zero" filter was comparing an empty price to zero, and that comparison failed the whole calculation instead of just skipping the step.
NetUnitPrice GreaterThan 0The fix is one condition: check that the price exists before comparing it.
NetUnitPrice IsNotNull
AND NetUnitPrice GreaterThan 0With the filter fixed, amendments were still blocked, for an older reason. In an amendment, the lines you don't touch come back flagged as unchanged, and Revenue Cloud won't let a discount apply to them. The percentage discount used for the free maintenance was applying to them too. After proving it on a copy of the procedure, that discount was limited to new sales.
In practice
- Treat a display rule that lives in the pricing procedure like a pricing rule: it runs on every calculation, on every path.
- In every filter that compares an amount, check first that the amount exists.
- Make every procedure change in a new version, and keep the old one ready to reactivate.
- Test first on a copy of the procedure that no quote uses, with a dry-run calculation.
- After every change, replay four paths: new sale, renewal, amendment, and recalculating an existing quote.