
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2014 05:17 PM
I have a reference field called hiring manager (u_hiring_manager) that reference the user table.
In a UI policy I need to find out if the hiring manager is in a group.
I've been at this for several hours - not finding any direct solutions.
I've tried:
var hm = g_form.getReference('u_hiring_manager', setAValue); |
to get the hiring manager's user information. Then I tried:
hm.isMemberOf('group name') - didn't seem to work
hm.sys_id.isMemberOf('group name') - didn't seem to work.
Any help will be much appreciated.
Thanks,
Rick Forristall
Goodwill of Central Arizona
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2014 07:23 AM
I would put an alert in as the first line in your 'onCondition' function to check that the UI policy condition is even firing and getting into the script. I have mine set up as a client script. You can log into demo003 here...
https://demo003.service-now.com/side_door.do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2015 04:07 PM
I am trying to use this in an email notification script, with the following code, and it is not working. Can someone please review and assist in this?
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.name', 'IT ServiceDesk');
grp.addQuery('user', g_form.getValue('requested_by'));
grp.query(groupMemberCallback);
if (grp.next()) {
answer = false;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2015 05:36 PM
Shane, in a mail script you're using back-end scripting so 'g_form' and the callback function wouldn't be applicable. You'll just want to use a standard GlideRecord query leveraging the 'current' object to get to record values.
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.name', 'IT ServiceDesk');
grp.addQuery('user', current.requested_by);
grp.query();
if (grp.next()) {
//Do something here if a member of the group...
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2015 09:34 AM
Thanks for the information Mark, that is working.
If I wanted to add a further "OR" condition, of say comparing one variable value to another, would this be sufficient?
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.name', 'IT ServiceDesk');
grp.addQuery('user', current.requested_by);
grp.query();
if (grp.next()) {

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2015 09:38 AM
That code looks just like what I just posted. If you want to do an 'or' condition then it depends on where you want to add it. Is it part of the query or part of the 'if' statement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2015 09:40 AM
My apologies, looks like it didn't copy to my clipboard. The extra condition check would be part of the 'if' statement, as I want it to be checked in addition to the group membership code, to provide the "False" answer to the advanced condition:
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.name', 'IT ServiceDesk');
grp.addQuery('user', current.u_requested_by);
grp.query();
if (grp.next() || current.u_requested_by == current.requested_for) {
answer = false;
}