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 an administrator
  • In the main Page, select Project and then New Project


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


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


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


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


  • The main window should look like this:



  • To insert parameters and conditions, simply choose them from the “ToolBox” on the left-hand side and drag these 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

The end result should look something like this:


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


  • Change all the values according to the defined parameters properties.


  • Do this for conditions and variables as well (keep in mind that different parameters have different values, and therefore the Properties menu for each of them may look different).


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


  • 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 similar to the following model:
  1. <Procedure name="PriceSubTotal" enabled="true">
  3.   <Declaration>
  4.     <Define name="item" direction="in" />
  5.     <Define name="discount" direction="out" value="0.0f"/>
  6.   </Declaration>
  8.   <If condition='item.Quantity >= 10'>
  9.     <Var name="discount" value="0.03f" />
  10.   </If>
  12. </Procedure>