In the rule's when condition(), how can I get the EffectiveEndDateTime of the parent ruleset?
Hi,
I want to ensure that the parent ruleset has an EffectiveEndDateTime when I evaluate a rule's when condition() . How would I do that please ?
Thank you.
W
Comments
You can get it from the rule execution context by using the effective end value passed into the generated rule evaluation code. One example of the generated routine shows these output variables being set during rule evaluation, including pEffectiveEnd, which represents the ruleset effective end value. [1]
If you need to use that value inside a when condition, the supported approach shown in the related rule discussions is to expose logic through a custom function class that extends Ens.Rule.FunctionSet, and call that function from the rule condition. [2][3][4]
A practical approach is therefore:
- Create a custom function in a class extending
Ens.Rule.FunctionSet. [2][3][4] - Pass in the rule context or otherwise access the execution state from that function. [3]
- Use the effective end value associated with the executing ruleset there, rather than trying to reference the parent ruleset metadata directly inside the raw
whenexpression. [1]
One related example also notes that rule definitions are stored as XML in the RuleDefinition XData and can be loaded programmatically with Ens.Rule.Model.ruleDefinition, so if your requirement is to inspect ruleset metadata structurally, that can be done outside normal rule-condition evaluation. [5]
Warning: This is not standard use or best practice, and I'm not recommending you do this - as it will effectively negate the rules sets with effective periods feature. which in the future, you may want to use. [6]
Sources: