Moving Decision Table Rows Using irSDK

  • Updated

Interacting with Decision Tables via irSDK is a little tricky, but quite do-able.  Below is an example of how to move Decision rows around with the resulting Decision order. You may also need to reference the DecisionTableDef.Conditions and Actions to compare against the Decision's ConditionNodes and ActionNodes to find the appropriate Decision row to shift.

 

private void MoveDecisionTableRow()
{
    var ruleApp = new FileSystemRuleApplicationReference(@"C:\Users\DanGardiner\Desktop\SimpleDT.ruleappx");
    var ruleAppDef = ruleApp.GetRuleApplicationDef();
    var myEntity = ruleAppDef.Entities["Entity1"];
    var myRuleSet = myEntity.GetRuleSet("RuleSet1");
    var decisionTable = myRuleSet.GetAllRuleElements().FirstOrDefault(r => r.Name == "DecisionTable1") as DecisionTableDef;
    var decisions = decisionTable.Decisions;
    Console.WriteLine(string.Join(", ", decisions.Select(d => d.Guid)));
    decisions.MoveDown(decisions.FirstOrDefault());
    Console.WriteLine(string.Join(", ", decisions.Select(d => d.Guid)));
    decisions.Move(2, 0);
    Console.WriteLine(string.Join(", ", decisions.Select(d => d.Guid)));
    ruleAppDef.SaveToFile(@"C:\Users\DanGardiner\Desktop\SimpleDT-Updated.ruleappx");
}

 

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.