6.5. Rule Templates
6.5.1. The Guided Rule Template
Procedure 6.5. 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 → .
- 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 .
- The new Guided Rule Template is now created and under the selected project.

Figure 6.25. Guided Template Editor
Note
6.5.2. WHEN conditions in the Guided Rule Template
Guided Template Editor within Business Central allows users to set rule templates where the data is completely separate from the rules.
WHEN constrains within the Edit tab.
Note
Procedure 6.6. 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 a 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
Nurse...condition from the list.
Figure 6.26. Nurse Roster WHEN Dialog Window
- Click
OKand the Guided Template Editor will display yourWHENcondition. - Click on the newly added
WHENcondition. In the example below, it is the "There is a Nurse" condition. A "Modify constraints for Nurse" 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
servicelengthto the condition.
Figure 6.28. Title
- 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.

Figure 6.30. Field Value Options
- By clicking on the
WHENcondition again, we can supply a variable name to help define the restriction. In the example below, we name it "nurse" and click the Set button.
Figure 6.31. Setting a variable name
- Continue to add
WHENconditions as appropriate for the project. The example below demonstrates "servicelength" and "rating" constraints.
Figure 6.32. WHEN Constraints
6.5.3. THEN actions in the Guided Rule Template
THEN section of a rule holds the actions to be executed when it matches the WHEN section.This section explores how to alter the THEN actions within the Edit tab of the Guided Template Editor.
Procedure 6.7. 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 nurse...action from the list.
Figure 6.33. Nurse Roster THEN Dialog Window
- Click
OKand the Guided Template Editor will display yourTHENaction. - Click on the newly added
THENaction. In the example below, it is the "Modify value of Nurse[nurse]"
action. An "Add a field" dialog appears.

Figure 6.34. 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.

Figure 6.35. Field Value Options
6.5.4. Data Tables in the Guided Rule Template
Procedure 6.8. 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.36. Data Table for Guided Template Editor
- To view the code source, click the Source tab at the bottom of the Guided Template Editor. Illustrated below is the source code for the Nurse example in the Veronica Template.

Figure 6.37. Source Code for Nurse Example
- 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.