The context service: context definitions and mappings
Why pricing, configuration and billing work on a context rather than directly on records, standard and custom context definitions, nodes, attributes and mappings to objects, extending context for custom fields, and performance considerations.
Simple explanation
Context is a structured, in-memory view of a transaction (for example a quote with its lines, attributes and account) that engines read and write.
Why it exists
- Engines (pricing, configurator, billing) can work on any source: a saved quote, a cart, an API payload, without each engine querying records its own way.
- Performance: data is loaded once and shared.
- Consistency: every channel prices the same way.
Pieces
| Piece | Meaning |
|---|---|
| Context definition | The shape: nodes (for example SalesTransaction, SalesTransactionItem), attributes and relationships |
| Mapping | How nodes and attributes map to objects and fields (quote, order, cart) |
| Tags | Names engines use to find attributes |
Extending
- Standard context definitions ship with Revenue Management; extend (clone/extend) them to add custom fields used in pricing or rules, then map those fields β verify exact extension mechanism in your release.
- Keep contexts lean: every extra attribute is loaded for every transaction.
Real-world analogy
The context is a shared tray the kitchen staff use: the waiter puts the order on the tray once, the chef, the pastry cook and the cashier all work from the same tray instead of each walking to the dining room to ask the customer again.
Worked example
A company prices by customer industry and contract term. It extends the sales transaction context with the account's industry and a custom term field, maps them for quotes and orders, and references them in a pricing procedure's decision table.
Diagram
Key points
- Engines work on a context, not directly on records.
- Context definitions define the shape; mappings link to objects.
- Extend standard definitions for custom fields.
- Keep context lean for performance.
- Context lets any channel use the same engines.
Limits and gotchas
- Forgetting to map a custom field means pricing can't see it; symptoms look like pricing bugs.
- Large contexts slow down big quotes.
- Changes to context definitions affect every engine using them; test across pricing, configuration and billing.
π€ How to say this in an interview
Explain why context exists and give an example of extending it for a custom pricing attribute.
Common follow-ups
A new custom field isn't affecting price. What do you check?
That the context definition includes the attribute, it's mapped for the object in use, and the pricing procedure references the right tag.
Why not query records inside pricing logic?
It duplicates queries, slows large transactions and breaks consistency across channels.