You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using the output from a rule as input to the expression for other rule #632
Is it possible to use the output of Rule1 as input to the next Rule ? Looking for something below. Accessing "Expression": "context.TotalAmount >= 100000", . The TotalAmount is conditionally calculated in the previous rule, and it needs to be passed to the next Rule.
// See https://aka.ms/new-console-template for more informationusingRE=RulesEngine;namespaceMsRulesEngine;publicclassChainedRuleExample{publicstaticasyncTaskRun(){stringfilePath=Path.Combine(Environment.CurrentDirectory,"RulesFiles","ChainedRuleExample.json");Console.WriteLine(filePath);stringjsonString=File.ReadAllText(filePath);varjsonDocument=JsonDocument.Parse(jsonString);varworkflows=JsonSerializer.Deserialize<Workflow[]>(jsonString);vard1=DateTime.Now;vard2=DateTime.Now.AddMinutes(20);varruleParameters=newRuleParameter[]{new("input1",50000),new("input2",50000)};RE.RulesEnginerulesEngine=new(workflows);varresult=awaitrulesEngine.ExecuteActionWorkflowAsync("EvaluateRuleActionTest","TotalAmount5W",ruleParameters);Console.WriteLine($"Rule: {result.Output}");}}
Activity
vamsidogiparthi commentedon Feb 4, 2025
naheedmk,
Please look into below example to work with chained rules
[ { "WorkflowName": "EvaluateRuleActionTest", "Rules": [ { "RuleName": "TotalAmount5W", "Expression": "input1 + input2 >= 50000", "ErrorMessage": "The game doesn't meet the criteria for 5% discount", "ErrorType": "Error", "Actions": { "OnSuccess": { "Name": "EvaluateRule", "Context": { "workflowName": "EvaluateRuleActionTest", "ruleName": "TotalAmount10W", "additionalInputs": [ { "Name": "TotalAmount", "Expression": "input1 + input2" } ] } } } }, { "RuleName": "TotalAmount10W", "Expression": "TotalAmount >= 100000", "Actions": { "OnSuccess": { "Name": "OutputExpression", "Context": { "Expression": "TotalAmount * 0.10" } } } } ] } ]