Validation Rules

Prev Next

Validation Rules define automated checks that must pass before an Approval Flow Instance can move from one stage to another.

They are reusable across transitions. If the same logic needs to be applied in multiple places, it can be linked to multiple transitions.

However, if a variation in logic is required (For example, slightly different FetchXML or API behaviour), a separate Validation Rule must be created.

General Section

The General section defines the core details and behaviour of the validation.

Field

Description

Name

Specifies the descriptive name for the rule.

Type

Specifies the type of process used for validation: FetchXML, Custom API, or Async Event.

Severity Level

Specify the severity applied if the validation fails: Warning, High, or Critical. Used in conjunction with the transition’s Max Allowed Severity setting to determine whether a failure blocks the action or proceeds with a warning.

Inverse Results

Specify if the pass/fail outcome must be reversed.

If enabled, a True becomes False, and vice versa.

Note: This setting has no effect on Async Event type validations.

Failure Message

Specifies the message displayed to the user on the Approval Flow Instance when the validation fails.

Validation Types

Validation Rules can be implemented as Custom APIs, FetchXML queries, or Async Events. Each type has distinct requirements and behaviour.

Custom API

Custom API rules run as a server-side process provided and maintained by the client.

Field

Description

Logical Name

Specifies the logical name of the API call message to execute.

Requirements:

  • The Custom API must be bound to the vel_approvalflowinstance entity.

  • The Custom API must return a Boolean output parameter called Results.

  • The Custom API must not accept any input parameters.

  • The client is responsible for developing and maintaining the Custom API.

FetchXML

Fetch XML runs a Dataverse FetchXML query to validate data conditions.

Field

Description

FetchXML Query

Specifies the FetchXML query to run. If at least one record is returned, the validation passes.

Note

  • Only one variable is currently supported:

    • {{recordId}} → vel_approvalflowinstanceid of the Approval Flow Instance

  • The variable is useful for queries like “no overlapping time entries” or “record must have linked resource”.

Example

<fetch top="1">
  <entity name="vel_approvalflowinstance">
    <attribute name="vel_approvalflowinstanceid" />
    <filter type="and">
      <condition attribute="vel_approvalflowinstanceid" operator="eq" value="{{recordId}}" />
      <filter type="and">
        <!--<condition attribute="vel_availabilitytypeid" operator="eq" value="51a99fa0-0841-f011-8779-002248e3ba67" />-->
      </filter>
    </filter>
  </entity>
</fetch>

Async Event

Async Event validations that do not return an immediate result and may take time to complete.

  • Async Events are triggered after synchronous validations (security, ownership, FetchXML, and Custom API) have passed.

  • The Approval Flow Instance is placed in a Pending state until all related Async Events are resolved.

  • Async Event validations do not have a dedicated section on the Validation Rules form. Instead, they are tracked as Approval Flow Async Event records linked to the Approval Flow Instance.

Approval Flow Async Event Records

Approval Flow Async Event Records are created automatically when a stage transition requires one or more Async Event validations. These records track the pending work and outcomes.

Field

Description

Name

Specifies the name of the Async Event record.

Approval Flow Validation Rule

Specifies the Async Event type Validation Rule that generated this record.

Acting User

Specifies the user who triggered the action. This information is useful for custom permission checks.

Approval Flow Instance

Specifies the instance waiting for this Async Event to complete.

Pending Action

Specifies the action type (Submit, Approve, Reject, Cancel, Close, or Reopen) associated with this Async Event.

Status

Specifies the current state of the Async Event (Pending, Passed, Failed, or Not Applicable).

Records are created as Pending. The client must update the status programmatically or manually.

Validation Message

Defaults to the Failure Message from the related Validation Rule if empty. Can be overridden by the client to add more context.

Async Event Lifecycle

The Async Event lifecycle describes the sequence of steps that occur when a transition involves one or more Async Event validations.

  1. Transition is triggered - The Approval Flow Instance first runs synchronous validations, which include security checks, FetchXML, and Custom API.

  2. Synchronous checks pass - If all synchronous validations succeed, the approval Flow Instance enters a pending state.

  3. Async Event records are generated - The system creates one record for each Async Event validation linked to the transition.

  4. Client processes events - The client (manually or via automation) updates each Async Event record’s Status to Passed, Failed, or Not Applicable.

  5. All Async Events are resolved:

    • If all events have passed, the instance moves to the target stage.

    • If any event has failed and the severity exceeds transition’s Max Allowed Severity, the transition is blocked. The instance stays in the current stage, and error messages (including synchronous validation errors) are displayed.

    • If any event has failed but severity does not exceed transition’s Max Allowed Severity, the transition proceeds. The instance moves to the target stage, but warnings are recorded and visible to the user on the instance record.

Best Practises

Follow these best practices when managing Validation Rules:

  • Keep validation logic modular by using reusable rules wherever possible.

  • For Custom API, always include clear error handling and ensure the required Boolean Results property is returned.

  • For FetchXML validation, test your query in Dataverse before saving to ensure it returns expected results.

  • For Async Events, ensure your process for updating Status is reliable to prevent stuck instances.

  • Use Inverse Results carefully and always document why a rule is inverted so others can maintain it.