
- 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-26-2015 09:43 AM
That looks like it should work fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2015 09:50 AM
I just submitted a request as a non-member of IT ServiceDesk, and I made sure that my 'requested_for' value was different than my 'u_requested_by' value, and the email did not fire off.
Any idea why this would not work? Could it be that I'd have to make a second "if" portion of code uniquely for my "current.u_requested_by == current.requested_for" to result in answer = false?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2015 10:48 AM
It could be any number of things. I would suggest adding some 'gs.log' entries in there to output data to the logs so that you can see what's happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2015 11:36 AM
Looks like I got it working in the end. My issue was that I thought the "answer = true" meant the entire advanced condition was equating to true, when instead it's the email being sent = true. Furthermore, because I am working with "not" situations, I really would want to use an AND operator, instead of an OR.
My final working code is as follows. Hopefully, it has the Crossfuze seal of approval:
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 = true;
}