addInfoMessage on g_list

medha_singri
ServiceNow Employee
ServiceNow Employee

I have a glideAjax on UI action (List Choice). Lets say, addInfoMessage is added from the server-side, its gone when I referesh the list, irrespective of before or after the ajax call. If I return the message to ajax call, g_list doesnt have addInfoMessage, how could I display it. Any help is much appreciated. Below is my code snippet.

function onClickFunctionName() {

  var selSysIds = g_list.getChecked();

  g_list.setFilterAndRefresh("");

  var ga = new GlideAjax('scriptName');

  ga.addParam('sysparm_name', 'funName');

  ga.addParam('sysparm_sys_id', selSysIds);

  ga.addParam('sysparm_show_msg', false);

  ga.getXMLAnswer(function(response){

          //GlideList2.get("tableName").setFilterAndRefresh("");

  });

}

Thanks,

Medha

1 ACCEPTED SOLUTION

venkatiyer1
Giga Guru

Hi Medha,



Try using the below function. It should work.




The first parameter is the message.


addFormMessage("Testing", "info", 0) // for info


addFormMessage("Testing", "error", 0) // for error


View solution in original post

18 REPLIES 18

venkatiyer1
Giga Guru

Hi Medha,



I have few questions around your requirements. If you want to add info message to the form you could use g_form.addInfoMessage method. If it is some server side message that you would like to get and then display on form. Then what you could do is not have the gs.addInfomessage in the Server code but just get the text and send it as response.





So in your ga.getXMLAnswer(function(response){


var answer =   response.responseXML.documentElement.getAttribute("answer");


g_form.addInfoMessage(answer);


});




Please let me know if that answers your question.


Hi Venkat,



I am on a list when I use the List choice UI action, which means g_form is not available and g_list doesnt have any API's for displaying message on the UI. Could you think of any other way of I could display?



Thanks,


Medha


venkatiyer1
Giga Guru

Hi Medha,



I am bit confused here. List Choice UI action could be on main form as well where you would have access to g_form. Can you add a screenshot of the UI from where you are using it?


Right, but my requirement is on the list and not on the form. So I open a table (tableName.list) and select multiple rows and click on an List Choice UI action. The above code I have is what happens in the UI action. In this case, how can I display a message on the UI?