---
schema_version: "1"
id: 244fa346fa31efbe0a418c49b319f4c1386602e81eafbbce0f2dbb814caa7d6e
title: Configure Rule Libraries for Promotion Context Definitions
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/mktg/264-0-0/global_promotions_management_setup_context_service_rule_library.md
canonical_url: https://help.salesforce.com/s/articleView?id=mktg.global_promotions_management_setup_context_service_rule_library.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: e98fe905b1f6a19f8dc2ce4badd0c2985c14d3094c3b27c55ee1cad7c384ff72
description: Global Promotions Management uses rule libraries to let marketing managers use context definition tags in promotion rule eligibility criteria. Rule libraries also enable the Eligible Promotions API to evaluate all active promotions available in the org and find the promotions and rules that are eligible for customer carts. If the admin and marketing managers decide to use different context definitions for the company's various promotions, the admin must create a rule library for each context definition.
products:
  - Marketing
release: "264"
---
# Configure Rule Libraries for Promotion Context Definitions

Global Promotions Management uses rule libraries to let marketing managers use context definition tags in promotion rule eligibility criteria. Rule libraries also enable the Eligible Promotions API to evaluate all active promotions available in the org and find the promotions and rules that are eligible for customer carts. If the admin and marketing managers decide to use different context definitions for the company's various promotions, the admin must create a rule library for each context definition.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>,&nbsp;<strong>Unlimited</strong>, and&nbsp;<strong>Developer</strong>&nbsp;Editions with Real-Time Offer Management</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d6798e67">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e67 ">To create a rule library:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e67 ">Context Service Admin permission set</td>

          </tr>
        </tbody>
      </table>

Depending on the requirements of a company’s various promotions, admins and marketing managers decide whether to use the standard CartDetailGetEligiblePromotion context definition or create custom context definitions. For each context definition, a Global Promotion Management rule library must be created. Marketing managers can’t activate their promotions until a Global Promotions Management type rule library is available in the org.

Rule libraries are versioned. After you create a rule library, the version of the library is automatically set to 1. You can’t create more versions of the rule library.

In the rule library version one, add custom tags mappings for all the context tags required to define promotion and promotion rule eligibility criteria, and to execute the Eligible Promotions API. The requirements of the promotions that use the rule library and the structure of the rule library's context definition decide the list of custom tag mappings required.

Here’s the list of required custom tag mappings that are required based on promotion requirements.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d6798e115">Business Requirement</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d6798e118">Custom Tag Mapping Name</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d6798e121">Context Tag</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">The Eligible Promotion API requires the date and time when a cart is
              evaluated.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">activityStartDate</td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">A tag that stores the date when the customer’s cart is evaluated</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library have a set of eligible products.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>cartLineProductCatalogId</li>

                <li>cartLineProductId</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">Tags that are related to the Catalog and the Product objects</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library have a set of eligible product
              categories.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>cartLineProductCatalogId</li>

                <li>cartLineProductCategoryId</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">Tags that are related to the Catalog and the Category objects</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library need to uniquely identify an
              individual.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>contactId</li>

                <li>contactLastName</li>

                <li>contactEmail</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">Tags that are related to the Contact object</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library consist of rule eligibility criteria that
              check whether customers have a set of products or products from a set of categories
              in their cart and offer a discount on the cart.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>cartLineItemQuantity</li>

                <li>cartLineItemAmount</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">Tags that are related to cart line quantity and cart line value</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library consist of rule eligibility criteria that
              check whether customers have a set of products, or products from a set of
              categories, in their cart and offer discounts on specific products or products from
              specific categories.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>cartLineItemId</li>

                <li>cartLineItemQuantity</li>

                <li>cartLineItemAmount</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">Tags that are related to the unique identifier of each cart line, cart line
              quantity, and cart line value</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library consist of rule eligibility criteria that
              check for the cart value and offer a discount on the cart.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">transactionAmount</td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">The tag that’s related to total cart value</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library consist of rule eligibility criteria that
              check for the cart value and offer discounts on specific products or products from
              specific categories.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>cartLineItemId</li>

                <li>transactionAmount</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">The tag that’s related to total cart value and the unique identifier of the
              cart line</td>

          </tr>

          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library consist of rules that have product selling
              model-based criteria condition.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">productSellingModel</td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">The tag that’s related to the Product Selling Model object</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library consist of rules that have product
              attribute-based criteria conditions.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>cartLineProduct</li>

                <li>cartLineProductAttribute</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">The tags that’s related to the context definition node for product attribute
              information</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library are evaluted based on an evaluation
              method.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>shouldEvaluatePromotions</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">The tags that are related to the promotion evaluation and execution
              configuration</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that are associated with the rule library must be manually selected
              by the customers to apply to their carts.</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>cartCouponCode</li>

                <li>cartLineCouponCode</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">The tags that’s related to the coupon codes</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">Promotions that use the rule library have a pricing procedure configured for
              promotion evaluation and execution</td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">
              <ul>
                <li>cartHeaderId</li>

                <li>initialTransactionAmount</li>

                <li>cartLevelDiscountValue </li>

                <li>cartLineDiscountFromCartDistribution</li>

              </ul>
            </td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">The tag that’s related to the context definition node for cart and discount
              details</td>

          </tr>
          <tr class="">
            <td data-label="Business Requirement" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e115 ">
              <ul>
                <li>The Eligible Promotions API shows all the promotions associated with a
                  product’s category hierarchy</li>

                <li>Promotion Evaluation and Execution API evaluates all the promotions associated
                  with a product’s category hierarchy when a cart value is calculated.</li>

              </ul>
            </td>

            <td data-label="Custom Tag Mapping Name" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e118 ">cartLineProductCategoryList</td>

            <td data-label="Context Tag" class="slds-cell-wrap" style="vertical-align:top;" headers="d6798e121 ">The tag that’s related to the ID of the hierarchical product category</td>

          </tr>
        </tbody>
      </table>

1. From the App Launcher, find and select **Rule Libraries**.
    
    If you can’t find Rule Libraries, add a tab for the Rule Library object from Setup.
2. Click **New**.
3. Give your rule library a name.
4. Enter the API name of the new context definition.
5. From Usage Type, select **Global Promotions Management**.
6. Save your changes.
7. On the Rule Library Version related list of the rule library that you created, click **v1**.
8. On the Custom Tag Mapping related list, click **New**.
9. Add the mapping name and select the mapping’s corresponding context tag.
10. Save your changes.
11. Repeat steps 8–10 for all the custom tag mappings that you require for the promotions that use the rule library.
12. Activate the rule library version.

After your rule library is ready, you can share the rule library name with the marketing managers who plan to use the rule library for their promotions. If marketing managers plan to create promotion rules by using templates such as Buy X, Get Discount + Rewards and Spend X, Get Unit Price Discount on Y + Rewards, they must select the promotion’s rule library.