You are here: Mobile > Custom mobile app > Offline capability > Error handling API in offline mode

Error handling API in offline mode

The error handling API provides a set of JavaScript methods. You can invoke these methods during post-processing of the flow action when you process cases in a mobile app while in offline mode. A form will not be submitted until all the errors are resolved.

Page error 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 will be retained.
addMessage(message, property) Adds an error message to both a property and a page. This function can be invoked multiple times and all of the messages added will be retained.
clearMessages() Clears error messages for a page and its nested properties.
clearMessages(property) Clears error messages for the embedded property.
getMessages(property) Obtains error messages for a property.
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 error messages.

The following sample JavaScript code adds an error message to a page called pyWorkPage, specifying that an invalid name was entered:

pega.ui.ClientCache.find("pyWorkPage").addMessage("Name should not contain numbers.");

Property error 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 will be retained.
clearMessages() Clears error messages for a property.
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 error messages.

The following sample JavaScript code clears error messages for the Name property belonging to a page called pyWorkPage:

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