Hi there,
I've written a very simple custom rule expression that returns a literal value. The value itself is stored in a WorkflowRuntimeService object.
I've also written a declared rule condition that uses this expression in an IfElseBranchActivity.
The problem - when my expression's 'Evaluate' method is called, the passed RuleExecution parameter doesn't have a reference to an ActivityExecutionContext object.
Looking around a bit with the reflector, it seems that a RuleExecution object is created with a reference to an ActivityExecutionContext object only when created for use in a RuleSet. Meaning that, individual declared rule conditions cannot access the workflow's activity context, because the RuleExecution object that is passed to them doesn't have a reference to said object.
Am I missing something here To me, the main selling point of a custom rule expression was the ability to access the workflow context. Why would there be a distinction between rules executed in a ruleset and rules executed as rule conditions
Thanks in advance,

How to get an ActivityExecutionContext in a custom rule expression, that's being used by a rule condition?
llorrac
We have logged this as a bug, we're so late in our ship cycle a fix almost certainly won't make it in.
Unfortunately, the workaround isn't terribly pretty. You could preceed your IfElse with a Policy activity which performs your test, and sets a boolean flag on your workflow (or custom activity). Your IfElseBranch would then simply test this boolean flag.
I hope that helps.