Scripting Alert, Info, and Error Messages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 06:43 AM
Hi!
i was wondering if someone can help me to understand better what is the difference between gs.addMessage and gs.alert??
I want to use the gs.addMessage for the users, and the gs.alert for the admins.
Can i get a simply example to better understanding?
Thanks and Regards!
-Sergio V.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 06:51 AM
Hi Sergio,
I don't see any reference to gs.alert(). I don't believe it is a supported GlideSystem method. Where did you see it used?
As for gs.addInfoMessage(), that's going to display a banner message at the top of the screen when called from a server side script.
https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_GS-addInfoMessage_O
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 06:55 AM
I want to use the gs.addMessage for the users, and the gs.alert for the admins.
Can i get a simply example to better understanding?
You probably want to use gs.addInfoMessage() and gs.addErrorMessage() to display messages to the user (there's also g_form.showFieldMsg() and g_form.showErrBox() methods)
Not sure about "for the admins", but for developers consider gs.info(), gs.warn(), gs.error() and gs.log().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 07:08 AM
Hey Sergio,
Here we go:
gs.addInfoMessage - gs is nothing but the GlideSystem. In order to show the server-side messages we generally use gs.addInfoMessage.
e.g.
var gr = new GlideRecord("incident");
gr.addQuery("Active",true);
gr.query();
if(gr.next()){
gs.addInfoMessage("I am used in the server-side");
}
gs.alert- basically doesnot exist where as we simply use alert() which is generally used in the simple javascript blocks in the client/browser end.
e.g
if(g_user.hasRole("itil')){
alert("Hey now you know the difference :)");
}
post me your feedback
Please Hit ✅Correct, âÂ��Helpful, or ��Like depending on the impact of the response
Have a lovely day ahead
Regards,
Divya Mishra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2022 08:33 AM
Is the message displayed on an alert stored somewhere like a log entry in ServiceNow to later refer to which table and what was the message in the alert?
Regards,
Anish