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,
|
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:
|
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");
}