Custom Validation

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 Adding Validation to Table Attributes.

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

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 Confirmation Message Configuration.

Form Field Validation

See Validation.

Worked Example

Here is a worked example using the Retail Data (available from the Learning Centre).

In this example, we are using:  

  • 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

  1. On the Shop Customer Form screen, add a new Actionflow to the Check button
  2. Configure the Shop Customer Form as the input data for the Actionflow
  3. Map into the Actionflow the attributes, first_name and last_name
  4. Create a  Calculate action - this will be used to process the results of a lookup
  5. Drag the  input node 
  6. Hover over the Calculate action and choose Add Lookup, then click onto the canvas to create a   View action
    1. Primary Table: Shop Customers

Configure the View

  1. The Output Attributes window will pop up for the   View
  2. Tick first_name and last_name and select Next
  3. For the Request (Incoming) Mappings, map the first_name and last_name attributes, then select Next
  4. For the Return (Outgoing) Mappings, map the first_name and last_name attributes
    1. You may wish to rename the Return (Outgoing) Mappings, by right-clicking and selecting  Edit, to make them easier to reference
    2. Select Confirm and create filter
  5. Create a filter to match the name on the input form to the name in the data
    1. Add two filter conditions:
    2. 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.

       Checkpoint

Configure the Calculate Action

  1. Click on the Calculate action and create 3 Output Attributes:
    1. Create an Output Attribute to count the records being returned from the lookup

       How?

      1. This will be mapped onto a dynamic text field to display how many duplicate records have been found
    2. Create an Output Attribute to display the First Name being returned from the lookup

       How?

    3. Create an Output Attribute to display the Last Name being returned from the lookup

       How?

Map Data to Popup Screen

  1. Create an  Open Screen action to open the Shop Customer Duplicate Popup screen
  2. Connect the Calculate action to the Open Screen action
  3. Map the three Output Attributes from the Calculate action to the relevant fields on the screen
    1. Open the screen and look in the layers to see the names of the fields

       Checkpoint

Testing

  1. Close and reopen the Customer Form
  2.  Lock the screen and populate the First Name and Last Name fields, then select Check
    1. 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)
    2. Test this a number of times to see the different results 
  3. 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