Writing a Process Flow to Impose Validation Logic Example
In some cases, an organization may want to use Aptify's Process Pipeline functionality to impose validation logic to the system rather than having to write an organization-specific entity object or a validation script for one or more Entity Fields.
In order to support these types of process flows, Aptify provides the BeforeValidate and AfterValidate event definitions (see About the Delivered Event Definitions). These are Entity-scoped events tied to the Aptify Generic Entity. When a process flow is tied to one of these events, the Process Flow Engine determines if a record passes or fails validation based on the process flow's result: Success or Failed. Note that this differs from other types of events where a Failed result typically indicates that the process flow failed to execute.
Keep in mind the following important points when working with validation process flows that fire using the BeforeValidate or AfterValidate event:
- The validation events support a ValidationMessage property so a process flow designer can specify the text of the error message that appears when validation fails (the system uses the ValidationMessage as the LastError and LastUserError in the Aptify Generic Entity). A validation process flow can support the following outcomes:
- If the process flow's result is a Success result code and the ValidationMessage property is empty, the validation was successful.
- If the process flow's result is a Failed result code and the ValidationMessage property has a value specified, a message box appears to the end user displaying the ValidationMessage text.
- If the process flow's result is a Failed result code and the ValidationMessage property is empty, the following generic message is displayed when validation fails: Validation has failed but no information about the failure has been provided.
- Note that the fourth option where a process flow's result is a Success result code and the ValidationMessage property is not empty will result in a validation failure and the validation message is displayed. However, this is not an expected outcome since a validation failure is expected to correspond to a process flow failure.
- The validation in the Aptify Generic Entity will not proceed if the BeforeValidate Event fails (Result Code of false or Failed). Therefore, the AfterValidate Event will not be fired if the BeforeValidate Event fails.
- Unlike other Aptify delivered events that only fire for top-level entities, the BeforeValidate and AfterValidate events fire for Sub-Type entities. In these cases, the system validates sub-type records (and fires the event) twice: once when the record is closed (for example, when a user clicks the OK button) and a second time when the top-level entity record is saved.
This topic provides an example of how to write a simple validation process flow and tie it to the AfterValidate event. Note that this tutorial references records found in Aptify's sample dataset.
Copyright © 2014-2019 Aptify - Confidential and Proprietary