Running a Validation Rule at Startup
  • Updated on 09 May 2013
  • 4 minutes to read
  • Print
  • Dark
    Light

Running a Validation Rule at Startup

  • Print
  • Dark
    Light

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.
2018-07-09_1442581.jpg

We'll give the flow a name and click CREATE to open it in the Flow Designer .
2018-07-09_144336.jpg

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.
2018-07-09_144433.jpg

Next, we'll connect the outcome paths in the flow.
2018-07-09_144520.jpg

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.
2018-07-09_144627.jpg

This opens theLeave Request Form in the Form Designer .
2018-07-09_144059.jpg

Expand the Properties panel. In the section Form Rules > Validation Rules , we will click the Add New button.
2018-07-09_145045.jpg

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.
2018-07-09_150028.jpg

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].
2018-07-09_150338.jpg

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 theFormDataName "start date".
This completes our definition for the Start Date input, so we will click the OK button to close theEdit Rule dialog.
2018-07-09_150448.jpg

Next, configure our rule's second input by selecting the second input End Date and selecting the Edit button.
2018-07-09_151004.jpg

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.
2018-07-09_151139.jpg

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.
2018-07-09_151414.jpg

If we were to save our form now, Start Date would be run every time we submit it via theFinish 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 .
2018-07-09_151804.jpg

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

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.
2018-07-09_152149.jpg

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.

Was this article helpful?