Running a Validation Rule at Startup

Last Updated: 12/04/2015 Introduced in Verision: 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 RunOutcomeRulesAtStartup 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 > RunOutcomeRulesAtStartup, 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.

expectedResult

 

Our example assumes that Leave Request Form and validation rules for the Employee EmailID and Select Leave Type field have already been configured.

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

createFlow

 

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

nameFlow

 

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.

flowStarts

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

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.

editForm

 

This opens the Leave Request Form in the Form Designer.

formOpens

 

To add our rule Start Date to the form, we will expand the Explorer panel and select Surface.

selectSurface

 

Next, we will collapse the Explorer panel and expand the Properties panel. In the section Custom Validation Rules > Rules, we will click the Add button.

addNewRule

 

In the resulting Edit Object pop-up, we will configure the details for our custom rule. We will name our rule and, in the Rule drop-down list, select Designer Folder > Start Date Rule.

addDateRule

 

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 SilverDatePicker 1 and SilverDatePicker 2.

To configure our rule inputs, we will select the first input Start Date and click the Edit button.

editStartDate

 

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

inputsToStartDate1

 

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

inputsToStartDate2

 

This completes our definition for the Start Date input, so we will click the Save button to close the Edit Object pop-up.

finishStartDate

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

editEndDate

 

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

inputsEndDate1

 

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

inputsEndDate2

 

This completes our definition for the End Date input, so we will click the Save button to close the Edit Object pop-up.

saveEndDate

 

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

saveRule

 

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 > RunOutcomeRulesAtStartup, check the box next to the Finish outcome.

runAtStartup

 

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

saveForm

 

Click the X icon in the top-right corner to close the Form Designer and return to the Flow Designer.

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.

runFlow

 

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 required Employee EmailID and Select Leave Type fields are in error because they are empty. 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.

expectedResult

 

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