Error and warning handling API in offline mode

The error and warning handling API provides a set of JavaScript methods that you can invoke during post-processing of the flow action when you process cases in an offline-enabled application. A form is not submitted until all the errors described in the messages are resolved. However, informational or warning messages in the offline-enabled application have no effect on whether you advance the case because you can manually set the message to the submitted state.

Page error and warning handling API

The following JavaScript methods are available for the ClientCachePage object:

Method Description
addMessage(message) Adds an error message to a page. This function can be invoked multiple times, and all the messages added are retained.
addMessage(message, property, type) Adds an informational, warning, or error message to both a property and a page. The type parameter specifies whether an informational, a warning, or an error message is added. If this parameter is not specified, an error message is added. This function can be invoked multiple times and all the added messages are retained.
clearMessages() Clears all informational, warning, and error messages for a page and its nested properties. This function checks whether the message was shown to the user.
clearMessages(property) Clears error messages for the embedded property.
getMessages(property, type) Obtains informational, warning, or error messages for a property. The type parameter specifies whether informational, warning, or error messages are returned.
getMessagesAll() Obtains all of the error messages for a page and properties that exist on this page.
getMessagesCountAll() Obtains the total number of error messages for a page and its nested properties.
hasMessages() Determines whether a page or its nested properties have any informational, warning, or error messages. This function checks whether the message was shown to the user.
setMessageState() Sets the message state to added, presented, or submitted.

The following sample JavaScript code adds a warning message to a page called pyWorkPage that suggests an insurance plan:

pega.ui.ClientCache.find("pyWorkPage").addMessage("Please take a Life Insurance Plan", "", "warning");

The following sample JavaScript code adds an informational message to a page called pyWorkPage that informs users that their settings were saved:

pega.ui.ClientCache.find("pyWorkPage").addMessage("The settings were successfully saved", "", "info");

Property error and warning handling API

The following JavaScript methods are available for the ClientCacheProperty object:

Method Description
addMessage(message) Adds an error message on both a property and a page. This function can be invoked multiple times and all the messages added are retained.
clearMessages() Clears all informational, warning, and error messages for a property. This function checks whether the message was shown to the user.
getMessageCount() Returns the total number of error messages for a property.
getMessages() Obtains all the error messages on a page.
hasMessages() Determines whether the property has any info, warning, or error messages. This function checks whether the message was shown to the user.

The following sample JavaScript code clears all info, warning, and error messages for the Name property that belongs to a page called pyWorkPage:

pega.ui.ClientCache.find("pyWorkPage").get("Name").clearMessages();