Handling data page errors by using a data transform
The Pega 7 Platform provides various ways to handle data page errors. Because data pages are inherently declarative in nature, error handling needs to be contained within the data page load process. A best practice is to use a response data transform that can detect the type of data source and handle the errors appropriately.
Identifying the data source type
The error handler must be able to identify the type of connected data source so that it can customize the solution. To identify the data source, use a response data transform or activity step for every data source, as shown in the following figure:
- Connector: Use a response data transform to detect and handle Connector data source errors.
- Report Definition: Similar to Connector, use a response data transform to detect and handle Report Definition data source errors.
- Lookup: Use a response data transform with the Run response data transform on error check box selected to detect and handle Lookup data source errors.
- Data transform: Use the hasMessages when condition to detect and handle data transform data source errors.
- Activity: Use appropriate transition conditions such as StepStatusFail in activity steps to detect and handle activity data source errors.
Creating the error handler
Create your custom error handler by using the default data transform.
- Create a data transform (for example, MyCoErrorHandlerMaster) by saving the default data transform pxErrorHandlingTemplate to your top-level class and ruleset. Also, change the status of the rule from Final to Available.
- From the data page, pass a parameter (for example, Connector-GetCustomerData) to the response data transform to uniquely identify the data source that is used to load the data page.
- On the Definition tab of each response data transform, use the when condition pxDataPageHasErrors to identify any errors in the data page and apply the MyCoErrorHandlerMaster data transform.
- In the MyCoErrorHandlerMaster data transform, create and call a decision table that determines the appropriate error handling based on the data source.
- Based on the decision table, perform the error handling action for the data source in the MyCoErrorHandlerMaster data transform.
- In the MyCoErrorHandlerMaster data transform, create andcall a decision table to map user-friendly error messages instead of the default error messages, as shown in the following figure:
This data transform can now be used across multiple data sources and data pages in the application. For example, with an activity data source, the same data transform can be used to handle data page errors.
Debugging tips
- To trace Data Page and Data Transform rules, open the Tracer tool directly from the rule form
- To trace date pages that are loaded asynchronously, open the Tracer tool from the Data Page rule.