client script did not show g_form.addInfoMessage()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 01:38 AM
It's my client script and script include , 'g_form.addInfoMessage(myObj) ' did not show the form when I update a form, why?
client script:
function onSubmit() {
//Type appropriate comment here, and begin script below
var GA = new GlideAjax('AA');
GA.addParam('sysparm_name', 'Test');
GA.addParam('sysparm_sys_id', g_form.getUniqueValue());
GA.getXML(Parse);
function Parse(response) {
var myObj = response.responseXML.documentElement.getAttribute('answer');
g_form.addInfoMessage(myObj);
}
}
script include:
var AA = Class.create();
AA.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Test: function() {
gs.info("include111111");
var message = "";
var arr = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord("u_child_test");
gr.addQuery('u_project', arr);
gr.addQuery('u_name', "1234");
gr.query();
gs.info("count=====" + gr.getRowCount());
if (gr.next()) {
message = "you can insert";
} else
message = "you have to have a child test record which name is 1234";
gs.info(message);
return message;
},
type: 'AA'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 01:59 AM
Hi, perhaps you could start by adding some debugging\logging to client and sever scripts so that you can see which part of your code is failing.
Have you confirmed that the onSubmit() script runs?
The ajax script is called server side, sysparm_sys_id has a suitable value when passed to the server script, that gr returns a result from it's query and 'message' has a suitable value before it is passed back to the client?
I would take a look at the if condition in your server script, in case the lack of {} formatting causes confusion and the return is considered part of the else condition, perhaps try
if (gr.next()) {
message = "you can insert";
} else {
message = "you have to have a child test record which name is 1234";
}
gs.info(message);
return message;
},