Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Overview

Parses the input and returns a function that can be used to execute the decision table.

DecisionTable $Decisions.Parse(input: ( string | Xml ))

Arguments

( string | Xml ) input
Xml node instance or decision table xml string

Example

Sample decision table xml

<MyDecisionTable HitPolicy="Any" Aggregation="">
    <OutputLabel>Discount by Customer Category</OutputLabel>
    <Inputs>
      <Input>
        <Label>Customer Category</Label>
        <Expression TypeRef="string">Customer.Category</Expression>
        <InputValues TypeRef="" />
      </Input>
      <Input>
        <Label>Order Size</Label>
        <Expression TypeRef="number">OrderSize</Expression>
        <InputValues TypeRef="" />
      </Input>
    </Inputs>
    <Outputs>
      <Output TypeRef="number" Name="Discount">
        <Label>Discount</Label>
        <OutputValues />
        <Default>0</Default>
      </Output>
    </Outputs>
    <Rules>
      <Rule>
        <Description />
        <Inputs>
          <Input>"Business"</Input>
          <Input><10</Input>
        </Inputs>
        <Outputs>
          <Output>0.10</Output>
        </Outputs>
      </Rule>
      <Rule>
        <Description />
        <Inputs>
          <Input>"Business"</Input>
          <Input>>=10</Input>
        </Inputs>
        <Outputs>
          <Output>0.15</Output>
        </Outputs>
      </Rule>
      <Rule>
        <Description />
        <Inputs>
          <Input>"Private"</Input>
          <Input />
        </Inputs>
        <Outputs>
          <Output>0.05</Output>
        </Outputs>
      </Rule>
    </Rules>
  </MyDecisionTable>

Example

Parsing decision table xml

var decisionTableNode = $Xml.SelectSingle('MyDecisionTable');
var fn = $Decisions.Parse(decisionTableNode);

Example

Providing JSON to evaluate

var result = fn({
    CustomerCategory: "Business",
    OrderSize: 10
});

Example

Providing XML Node object to evaluate

var dataNode = $Xml.SelectSingle('MyDataInputs');
var result = fn(dataNode);
  • No labels