
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 08:40 AM - edited 11-29-2022 08:41 AM
Gist/Background: Want to simply add a field message in Incident record, onLoad or onChange, under the "Customer" (caller_id) field, if the State is neither Closed nor Resolved, and if the "Customer" is inactive.
To accomplish this, I modified an existing (custom) Script Include called "userDetails", adding a "getActiveState" function. I use that to fetch the user's active value.
I then call this Script Include from both onLoad and an onChange client scripts. I'm using alerts to help me troubleshoot since you can't write gs.log statements from client-side scripts.
For some reason, the Script Include returns 'false' no matter what the user's active value is. I would really appreciate if someone can review these and let me know what I might be doing wrong. I've included the pertinent Script Include function and one of the two client scripts.
Script Include "userDetails":
var userDetails = Class.create();
userDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getActiveState: function () {
var gr = new GlideRecord("sys_user");
gr.addQuerey("sys_id", this.getParameter('sysparam_id'));
gr.query();
gr.next();
return 'false';
},
//irrelevant functions removed
type: 'userDetails'
});
Client Script "Warn if end-user is inactive (onLoad)":
Table: Incident
function onLoad() {
//This script calls the "userDetails" script include
var activeState = new GlideAjax('userDetails');
activeState.addParam('sysparm_name', 'getActiveState'); //[parameter],[function] in the script include to use
activeState.addParam('sysparam_id', g_form.getValue('caller_id')); //pass the Customer's sys_id value
activeState.getXML(getAnswer);
}
function getAnswer(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
var incState = g_form.getValue('state');
if (answer == 'false' && incState != 6 && incState != 7) {
g_form.showFieldMsg('caller_id','WARNING (OL): The selected Customer is INACTIVE and cannot receive notifications.','error');
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 09:03 AM
My colleague found it. I had a typo:
gr.addQuerey("sys_id", this.getParameter('sysparam_id'));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 08:55 AM
Ugh, I forgot to change it back. Originally I was using return gr.active;. I'll change it back and test again.
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 09:03 AM
My colleague found it. I had a typo:
gr.addQuerey("sys_id", this.getParameter('sysparam_id'));