- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2025 10:16 AM
Hi Team,
I need to filter the data based on a particular assignment group from the HR Core Case table.
Since the element ID does not have one of the options, I have decided to write a script include and add those in the element ID filter.
I have tried below script, but it is showing as undefined.
Client callable is yes, and the script is active.
var getelementID = Class.create();
getelementID.prototype = {
initialize: function() {
},
getelementID: function() {
var arrUser = [];
var gr = new GlideRecord('sn_hr_core_case');
gr.addQuery('assignment_group', 'e26a8785dbd5c150dbc71a8c139619a9');
gr.addQuery('state',1);
gr.query();
while (gr.next()) {
arrUser.push(gr.sys_id.toString());
}
gs.info('getelementID: ' + arrUser); // Log the array for debugging
return arrUser;
},
type: 'getelementID'
};
Filter script : javascript:getelementID.getelementID()
Name of the script include is getelementID.
Anyone please help me how to achieve this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2025 05:59 AM - edited ‎05-21-2025 06:07 AM
make these changes and see if it works
The Element ID field is char type and not string and hence it won't be supporting IS ONE OF operator and hence it won't work
You can use left nav module and then add this in the filter condition
Script Include: The name of script include and function I made different
var getelementID = Class.create();
getelementID.prototype = {
initialize: function() {},
getRecords: function() {
var arrUser = [];
var gr = new GlideRecord('sn_hr_core_case');
gr.addQuery('assignment_group', 'e26a8785dbd5c150dbc71a8c139619a9');
gr.addQuery('state', 1);
gr.query();
while (gr.next()) {
arrUser.push(gr.sys_id.toString());
}
return arrUser.toString();
},
type: 'getelementID'
};
Then call it like this in left nav module and see
Element ID [IS ONE OF] javascript: new getelementID().getRecords();
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-2025 05:59 AM - edited ‎05-21-2025 06:07 AM
make these changes and see if it works
The Element ID field is char type and not string and hence it won't be supporting IS ONE OF operator and hence it won't work
You can use left nav module and then add this in the filter condition
Script Include: The name of script include and function I made different
var getelementID = Class.create();
getelementID.prototype = {
initialize: function() {},
getRecords: function() {
var arrUser = [];
var gr = new GlideRecord('sn_hr_core_case');
gr.addQuery('assignment_group', 'e26a8785dbd5c150dbc71a8c139619a9');
gr.addQuery('state', 1);
gr.query();
while (gr.next()) {
arrUser.push(gr.sys_id.toString());
}
return arrUser.toString();
},
type: 'getelementID'
};
Then call it like this in left nav module and see
Element ID [IS ONE OF] javascript: new getelementID().getRecords();
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