microsoft / microsoft/RulesEngine

Custom method is not being called with ExecuteActionWorkflowAsync; throwing parser error.

Open
#584 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
616
Avg merge
6m
Merged PRs (30d)
2

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ExecuteActionWorkflowAsync and ExecuteAllRulesAsync entry points using the supplied workflow, expression, and customMethods parameter. Compare their parsing and method-accessibility behavior, then verify that the custom method executes without a parser error while the existing ExecuteAllRulesAsync behavior remains working.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.