Rules
You can create formatting and validation rules.
A rule is triggered when its condition expression evaluates to true. If the condition expression evaluates to false, the rule is not triggered. When a validation rule is triggered, red boxes appear around the affected controls.
The condition syntax can include any variables available in the formula builder, including item properties and named controls. Runtime functions and standard mathematical symbols can be used to manipulate or compare values for the purpose of crafting a condition. If all values in the condition (formula) are of the number data type, then the value is calculated.
Formulas (conditions) differ from inline functions, which are resolved on form load at run time. For more information about inline functions, see Functions.
Following are example condition scenarios.
- To concatenate strings, include the "+" symbol between named controls and string or number values.
- To specify a string literal, use double quotes. Example: Option=="High"
Add rules to selected controls to configure form behavior when defined trigger conditions occur. For example, you can hide a set of detailed fields if a particular option is not selected.
To add a rule
-
Make sure all desired controls are selected.
You can add a rule to multiple controls.
- Do one of the following.
- In the Control tab of the Nintex Forms designer ribbon, click Add Rule.
- In the Rules pane, click Add. (To access this pane, click Rules in the Designer tab.)
The rule configuration fields appear in the Rules pane.
- Classic designer: For Rule Type, select an option.
- To apply formatting, visibility, and editable changes based on condition, select Formatting.
- To mark the controls as invalid based on a condition, thus preventing submission of the form, select Validation.
-
Define the condition and fill in other fields as needed.
Note: For Nintex Mobile, define rules using runtime functions. Operators are not currently supported by forms in Nintex Mobile apps.
You can change the order of the rules for a given control or a set of controls, thus changing the order of rule execution for those controls.
-
Click the rule you want and drag and drop it to the position you want.
-
To move a rule to the top or bottom of the list, click to open the context menu and select the related option: Send to top or Send to bottom.
In the Classic Forms designer, you can also position rules In the Rules pane, by dragging the rule to the desired position.
This tutorial helps you:
- Create a form that validates hidden controls.
- View the problematic validation.
- Resolve the problematic validation
- Confirm the resolution.
When you set up validation rules for controls that may be hidden, make sure the rule condition resolves only when the control is visible. For example, consider a document review form that shows a required comment field only when the user rejects the document. When a user of the form approves the document, the required comment field does not appear. However, if the rule condition resolves regardless of control visibility, then users who approve the document are not able to submit the form because the required field is not visible.
See also the following Nintex Connect article: Validation Around Hidden Elements.
To create a form that validates hidden controls
Note: References inserted into property values are indicated here by red text. For example, a reference to the item identifier ("ID") is indicated by "ID". To insert item properties, named controls, and other references, use the Insert Reference pane. For more information, see Insert References.
-
Access the Nintex Forms designer.
Note: This scenario assumes use of the classic forms designer.
- Add a choice control with Approve and Reject options.
Add the following form control to the designer canvas.
Double-click the control to display the control settings dialog box, set property values as follows, and then click Save.
Property name Property value Name ApproveReject Display format Drop down list Choices Approve,Reject
- Add a panel control.
Add the following form control to the designer canvas.
Double-click the control to display the control settings dialog box, set property values as follows, and then click Save.
Property name Property value Name RejectPanel Title Fields required for rejection
- Within the panel control, add a sample choice control.
Add the following form control to the designer canvas.
Double-click the control to display the control settings dialog box, set property values as follows, and then click Save.
Property name Property value Name SampleChoices
- Within the panel control, add a multiple line text box control.
Add the following form control to the designer canvas.
Double-click the control to display the control settings dialog box, set property values as follows, and then click Save.
Property name Property value Name Multi
- Require entry in the multiple line text box control named "Multi."
- On the designer canvas, select the multiple line text box control ("Multi").
- In the Control tab of the Nintex Forms designer ribbon, click Add Rule.
In the Rules pane, set property values as follows.
Property name Property value Name Multi Required Rule Type Validation Condition Multi == "" Message The Multi field is required!
- Hide the panel control if the user does not select Reject for the choice control named "ApproveReject."
- On the designer canvas, select the panel control ("RejectPanel").
- In the Control tab of the Nintex Forms designer ribbon, click Add Rule.
In the Rules pane, set property values as follows.
Property name Property value Name Hide Panel Rule Type Formatting Condition ApproveReject != "Reject" Disable (leave this check box cleared) Hide (select this check box)
To view the problematic validation behavior
-
In the Designer tab of the Forms designer ribbon, click Preview.
- In the Preview Settings dialog box, select the device and preview mode.
- Click Generate Preview.
-
In the preview window, select Approve from the drop-down list (first choice control).
Observe that the Multi field is hidden, as expected.
-
and then click Save.
Observe the problematic validation behavior: the validation message "The Multi field is required!" appears even though the field is hidden.
- To close the preview window, click Close on the upper right.
To resolve the problematic validation behavior, update the rule condition for "Multi"
- On the designer canvas, select the multiple line text box control ("Multi").
- In the Rules pane, select the existing rule "Multi Required."
-
Update the condition property value as follows.
Multi == "" && ApproveReject == "Reject"
To confirm resolution of the problematic validation behavior
-
In the Designer tab of the Forms designer ribbon, click Preview.
- In the Preview Settings dialog box, select the device and preview mode.
- Click Generate Preview.
-
In the preview window, select Approve from the drop-down list (first choice control). and then click Save.
Observe that the Multi field is hidden, as expected.
-
Click Save.
Observe that the problematic validation behavior is resolved; the validation message for the Multi control does not appear. If no other fields are required, the save operation is accepted.
- To close the preview window, click Close on the upper right.
The Rules pane can be displayed on the right of the Nintex Forms designer.
Use this pane to configure form behavior when defined conditions exist. For example, you can hide a set of detailed fields if a particular option is not selected.
The Rules pane contains the following selections.
Icon | Label or tooltip | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
(none) |
View All Rules / View Control Rules |
Toggles between displaying all rules for the form and all rules for the selected control. |
||||||||||||||||||||||||
Add Rule | Adds a rule to the selected control. | |||||||||||||||||||||||||
(none) | Select All | Selects the check boxes for all displayed rules. | ||||||||||||||||||||||||
(none) | Deselect All | Clears the check boxes for all displayed rules. | ||||||||||||||||||||||||
(none) |
Delete |
Deletes all selected rules. |
||||||||||||||||||||||||
/ | (none) | Disables or enables the indicated rule. | ||||||||||||||||||||||||
/ | (none) | Minimizes or maximizes the indicated rule. When maximized, displays rule configuration foelds. | ||||||||||||||||||||||||
... | (none) |
Lists the following options for the indicated rule.
|
Configuration settings are displayed for maximized rules as follows.
Field | Description |
---|---|
Rule name |
The name of the rule. To delete the rule, click the delete icon to the right of the field. |
When |
The condition that must exist for the rule to be executed. Click (to the right of the field) to open the Formula Builder. When building a condition or other formula for a control within a repeating section (an instance of the control Repeating Section control), keep in mind the possibility of multiple rows. For example, use an average or other aggregate formula instead of an equivalent, or include the function currentRowNumber in the formula. Conditions and other formulas that reference a control in a repeating section without following these best practices may not work. If the referenced control has multiple rows, then a badly formed condition or formula (one that assumes a single row) cannot be completed. |
Then |
The action to take with the selected control when the condition exists. The following options are available.
|
Icon | Selection | Description |
---|---|---|
Add | Adds a rule to the selected control. | |
(none) | Show all |
When selected, shows rules for all controls on the form. When cleared, shows rules for the selected control only. Default: Cleared. |
Reorder rule | Repositions the selected rule within the list of rules. | |
Formatting rule | Indicates a rule of the formatting type. | |
Validation rule | Indicates a rule of the validation type. | |
Associated Rule/Rule Details | (Displayed when Show All is selected.) Indicates that the rule is associated with all controls that are currently selected. |
Rule drop-down list options are as follows.
Icon | Option | Description |
---|---|---|
Select associated controls |
Resets control selection to those on the current device layout that are associated with the current rule. |
|
Add to selected controls |
Adds the current rule to all of the selected controls. |
|
Remove from selected controls |
Removes the current rule from all selected controls. |
|
Send to top |
Makes this rule first; moves the rule to the top of the list of rules. |
|
Send to bottom |
Makes this rule last; moves the rule to the bottom of the list of rules. |
|
Delete rule |
Deletes the rule from the form. |
Configuration settings for a rule are as follows.
Field | Description |
---|---|
Name |
The name of the selected rule. The icon (Unselected Controls) appears to the right of the Name field if some controls using this rule are not currently selected. |
Rule Type |
The type of rule:
|
Condition |
The condition that must exist for the rule to be executed. Click (to the right of the field) to open the Formula Builder. When building a condition or other formula for a control within a repeating section (an instance of the control Repeating Section control), keep in mind the possibility of multiple rows. For example, use an average or other aggregate formula instead of an equivalent, or include the function currentRowNumber in the formula. Conditions and other formulas that reference a control in a repeating section without following these best practices may not work. If the referenced control has multiple rows, then a badly formed condition or formula (one that assumes a single row) cannot be completed. |
Formatting |
(Available when Formatting is selected for Rule Type.) The formatting to apply for this rule.
|
Disable | (Available when Formatting is selected for Rule Type.) When selected, disables the control when the condition exists. |
Hide | (Available when Formatting is selected for Rule Type.) When selected, hides the control and associated labels when the condition exists. |
Message | (Available when Validation is selected for Rule Type.) Text to display if control does not pass validation rule. |
To display the Rules pane, do one of the following
- Click Rules in the Designer tab of the Nintex Forms designer ribbon.
-
Click Add Rule in the Control tab of the Nintex Forms designer ribbon.
This action also creates a new rule.
To close the Rules pane
- Click X on the upper right of the pane.