Messages, such as the red error text next to a field, are stored on the page. If an earlier step added an error and you now want to start clean, you have to clear the messages. In an activity that is easy. In a data transform it is less obvious.
In an activity
Use the Page-Clear-Messages method. It removes all messages from the step page.
In a data transform
A data transform has no such method, but you can call a function with a Set action:
Set Param.Status equal to @pxClearMessages() Set Param.Status equal to @pxClearMessages(tempPage)
@pxClearMessages()clears the messages on the primary page.@pxClearMessages(page)clears the messages on the named clipboard page.- The function returns true when it has cleared the messages, so the parameter ends up as
true.
A worked example
A bank fetches a customer's balance through a REST service and uses a data page. If the service call fails, Pega puts an error message on the data page. The team wants the screen to fall back to "Balance not available" without the red error banner.
- Open the response data transform of the data page source.
- Add an action:
Set Param.Cleared equal to @pxClearMessages(). - Add another action that sets
.BalanceTextto "Balance not available".
The page now carries the friendly text and no error, and the section that shows it renders normally.
Where this is usually used
- Error handling in the response data transform of a data page.
- Resetting a form after the user corrects an input, so old errors do not stay behind.
- Preparing a page for a second validation run.
Cautions
- Do not clear messages blindly. Errors that came from a real validation failure should still reach the user.
- Clear messages on the right page. Clearing the primary page will not help if the messages are on an embedded page.
- Test with the Tracer, because messages are easy to lose by accident.
Related: the Data Transform label.
Can you please share a post on data transform in brief
ReplyDeleteSure..will post soon.
Deletecan we call activity in Data transform..?If yes please elaborate.
ReplyDelete@pxExecuteAnActivity(Page Name,activity Name)
ReplyDelete