Effects Autocomplete

Learn more about available autocomplete options for the effects, and how to use templates and variables.

What It Does

Open Loyalty provides powerful autocomplete support when building campaign formulas—whether for calculating rewards, setting pending or expiration dates, or referencing balances. You can access both templates (common formulas) and variables (context-specific data) through dropdown suggestions.


🧰 Overview

  • The dropdown appears when you click into any formula field (e.g., Add units, Expiration date, Pending units).

  • It’s divided into Templates (pre-defined formula snippets) and Variables (data fields you can insert).


🔄 Trigger‑Specific Variables

Depending on the campaign trigger you chose, the dropdown will surface different context variables:

For Purchase or Return campaigns:

  • transaction.grossValue – total value of the entire purchase/return

  • transaction.qty – total item count

  • Item-level filters create expressions like:

    • transaction.sku('ABC123').qty or .grossValue

    • transaction.category('Beverage').grossValue

    • transaction.maker('BrandX').qty

These allow precise designs such as “Give 10 points for each specific SKU purchased” or “Deduct units only for returns above $100 worth of electronics.”

For Custom Event and Redemption Code campaigns:

  • Variables map to schema-defined attributes. For example, if your schema includes an integer steps attribute:

    • event.body.steps becomes available.

This enables expressions like:

1 * event.body.steps

to award 1 point per step counted in the event payload.


💳 Wallet Balance Variables

Under the Variables tab, you'll also find wallet-related data that can be used in conditions:

  • customer.getWallet('<walletType>').activeUnits

  • customer.getWallet('<walletType>').blockedUnits

  • customer.getWallet('<walletType>').pendingUnits

Use these to set effects like “Give triple points for all active points” or “Deduct all currently active points”


🎯 Templates

Common formula templates are available under Templates, such as:

  • Fixed rewards (e.g., 100 for 100 points)

  • Multipliers tied to transaction or event data:

    10*transaction.sku('ABC123').qty
    20*transaction.maker('BrandX').qty
    1*transaction.grossValue

Selecting a template inserts proper syntax without manual typing, saving time and reducing errors.


🛠 Building Custom Expressions

Once a template or variable is inserted, you can further refine using supported operations and functions:

  • Math operators: + - * /

  • Date functions:

    add_days_to_date(executionContext.processedAt, 15)
    add_days_to_date(transaction.purchasedAt, 5)
  • Member custom attribute conversions:

    add_days_to_date(
      to_date(agg(customer.labels).getLabelValue('subscription_end_date')),
      6
    )

These can set dynamic expiration/pending dates or attribute-based caps.


✅ Benefits

  • Speed & accuracy: Avoid typing errors and learn variable options as you go

  • Context awareness: Only relevant templates and data appear based on the selected trigger

  • Advanced logic at your fingertips: Combine templates and variables for powerful conditional logic


📌 Tips & Best Practices

  • Explore both categories in the dropdown—templates and variables each serve a role.

  • For transaction campaigns, item-level filters enable fine-grained logic (e.g., deduct only for high-value returns).

  • For custom events, verify the schema matches your attribute names so variables appear correctly.

  • Use wallet variables to manage campaign eligibility or prevent over-issuing rewards.

  • Test formulas using the campaign simulator to ensure values are computed as expected.

Last updated

Was this helpful?