Adding Validation
Overview
Validation can be configured to check data as it is being entered and before completing an actionflow. This could be from simply checking if a field has been completed, to checking for duplicate records using a lookup to a View node.
Validation can be applied at the Table level. Validation set against an attribute in a table will be applied everywhere the attribute exists. See Table Attribute Validation.
Table of Content
Validation Details
Validation is checked On Blur, which means once the user leaves the field the validation is run. It is checked when an existing record is loaded. It can also be checked when the user submits their data via a form.
Validation Type Check
For version 10.1 and above
If a form field on a screen is backed by an Attribute, PhixFlow ensures that it only accept values valid for that Attribute. For example, form fields backed by Integer attributes check if the value provided is a valid Integer without any decimal numbers. This can be overridden by setting a custom Validation Type on the field.
Error Messages - _field.errors
Where validation fails, an error will be displayed by default when a user places their mouse over an invalid field explaining what this issue is. Conditional formatting can be used to highlight the field and display the error message. The error details are accessed using the internal variable _field.errors
.
Prevent Saving of Invalid Fields
Actionflows by default (since version 10.1) are configured to perform validation checks before running the actionflow and not start the actionflow if the validation check fails. For example, when a user presses the Save button on a form, any validation on the form fields will be triggered, and stop the form being saved with validation errors.
The form will highlight the fields that have failed validation and will not allow the user to proceed until the validation issues have been resolved.
Save Data with Validation Errors
An actionflow can be configured to run, even if validation errors occur. For example, if a user does not complete all mandatory fields on a form, they can still save their progress and complete the form later.
The form will highlight the fields that have failed validation and will still give the option to save the form.
- Open the actionflow
- On the toolbar, click Properties
- Within the Basic Settings, uncheck the option Perform Validation before running
- Click the additional tickbox, Allow to Run with Validation Errors to enable this option
Adding a Confirmation Message
Form Field Validation - Video Tutorial
- Perform Validation before running is the default setting from PhixFlow version 10.1 onwards.
Form Field Validation - Mandatory Field
Setting a form field as mandatory.
- Right-click on the form field you would like to set as mandatory and choose Set Validation
- In PhixFlow version 11.0.2 and older, select the field's inner input field and the properties will open on the right
- The properties will open on the right, scroll down to the Validation section
- Click on the tickbox next to Mandatory
- Then toggle this on
- Apply your changes
- If you are using the Serene Grey Template, the following will be seen:
- The form field header text will show with an asterisk *
- The form fields that fail validation will have a red outline after changing the value or when a form is loaded with data in it, such as an edit form
Form Field Validation - Minimum/Maximum Length
- Right-click on the form field you would like to set a minimum or maximum length for and choose Set Validation
- In PhixFlow version 11.0.2 and older, select the field's inner input field and the properties will open on the right
- The properties will open on the right, scroll down to the Validation section
- Click on the tickbox next to Validation Type
- Next to Validation Type, click
- A validation type can also be selected from the drop-down, if the desired validation exists, or edited by clicking the Validation Type hyperlink
- The Validation Type properties open, see Validation Type
- Enter:
- Name, this should be indicative of its purpose. For example, minimum name length
- Base Type, select the type of data. For example, different data types have different parameters such as numbers specifying the maximum value
- Minimum Length (optional), sets the minimum number of characters. For example, 2
- Maximum Length (optional), sets the maximum of characters. For example, 150. If left blank there is no maximum
- Error Message (optional), enter a custom message or leave blank for the default message. This is shown when the field fails the validation check and you mouseover the field
- Apply your changes
- If you are using the Serene Grey Template, the form fields that fail validation will have a red outline after changing the value or when a form is loaded with data in it, such as an edit form
Form Field Validation - Matching a Given Pattern
- Right-click on the form field you would like to set a pattern match for and choose Set Validation
- In PhixFlow version 11.0.2 and older, select the field's inner input field and the properties will open on the right
- The properties will open on the right, scroll down to the Validation section
- Click on the tickbox next to Validation Type
- Next to Validation Type, click
- A validation type can also be selected from the drop-down if the desired validation exists or edited by clicking the Validation Type hyperlink
- The Validation Type properties open, see Validation Type
- Enter:
- Name, this should be indicative of its purpose. For example, minimum name length
- Base Type, select
String
- Pattern, define a pattern the input must adhere to in the form of a regular expression. Pattern examples are provided at the end of this section
- Apply your changes
- If you are using the Serene Grey Template, the form fields that fail validation will have a red outline after changing the value or when a form is loaded with data in it, such as an edit form
Example Patterns
See Regular Expressions for details on how to create a pattern.
Description | Pattern |
---|---|
Alpha Only | [A-Za-z] |
Alpha Numeric including, hyphens, underscores, spaces, ampersands and full stops |
|
Numeric Only | [0-9] |
| |
Specific words e.g. hello or world | \b(hello|world)\b |
Editing an Existing Validation
To edit an existing validation:
- Opening an existing Validation
- Open the table attribute that has the Validation Type applied to it. In the Validation section click the Validation Type link to open it.
- Alternatively, in the Repository open the Validation Type section within your application or within the package associated to your application and double-click the Validation Type you wish to change.
- Make the required changes and Apply your changes.
Editing Existing Validations
Changes to an existing Validation Type impact everywhere it is currently being used. If you are changing a Validation Type from a shared package, these changes can impact other applications also using this package. Therefore, we recommend adding new validation if you have a specific requirement.
Verify a Record is Selected
This is achieved by performing a lookup on the data that is driving the Actionflow. The setup is as follows:
- Open the Actionflow that will check a record is selected
- Above the Actionflow canvas are the phases. On the Processing Phase, click Add New
- Select Add Phase Before and set the Name to
Record Counter
Click Connect on the connections pane and select the Event input
Click Add New in the Connections pane:
Name, the connection CountRecords
Select Lookup
Click Create Connection Point
Select the View Component, which contains the grid we are checking has a selected record
- Click Connect Input
- On the mappings screen that appears drag the UID, or other primary key, across to create a mapping
- Make sure the data being used is set to Selected Records
- Click Save
- Create a Calculate Node by dragging and dropping from the toolbar
- Name the node
Count Records
- Name the node
- Connect the Event Input Connection to the calculate. This is what causes the actionflow to run
- Connect the Lookup Input Connection, Count Records, to the calculate
- Select Add Lookup
- Name the connection
lu
- Drag and drop the UID field to create a mapping to the Calculate node.
- Click Confirm Mappings
- Click on the Calculate node to open its editor
In the Calculate Attributes section, click
Use the following settings:
Name: Count
Type: integer
Expression,
countElements(lu.UID)
This counts the number of selected records on the grid we are looking up
- Save the attribute
- We will now create a second attribute that will hold the message for the user
In the Calculate Attributes section, click
Use the following settings:
Name: Message
Type: string
Expression,
"Please select 1 record from the grid."
Save the attribute
- We now have a count of the number of selected records
- Checkpoint
- We can now use a gateway action to allow the actionflow to continue if we have 1 record or pass a message back to the user to inform them of what to do
- Drag a Gateway action from the toolbar onto the canvas
- Name,
Decision
- Click Create Action
- Name,
- Connect the Calculate Action to the Gateway Action
- In the mapping window that opens drag the Count and Message attributes to the right to create gateway input attributes
- To change these mappings in the future click on the connecting line
- Click Save
- In the mapping window that opens drag the Count and Message attributes to the right to create gateway input attributes
- Click on the Gateway Action to open its properties
- In the Rules section double-click the existing rule
- Set Expression to,
in.Count == 1
- Note these expressions must equate to true or false, therefore there is n need to provide an if statement as it is implied
- Apply and Close your changes
- Set Expression to,
- In the Rules section click , and set the following:
- Name,
Message
. - Expression,
in.Count != 1
- Apply and Close your changes
- Name,
- In the Rules section double-click the existing rule
- The Gateway Action now has two outputs available,
out
andMessage
- Out,
- Drag a Start Phase action onto the canvas
- Select Processing Phase, or whichever phase you require
- Place your mouse over the Gateway, click on out and drag it to connect to the Start Phase action. Out runs when the user has selected 1 record so we want to continue with our actionflow
- Message,
Create an output connection
Click Add New in the Connections pane:
Name, the connection screen
Select Output
Click Create Connection Point
Select the Form Component, this will require a dynamic text to write to. If you do not have a dynamic text on your screen create one before continuing
- Click Connect Output
- Drag the Count and Message attributes to the right to create outputs
- Right-click on the line connecting the output connection back to your screen's form and select Configure Mappings
- Map your Message attribute onto the dynamic text area on your screen. This will display the message where a user has not selected a single record
- Out,
- Checkpoint
The final configuration will look like this
In this example setup, if a user tries to click edit on the screen without having first selected a record, a message will appear on the screen informing them to select a record
Duplicate Entry Check
The following example will check for a duplicate company name when trying to save a new company record.
- Open the actionflow that will check a record is selected
- Above the actionflow canvas are the phases. On the Processing Phase click Add New
- Select Add Phase Before and set the Name to Duplicate Check.
Click on Click to Connect on the Connections pane
- Connect the Form as an input into the actionflow and click Connect Input
- The Mappings Screen opens, map in the Name attribute you wish to check for duplicates
- Create a Calculate node by dragging and dropping from the toolbar
- Connect the Input Connection Point to the Calculate Action and map in the Name attribute
- Hover over the Calculate Action and select Add Lookup
- Name it
dup
- Drop the arrow into space on the canvas to create the node
- Name the View
Companies
, or something appropriate for your use case - Select the table where you are checking for duplicates, this will be the primary table
- An output attribute selection popup will appear. Add attributes to the view node by selecting all the attributes and dragging and dropping them onto the Output Attributes section on the View property editor
- Click Next
- Name the View
- Select the dashed line connecting the Calculate to the View to open the Mappings:
- Incoming Mappings, are used to filter the records in the view. These can be thought of as the request details. Drag and drop the Name attribute to the View node section to create a mapping. This will be used to configure the filter later
- Click Next
- Outgoing Mappings are the attributes returned from a lookup. Drag and drop UID, or the primary key for your table, from the View to the Calculate Action. This will be used in the calculate attribute expression later
- Creating a filter. Click on the node to open its editor. Under Data Retrieval Options click next to the Default Filter to add a filter. Provide the following information:
- Name: Filter by Name
- Private: false
Select the options:
Name
equals
in.Name
. Make sure to click the 'abc' button to convert it to an expression
Apply and Close your changes
- Click on the node to open its editor and add a Calculate Calculate Attribute with the following settings
Name, DuplicateCheck
Type, Integer
Order, 1
Expression,
// This will display a user error and stop the actionflow immediately if // any duplicates are found. do( $count = countElements( dup.UID ), if($count > 0, do( error("There is already a Company with the name: "+in.Name), stop() ) ), $count )
- It is possible to remove the
stop()
from the expression and instead, use a Gateway Action to decide if to continue to the next phase (see next step) or write a message back to the screen for the user to see.
- Apply all your changes
Hover over the and click Out Calculate
- Drag the arrow into space on the canvas and click where the new node should appear
- Select Phase and select Processing Phase. This will then run the processing phase if the actionflow hasn't been stopped by the DuplicateCheck attribute
Validation Involving Lookups
To find out more about using validation to check for duplicates or to check a value against existing data, see Using Lookups in Actionflows.
Validation Phase Example
Setting up a Validation Phase at the start of an actionflow. This phase will do all the necessary checks and if these checks have passed, the next phase of the actionflow can be initiated using a Phase node. For example, a user has a list of objects and has created an edit form to add a new object and wants to verify some information about the entry.
The save button in this example by default uses the following actionflow. The edit form is wired into the actionflow and the Save saves the fields on the form automatically.
The user decides that the name field must be supplied for every record and therefore adds a check to make sure this field is populated before saving.
To do this:
- Add a phase before the current Processing Phase
- Name this Validation
- Click Connect to connect the form as an input into the actionflow
- On the mappings popup, drag and drop the Name field to the interface to create a mapping
- Click Confirm Mappings
- Add a Calculate node to the canvas by dragging and dropping from the toolbar
- Name this Validate Records
- Connect the interface connection point to Validate Records by dragging from the arrow to the node
- On the mappings popup, drag and drop the Name field to the calculate section to create a mapping
- Click Confirm Mappings
- Click on Validate Records to open its editor. Add a calculate attribute:
Name, CheckName
Type, String
Order, 1
Expression,
if(isNull(in.Name), do( error("Please provide a name."), stop("message") ), _NULL )
stop()
will terminate the actionflow immediately at the node it is being used.error()
displays an error message to the user.
- Add a Phase node to the canvas by hovering over the Calculate Action and selecting out as the output connection point
- Drop the line into empty space
- Select Phase
- Select Processing Phase
- The processing phase will only run if the actionflow is not terminated by the stop() function in the Calculate Action