Skip to content

Smart Quote: Customer Facts

Customer Facts allow your Smart Quote Rules to make logical decisions based on the specific customer associated with a quote or order. This enables powerful automation, such as customer-specific pricing, regional tax adjustments, or restricting certain products to specific clients.

Accessing Customer Data in Rules

In the when block of a rule, you can use the CustomerFact function to retrieve data about the current customer.

Example: Targeted Messaging

This rule checks if the customer is "Acme Corp" and displays a specific reminder to the Sales Rep.

when
    var config = Configurator();
    var cust = CustomerFact(x => x.Name == "Acme Corp");

then
    config.LogInformation("Reminder: Acme Corp requires specialized packaging for all orders.");

Example: Regional Logic

You can also use customer properties like State or Country to drive configuration logic (e.g., ensuring electrical components match the customer's regional standards).

when
    var config = Configurator();
    var cust = CustomerFact(x => x.Country == "UK");

then
    config.AddItem("PLUG_TYPE_G", 1.0m); // Automatically add UK-style power cord

Dynamic Filtering Based on Customer Data

One of the most common uses for Customer Facts is filtering the valid values for Attributes. By using SQL queries in the attribute setup, you can ensure that the configuration options are always relevant to the specific customer.

Example: Customer-Specific Item Lists

This SQL query populates an attribute dropdown with item numbers that are specific to the current customer's preferred "Material Grade" (stored in a custom attribute on the customer record).

<queries>
    <valuesvalid attribute="MATCOND">
        <sql>
          SELECT
          JSON_UNQUOTE(JSON_EXTRACT(AttributesJSON, "$.COND")) AS MATCOND
          FROM catalog_items
          WHERE
          InstanceID=?paramInstanceID
          AND Category='Raw Materials'
          AND ?paramGRD=JSON_UNQUOTE(JSON_EXTRACT(AttributesJSON, "$.GRD"))
          AND JSON_UNQUOTE(JSON_EXTRACT(AttributesJSON, "$.COND")) IS NOT NULL
          GROUP BY MATCOND
          ORDER BY MATCOND
       </sql>
    </valuesvalid>
</queries>

Best Practices

  1. Data Integrity: Ensure your Customer Master Data is clean and consistent, as any errors in customer records will directly impact how rules fire.
  2. Use for Compliance: Use Customer Facts to block the sale of specific items to customers in regions with specific regulatory restrictions.
  3. Tiered Benefits: Combine Customer Facts with Price Factor Rules to automatically apply negotiated discounts for strategic accounts.