6.5. Rule Templates
6.5.1. The Guided Rule Template
Rule Templates allow the user to define a rule structure. They provide a place-holder for values and data, and they populate templates to generate many rules. From the user’s perspective, Guided Rule Templates are a parametrized guided rule with a data table which provides parameter values. This can allow for more flexible decision tables and it can enhance the flexibility of rules in existing databases. For information on managing dependencies of Rule Templates, see the Dependency Management for Guided Decision Tables, Scorecards, and Rule Templates section of the Red Hat JBoss BRMS Development Guide.
Procedure: Creating a new Guided Rule Template
In the Project Explorer view, do one of the following:
- If you are in the Project view, select the organizational unit, repository, and the project where you want to create the template.
-
If you are in the Repository view, navigate to
src/main/resources/and theSUBFOLDER/PACKAGEwhere you want to create the project folder for the rule template.
- In the perspective menu, go to New Item → Guided Rule Template.
In the Create new Guided Rule Template dialog window, specify the rule template name:
- In the Resource Name text box, enter the Guided Rule Template name and click OK.
- The new Guided Rule Template is now created and under the selected project.
Figure 6.25. Guided Template Editor

Using a plain rule template and manipulating rules and spreadsheets directly from Business Central is not supported by Red Hat. It is recommended that you create and use Guided Rule Template using Business Central.
6.5.2. WHEN conditions in the Guided Rule Template
The Guided Template Editor in Business Central allows users to set rule templates where the data is kept separate from the rules.
In the Guided Rule Template example procedures below, a Nurse Rostering data model was created for a fictitious hospital, Sister Veronica’s.
Procedure: Using the Guided Template Editor with WHEN Constraints
-
Assuming you have already set up a Data Model for your project (as described in Section 5.3, “Creating Data Object (Not Persistable)”), select the plus icon
to the right of the WHENsection of the Guided Template Editor. A dialog window will appear with available condition templates to choose from. In the example below, we select the Applicant… condition from the list.
Figure 6.26. Nurse Roster WHEN Dialog Window

-
Click OK and the Guided Template Editor will display your
WHENcondition. Click on the newly added
WHENcondition. In the example below, it is the "There is a Loan" condition. A "Modify constraints for LoanApplication" dialog appears.Figure 6.27. Modify Constraints Dialog

- From here you can add a restriction on a field, apply multiple field constraints, add a new formula style expression, apply an expression editor, or set a variable name.
In the example below, we will add a restriction of
approvedRateto the condition.Figure 6.28. Adding a Restriction on a Field

- Once selected, the dialog window closes automatically.
Next to the newly selected restriction will be a drop down box to choose an operator. In the example below, we have chosen an operator of "less than."
Figure 6.29. Restriction Drop-Down Menu

-
By selecting the Edit Icon
within the restrictions field, you will be able to define the field value with a literal value, template key, a formula, or expression editor.
By clicking on the WHEN condition again, we can supply a variable name to help define the restriction. In the example below, we name it "a" and click Set.
Figure 6.30. Setting a Variable Name

-
Continue to add
WHENconditions as appropriate for the project.
6.5.3. THEN Actions in the Guided Rule Template
The THEN section of a rule holds the actions to be executed when it matches the WHEN section.
Procedure: Using the Guided Template Editor with THEN Actions
-
Select the plus icon
to the right of the THENsection of the Guided Template Editor to inputTHENactions. A dialog window will appear with available action templates to choose from. In the example below, we select the Modify a… action from the list.
Figure 6.31. Nurse Roster THEN Dialog Window

-
Click OK and the Guided Template Editor will display your
THENaction. Click on the newly added
THENaction. In the example below, it is the "Modify value of LoanApplication [a]"
action. An Add a field dialog appears.
Figure 6.32. Add a Field Dialog

- Within this dialog, you can choose a field from the Add field drop-down menu.
- Once selected, the dialog window closes automatically.
-
By selecting the Edit Icon
within the item field, you will be able to define the field value with a literal value, template key, or a formula.
6.5.4. Data Tables in the Guided Rule Template
Data tables can be altered within the Guided Template Editor directly by clicking on the Data tab. The procedure below illustrates how to alter the data created within Guided Template Editor itself.
Procedure: Using the Guided Template Editor with Data Tables
- Click on the Data tab at the bottom of the Guided Template Editor in order to access the newly created data table.
-
Click the Add row…
button to add more table rows.
Input additional data into the table. In the example below, we see the ServiceLessThan, ServiceGreaterThan, EmployeeRating, and VacationTime column options and supply data to each field.
Figure 6.33. Data Table for Guided Template Editor

-
To view the code, click the
Sourcetab at the top of the Guided Template Editor. - Save the template when you are finished working in the Guided Template Editor.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.