Create a new rule project

From FlexRule Wiki
Jump to: navigation, search

Using a designer

Although you can use any text editor to create a rule in XML, it is much more convenient to use a rule designer for this purpose. Fortunately, FlexRule comes with its own flexible and easy to use designer. To create a new rule you have to follow some very simple steps.


  • First open FlexRule.Desinger as administrator
  • In the main Page select Project and then New Project

1NewProject.jpg


  • Or you can simply click on “create a new rule project” link in the main page

2NewProject.jpg


  • In the new project menu enter the project name, chose the project’s path, and write a short description.

3ProjcetProperties.jpg


  • Click OK and then look at the project explorer window in upper hand side of the program. There you can see a project tree containing an empty root folder.

4ProjectExplorer.jpg


  • Click the root folder and select it then click on the “add new” icon on the upper right to open the new document menu. Select “Procedural Engine” folder from the “Document Types” section and then choose “Tree Procedure” from templates. Enter a name (location is automatically selected to be in your project root folder) and then click OK.

5NewDocument.jpg


  • The main window should look like this:

6ProjectExplorer.jpg

7Project.jpg


  • To insert parameters and conditions, simply choose them from the “ToolBox” from the left hand side and drag them to the main window. Try to arrange them in a proper order on the tree. Four handlers are automatically defined in the project. If you need any more handlers you can easily create them the same way you create other parameters.


* Drag and drop two “defines” from
“deceleration and scopes”
(as item and parameters)
* an “if” from “Flow Controls”
(as condition)
* and a “var“ from “Objects and Variables”
(as variable)
8Define.jpg 91if.jpg 10Var.jpg

At the end, the result should look something like this:

11Main.jpg


  • The next step is to change the parameters properties using “properties” menu on the lower left corner. To do so, simply select parameters and then in their properties menu click on fields to change the value.

12Properties.jpg


  • Change all the values according to defined parameters properties.

13Properties.jpg


  • Do it for condition and variable as well (keep in mind, different parameters have different values and therefore the properties menu for each of them may look different).

14Properties.jpg


  • After entering all the values, the final tree will look like something this:

16Main.jpg


  • Save the project by pressing “Ctrl+s” or by clicking on the save icon on the menu. Then go to the project folder and open the file “discount.xml” ( or the file with your chosen name) using a browser or an editor. The final output will be an xml file like the following model:
  1. <Procedure name="PriceSubTotal" enabled="true">
  2.  
  3.   <Declaration>
  4.     <Define name="item" direction="in" />
  5.     <Define name="discount" direction="out" value="0.0f"/>
  6.   </Declaration>
  7.  
  8.   <If condition='item.Quantity >= 10'>
  9.     <Var name="discount" value="0.03f" />
  10.   </If>
  11.  
  12. </Procedure>