You are here:
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.
- In Vlocity Product Console under Rules, click the create icon next to Context Dimension.
-
In the New Context Dimension dialog, enter
the following information.
Property
Value
Description
Name
CurrentRuleObjectIdThis 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.
Code
CurrentRuleObjectIdThe code by which you will refer to this rule when creating custom expressions.
You cannot use spaces in the code of a context dimension due to requirements from the rules parsing engine.
Data Type
TextDomain Type
Type inActive
Click to select
Only active context dimensions are evaluated by the rules engine.
Effective From Date
Select a date
The start date of the period during which the context dimension will be effective.
Effective Until Date
Select a date
The end date of the period during which the context dimension will be effective.
- 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.
- In the left sidebar, click Context Mappings.
- In the Context Mappings facet, click New Context Mapping.
-
In the New Context Mapping dialog, enter
the following information.
Property
Value
Description
Context Scope
Select a context scope using the Context Scope Lookup dialog.
The CurrentRuleObjectId variable supports all context scopes.
Initialization Policy
Always Reinitialize
Specifies how frequently context mapping values should be refreshed in the session cache.
For a CurrentRuleObjectId, the Initialization Policy must be set to Always Reinitialize. By default, the current object ID is not reset, and instead remains the typed-in value specified below.
Initialization Type
Type In
Specifies where to retrieve the data that is used to compare to the rule condition. For a CurrentRuleObjectId this property must be set to
Type In.Type In Value
[current object id]
Displays when the Initialization Type is set to Type In.
This is a temporary value that is replaced by the current object record ID at run time.
Sequence
10
Specifies the context mapping sequence. To allow for future sequence changes, use a sequence of 10, 20, 30, and so on.
Active
Click to select
Only active context mappings dimensions are evaluated by the rules engine.
Effective From Date
Select a date
The start date of the period during which the context mapping can be used in rules.
Effective Until Date
Select a date
The end date of the period during which the context mapping can be used in rules.
- 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.
For more information on creating and using functions, see Functions for Rules.

