Create a new rule project
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”
| * and a “var“ from “Objects and Variables” |
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:
<Procedure name="PriceSubTotal" enabled="true">
<Define name="item" direction="in" />
<Define name="discount" direction="out" value="0.0f"/>
<If condition='item.Quantity >= 10'>
<Var name="discount" value="0.03f" />