Close popover

Table of Contents

Understanding validate rule support in offline mode

Version:

To improve the user experience, you can use validate rules in offline-enabled applications. For example, a validate rule can test properties and pages input values of the offline-enabled application against conditions that are defined as part of the validate rule. The validation is performed automatically if the rule is referenced by a flow action.

Packaging

A validate rule that conforms to the supported features is packaged on the Pega Platform server for use in an offline-enabled application. A subset of the validate rule model is packaged and interpreted in the client after validation processing has finished. The validation logic is directly derived from the model.

If a validate rule that is packaged for offline use contains an unsupported action, library, or feature, it is not processed in the offline-enabled application. Pega Platform adds an error message to the log files that indicate that the validate rule was not processed.

Supported features

The following features are supported in offline-enabled applications:

  • A validate rule that is referenced by a flow action only (and also validate rules that are explicitly added to the list of offline-supported validate rules).
  • One level of validation only - one column for each property is supported.
  • Adding warning and error messages to properties and pages, if a supported validation fails.
  • Several validation conditions:

    • Enable conditions
    • Select a function
    • Required check box with a default message: This field may not be blank
    • Continue validation
    • Message as a text or a reference to a message rule with parameters
    • Validation condition with function rules
  • Only direct validation of a single-value property that is defined:

    • Individually - for example: .CustomerType.
    • In a Page property - for example: .ItemToAdd.Name.
    • In a Page List property - for example: .Items(1).CategoryID.
    • In a Page Group property - for example: .ShipmentsGroup(A).TrackingNumber.
    • In a specific page of a Page List property in a Page property, for example: .ItemToAdd.Items(1).CategoryID.
  • Localization of parameterized message rules for the validation conditions.

Unsupported features

The following features are not supported in offline-enabled applications:

  • References to a validate rule from any rule other than a flow action.
  • Case level validation - Validation when a case is created and validation when a case is saved.
  • Stage entry validation.
  • Any validate rule configuration in the flow action rule.
  • Validate rule in an assignment, when performing postprocessing while navigating away from a step.
  • Additional validation - Specifying Edit Validate or another validate rule that is to run after evaluating the previous validation.
  • Validate rule Input tab - Input property, proposed work status, flow action name, stages.
  • No direct validation of a single-value property - Validate Each, Call for Each, Call.

Offline validation API

The offline validation API consists of a JavaScript method that allows you to run a validate rule in offline-enabled applications by using a Run script action or a custom JavaScript function. Validate rules that are referenced by a flow action are packaged automatically. To package other validate rules, you must add their definition to the pyValidateWhitelistForOffline rule. Remember that a validation rule can also call any number of function rules. These function rules that are part of the validation rule are also packaged automatically.

The following JavaScript method is available for the pega.offline object:

Method Description
runValidate( validateName, className )

A synchronous method that runs a validate rule in the offline mode with the specified name and class. It returns a Boolean value specifying whether the validation was successful (true) or not (false). The method also adds messages to properties for which the validation rule failed.

The method has the following parameters:

validateName Required. Specifies the name of the validate rule to run.
className Required. Specifies the name of the class that the validate rule belongs to.

The following sample JavaScript code allows you to run a validate rule called pzValidateMeetingTime, which belongs to the PEGA-MANAGEMENT-MEETING class.

if ( !pega.offline.runValidate( "pzValidateMeetingTime", "PEGA-MANAGEMENT-MEETING" ) ) { console.log("Meeting cannot be set up in the past"); }

  • Adding validate rules to the allow list for offline use

    Improve the user experience and test properties and pages input values of the offline-enabled application against defined conditions by adding a validate rule to the list of offline-supported validate rules. You can use these rules in custom JavaScript code.

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.