Reference qualifier not calling script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi, I have a requirement in catalog item. I have two variables "Search for people" and "Type keyword for search" based on this I want users should be display in reference fields called "search results" but it is showing all users.
I am using script include and advance reference qualifier but it is not working even no logs are showing in logs table.
Not sure what I am doing wrong.
getFilter: function(type, keyword, selectedUsers) {
gs.info("GEVN_ONEIDM: type = " + type);
gs.info("GEVN_ONEIDM: keyword = " + keyword);
gs.info("GEVN_ONEIDM: selectedUsers = " + selectedUsers);
if (!keyword || keyword=='' || keyword == 'undefined') {
gs.info("GEVN_ONEIDM: No keyword entered");
return 'sys_id=NULL';
}
var query = '';
// SSO search
if (type == 'sso') {
query = 'user_nameLIKE' + keyword;
}
// First name / Last name search
if (type == 'first_name_last_name') {
query = 'first_nameLIKE' + keyword + '^ORlast_nameLIKE' + keyword;
}
// Email search
if (type == 'email_address') {
query = 'emailLIKE' + keyword;
}
// Manager search
if (type == 'directly_reports_to') {
gs.info("GEVN_ONEIDM: Searching manager using SSO");
var mgr = new GlideRecord('sys_user');
mgr.addQuery('user_name', keyword);
mgr.setLimit(1);
mgr.query();
if (mgr.next()) {
gs.info("GEVN_ONEIDM: Manager found = " + mgr.name);
query = 'manager=' + mgr.sys_id;
} else {
gs.info("GEVN_ONEIDM: Manager NOT found");
return 'sys_idISEMPTY';
}
}
// Remove already selected users
if (selectedUsers) {
gs.info("GEVN_ONEIDM: Removing selected users");
query += '^sys_idNOT IN' + selectedUsers;
}
if(!query){
return 'sys_idISEMPTY';
}
gs.info("GEVN_ONEIDM FINAL QUERY: " + query);
return query;
},
Reference qualifier in search result variable:
javascript: new global.GEVN_ONEIDM().getFilter(current.variables.v_search_for_people,current.variables.v_type_keyword_for_search,current.variables.v_people);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
script include screenshot is incomplete
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Ankur Bawiskar Please find attached ss and script.
var GEVN_ONEIDM = Class.create();
GEVN_ONEIDM.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getFilter: function(type, keyword, selectedUsers) {
gs.info("GEVN_ONEIDM: type = " + type);
gs.info("GEVN_ONEIDM: keyword = " + keyword);
gs.info("GEVN_ONEIDM: selectedUsers = " + selectedUsers);
if (!keyword || keyword == '' || keyword == 'undefined') {
gs.info("GEVN_ONEIDM: No keyword entered");
return 'sys_id=NULL';
}
var query = '';
// SSO search
if (type == 'sso') {
query = 'user_nameLIKE' + keyword;
}
// First name / Last name search
if (type == 'first_name_last_name') {
query = 'first_nameLIKE' + keyword + '^ORlast_nameLIKE' + keyword;
}
// Email search
if (type == 'email_address') {
query = 'emailLIKE' + keyword;
}
// Manager search
if (type == 'directly_reports_to') {
gs.info("GEVN_ONEIDM: Searching manager using SSO");
var mgr = new GlideRecord('sys_user');
mgr.addQuery('user_name', keyword);
mgr.setLimit(1);
mgr.query();
if (mgr.next()) {
gs.info("GEVN_ONEIDM: Manager found = " + mgr.name);
query = 'manager=' + mgr.sys_id;
} else {
gs.info("GEVN_ONEIDM: Manager NOT found");
return 'sys_idISEMPTY';
}
}
// Remove already selected users
if (selectedUsers) {
gs.info("GEVN_ONEIDM: Removing selected users");
query += '^sys_idNOT IN' + selectedUsers;
}
if (!query) {
return 'sys_idISEMPTY';
}
gs.info("GEVN_ONEIDM FINAL QUERY: " + query);
return query;
},
type: 'GEVN_ONEIDM'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
try creating fresh script include and then see
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Ankur Bawiskar is there any issue with this script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
looks fine to me.
but why you made this script include client callable?
are you having any other function in that which is being called from GlideAjax?
if not then make that non client callable
if yes then keep it client callable
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
