flushMessages ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 08:27 PM
The flushMessages() method in ServiceNow is typically used in the context of the GlideSystem (referred to as gs) object. This method is used to clear any informational messages that have been queued up for display to the user during the execution of a script.
Usage
The flushMessages() method doesn't take any parameters, and its purpose is to ensure that all current messages are removed from the queue. This can be helpful if you want to clear messages before displaying new ones to the user.
Syntax
Example
Here's a simple example to demonstrate how you might use flushMessages() in a script:
In this example:
- Two messages are added to the message queue.
- gs.flushMessages() clears all the messages that were added.
- The new message will be the only one displayed.
This method is helpful when you want to ensure that outdated or irrelevant messages are not shown to the user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 04:55 AM
Hi @Sumanth16 ,
I have use case where all previous error messages must be removed and a certain message must be displayed. I believe the 'gs.flushMessages()' removes messages from the same script. Is there another function that will remove messages from all scripts triggers for a table.