Quick Start

 

Walkthrough #1 – create and test a basic rule

 

We’d like to show you how you can quickly and easily use RuleLab.Net to create a Rule that updates an application XML. Let’s say you need to make a Rule that sets the discount for a 3-day sale. The application XML data document looks like this:

 

<sale>

    <dateStart>1/1/2000</dateStart>

    <discount></discount>

</sale>

 

The Rule that we are about to add is setting the discount to 10% if sale is still in effect.

 

1. Create a new Project and XML files

 

In the Project screen, click the New Project button and enter the name of the new project, for example: quickstart.

 

In the XML References section of the Project screen, click the New button and enter the name of the new References file, for example: myrefs. Highlight myrefs.xml and click the arrow button to copy it into the project’s textbox above.

 

In the Rules section, click the New button and enter the name of the new Rules file, for example: myrules. Highlight myrules.xml and click the arrow button to copy it into the project’s textbox above.

 

Click the Reload button to load the 2 new files into the project.

 

 

 

 

2. Add XML References

 

Ø      Click the References tab to open the XML References screen.

Ø      Fill in the table as follows:

 

Alias

XPath

Type

Atom

Sale Start Date   

/sale/dateStart

date

ü       

Discount 

/sale/discount     

numeric

ü       

 

Ø      Click the Save References button. The browser should respond with “References have been saved” in the status bar (at the bottom) and no error messages.

 

 

3. Create a Rule

 

Ø      Click the Rules tab. Close the tip if one is open.

Ø      Click the Append button and type the new rule alias, for example: Offer Discount. Once you click the Create Rule button the Rule Editor should open.

 

Ø      Locate the Rule Condition expression template that looks like this:

 

Ø      Click the atom/formula link.

Ø      In the popup, select Sale Start Date and

Ø      In the Apply function to data dropdown select number of days since

 

 

Ø      Click the Apply button. The rule condition changes to:

 

 

Ø      Click the “is” link and double click  “is Less Than or Equal To” in the popup

 

Ø      Click the atom/fact/formula/value link.

Ø      In the popup, click the Data radio button

Ø      Enter “3” and click the Apply button:

 

 

 

Ø      The complete Condition should look like this:

 

 

Ø      In the Rule Action – Then section, click the assign link:

 

 

Ø      The Action should now display a new blank assignment:

 

 

Ø      Click the atom link, select the Discount atom, and click the Apply button

 

Ø      Click the atom/fact/formula/value link, in the Data panel enter “10”, and click the Apply button:

 

 

 

Ø      The rule is now complete:

 

 

Ø      Click the Apply & Go Back button. You will be taken back to the Rule Browser which should display the new rule as:

 

Ø      Click the Save Rules button

 

 

4. Test the new Rule

Ø      Switch over to the Test tab.

Ø      Copy the application XML from the top of this page and paste it into the Input Test Data XML document textbox:

 

 

Ø      Click the Run Test button. The rules engine should respond with the updated application field list and the execution trace (actual dates will differ from the shown dates):

 

 

 

We are done. Now, if you click the discount link in the modified XML data fields box it will highlight the corresponding tag in the application XML. If you click the Discount - or another atom or rule link - within the Log, it will take you to the definition of this atom or rule.

 

Next: go to Walkthrough #2 – create a fact and verbalize a rule

 

See also Complete project walkthrough

RuleLab.Net online service

Client-hosted solution

Rules Designer

Managing RuleLab.Net projects.

Security of the online content