How to Display g_form.addErrorMessage() Permanently in ServiceNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi,
I have a requirement where an error message added using g_form.addErrorMessage() needs to be displayed permanently on the form.
Currently, I am adding the error message through a client script. The message appears initially, but after some time it automatically disappears. I understand that this is the out-of-box (OOB) behavior in ServiceNow.
Is there a way to override this behavior and make the error message persist on the form? If so, I would appreciate any guidance or best practices to achieve this.
Thanks in advance for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hello @zee15 ,
Just to confirm the requirement — should the error message be displayed only when certain conditions are met (like based on field values), or is it meant to be a persistent alert/error message that appears on form load and never disappears regardless of user interaction?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @RakeshM49470519 Yes, the message should be displayed based on a specific condition. For example, I have created an onChange client script that validates the selected record. If the user selects an incorrect record, an error message should be displayed. However, this error message needs to remain visible permanently.
The message should only be removed when the page is reloaded or when the user manually closes the message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
hi @zee15 ,
The error message added using g_form.addErrorMessage() will remain visible until the user manually closes it (clicks “X”) or reloads the form.
Could you please clarify the exact requirement here? Are you expecting a different behavior than this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @zee15 ,
When you mentioned it as when a field value changes ,
use ShowFieldMsg on a particular field , when the condition mets , field msg will be displayed , it is permanently visibile
g_form.showFieldMsg('<field_name>','Your message','error');Feel free to msg back for any queries
Thanks regards
Badrinarayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
use form annotation and show the text always on form
How to Create and Show/Hide Annotations in a Form
Administering form annotations
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
