- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 11:06 PM
Dear experts,
I am trying to make a script include to call in a reference qualifier to show only the users with the same department with the user field in the sys_user_delegate form. But currently the return value is null for the sys_id. May I know what is wrong with my scripts and how should I modify it?
Reference Qualifier:
javascript: new global.FilterDepartmentUtils().getRefQualifier()
Script Include:
var FilterDepartmentUtils = Class.create();
FilterDepartmentUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getRefQualifier: function(recordId) {
if (!recordId)
return 'sys_id=NULL';
var delegateRec = new GlideRecord('sys_user_delegate');
if (!delegateRec.get(recordId))
return 'sys_id=NULL';
var user = delegateRec.getValue('user');
if (!user)
return 'sys_id=NULL';
var userGr = new GlideRecord('sys_user');
if (!userGr.get(user))
return 'sys_id=NULL';
var dept = userGr.getValue('department');
if (!dept)
return 'sys_id=NULL';
return 'department=' + dept + '^roles=sn_risk_advanced.Boost - BU Lead';
},
type: 'FilterDepartmentUtils'
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 11:28 PM - edited 06-11-2025 12:11 AM
Hi @ChuanYanF
use this ref qual directly
javascript:'department='+current.user.department+'^departmentISNOTEMPTY^roles=sn_risk_advanced.Boost - BU Lead'
OR
update your script like this
var FilterDepartmentUtils = Class.create();
FilterDepartmentUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getRefQualifier: function(delegateRec) {
if (!delegateRec || !delegateRec.user || !delegateRec.user.department)
return 'sys_id=NULL';
return 'department=' + delegateRec.user.department + '^roles=sn_risk_advanced.Boost - BU Lead';
},
type: 'FilterDepartmentUtils'
});
and Ref qual to
javascript:new global.FilterDepartmentUtils().getRefQualifier(current)
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 11:15 PM
Hi @ChuanYanF ,
getRefQualifier method accepts a parameter (recordId) since it's not passed it's returning sys_id=nul
what's recordId parameter here?
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 11:21 PM
It should be the sys_id of my delegate's record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2025 11:28 PM - edited 06-11-2025 12:11 AM
Hi @ChuanYanF
use this ref qual directly
javascript:'department='+current.user.department+'^departmentISNOTEMPTY^roles=sn_risk_advanced.Boost - BU Lead'
OR
update your script like this
var FilterDepartmentUtils = Class.create();
FilterDepartmentUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getRefQualifier: function(delegateRec) {
if (!delegateRec || !delegateRec.user || !delegateRec.user.department)
return 'sys_id=NULL';
return 'department=' + delegateRec.user.department + '^roles=sn_risk_advanced.Boost - BU Lead';
},
type: 'FilterDepartmentUtils'
});
and Ref qual to
javascript:new global.FilterDepartmentUtils().getRefQualifier(current)
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 12:40 AM
reference qualifier shared by @Chaitanya ILCR should work
Try that and share the feedback.
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