- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 08:57 AM
Hello,
I am trying to use an advanced reference qualifier to call a script include for filtering the assignment group. But my script include does not seem to be getting hit. I placed alerts and gs.info statement but they do not seem to be getting hit. What am I doing wrong?
Reference qualifier: javascript: new InteractionAssignmentGroup().getUserGroups(current.assigned_to);
Script include-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 09:48 AM
I assume both the field, script include are in same scope
try this
var InteractionAssignmentGroup = Class.create();
InteractionAssignmentGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
//Get list of all assignment groups that the user is part of
getUserGroups: function(assigned_to) {
var userID = assigned_to;
var usergroups = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery("user", userID);
gr.addQuery("group.active", true);
gr.query();
while (gr.next()) {
usergroups.push(gr.getValue('group'));
}
return 'sys_idIN' + usergroups;
},
type: 'InteractionAssignmentGroup'
});
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 09:48 AM
I assume both the field, script include are in same scope
try this
var InteractionAssignmentGroup = Class.create();
InteractionAssignmentGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
//Get list of all assignment groups that the user is part of
getUserGroups: function(assigned_to) {
var userID = assigned_to;
var usergroups = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery("user", userID);
gr.addQuery("group.active", true);
gr.query();
while (gr.next()) {
usergroups.push(gr.getValue('group'));
}
return 'sys_idIN' + usergroups;
},
type: 'InteractionAssignmentGroup'
});
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 11:23 AM
I tried this and now the script include gets hit, the first gs.info message can be seen in the log but it does not go inside the while
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 11:41 AM
It works, thank you!
I updated reference qualifier to this -
javascript: new InteractionAssignmentGroup().getUserGroups(gs.getUserID()) ;
and script include to this-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 09:54 AM - edited 05-21-2024 11:53 AM
I tested and see the gs.info() in Script log statements. The 'alerts' don't work in server scripts. use all gs.info() and look in the Script log statements module.