Calling out a Manager (One who has direct Reports) in an Entitlement Script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2009 10:07 PM
***This may be applicable to multiple situations.***
Current Situation: I need to utilize a Request Item Entitlement Script to restrict access to the RITM to managers. I do not have an easily selected flag for managers. However, I do have two half-baked ideas for which I need advice and detail. My AD (active directory) has a field which identifies Direct Reports. This filed only appears in the LDAP source record if there is a direct report. My 1st. idea is to query if this exists in the AD profile and if so set a true flag on a sys_user.u_has_direct_reports field to then use to grant access. My second Idea is to utilize the same properties which populate the Related List on an User Form which identifies direct reports and stipulate if this property is not empty to grant access. This concludes my request. Can you help?
__________________________________________________________________
I'm thinking the Entitlement script would look something like this:
gs.log('Running Entitlement script for Managers and HR Department Members');
if(gs.getUser.u_has_direct_reports() == 'true')
true;
else
false;
___________________________________________________________________
And maybe an onBefore LDAP Transform Script would look like this?
//Determine if the the direct report value for the record exists and if yes set Has Direct Reports flag.
if source.u_directreports.exist();{
target.u_has_direct_reports == 'true';
else
target.u_has_direct_reports == 'false';
}
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2009 09:28 AM
This is one way i know someone set this up, try it out, may be able to clean it up some.
Created a check box on the user table, check that if it the person has direct reports via before business rule:
Before BR on user table:
var ct = current.sys_id;
var count = 0;
var usr = new GlideRecord('sys_user');
usr.addQuery('manager.sys_id', ct);
usr.addQuery('active', true);
usr.query();
while (usr.next()){
count++;
}
//gs.print(count);
//gs.print(usr.name);
if (count >= 1){
current.u_manager_check = true;
}else{
current.u_manager_check = false;
}
Entitlement Script:
var userid = gs.getUserID();
var gr = new GlideRecord('sys_user');
gr.get('sys_id', userid);
if (gr.u_manager_check == true){
true;
}else{
false;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2009 01:47 PM
Brozi, Thank you. I was able to make it work. BTW, what is the process for posting the script in the gray boxes? Thank you again. -Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2009 01:56 PM
You can wrap your script in a code tag, use just like any html tag.