Create a custom context variable

  • Release version: Australia
  • Updated March 12, 2026
  • 4 minutes to read
  • Create custom context variables to represent product or non-product characteristics that can be used by pricing admins to apply different pricing features, such as pricing adjustments, or product catalog admins to set product offering eligibility rules.

    Before you begin

    Before creating a custom variable, review the context variables available in the Context Variables [sn_csm_ctxrul_mgt_context_variable] table to verify whether you need a new one. This table identifies the system-defined variables provided with Product Catalog Management and Pricing Management and also any custom variables that have been created.

    For example, the system-defined context variables provided for non-product attributes include: Account, Shipping Country, Shipping City, Shipping State, Shipping Zip, Billing Country, Billing City, Billing State, Billing Zip, and Transaction Date.

    Role required: admin

    About this task

    As an administrator, you can create custom context variables for items such as non-product characteristics, that your pricing and product catalog administrators can use in rule matrices to control pricing features or product offering eligibility. For example, your pricing administrator might want to define pricing adjustments based on sales segment, but sales segment isn’t a system-defined context variable.

    You create the variable name and define the variable type, so that the variable can be used in a decision rule for a rule matrix. After you create the variable, you must also map the context variable to the transaction entity, such as quote or order, from which the system retrieves the context.

    Procedure

    1. In the CSM Configurable Workspace, select the List view.
    2. Navigate to Context Rule Management > Context Variables.
    3. In the Context Variables list, select New.
    4. On the form, fill in the fields.
      Table 1. Context Variable form
      Field Description
      Type Context variable type. Choose the type of field for the variable. For example, the choice list field type lets your user select from a predefined list of choices.

      For more information on the different field types, see Field types reference.

      Note:
      Depending on the Type selected, other fields and sections in the form are displayed.
      Label Name of the context variable to be displayed in the user interface, such as sales segment.
      Column name ID of the context variable for which the context variable type is created. The system assigns this name automatically based on the Label name entered, for example sales_segment.
      Code System-generated alphanumeric number based on the label name. You can enter your own code to replace the system-generated code.
      Note:
      After the context variable is used in a published pricing or product eligibility matrix, the Code value can't be changed.
      Context type Option that indicates from where the context is retrieved. For example you can select a context type such as:
      • Transaction Header: Context is fetched from the header record for a transaction, such as an opportunity, quote, or sales order.
      • Transaction Line: Context is fetched from the line record for an opportunity, quote, or sales order transaction.
      Application Name of the application scope. The default scope is Global.
      System defined Option indicating the context variable is defined by the pricing system.
      Applicable to Option indicating the module to which this context variable applies. Currently supports Pricing. The pricing engine uses this field to determine which context variables to resolve during pricing calculations.

      If the context variable is used in pricing, select Pricing. Otherwise, leave this field as None.

      Type of mapping Option indicating how the context variable is mapped:
      • Field mapping: Map the context variable to a transaction entity.
      • Scripted: JavaScript that you provide in the Script field, which defines complex logic for computing values using the context variable. For example, a script might be used for the following:
        • Calculations, such as discount percentages or account age
        • Complex lookups, such as checks for accounts that have made purchases
        • Business logic, such inventory check or eligibility
        • Aggregrations across lines, for example, the number of products in a cart.
      Pricing api key field Reference field for a context variable that defines an external ID used in pricing requests in the Sales CRM Pricing API.

      For more information on external IDs and custom context variables, see External ID support in Sales CRM Pricing API.

      Active Option that indicates the context variable is available for use in rule matrices.
    5. If you're using the external ID feature in the Sales CRM Pricing API, in the Reference Specification section, select the reference table for the context variable that defines an external ID to be used in a pricing request.

      For more information on external IDs and custom context variables, see External ID support in Sales CRM Pricing API.

    6. Select Save.
      The tab (related list) for the Type that you selected in Step 4 and the Variable Mapping tab are displayed.
    7. Depending on the Type you selected, create the values for the type, then select Save.
      For example, in Step 4, if you selected the Choice type, select New in the Choices tab and define the choices.

    What to do next

    For context variables that are mapped to fields, map the custom context variable to a transaction entity.