Child rules can see a parent's rule inputs - is this expected behavior?

I was going through someone else's code at my company and found a puzzling thing.  There was a parent expression rule calling a child expression rule.  The child expression rule referenced a rule input that it did not have defined.  The parent rule did have that rule input defined, and the child rule was able to access the rule input defined only in the parent.

I want to make it clear that I believe the child rule *should* have had a rule input defined, and that the input should have been explicitly passed by the parent rule.  The situation I ran into is not something I would personally rely on or a best practice I would recommend.

Is this behavior intentional?  Just curious.

Below is a simple example:

The parent rule has one rule input of a CDT "Widget" which has field1, field2, field3.  ri!widget of type Widget is defined on expression rule "parentRule".

contents of parentRule

rule!childRule(

)

childRule has *no* rule inputs.

contents of childRule

{
ri!widget.field1,
ri!widget.field2,
ri!widget.field3
}   

When I execute parentRule, I get back the contents of the widget rule input.  If I tried to execute the childRule by itself, it complains that it does not recognize the ri!widget variable, but executing from the parent it all works.

  Discussion posts and replies are publicly visible

Parents Reply
  • It becomes a bit of a savior when you need to set a complex-ish expression to determine the value of a column in a Portal Report (process report, task report, etc), since due to whatever weirdness still exists in those, you CAN'T actually pass in parameters using dictionary syntax to expression rules, but you CAN make the expression rule manually reference PVs that you expect to exist in the process model(s) in question. 

    Of course this is an extreme edge case, but very useful sometimes.  Now, if they actually fixed the expressionable values in Reports to not break when using dictionary syntax or non-primitive functions....

Children