Audience
  • Developers
  • Form Designers
Required Knowledge
  • SmartObjects
  • Views
  • Rules, State and Rule Designer

Introduction

The latest How To topics are available in the K2 Five User Guide or the K2 Cloud User Guide’s How to section.

Rules can now be enabled or disabled in the Rule Designer. This is useful when having different Form states or opening subviews or subforms for example and certain Rules are not required.

Implementation Details

Rules can be disabled and enabled using the appropriate button displayed on the Rule Designer toolbar. When a Rule is disabled, the text of the Rule changes to gray and the icon of the Rule changes as seen below. Enabling the Rule will restore the icon and change the text to black.

Image

It is however important to note the influence enabling or disabling Rules has on Rule inheritance.

If a parent View is opening a subview for example which inherits the Rules from the parent View, and changes are made to the Rules on the subview, the Rule inheritance to the parent View is lost.

Rule Inheritance

View Rules can be set up to execute independently from Form Rules , but they can also be used to add to in a Form, meaning a View Rule created in the View Designer is available for editing in the Form Designer's rules section. When the View rule is changed on the Form, it does not modify the rule on the View. However, if the rule is changed in the View Designer for the rule that was previously overwritten in the Form, the change to the View rule will apply to the rule on the Form. The Form rule therefore inherits the View Rule and will see the changes made, but will still apply the previous change made to the View Rule on the Form as well.

A Rule Definition that was created in the View Designer can be enabled or disabled in the Form, but not be removed from the Rule. Only Rule Definitions that belong to the specific designer can be removed in that designer.

Considerations

The following needs to be considered when disabling a Rule:

  • Changes to the parent View/Form, such as adding/removing/editing of Actions or Conditions will still be applied to the child. However enabling or disabling Rules will not be applied to the child as the inheritance is lost.
  • When a Rule is disabled all Actions, Conditions and Events contained within that Rule are also disabled.
  • When a Rule is disabled the Rule can still be removed but it cannot be edited.
  • If a Rule is disabled and it contains an Action to execute another rule, that rule will not be executed as the parent rule is disabled.

For more information or examples on Rules and Rule Inheritance refer to the following:

Example Scenario

In this scenario we will use two Views created from the same SmartObject, and then enable and disable certain Rules. Afterwhich we will create a Form with a Form state to enable and disable Rules.

Follow the steps below to set up the scenario as described above:

  1. Create an Item View (Customer Item) from a SmartObject. On the Rules screen select the When Delete Button is Clicked rule and click the disable button on the toolbar.
    Image
  2. Create another View (Customer Item 2) from the same SmartObject and add a Button control to the View.
  3. Navigate to the Rules section and add the following new Rule for the Button control.
    1. Events: When a control (Button) on the View raises an event (Clicked)
    2. Actions: open a subview. Select the View created in step 1 (Customer Item) as the subview. Click Finish.Image
  4. The Customer Item View Rules are now also listed and the Rules are inherited from the Customer Item View as shown below. Note the disabled Rule as configured in the Customer Item View:
    Image
  5. Enable the above mentioned Rule and disable the Rule when Load Button is clicked as shown below. The inheritance is now lost between the Customer Item View and the Customer Item 2 View since we changed the enable and disable Rule settings of the parent View on the child View.
    Image
  6. Save the Customer Item 2 View and Finish the View.
  7. Edit the Customer Item View and navigate to the Rules.
  8. Note that the changes made in step 5 are not applied to the parent View as the Rule inheritance was lost as mentioned previously.
    Image
  9. Generate a Form containing the Customer Item View and the Customer Item 2 View.
  10. Edit the Form and navigate to the Rules. The Rules of the two Views are displayed and have no influence on each other.
    Image
  11. Add a Manager state. The Manager state inherits the Rules of the Base state as shown below.
    Image
  12. Enable the when Delete Button is clicked Rule of the Customer Item View of the Manager state.
    Image
  13. Click on the Base state. Both Rules are still disabled.
    Image
  14. Save and Finish the Form.
  15. Edit the Customer Item View and navigate to the Rules. The When Delete Button is clicked Rule is still disabled. The change made to the Manager state is not applied to the parent View as the inheritance was lost when the Rule was changed in the Manager state.
    Image