How can we display error messages with Event PX
Hello there,
Just curious if we can throw any error message in the UI with the Event PX. I tried with throw new Exception(“Hello World!!); , but this also doesn’t work.
Thanks..!!
Hi Nagma,
The sample code for your situation will be like :
—————————————————
public EventActionResult doAction(IAgileSession m_session, INode m_node, IeventInfo m_context) {
try{
ActionResult result= new ActionResult(ActionResult.String, “Hello World!!!”); //This is where you build your string
return new EventActionResult(m_context, result); //This is what throws the message.
}
catch (Throwable error) {
ActionResult error= new ActionResult(ActionResult.Exception, error);
return new EventActionResult(m_context , error);
}
—————————————————
I advise you to go through Developing extensions guide for detailed information.
Regards,
Arif
Hello Arif,
Thank you..!! Actually, I want to display the “Hello World..!!” as an error on the screen.
Ex:
if(str.matches(str2))
continue;
else
{
String msg = “Please enter the correct value for ” + str2;
return new EventActionResult(req, new ActionResult(ActionResult.EXCEPTION,new Exception( msg)));
}
I tried this way, still, it doesn’t show the message on the screen. And I didn’t see “ActionResult.ERROR”, there is only Exception.
My bad, It should be ActionResult.Exception only.
Coming to if you want to show string message based on the validation you don’t need to use it the exception block. You can achieve that using ActionResult.String.
Do you want the error message to be printed like i have shared in the attached image.