Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
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
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Table of Content
Table of Contents | ||||
---|---|---|---|---|
|
|
Validation Details - _field.errors
Validation is checked On Blur, which means once the user leaves the field the validation is run. It is also checked when an existing record is loaded.
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
Coming soon.
Adding a Confirmation Message
Form Field Validation - Mandatory Field
Setting a form field as mandatory
- On the form field you would like to set as mandatory select its inner input field.
- In the properties that open n the right, scroll down to the Validation section.
- Click on the tick box next to mandatory.
- It is also possible to enter an error message that will be used by the mouseover and accessible using
_field.errors
- It is also possible to enter an error message that will be used by the mouseover and accessible using
- These settings are illustrated below:
your changes.Insert excerpt _save _save nopanel true - If using a Serene Grey Template, the fields failing validation will appear with a red under.
Form Field Validation - Minimum Length
- On the form field you would like to set a minimum or maximum length for, select its inner input field.
- In the properties, scroll down to the Validation section.
- Next to Validation Type click
.Insert excerpt _addIcon _addIcon nopanel true - 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. Different data types have different parameters such as numbers specifying the maximum value. For example,
String
. - Minimum Length, sets the minimum number of characters. For example, 2.
- Maximum Length, sets the maximum of characters. If left blank there is no maximum. For example, 150.
your changes.Insert excerpt _save _save nopanel true - These options are illustrated below:
- If using a Serene Grey Template, the fields failing validation will appear with a red under.
Form Field Validation - Matching a Given Pattern
- On the form field you would like to set a pattern match for, select its inner input field.
- In the properties, scroll down to the Validation section.
- Next to Validation Type click
.Insert excerpt _addIcon _addIcon nopanel true - 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. Different data types have different parameters such as numbers specifying the maximum value. For example,
String
. - Pattern, define a pattern the input must adhere to in the form of a regular expression. Pattern example provided at the end of this section.
your changes.Insert excerpt _save _save nopanel true - These options are illustrated below:
- These options are illustrated below:
- If using a Serene Grey Template, the fields failing validation will appear with a red under.
Example Patters
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 |
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
.Insert excerpt _add _add nopanel true - Select Add Phase Before and set the Name to
Record Counter
. Click Connect on the connections pane and select the Event input.
Click
in the Connections pane:Insert excerpt _add _add nopanel true Name, the connection CountRecords
Select Lookup
Click Create Connection Point
Select theView 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
Node by dragging and dropping from the toolbarInsert excerpt _action_calculate _action_calculate nopanel true - 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
.Insert excerpt _addIcon _addIcon nopanel true 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
.Insert excerpt _addIcon _addIcon nopanel true 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
action from the toolbar onto the canvas.Insert excerpt _action_gateway _action_gateway nopanel true - 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.
your changes.Insert excerpt _finish _finish nopanel true
- Set Expression to,
- In the Rules section click
, and set the following:Insert excerpt _addIcon _addIcon nopanel true - Name,
Message
. - Expression,
in.Count != 1
your changes.Insert excerpt _finish _finish nopanel true
- 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
in the Connections pane:Insert excerpt _add _add nopanel true Name, the connection screen
Select Output
Click Create Connection Point
Select theForm 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
CheckingCheck
The following example will check for a duplicate company name match 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
.Insert excerpt _add _add nopanel true - Select Add Phase Before and set the Name to Duplicate Check.
- Above the actionflow canvas are the phases. On the Processing Phase click
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:Insert excerpt _addIcon _addIcon nopanel true - Name: Filter by Name
- Private: false
Select the options:
Name
equals
req is used to reference the incoming attributesreqin.Name
. Make sure to click the 'abc' button to convert it to an expression..
Case Sensitive, turn this off if you want to remove
your changes.Insert excerpt _finish _finish nopanel true
- 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,
Code Block // 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.
all your changes.Insert excerpt _save _save nopanel true Hover over the and click Out. Calculate
- Drag the arrow into space on the canvas and click where the new node should appear.
- Select
and select Processing Phase. This will then run the processing phase if the actionflow hasn't been stopped by the DuplicateCheck attribute.Insert excerpt _action_phase _action_phase nopanel true
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.
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
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
The save button in this example by default uses the following actionflow. The edit form is wired into the actionflow and the
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
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
node to the canvas by dragging and dropping from the toolbar.Insert excerpt _actionflow_calculate _actionflow_calculate nopanel true - 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,
Code Block if(isNull(in.Name), do( error("Please provide a name."), stop("message") ), _NULL )
Note stop()
will terminate the actionflow immediately at the node it is being used.error()
displays an error message to the user.
- Add a
node to the canvas by hovering over the Calculate Action and selecting out as the output connection point.Insert excerpt _action_phase _action_phase nopanel true - Drop the line into empty space.
- Select
Insert excerpt _action_phase _action_phase nopanel true - Select Processing Phase.
- The processing phase will only run if the actionflow is not terminated by the stop() function in the Calculate Action.