gs.addErrormessage is popping on form

sowmyaj
Giga Expert

Hi All,

        In the advance script of BR I have added

                  gs.addErrorMessage('xyz.');

                  current.setAbortAction(true);

                  current.state = previous.state;

The above message is just flashing on the form and disappears. I want to make the message to be visible to the user. how can I do?

Thanks,

Sowmya.

15 REPLIES 15

Chuck Tomasi
Tera Patron

That's odd. I just did this in a BEFORE (insert/update) business rule and it worked fine.



find_real_file.png



Let's compare notes... what release of ServiceNow are you using?


How about the UI (UI15? UI16?)


Hi Tomasi,



        Helsinki release and ui16



Thanks,


Sowmya


Please provide screen shot, how it is showing?


Hi Tomasi,



Business rule


      Condition:       when state changes from 1 to 2


      Advanced script:


Initially flag is set to true.



Doing glide record.


if(record is found){}


else {flag=false;}



if(!flag) {


  current.state = previous.state;


  gs.addInfoMessage('xyz.');


  current.setAbortAction(true);


  }




I have a ui action with few condition and below is the script



current.state = 2;


current.update();


//action.setRedirectURL(current);



May I know where I'm wrong so the info message is flashing away instead of staying on the form.



Thanks,


Sowmya


The standard behavior for gs.addInfoMessage() and gs.addErrorMessage() is to stay on the screen. I do not know what might be causing it to disappear.



Have you tried an extremely simple case of a before/update business rule with just one line:



gs.addInfoMessage('Record updated').



and see how that behaves? When ever things don't work as expected, start simple and check the differences.