---
schema_version: "1"
id: fd86eae5aed8871f9988e1fe6fc38561a13e340d8f630abf34ca2a4fa0a601d2
title: CurrentRuleObjectId Variable
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/comms_currentruleobjectid_variable.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.comms_currentruleobjectid_variable.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: b89726e841176fbe2f46a4b686b0a036eb1993d6240afa601b86cca62e273741
description: In some cases, you might want to create a context rule that evaluates the entity to which it is applied. For example, you might want to create a rule that disqualifies a promotion for accounts that have already used that promotion. Or perhaps you want a rule to disqualify products when they are already in the cart line items of Industries Cart. To do this, you use a special variable called CurrentRuleObjectId, which enables your rule conditions or functions to access the current object's record Id as it iterates over them.
products:
  - Communications
  - Media
  - Energy and Utilities
release: "264"
---
# CurrentRuleObjectId Variable

In some cases, you might want to create a context rule that evaluates the entity to which it is applied. For example, you might want to create a rule that disqualifies a promotion for accounts that have already used that promotion. Or perhaps you want a rule to disqualify products when they are already in the cart line items of Industries Cart. To do this, you use a special variable called CurrentRuleObjectId, which enables your rule conditions or functions to access the current object's record Id as it iterates over them.

## Create the CurrentRuleObjectId Context Dimension

Before you can use the CurrentObjectId variable, you must create a context dimension and a context mapping to store it in. After this context dimension and context mapping are created, you can specify the context dimension for a rule condition or as an input argument to a function. At run time, the context rules service replaces the context mapping's Type In Value with the record Id of the current entity that it is evaluating.

1. In Vlocity Product Console under **Rules**, click the create icon next to Context Dimension.
2. In the **New Context Dimension** dialog, enter the following information.
    
    <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
                <colgroup>
                  <col>
                  <col>
                  <col>
                </colgroup>
                <thead class="slds-text-title_caps ">
                  <tr class="">
                    <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d357416e86">
                      <p style="margin-bottom:0;">Property</p>
                    </th>
                    <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d357416e92">
                      <p style="margin-bottom:0;">Value</p>
                    </th>
                    <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d357416e98">
                      <p style="margin-bottom:0;">Description</p>
                    </th>
                  </tr>
                </thead>
                <tbody>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e86 ">
                      <p style="margin-bottom:0;">Name</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e92 ">
                      <p style="margin-bottom:0;">
                        <code>CurrentRuleObjectId</code>
                      </p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e98 ">
                      <p style="margin-bottom:0;">This name must be typed exactly as shown here in order
                        for the context rules service to recognize this as the
                        CurrentRuleObjectId variable. The name of this context
                        dimension is the key.You cannot use spaces in the name of a
                        context dimension due to requirements from the rules parsing
                        engine.</p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e86 ">
                      <p style="margin-bottom:0;">Code</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e92 ">
                      <p style="margin-bottom:0;">
                        <code>CurrentRuleObjectId</code>
                      </p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e98 ">
                      <p>The code by which you will refer to this rule when
                        creating custom expressions.</p>
                      <p style="margin-bottom:0;">You cannot use
                        spaces in the code of a context dimension due to
                        requirements from the rules parsing engine.</p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e86 ">
                      <p style="margin-bottom:0;">Data Type</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e92 ">
                      <p style="margin-bottom:0;">
                        <code>Text</code>
                      </p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e98 ">&nbsp;</td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e86 ">
                      <p style="margin-bottom:0;">Domain Type</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e92 ">
                      <p style="margin-bottom:0;">
                        <code>Type in</code>
                      </p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e98 ">&nbsp;</td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e86 ">
                      <p style="margin-bottom:0;">Active</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e92 ">
                      <p style="margin-bottom:0;">Click to select</p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e98 ">
                      <p style="margin-bottom:0;">Only active context dimensions are evaluated by the
                        rules engine.</p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e86 ">
                      <p style="margin-bottom:0;">Effective From Date</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e92 ">
                      <p style="margin-bottom:0;">Select a date</p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e98 ">
                      <p style="margin-bottom:0;">The start date of the period during which the context
                        dimension will be effective.</p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e86 ">
                      <p style="margin-bottom:0;">Effective Until Date</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e92 ">
                      <p style="margin-bottom:0;">Select a date</p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e98 ">
                      <p style="margin-bottom:0;">The end date of the period during which the context
                        dimension will be effective.</p>
                    </td>

                  </tr>
                </tbody>
              </table>
3. Click **Save**.

## Create the CurrentRuleObjectId Context Mapping

The CurrentRuleObjectId variable enables your rule conditions or functions to access the current object's record Id as it iterates over them.

