gs.addErrorMessage() is cleared automatically after 2 seconds

Igor __tek
Tera Contributor

Hi developer community,

 

I created a simple business rule which aborts an action if someone tries to change the value in the field "assigned_to" and if there is an open part requirement record at the same time (errors based on states). 
The issue is that if I call setAbortAction(true) the gs.addErrrorMesage() shows the error only for 2 seconds. 

 

I tried all orders from these 3 functions but nothing worked. (setAbortAction(true), addErrorMessage(), setRedirectURL())
Does someone have an idea?

Igor__tek_0-1676029212737.png

 

5 REPLIES 5

RaghavSh
Kilo Patron

That is the default behaviour of servicenow.

 

Refer https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0713722  for more details


Please mark the answer correct/helpful accordingly.


Raghav
MVP 2023

Hi Raghav,

sadly it didn't help that sys property is only for Service Portal use.

But thanks.

 

4b0d3
Giga Guru

I tend to build it to be more proactive than reaction.  Block them before they can do it. 

  • could block access to the field with ACL and conditions/role
  • could use a client script (if it's a form issue) to set the field to read only.
  • could use a onChange client script to post the error if basic.  or call an ajax to build conditions, if returns true, then use g_form.addInfoMessage.  

Lakshmiprasann7
Tera Contributor
check the line setRedirectURL is inorrect syntax,Please find below appropriate syntax:



gs.setRedirect(url);



Please mark as accept solution if it resolves your issue.