ActionContext is not able to get the actual value assigned from the rules
Hi,
Here is a snippet where we pass certain parameters on success and failure methods.

Now I was expecting the underlying value in my action context but instead I get the value in string like "Device.Id".
I tried a simple arithematic equation like "20*2" that too is being received as a string

Hi @vprabhu81, this is intended behavior, context does not automatically get evaluated.
Can you provide the context on what you are trying to achieve?
I have these parameters passed into the rule engines, On success or failure I would need to retireve those data set to send notifications.
I am bit surprised though because I see that in the sample below we do pass the expressions as an input
https://microsoft.github.io/RulesEngine/#outputexpression
@abbasc52 : Just wanted to check with you if got a chance to look at the sample provided
Hi @vprabhu81 , assuming you want to create a custom action, context is passed as is and needs to be parsed at the custom action code e.g. https://github.com/microsoft/RulesEngine/blob/a74f73a44e38ce27c76945f15fd697c7abe5eef9/src/RulesEngine/Actions/ExpressionOutputAction.cs#L21-L22 The ruleparser is a public class and can be used to evaluate expressions
If you just want to return an object , just use outputExpression and set the object there e.g.
"OnSuccess": {
"Name": "OutputExpression", //Name of action you want to call
"Context": { //This is passed to the action as action context
"Expression": "new (Device.Id as BodyId, Device.DateTimeUTC as EventUTCTime)"
}
}
@abbasc52 ,
How do I Inject the RuleExpressionParser into my custom action? while registering the custom actions in RESettings, I will not have the rule engine instance yet, Is there an example I can refer to?
I tried the second approach as I just need the object in the custom action "Expression": "new (Device.Id as BodyId, Device.DateTimeUTC as EventUTCTime)"
Unfortunately I still get it as string at the receiving end
@abbasc52 ,
How do I Inject the RuleExpressionParser into my custom action? while registering the custom actions in RESettings, I will not have the rule engine instance yet, Is there an example I can refer to?
I tried the second approach as I just need the object in the custom action "Expression": "new (Device.Id as BodyId, Device.DateTimeUTC as EventUTCTime)"
Unfortunately I still get it as string at the receiving end
Hi @abbasc52
I found the answer on UnitTests
Name: "OutputExpression" expression: "input1.country.ToString() + input2.totalOrders.ToString()",
"OnSuccess": {
"Name": "OutputExpression",
"Context": { //This is passed to the action as action context
"expression": "input1.country.ToString() + input2.totalOrders.ToString()"
}
}
See here
I hope this snippet can be added to the docs.