Running a Validation Rule at Startup

Last Updated: 07/09/2018 Introduced in Version: 2.0

To ensure that a user enters valid data in a form’s required fields, you can configure a form to run validation rules when it opens and to display alerts next to the fields. This can be useful for highlighting form fields that must be changed because their default values, or values inherited from a preceding step, are invalid.

The RunRulesAssumingOutcomes form property enforces the validation rules for a specified outcome when a form opens. Add it to a form in the Properties panel, under the section Rules > RunRulesAssumingOutcomes, by selecting the Finish checkbox.

Example

Our example flow will contain a single form step. This form Leave Request Form will have four fields: Employee EmailID, Select Leave Type, Start Date, and End Date.

All four form entries will be required values. In addition, the custom rule Start Date will be hooked into our form, requiring that the Start Date be earlier than End Date. These rules will be enforced at startup, so that if any field is in error, it will be highlighted when the form is instantiated, rather than only when it is submitted.

We’ll begin in the portal by navigating to our project folder and clicking the Create Flow button.

 

We’ll give the flow a name and click CREATE to open it in the Flow Designer.

 

In the Flow Designer’s start-up window, in the category Flows, Rules, Forms and Reports > Forms [Interaction] > [Current Folder], we select a Leave Request Form component and click Add to add it to the workspace.

 
Next, we’ll connect the outcome paths in the flow.
 

To add the Start Date validation rule to the form, we select it in the workspace and click the Edit Form link in the Properties panel.

 

This opens the Leave Request Form in the Form Designer.

 

Expand the Properties panel. In the section Form Rules > Validation Rules, we will click the Add New button.

 

In the resulting Add Validation Rule dialog, configure the details for the custom rule. Name the rule then in the Rule drop-down list, select Designer Folder > Start Date Rule.

 

Next, we will update the message that is displayed when this rule is broken by changing ValidationBreakText’s value to “Start date must be less than End date.”

Next, we will configure our rule to apply to the appropriate controls in the ApplyToControls list by checking the checkboxes for both Date Pickers.

To configure our rule inputs, we will select the first input Start Date and click the Edit button [pencil shaped icon].

 

In the resulting Edit object pop-up, we will change Start Date’s input type from “InputData” to “Form”.

Then define the form element which will serve as the Start Date input by selecting the FormDataName “start date”.

This completes our definition for the Start Date input, so we will click the OK button to close the Edit Rule dialog.

 

Next, configure our rule’s second input by selecting the second input End Date and selecting the Edit button.

 

In the resulting Edit Rule dialog, change End Date’s input type from “InputData” to “Form Component”.

Then define the form element which will serve as the End Date input by selecting the FormDataName “end date”.

This completes our definition for the End Date input, so we will click the OK button to close the Edit Rule dialog.

 

This also completes our configuration of our custom rule – Start Date –  so we will click the OK button to save the configuration and close the Edit object pop-up.

 

If we were to save our form now, Start Date would be run every time we submit it via the Finish button. To run this rule at startup, we will go to the Properties panel and, under the heading Rules > RunRulesAssumingOutcomes, check the box next to the Finish outcome.

This completes our form. We will click the Save link at the top of the Form Designer to save it. Close the form.

This also completes our flow, so we save the flow and close the Flow Designer.

 

Back in our project folder, we will run our new flow by clicking its thumbnail and selecting Run > Run Flow from its Action menu.

 

In the resulting pop-up, we’re presented with a version of Leave Request Form where the rules that would ordinarily be applied upon submission have already been applied.

 The Start Date and End Date fields are in error because the date provided by End Date is not later than the date provided by Start Date

A user seeing this form for the first time can tell immediately which values need to be changed in order for the form to be valid.

 

A user seeing this form for the first time can tell immediately which values need to be changed in order for the form to be valid.

Additional Resources