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.

 If using version 10.0 or below
  1. Open the actionflow
  2. On the toolbar, click  Properties
  3. Within the Basic Settings, check the option Perform Validation before running
 How to setup a Save actionflow

Save actionflows can be created automatically by PhixFlow when setting up CRUD actions, see 7. Editing Content on a Screen - Part 1. Or, created manually by right clicking on a button and pressing  Create Actionflow, then setting up a  Save actionflow, see Save Node.

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.

  1. Open the actionflow
  2. On the toolbar, click  Properties
  3. Within the Basic Settings, uncheck the option Perform Validation before running
  4. Click the additional tickbox, Allow to Run with Validation Errors to enable this option

Adding a Confirmation Message

See Configure a Confirmation

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.

  1. Right-click on the form field you would like to set as mandatory and choose  Set Validation 
    1. In PhixFlow version 11.0.2 and older, select the field's inner input field and the properties will open on the right
  2. The properties will open on the right, scroll down to the Validation section
  3. Click on the tickbox next to Mandatory
  4. Then toggle this on 
  5.  Apply your changes
  6. If you are using the Serene Grey Template, the following will be seen:
    1. The form field header text will show with an asterisk *
    2. 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

  1. Right-click on the form field you would like to set a minimum or maximum length for and choose  Set Validation 
    1. In PhixFlow version 11.0.2 and older, select the field's inner input field and the properties will open on the right
  2. The properties will open on the right, scroll down to the Validation section
  3. Click on the tickbox next to Validation Type
  4. Next to Validation Type, click 
    1. A validation type can also be selected from the drop-down, if the desired validation exists, or edited by clicking the Validation Type hyperlink
  5. The Validation Type properties open, see Validation Type
  6. Enter:
    1. Name, this should be indicative of its purpose. For example, minimum name length
    2. Base Type, select the type of data. For example, different data types have different parameters such as numbers specifying the maximum value
    3. Minimum Length (optional), sets the minimum number of characters. For example, 2
    4. Maximum Length (optional), sets the maximum of characters. For example, 150.  If left blank there is no maximum
    5. 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
  7.  Apply your changes
  8. 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

  1. Right-click on the form field you would like to set a pattern match for and choose  Set Validation 
    1. In PhixFlow version 11.0.2 and older, select the field's inner input field and the properties will open on the right
  2. The properties will open on the right, scroll down to the Validation section
  3. Click on the tickbox next to Validation Type
  4. Next to Validation Type, click 
    1. A validation type can also be selected from the drop-down if the desired validation exists or edited by clicking the Validation Type hyperlink
  5. The Validation Type properties open, see Validation Type
  6. Enter:
    1. Name, this should be indicative of its purpose. For example, minimum name length
    2. Base Type, select String
    3. 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
  7.  Apply your changes
  8. 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.

DescriptionPattern
Alpha Only[A-Za-z]
Alpha Numeric including, hyphens, underscores, spaces, ampersands and full stops

[A-Za-z0-9\s\-_.)(\/\-\&]

Numeric Only[0-9]
Email

