Rules

A form can consists of multiple pages, the rules can be used to define when and which page is to be presented to the user when any particular selection is made or any button is clicked. The Form Designer Rules tab allows you to create rules that can be used on the form.

In the Rules tab, you can add, edit, clone, delete, as well as enabling and disabling the rules.

Add

To add a new rule, click on the “Add” button on the upper right corner of the page. The “Add” page will appear.

In the “Properties” panel, key in an unique name for the new rule in the “Name” field and a brief description in the “Description” field. Selecting the “Inverse” field allows you to invert the condition set in the “Condition” panel. The “Enabled” field is selected by default, which enables the new rule for the form.

In the “Conditions” panel, click on the “+” icon to add a new condition.

In the first field, select the condition from the drop-down list. Select the operator from the second field. Key in the desired result in the third field. More than one condition can be added. Simply click on the “+” icon to add more conditions.

In the “Actions” panel, click on the “+” icon to add a new action.

Select the desired action from the drop-down list for the first field. Select the desired page or input from the dorp-down list for the second field. More than one action can be added. Simple click on the “+” icon to add more actions.

To remove any condition or action, click on the “Delete” icon on the right of the condition or action.

After the required conditions and actions are added, click on the “Save” button to save the new rule. Click on the “Cancel” button to abort the new rule.

If the name for the “Name” field is already in use, an error message will appear.

Edit

To edit an existing rule, click on the “Edit” icon under the “Actions” column corresponding the desired rule. The “Edit” page will appear.

The fields are as per in the “Add” page. Edit the rule as desired and click on the “Save” button to save the changes.

Clone

This clone function allows you to copy an existing rule, so that you need not create a new rule from the beginning.

To clone an existing rule, click on the “Clone” icon under the “Actions” column corresponding the desired rule. A new rule will be added into the Rules tab, with a new name <rulename Copy 1> along with the conditions and actions from the selected rule.

Delete

To remove a rule from the Rules tab, click on the “Delete” icon under the “Actions” column corresponding to the desired rule. Note that there is no message and you cannot undo this action.

Refresh

After performing actions on the browser/tab, the list is reloaded to display the list of rules. The manual “Refresh” button is available and is particularly useful if there are others making changes on the same page.

The “Refresh” button is found on the upper right corner of the page. Clicking on it reloads the list.

Search

There is a cross-field search function for the list of rules. It is located at the upper left corner of the page.

This provides an easy way to search through the rules. It is case-insensitive and displays rules that have the entered search value in any of the values of the fields below:

  • Name
  • Description

Examples

Using Rules to Show/Hide Form Components

The rules in the form can be used to control the show/hide or enable/disable of components based on values selected by users. You can also use rules to limit the users from using part of the form.

Below is an example using a fixed value to show/hide certain components in the form. In this case, the “ContactNo” field in the form is only visible by those with the role Sales. In the one of the component properties in the form, add a hidden field whose “Id” field indicates role and the “Value” field indicates Sales.

In the Rules tab, add a new rule.

In the “Properties” panel, key in an unique name for the new rule. Ensure the “Inverse” and “Enabled” fields are selected.

In the “Conditions” and “Actions” panel, set up as per the screenshot below.

Click on the “Save” button to save the new rule. Test the form using the “Run Form” option in the Form tab with two different users, one with the Sales role and one without.

There are other substitutions that are supported. Below are some examples:

  • ${username}
  • ${userid}
  • ${email}
  • ${roles}
  • ${privileges}

For a more dynamic case, take a leave application for example. Employee A applies to take leave and Employee A’s manager (Employee B) needs to approves it. The ETL in the “Submit” transition looks up Employee B and inserts that into elxPublic.

{
  "approver":"B"
}

The hidden field “approver” in the form dynamically gets the value “B”.

A rule can be added that says “shows the ”Approve“ button if username is B”.

Using a Hidden Component to Show/Hide Form

In the form created, add a Hidden component. In the properties of the Hidden component, set the “Id” and “Value” as “disabled”.

Create a rule with condition and action as per the screenshot below.

This rule states that if ${mode} is disabled, the entire form will be disabled. Run the form and you will get a normal editable form.

Add mode=disable to the end of the URL of the form. For example:

  http://localhost:1740/form-runtime/c6f8307b-2f2a-464c-83ec-3940fba6881e/index.html?mode=disable

The form is now disabled and is not editable.