- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 11:26 PM
Hi all,
I have a list collector variable called 'current_users' which refer sy_user table
In Reference qual, I call a script include to filter the selectable choices based on another variable
So, if there are no matches (glide query returns empty), list collector variables shows all sys_user records. Can I set this to be empty/non selectable?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 03:01 AM
Hi,
I used return 'sys_idIN'; if getUsers is empty and then it worked!
Many thanks,
Bimsari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 02:44 AM
I would be interested in seeing your reference qualifier and Script Include. Your Script Include should be returning 'sys_idIN1...,2...,3...' listing each record to be used in the filter of list, so if you're building an array of gliderecord query results, then your array would be empty, so the result returned would be 'sys_idIN' which should be interpreted as showing 0 records, not all. If you're already doing something similar to this, but that empty array results in all records being displayed, then I would push a dummy sys_id to the array when there are no query results - or even if there are would be fine as it wouldn't affect anything. It could even be something short like '1'. That record would never be found/shown in the list, and if there aren't any others then it will be empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 03:09 AM
Hi Brad,
Thank you for your answer. I have tried returning sys_idIN001 also but still it shows all the records when query returns empty
Following is my script include
Name: demoStudioUtil
getExisitingUsers: function(user_role,studio_id,filter) {
var getUsers = '';
var ret ='';
var gr = new GlideRecord('u_util_custom_data');
gr.addQuery('u_catalog_item', '443063a587b9cd503a900e590cbb3569');
gr.addQuery('u_string1',studio_id);
gr.query();
if(gr.next()){
var all_users = JSON.parse(gr.u_string4);
}
if(user_role == 'admin'){
getUsers = all_users.administrators.split(',');
}
else if(user_role == 'presales'){
getUsers = all_users.presalesConsultants.split(',');
}
else if(user_role == 'technicians'){
getUsers = all_users.technicians.split(',');
}
return 'sys_idIN'+getUsers;
},
Following is my reference qual
javascript: new demoStudioUtil().getExisitingUsers('admin',current.variables.demo_studio,'');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 04:36 AM
Have you tried adding a log to the SI to confirm the value being returned? I suspect there's an error or invalid format, so it's defaulting to returning every record. You should declare the all_users variable before the gr if block since you're using it outside of the gr if, and while you're at it, there's no use building getUsers from empty results, so something more like this makes more logical sense and should also show no records when the gr is empty.
getExisitingUsers: function(user_role, studio_id, filter) {
var getUsers = [];
var all_users = '';
var gr = new GlideRecord('u_util_custom_data');
gr.addQuery('u_catalog_item', '443063a587b9cd503a900e590cbb3569');
gr.addQuery('u_string1', studio_id);
gr.query();
if (gr.next()) {
all_users = JSON.parse(gr.u_string4);
if (user_role == 'admin') {
getUsers = all_users.administrators.split(',');
} else if (user_role == 'presales') {
getUsers = all_users.presalesConsultants.split(',');
} else if (user_role == 'technicians') {
getUsers = all_users.technicians.split(',');
}
}
//this else block is probably not needed
else {
getUsers.push('001');
}
return 'sys_idIN' + getUsers.join(',');
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 03:01 AM
Hi,
I used return 'sys_idIN'; if getUsers is empty and then it worked!
Many thanks,
Bimsari