Info Message on UI Page?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 03:18 PM
Hoping this is a relatively simple question; I couldn't find it via a precursory search in communities.
On a UI Page, how do I display an info message?
Use case:
User hits Submit button on UI page
Client Script calls GlideAJAX script include
GlideAJAX does some processing, returns a value
callback function looks like this:
ga.getXML(myCallBack);
function myCallBack(response) {
var response = response.responseXML.documentElement.getAttribute("answer");
if (response.blahblah)
gs.addInfoMessage("Record " + response.blahblah + " inserted successfully."); // doesn't work (gs is undefined)
}
- Labels:
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 03:24 PM
try this
g_form.addInfoMessage("Record " + response.blahblah + " inserted successfully.");
or use alert()
alert("Record " + response.blahblah + " inserted successfully.");
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 03:50 PM
g_form not defined either.
Alert is OK, but would prefer something that doesn't intrude too much.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 04:56 PM
Ah okay. your UI page is standalone page and not being used as POP UP page on any other form that's why g_form is undefined.
In that case, you will have to create a custom div to display a message in your UI page and show/hide message/div based on condition either via Jelly script or Client Script.
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2020 04:29 PM
>g_form not defined either.
Where are you writing this script? Is in in Catalog Client Script? If so, g_form should of available.
gs is only used in server-side scripting.
>The GlideSystem (referred to by the variable name 'gs' in any server-side JavaScript)
If you are using in server-side script, the script can not be async nor transform scripts.
This method is not supported for asynchronous business rules and cannot be used within
transform scripts.
https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/c_GlideSystemAPI
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
ga.getXML(myCallBack);
function myCallBack(response) {
var resp = response.responseXML.documentElement.getAttribute("answer");
if (resp.blahblah)
g_form.addInfoMessage("Record " + resp.blahblah + " inserted successfully.");
}