UI Action - Showing error message on reload

naresh831
Tera Contributor

Hi,

I need to show an error message after clicking the UI Action button. It's displaying the error message but disappearing after 1 second.

How to show the error message after refreshing the page ?

Thanks

Ram

4 REPLIES 4

oharel
Kilo Sage

Can you share your code? What type of error message is that?



harel


naresh831
Tera Contributor

Below is the code I'm using in UI Action(server side). If the condition met, I need to show the error message.



    Right now, error message is coming but disappearing in a second. How can we show error message for long time or how to prevent the page reload after clicking the UI Action button ?



Please provide your inputs.



if <condition>


{


    gs.addErrorMessage("a change task must be added before submitting the change");


action.setRedirectURL(current);


}


else


current.update;


Hi Ram,



Not sure why it disappears. Maybe you can share your condition as well?


I tested on my instance. My insights are few:


if <condition> {


gs.addErrorMessage("a change task must be added before submitting the change");


action.setRedirectURL(current);


} else {


current.update();


}


naresh831
Tera Contributor

var grChtask = new GlideRecord('change_task');


if(!grChtask.get('change_request',current.sys_id))


{        


  gs.addInfoMessage("A Change Task must be added to the change " + current.number);


  action.setRedirectURL(current);


}


else {


current.update();


}