Skip to main content

Discount tiers with conditional auto fields

Apply different discount rates from rules on the same record — for example by customer type, order size, or age. Use an auto field with several conditional rules; Bobuild evaluates them in order.

When to use this​

  • VIP / retail / wholesale discount percentages
  • Volume tiers (subtotal brackets)
  • Promo rates based on a Choice field or linked customer attributes

For a one-off percentage typed on the form, a plain Number field (or a live formula for the discounted amount) is enough — no tiers required.

Data model​

ObjectKey fields
Customer (optional)type (Choice: Retail / VIP / Partner), birth_date (Date, optional)
Ordercustomer (Reference), subtotal (Number, auto sum), discount_pct (Number, auto), discount_amount (Number, auto), total (Number, auto)

You can put the percentage on Customer instead and copy it onto the order with Set to a field value (customer → discount_pct).

Steps​

1. Subtotal​

Roll up line amounts into subtotal — see Sum of prices.

2. Percentage from conditional rules​

On Order (or Customer), create Number field discount_pct:

  1. Enable Automatic Value.
  2. Add one rule per tier. Example on Order using the linked customer:
WhenSet to a given value
customer.type is VIP15
customer.type is Partner10
(no condition — or default value)0

Rules run top to bottom; with Set this field → to the last rule that matches, the first matching rule wins if you stop overlapping conditions — keep tiers mutually exclusive, or put the most specific rules first and rely on last-match if you configure overlaps intentionally.

The age-based example in Auto fields — Conditional rules is the same idea with date conditions.

3. Amounts​

Add numeric-expression auto fields:

FieldExpression
discount_amount{subtotal} * {discount_pct} / 100
total{subtotal} - {discount_amount}

4. Volume tiers (optional)​

Instead of (or in addition to) customer type, condition on subtotal:

Whendiscount_pct
subtotal ≥ 100010
subtotal ≥ 5005
default0

Order the rules from highest threshold to lowest so the strongest tier wins under last-match, or keep ranges non-overlapping.

Tips​

  • Store the percentage and computed amounts on the order so later customer-type changes do not rewrite closed orders (same snapshot idea as priced dropdowns).
  • Show discount_pct and total on the order Detail or KPI Cards.
  • Deep chains of auto fields slow writes — keep the chain shallow (subtotal → % → amounts).