^[a-zA-Z0-9!#$%&'*+/=?^_‘{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_‘{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$

Specific words e.g. hello or world\b(hello|world)\b

Editing an Existing Validation

To edit an existing validation:

  1. Opening an existing Validation
    1. Open the table attribute that has the  Validation Type applied to it. In the Validation section click the Validation Type link to open it.
    2. 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.
  2. 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:

  1. Open the Actionflow that will check a record is selected
  2. Above the Actionflow canvas are the phases. On the Processing Phase, click  Add New
  3. Select Add Phase Before and set the Name to Record Counter
  4. Click Connect on the connections pane and select the Event input

  5. Click  Add New in the Connections pane:

    1. Name, the connection CountRecords

    2. Select Lookup

    3. Click Create Connection Point

    4. Select the View Component, which contains the grid we are checking has a selected record

    5. Click Connect Input
  6. On the mappings screen that appears drag the UID, or other primary key, across to create a mapping
    1. Make sure the data being used is set to Selected Records
    2. Click Save
  7. Create a  Calculate Node by dragging and dropping from the toolbar
    1. Name the node Count Records
  8. Connect the Event Input Connection to the calculate. This is what causes the actionflow to run
  9. Connect the Lookup Input Connection, Count Records, to the calculate
    1. Select Add Lookup
    2. Name the connection lu
    3. Drag and drop the UID field to create a mapping to the Calculate node.
    4. Click Confirm Mappings
  10. Click on the Calculate node to open its editor
    1. In the Calculate Attributes section, click

    2. Use the following settings:

      1. Name: Count

      2. Type: integer

      3. Expression, countElements(lu.UID)

        1. This counts the number of selected records on the grid we are looking up

      4. Save the attribute
    3. We will now create a second attribute that will hold the message for the user
    4. In the Calculate Attributes section, click

    5. Use the following settings:

      1. Name: Message

      2. Type: string

      3. Expression, "Please select 1 record from the grid."

      4. Save the attribute

  11. We now have a count of the number of selected records
  12. Checkpoint
  13. 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
  14. Drag a  Gateway action from the toolbar onto the canvas
    1. Name, Decision
    2. Click Create Action
  15. Connect the Calculate Action to the Gateway Action
    1. In the mapping window that opens drag the Count and Message attributes to the right to create gateway input attributes
      1. To change these mappings in the future click on the connecting line
    2. Click Save
  16.  Click on the Gateway Action to open its properties
    1. In the Rules section double-click the existing rule
      1.  Set Expression to, in.Count == 1
        1. Note these expressions must equate to true or false, therefore there is n need to provide an if statement as it is implied
      2.  Apply and Close your changes
    2. In the Rules section click , and set the following:
      1. Name, Message.
      2. Expression, in.Count != 1
      3.  Apply and Close your changes
  17. The Gateway Action now has two outputs available, out and Message
    1. Out,
      1. Drag a Start Phase action onto the canvas
      2. Select Processing Phase, or whichever phase you require
      3. 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
    2. Message,
      1. Create an output connection

      2. Click  Add New in the Connections pane:

      3. Name, the connection screen

      4. Select Output

      5. Click Create Connection Point

      6. 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

      7. Click Connect Output
      8. Drag the Count and Message attributes to the right to create outputs
      9. Right-click on the line connecting the output connection back to your screen's form and select Configure Mappings
      10. 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
  18. Checkpoint
    1. The final configuration will look like this

    2. 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.

  1. Open the actionflow that will check a record is selected
    1. Above the actionflow canvas are the phases. On the Processing Phase click  Add New
    2. Select Add Phase Before and set the Name to Duplicate Check.
  2. Click on Click to Connect on the Connections pane

  3. Connect the Form as an input into the actionflow and click Connect Input
  4. The Mappings Screen opens, map in the Name attribute you wish to check for duplicates
  5. Create a  Calculate node by dragging and dropping from the toolbar
  6. Connect the Input Connection Point to the Calculate Action and map in the Name attribute
  7. Hover over the Calculate Action and select Add Lookup
  8. Name it dup
  9. Drop the arrow into space on the canvas to create the   View node
    1. Name the View Companies, or something appropriate for your use case
    2. Select the table where you are checking for duplicates, this will be the primary table
    3. 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
    4. Click Next
  10. Select the dashed line connecting the Calculate to the View to open the Mappings:
    1. 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
    2. Click Next
    3. 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
  11. Creating a filter. Click on the    View node to open its editor. Under Data Retrieval Options click next to the Default Filter to add a filter. Provide the following information:
    1. Name: Filter by Name
    2. Private: false
    3. Select the options:

      1. Name

      2. equals

      3. in.Name. Make sure to click the 'abc' button to convert it to an expression

    4.  Apply and Close your changes

  12. Click on the  Calculate node to open its editor and add a Calculate Attribute with the following settings
    1. Name, DuplicateCheck

    2. Type, Integer

    3. Order, 1

    4. 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
      )
    5. 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.
  13.  Apply all your changes
  14. Hover over the  Calculate and click Out

    1. Drag the arrow into space on the canvas and click where the new node should appear
    2. 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:

  1. Add a phase before the current Processing Phase
    1. Name this Validation
  2. Click Connect to connect the form as an input into the actionflow
  3. On the mappings popup, drag and drop the Name field to the interface to create a mapping
    1. Click Confirm Mappings
  4. Add a  Calculate node to the canvas by dragging and dropping from the toolbar
    1. Name this Validate Records
  5. Connect the interface connection point to Validate Records by dragging from the arrow to the node
  6. On the mappings popup, drag and drop the Name field to the calculate section to create a mapping
  7. Click Confirm Mappings
  8. Click on Validate Records to open its editor. Add a calculate attribute:
    1. NameCheckName

    2. TypeString

    3. Order, 1

    4. 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.

  9. Add a  Phase node to the canvas by hovering over the Calculate Action and selecting out as the output connection point
    1. Drop the line into empty space
    2. Select  Phase 
    3. Select Processing Phase
  10. The processing phase will only run if the actionflow is not terminated by the stop() function in the Calculate Action