Issue with Script Include function call
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 06:08 AM
Hi All,
Requirement is based on change of assigned to, I need to display count of incidents assigned to the selected assigned to.
I had used onChange client script and Script include, but I am getting null value.
When I tried to debug using script debugger, logs, the function written inside script include is not getting executed.
I have provide admin role for the execute ACL for the script include, also it is client callable.
Below is the code-
Client script-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var sc = new GlideAjax('getIncidentCount');
sc.addParam('sysparm_func', 'getCount');
sc.addParam('sysparm_value', g_form.getValue('assigned_to'));
sc.getXML(getResponse);
function getResponse(response) {
var name = response.responseXML.documentElement.getAttribute('answer');
g_form.addInfoMessage(name);
}
}
Script include-
var getIncidentCount = Class.create();
getIncidentCount.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCount: function()
{
var count;
gs.log('inside SI');
var assign= this.getParamater('sysparm_value');
var user= new GlideAggregate('incident');
user.addQuery('assigned_to',assign);
user.addAggregate('COUNT','assigned_to');
user.groupBy('assigned_to');
user.query();
while(user.next())
{
gs.log('inside SI if');
count= user.getAggregate('COUNT','assigned_to');
gs.log("inc count is "+count);
}
return count;
},
type: 'getIncidentCount'
});
Could someone help me resolve this issue?
@Ankur Bawiskar Your help is highly appreciated.
Thanks in advance.
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 11:27 PM
It is working now. But when I try to display the message in the client script using-
g_form.addInfoMessage("User " +g_form.getDisplayValue('assigned_to')+ " has " +count+ " assigned incidents");
It is showing the message on the form in this way- User INC0000055 has 9 assigned incidents.
Instead of assigned to name, it is showing incident number.
Instead of assigned to name, it is showing incident number.