How to implement manager's manager as approver has VP in title?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2016 12:21 PM
Hi,
I wants to implement below request in catalog item -
Requirement is : it should go for the requester's VP approval, but VP's level is not defined and sure .
There is a title field in which "VP" is mention.
It can be - >
requester -> Manager (Title is VP)
requester -> manager -> manager (Title is VP)
requester- > Manager -> Manger -> manager (Title is VP).
Could you please suggest ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2016 12:43 PM
Hi Neeta,
If I understand the requirement correctly, you want to take a look at the requester and say "Does your manager have VP in the title?" If so, use that as the approver.
If not, does their manager have VP in the title? If so, that's the approver.
And continue until you get no more managers in the chain.
Correct?
If that's the case, you will need to write a script in your approval activity that recursively looks at the user's manager for a title containing "VP".
Let me know if you need details on that script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2016 12:55 PM
Query the user table with position title and push to the approve user
// Set the variable 'answer' to a comma-separated list of user ids and/or group ids or an array of user/group ids to add as approvers.
var target = new GlideRecord('sys_user');
target.addQuery('title', 'VP');
target.query(); // Issue the query to the database to get relevant records
while (target.next()) {
answer.push(target.sys_id);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2016 01:02 PM
Thank you Manohar. I believe your script returns ALL people with people with the title "VP".
Correct me if I'm wrong Neeta, you only want 1 person with VP in the title, and that should be in the requester's management chain. Correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2016 10:50 AM
Hi Chuck/Manohar,
Requirement is that if requester's manager is VP then only it should go for his approval.
I have written below query ,but it is not working.
could you please help -
answer = [];
var recipient = current.variables.u_requester.getDisplayValue();
var user = new GlideRecord('sys_user');
user.addQuery('name',recipient);
user.query();
if(user.next())
{
var mgr = user.manager.getDisplayValue();
var user1 = new GlideRecord('sys_user');
user1.addQuery('name',mgr);
user1.query();
if(user1.next())
{
var mgrTitle = user1.title;
if(mgrTitle == 'VP')
{
answer.push(mgr);
}
}
}