No Records Found error in requested for field on catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 08:11 AM
Hello Team,
I'm getting 'No Matches Found' in reference field, I have gone through one Kb article where it's mentioned to check Display is set to true for the reference table field, but I don't see any field set to display 'true'.
Please help me here with your inputs.
PF screen shot below,
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 08:19 AM
Try printing the output of the script in SCRIPTS background first just to get an idea whether the SCRIPT include works or not.
I have attached the link above for sample example.
And also it would be better if you could share script include code as it is difficult to find error just by saying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 08:36 AM
Hello Mega.
Thanks for the reply.
Please find the code below,
var SE_DelegateCheck = Class.create();
SE_DelegateCheck.prototype = {
initialize: function() {},
/*
check the scope of delegates for Super Requester
*/
getDelegates: function(group) {
var refQual = '';
if (!group.nil()) {
if (gs.getUser().isMemberOf(group.toString())) {
refQual = 'active=true';
return refQual;
}
}
var Users = [];
var Locations = [];
var userID = gs.getUserID();
var del = new GlideRecord('x_sgapg_delegatead_delegate_administration');
del.addEncodedQuery('delegate=' + userID);
del.addQuery("active", "true");
del.query();
while (del.next()) {
// check Locations
if (!del.location.nil()) {
var sepLOC = del.getValue("location").split(',');
Locations = this.getLocs(sepLOC, 4); //check recursively until the selected depth is reached
}
// check ARE
if (!del.are.nil()) {
var sepARE = del.are.split(',');
if (sepARE.length > 0) {
for (var i = 0; i < sepARE.length; i++) {
var usrare = new GlideRecord('sys_user');
usrare.addQuery('active', true);
usrare.addQuery('u_are', sepARE[i]);
usrare.query();
while (usrare.next()) {
Users.push(usrare.sys_id + '');
}
}
}
}
// check Costcenters
if (!del.cost_center.nil()) {
var sepCOS = del.cost_center.split(',');
if (sepCOS.length > 0) {
for (var j = 0; j < sepCOS.length; j++) {
var usrcc = new GlideRecord('sys_user');
usrcc.addQuery('active', true);
usrcc.addQuery('cost_center', sepCOS[j]);
usrcc.query();
while (usrcc.next()) {
Users.push(usrcc.sys_id + '');
}
}
}
}
// check Manager
if (del.managing_group != '' || del.managing_group.nil()) {
var usrMem = new GlideRecord('sys_user_grmember');
usrMem.addEncodedQuery('group=' + del.managing_group);
usrMem.query();
while (usrMem.next()) {
Users.push(usrMem.user + '');
}
}
if (!del.users.nil()) {
var users_string = del.getValue("users");
var users_array = users_string.split(",");
for (i in users_array) {
Users.push(users_array[i]);
}
}
if (!del.departments.nil()) {
var department_string = del.getValue("departments");
var dep_gr = new GlideRecord("sys_user");
dep_gr.addQuery("department", "IN", department_string);
dep_gr.query();
while (dep_gr.next()) {
Users.push(dep_gr.getUniqueValue());
}
}
}
// check manager 2
var usrMan = new GlideRecord('sys_user');
usrMan.addEncodedQuery('managerDYNAMIC' + userID);
usrMan.query();
while (usrMan.next()) {
Users.push(usrMan.sys_id + '');
}
Users = new global.ArrayUtil().unique(Users);
Locations = new global.ArrayUtil().unique(Locations);
refQual += 'sys_idIN' + Users;
if (Locations.length > 0) {
refQual += '^OR';
refQual += "locationIN" + Locations.toString();
}
return refQual;
},
getLocs: function(array, level) {
var grloc = new GlideRecord("cmn_location");
grloc.addQuery("parent", "IN", array);
grloc.query();
while (grloc.next()) {
array.push(grloc.getUniqueValue());
}
if (level > 0) {
level--;
array = this.getLocs(array, level);
}
return array;
},
type: 'SE_DelegateCheck'
//});
};
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 08:38 AM
and the same script is working in Production but in lower environments this issue is present.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 10:33 AM
As per your reference qualifier of getDelegate
it is expecting group name in the input that is passed from catalog item form.
And then once you have that group it would check whether the user you selected is member of that group or not.
So ideally your focus should be on checking whether the group has that current user in it or not otherwise it won't work.
because gs.getUserID() means current logged in user. and as per your code it is checking whether this user is part of that catalog group or not if yes only then show the value in reference field.