Having Issues Populating Records into a list collector variable from a script include and Ref qual
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 04:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 05:10 PM - edited 10-04-2023 05:12 PM
Hi, assuming your ref qualifier script-include is functioning and is called ok?
it is returning an array, whereas I think you need a comma separated string of sys_id's.
You also need to include query syntax for the field you are referencing\filtering on, so something like this should work.
javascript: 'sys_idIN' + new Laz_GetVIPUserList().fn_getUserMemberNames(action).toString();
Edit: Sorry missed the current reference
javascript: 'sys_idIN' + new Laz_GetVIPUserList().fn_getUserMemberNames(current.action).toString();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 09:02 PM
HI @guzman ,
I trust you are doing great.
Please find the corrected script include
var Laz_GetVIPUserList = Class.create();
Laz_GetVIPUserList.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fn_getUserMemberNames: function(action) {
var actionTaken = action; // Action: 'add' or 'remove'
var encoded_query = '';
var memberList = [];
if (actionTaken == 'add')
encoded_query = 'active=true^u_hr_active_employee=true^vip=false';
if (actionTaken == 'remove')
encoded_query = 'active=true^u_hr_active_employee=true^vip=true^titleLIKECEO^ORtitleLIKECOO^ORtitleLIKEChairman^ORtitleLIKEChief^ORtitleLIKEGeneral^ORtitleLIKEGlobal^ORtitleLIKEHead^ORtitleLIKEManaging';
var vip_user = new GlideRecord('sys_user');
vip_user.addEncodedQuery(encoded_query);
vip_user.query();
while (vip_user.next()) {
memberList.push(vip_user.sys_id.toString());
}
return memberList.join(','); // Return comma-separated list of sys_ids
},
type: 'Laz_GetVIPUserList'
});
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 09:14 PM
Hi @guzman
Assuming you are doing this on Catalog item variable :
Can you update reference qualifier as :
javascript : new Laz_GetVIPUserList().fn_getUserMemberNames(current.variables.action);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates