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..!!

Agile Talent Asked on February 20, 2019 in Other APIs,   Software Development Kit (API).
Add Comment
3 Answer(s)

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

Agile Angel Answered on February 20, 2019.
Add Comment

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. 

Agile Talent Answered on February 20, 2019.

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.

RE: How can we display error messages with Event PX

on February 20, 2019.
Add Comment

Hello Arif,
Yes, I wanted it to be displayed in Red and it worked with Exception. 

Thank You..!! 🙂

Agile Talent Answered on February 21, 2019.

Great. Congrats.

on February 21, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.