1. In the left sidebar, click **Context Mappings**.
2. In the **Context Mappings** facet, click **New Context Mapping**.
3. In the **New Context Mapping** dialog, enter the following information.
    
    <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
                <colgroup>
                  <col>
                  <col>
                  <col>
                </colgroup>
                <thead class="slds-text-title_caps ">
                  <tr class="">
                    <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d357416e342">
                      <p style="margin-bottom:0;">Property</p>
                    </th>
                    <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d357416e348">
                      <p style="margin-bottom:0;">Value</p>
                    </th>
                    <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d357416e354">
                      <p style="margin-bottom:0;">Description</p>
                    </th>
                  </tr>
                </thead>
                <tbody>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e342 ">
                      <p style="margin-bottom:0;">Context Scope</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e348 ">
                      <p style="margin-bottom:0;">Select a context scope using the <strong class="uicontrol">Context
                          Scope Lookup</strong> dialog.</p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e354 ">
                      <p style="margin-bottom:0;">The CurrentRuleObjectId variable supports all context
                        scopes.</p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e342 ">
                      <p style="margin-bottom:0;">Initialization Policy</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e348 ">
                      <p style="margin-bottom:0;">
                        <kbd>Always Reinitialize</kbd>
                      </p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e354 ">
                      <p>Specifies how frequently context mapping values should
                        be refreshed in the session cache.</p>
                      <p style="margin-bottom:0;">For a
                        <strong class="uicontrol">CurrentRuleObjectId</strong>, the
                        <strong class="uicontrol">Initialization Policy</strong> must be set to
                        <kbd>Always Reinitialize</kbd>. By default,
                        the current object ID is not reset, and instead remains the
                        typed-in value specified below.
                      </p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e342 ">
                      <p style="margin-bottom:0;">Initialization Type</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e348 ">
                      <p style="margin-bottom:0;">
                        <kbd>Type In</kbd>
                      </p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e354 ">
                      <p style="margin-bottom:0;">Specifies where to retrieve the data that is used to
                        compare to the rule condition. For a
                        <strong class="uicontrol">CurrentRuleObjectId</strong> this property
                        must be set to <code>Type In</code>.
                      </p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e342 ">
                      <p style="margin-bottom:0;">Type In Value</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e348 ">
                      <p style="margin-bottom:0;">
                        <kbd>[current object id]</kbd>
                      </p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e354 ">
                      <p>Displays when the <strong class="uicontrol">Initialization
                          Type</strong> is set to <kbd>Type
                          In</kbd>.</p>
                      <p style="margin-bottom:0;">This is a temporary value that
                        is replaced by the current object record ID at run
                        time.</p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e342 ">
                      <p style="margin-bottom:0;">Sequence</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e348 ">
                      <p style="margin-bottom:0;">10</p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e354 ">
                      <p style="margin-bottom:0;">Specifies the context mapping sequence. To allow for
                        future sequence changes, use a sequence of 10, 20, 30, and
                        so on.</p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e342 ">
                      <p style="margin-bottom:0;">Active</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e348 ">
                      <p style="margin-bottom:0;">Click to select</p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e354 ">
                      <p style="margin-bottom:0;">Only active context mappings dimensions are evaluated
                        by the rules engine.</p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e342 ">
                      <p style="margin-bottom:0;">Effective From Date</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e348 ">
                      <p style="margin-bottom:0;">Select a date</p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e354 ">
                      <p style="margin-bottom:0;">The start date of the period during which the context
                        mapping can be used in rules.</p>
                    </td>

                  </tr>
                  <tr class="">
                    <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e342 ">
                      <p style="margin-bottom:0;">Effective Until Date</p>
                    </td>

                    <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e348 ">
                      <p style="margin-bottom:0;">Select a date</p>
                    </td>

                    <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d357416e354 ">
                      <p style="margin-bottom:0;">The end date of the period during which the context
                        mapping can be used in rules.</p>
                    </td>

                  </tr>
                </tbody>
              </table>
4. Click **Save**.

After you create the CurrentRuleObjectId variable, you can use it in a rule condition or as an input argument to a function.

For more information on rule conditions, see [Context Rules](https://help.salesforce.com/s/articleView?id=ind.comms_context_rules.htm&release=264.0.0&type=5 "Context rules determine when a rule set applies in Industries Cart. Context rules are analogous to entity filters in the advanced rules framework.").

For more information on creating and using functions, see [Functions for Rules](https://help.salesforce.com/s/articleView?id=ind.comms_functions_for_rules.htm&release=264.0.0&type=5 "In context rules, when you need rules to evaluate complex criteria, you can create a function.").