Info Message on UI Page?

Daniel188
Giga Contributor

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)
}
6 REPLIES 6

MrMuhammad
Giga Sage

try this

g_form.addInfoMessage("Record " + response.blahblah + " inserted successfully.");

or use alert()

alert("Record " + response.blahblah + " inserted successfully.");

 

Regards,
Muhammad

g_form not defined either.

Alert is OK, but would prefer something that doesn't intrude too much.

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. 

Regards,
Muhammad

Hitoshi Ozawa
Giga Sage
Giga Sage

>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.");
}