Question

Bluerose Technology
IN
Last activity: 2 Jun 2023 7:37 EDT
pxAddMessageToProperty Does not work to set error message on current page in a Loop
If you want to display an error message on Property when you are in a loop, pxAddMessageToProeprty doesn't work as it takes the Primary page by default inside of the function.
PublicAPI tools = null; PRThread thisThread = (PRThread)ThreadContainer.get();
if (thisThread != null) { tools = thisThread.getPublicAPI(); } if (tools == null) { throw new com.pega.pegarules.pub.PRRuntimeError("Can't get a PublicAPI reference."); }
ClipboardPage primaryPage = tools.getPrimaryPage(); return primaryPage.addMessage(aMsgDescr, aReference);
We can use pxAddMessageToProperty activity which will execute under the current page context.
String pRef = tools.getParameterPage().getString("PropertyReference"); String msg = tools.getParameterPage().getString("MessageName");
ClipboardProperty targetProp = myStepPage.getProperty(pRef); if (targetProp != null) { targetProp.addMessage(msg); }
Ex: