Overview
Validation can be configured to check data as it is being entered and/or before completing an Actionflow.. This could be simply checking if a field has been completed, checking for duplicate records or checking data meets certain criteria before being saved.
Validation can be applied at the Table level. Validation set against an attribute in a table is applied everywhere the attribute exists. See Table Attribute Validation.
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
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
.
Adding a Confirmation Message
See 1.13 Confirmation Message Configuration.
Form Field Validation
See 1.10 Validation.
Worked Example
Here is a worked example using the Shop Data (available from the Learning Centre).
In this example, we are using:
- A Shop Customer Form screen containing blank input fields, set up to create a new staff member - this screen was created using the Edit Form template
- A Shop Customer Duplicate Popup screen containing a grid of the FirstName and LastName attributes from the Shop Orders data, dynamic text fields and a background filter to filter the grid - this screen was created using the Tile no Buttons template
If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Intermediate Application. For these example, we'll be working on the Check button on the Shop Customer Form, and the Shop Customer Duplicate Popup screen.
Identify If New Customer Already Exists
In this example, we'll create an Actionflow that checks if a new customer's name matches any existing customers, then shows this information in a pop up.
Initial Setup
- On the Shop Customer Form screen, add a new Actionflow to the Check button
- Configure the Shop Customer Form as the input data for the Actionflow
- Map into the Actionflow the attributes, first_name and last_name
- Create a Calculate action - this will be used to process the results of a lookup
- Drag the input node
- Hover over the Calculate action and choose Add Lookup, then click onto the canvas to create a View action
- Primary Table: Shop Customers
Configure the View
- The Output Attributes window will pop up for the View
- Tick first_name and last_name and select Next
- For the Incoming Mappings, map the first_name and last_name attributes, then select Next
- For the Outgoing Mappings, map the first_name and last_name attributes
- You may wish to rename the Outgoing Mappings (right-click and Edit) to make them easier to reference
- Select Confirm and create filter
- Create a filter to match the name on the input form to the name in the data
- Add two filter conditions:
Ensure Case Sensitive is toggled off to capture names being entered in upper and lowercase
This could be changed to, Where ALL of the following are true, if you wanted to only find existing customers that match the first and last name.
Configure the Calculate Action
- Click on the Calculate action and create 3 Output Attributes:
Create an Output Attribute to count the records being returned from the lookup
- This will be mapped onto a dynamic text field to display how many duplicate records have been found
Create an Output Attribute to display the First Name being returned from the lookup
Create an Output Attribute to display the Last Name being returned from the lookup
Map Data to Popup Screen
- Create an Open Screen action to open the Shop Customer Duplicate Popup screen
- Connect the Calculate action to the Open Screen action
- Map the three Output Attributes from the Calculate action to the relevant fields on the screen
Open the screen and look in the layers to see the names of the fields
Testing
- Close and reopen the Customer Form
- the screen and populate the First Name and Last Name fields, then select Check
- You can see that the Actionflow is working because the Shop Customer Duplicate Popup screen will open showing the number of potential duplicates found and their name(s)
- Test this a number of times to see the different results
- Once you have verified your Actionflow is working, you can tidy up the screen by hiding the two dynamic text components that the Actionflow is mapping to