- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 11:18 AM
I'm trying to make a form show up in the service portal for only certain users. I have used an Available For group, which has worked perfectly for one half of my requirements. The other half is to show up only for supervisors. In my case, all supervisors will have u_user_has_direct_reports == true, and this is how I want to tell if an individual is a supervisor.
function answer(){
var gr = new GlideRecord('sys_user');
gr.addQuery('u_user_has_direct_reports','true');
gr.query();
var users = [];
while (gr.next){
users.push(gr.getValue('sys_id'));
}
return users;
}
This is what I have so far, but am having troubles make it work correctly.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 12:29 PM
The Advanced portion of "Available for" returns true or false, not a query string or collection of sys_id's.
I did a brief test, and you'll want to do something more along the lines of:
getAnswer();
function getAnswer(){
var gr = new GlideRecord('sys_user');
gr.get('sys_id',gs.getUserID());
if (gr.u_user_has_direct_reports == true)
return true;
else
return false;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 11:58 AM
please try this, let's see if this helps.
function answer(){
var gr = new GlideRecord('sys_user');
gr.addQuery('u_user_has_direct_reports', true);
gr.query();
var users = [];
while (gr.next()){
users.push(gr.manager.toString());
}
return 'sys_idIN' + users;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 12:05 PM
still nothing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 12:29 PM
The Advanced portion of "Available for" returns true or false, not a query string or collection of sys_id's.
I did a brief test, and you'll want to do something more along the lines of:
getAnswer();
function getAnswer(){
var gr = new GlideRecord('sys_user');
gr.get('sys_id',gs.getUserID());
if (gr.u_user_has_direct_reports == true)
return true;
else
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 12:35 PM
This was my initial understanding as well, and what my original code looked like. Your code works, and corrected a small mistake on my initial code. Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 02:04 PM
Great! Sometimes you just need another set of eyes on something.