What are the responsibilities of the Response Data Transform in error handling for Data Page loading and saving?
The Response Data Transform for the Savable Data page is the primary opportunity you have to apply configuration that tests for errors from the System of Record (load and save), whilst encapsulating these within the Data Page.
New Data Transforms created from the Response Data Transform field of a Data Page include suggestions of the pxDataPageHasErrors When rule and a pxErrorHandlingTemplate Data Transform. All of these are disabled by default -- consider them suggestions / reminders / for reference only.
If the Data Source yields an error, then this can be checked for in your Response Data Transform using pxDataPageHasErrors. If true, you might include some of the functions showcased in pxErrorHandlingTemplate. For example, to send the error message to the PegaRULES log, call the Function pxLogMessage(...) [perhaps in conjunction with pxGetPageMessages(...)].
Alternatively, the Data Source may return a genuine response, but through inspection of the response's content (for example, a "response code" field set by the System of Record) you identify a "business error". pxErrorHandlingTemplate showcases an example of the pxAddMessageToPage(...) Function which can be used when the Response Data Transform needs to set an error where none was incurred at the transport level (couldn't connect to the System of Record) or the protocol level (HTTP 500: internal server error).
Finally, consider also a scenario where a lookup attempt on the System of Record failed to find a match. Depending on the API implementation of this (e.g. HTTP 404), it may be initially represented as an error on the Data Page. If your Data Page's contract to the application does not consider this an 'error', the Data Page may need to return blank page -- with no errors -- to the application. pxErrorHandlingTemplate showcases the usage of the pxClearMessages(...) Function which could be used to achieve this scenario.