Overview
Validation can be configured to check incoming data 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. To see examples of validation which include lookups, also see Using Lookups.
Adding a validation phase
The simplest way to set up validation is to add an additional 'Validation' phase at the start of the actionflow. This phase will do all the necessary checks and if these checks have passed then 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.
The save button uses the following actionflow:
The edit form is wired into the actionflow and the Save Records 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 not null 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 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() ), _NULL )
Using stop() will terminate the actionflow immediately at the node it is being used.
Using error() displays an error message to the user
- Add a Phase node to the canvas by hovering over the calculate node 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 node.
Validation involving lookups
To find out more about using validation to check for duplicates and to check a value against a list, see Using Lookups.