- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 04:27 PM
Hello,
I have a reference field pointing to the sys_user table called "GP Approvers" attached to a MRVS on the portal
I need it to filter its choices based on a group, to show only this group members. Here's my code
Script Include:
getGPapprovers: function() {
var users = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", "2d5b43881b864110d9ad0dcbe54bcb5c");
gr.query();
while (gr.next()) {
users.push(gr.getValue("user"));
}
return 'sys_idIN' + users.join();
},
Field:
In my understanding this is properly set, unless I'm not seeing the error. Or even the MRVS doesnt accept this setup ...
Whats wrong ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 07:18 PM
Hi,
are you using this in scoped app?
if yes then getValue() won't work
use this
getGPapprovers: function() {
var users = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", "2d5b43881b864110d9ad0dcbe54bcb5c");
gr.query();
while (gr.next()) {
users.push(gr.user.toString());
}
return 'sys_idIN' + users.join();
},
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 06:35 PM
Hi
Script Include:
var CriacaoUtils = Class.create();
CriacaoUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGPapprovers: function() {
var users = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", "<Group_Sys_id>");
gr.query();
while (gr.next()) {
//users.push(gr.user.sys_id);
users.push(gr.getValue("user"));
}
return users.toString();
},
type: 'CriacaoUtils'
});
Reference Qualifier:
sys_idINjavascript: new CriacaoUtils().getGPapprovers();
Please check and Let me Know.
Thanks 🙂
Shakeel Shaik 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 07:18 PM
Hi,
are you using this in scoped app?
if yes then getValue() won't work
use this
getGPapprovers: function() {
var users = [];
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", "2d5b43881b864110d9ad0dcbe54bcb5c");
gr.query();
while (gr.next()) {
users.push(gr.user.toString());
}
return 'sys_idIN' + users.join();
},
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader