gs.addInfoMessage not displaying the message

muktha1
Tera Guru

I have a List choice UI action which on selecting will open a glide dialog window asking for confirmation to send a mail to the selected list entries.. This I have achieved by calling a script include in the UI Action. The script include queries the table and sends the mail. For me the window appears. On confirmation the mail is also sent. But the message in gs.addInfoMessage is not displayed anywhere. Where am I going wrong? Can anyone please help ?  I am in serviceNow London version.

var comSentAJAX = Class.create();

comSentAJAX.prototype = Object.extendsObject(AbstractAjaxProcessor, {
ajaxcom: function() {
var id = this.getParameter("sysparm_id");

var gr = new GlideRecord('alm_asset');
gr.addQuery('sys_id','IN', id);
gr.query();
while(gr.next())
{

gs.eventQueue('comp.sent',gr, gs.getUserID(), gs.getUserName());
gs.addInfoMessage("Emails sent");

}

},

type: 'comSentAJAX'
});



}

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hi Muktha,

I think as you are reloading the window once you get the ajax response that is the only reason why you are not able to see the info message on your list view. because if you reload the window the info or error message will disappear.

var Close = function() {
reloadWindow(window);
};

ga.getXMLAnswer(Close.bind(this));
return true;
};

please try not to reload window once you receive the ajax response.

Thanks

View solution in original post

16 REPLIES 16

Hi Ian,

The extra errand is not there in my actual script include. While  copying it in my query here some mistake had  happened. The message is not getting displayed . I don' t understand where I am going wrong.

The only time I've seen a gs.addInfoMessage not display from a script include is if the script (or some part of it) failed to run.

So, if the UI Action is correctly calling the script include, which in turn is correctly triggering the event queue, then the message should work.

During my recent work on creating and troubleshooting a script include I made extensive use of gs.addInfoMessage("") and gs.addErrorMessage("") to identify which bits were working.

Ian Mildon
Tera Guru

Give these edits a try and see if you get either message displaying.

var comSentAJAX = Class.create();

comSentAJAX.prototype = Object.extendsObject(AbstractAjaxProcessor, {
ajaxcom: function() { 
var id = this.getParameter("sysparm_id"); 

var gr = new GlideRecord('alm_asset'); 
gr.addQuery('sys_id','IN', id);
gr.query();
if(gr.next())
    {
        gs.eventQueue('comp.sent',gr, gs.getUserID(), gs.getUserName());
        gs.addInfoMessage("Emails sent");

    } else {
        gs.addErrorMessage("Emails not sent");
    }

},

type: 'comSentAJAX'
});

Chuck Tomasi
Tera Patron

Something interesting I almost forgot about... in the Server side code, try using UINotification. Here's an article in the community that discusses it and gives and example.

 

Mahendra RC
Mega Sage

Hi Muktha,

I think as you are reloading the window once you get the ajax response that is the only reason why you are not able to see the info message on your list view. because if you reload the window the info or error message will disappear.

var Close = function() {
reloadWindow(window);
};

ga.getXMLAnswer(Close.bind(this));
return true;
};

please try not to reload window once you receive the ajax response.

Thanks