Description
Hi Team,
I am trying to execute my workflow using ExecuteActionWorkflowAsync method of MS rule engine but here I am not being able to use custom method in an expression, it is throwing parser error while execution.
Whereas it is working fine with ExecuteAllRulesAsync method.
I need to execute my rules in a sequence within a workflow with some custom methods in execution, hence, I have to use ExecuteActionWorkflowAsync method.
Here is a sample code.
//JSON:
[
{
"WorkflowName": "MyWorkFlow",
"Rules": [
{
"RuleName": "Rule1",
"SuccessEvent": "ok",
"ErrorMessage": "Reject",
"ErrorType": "Error",
"RuleExpressionType": "LambdaExpression",
"Expression": "customMethods.doSomething()",
"Actions": {
//action
}
}
}
]
// Custom method class
public class CustomMethods
{
public CustomMethods()
{
}
public bool doSomething()
{
return false;
}
}
//input construction
var input1 = new RuleParameter("string1", "hello");
var cust = new RuleParameter("customMethods", customMethods);
//engine execution with action workflow
_engine.ExecuteActionWorkflowAsync("MyWorkFlow","Rule1", {input1,cust }).Result;
//throwing parsing error "doSomething" is not accessible.
//engine execution with all rules
_engine.ExecuteAllRulesAsync("MyWorkFlow",{input1,cust }).Result
//working fine.
Regards
Lokesh