How to populate group members in the dropdown?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2015 11:23 AM
There is a dropdown in change page, where we need to populate all users listed in one particular group.
Any Idea how to do this?
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2015 11:27 AM
Do an onLoad AJAX call that queries the group member table for that group, then use the addOption to add the members to the dropdown.
GlideForm (g form) - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2015 11:46 AM
This will get you started. This queries the group you want the members from, then populates your field (I named it 'Test User Field') with the sys_ids of the group members. You can use this and figure out getting the display value (which is a dot-walk, and client scripts don't like dot-walk).
function onLoad() {
//Type appropriate comment here, and begin script below
var users = new GlideRecord('sys_user_grmember');
users.addQuery('group', '287ee6fea9fe198100ada7950d0b1b73');
users.query();
while(users.next()){
g_form.addOption('u_test_user_field', users.user, user.user);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2015 12:14 PM
Hi Mike,
I wrote below script and still it is populating all users which is there in the servicenow.
function onLoad() {
//Type appropriate comment here, and begin script below
var users = new GlideRecord('sys_user_grmember');
users.addQuery('group', '48b6c2d92b7671000b877fb5a8da15ae');
users.query();
while(users.next()){
g_form.addOption('u_product_manager', users.user, users.user);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2015 12:21 PM
Oh, it looks like you want a reference qualifier on your reference field. Hold on.