Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 01:23 PM
Here's a robust way of going through groups to find the right one:
answer = findApprovingManager();
function findApprovingManager() {
if (current.assignment_group.u_organizational_type == 'division') {
answer.push(current.assignment_group.manager.toString()); // Base Case
} else {
answer.push(grabHierarchy(current.assignment_group.parent.toString()));
}
return answer;
}
function grabManager(selectedGrp) {
var result = [];
var divGrp = new GlideRecord('sys_user_group');
divGrp.addQuery('sys_id', selectedGrp.toString());
divGrp.addQuery('u_organizational_type', 'division');
divGrp.addActiveQuery();
divGrp.query();
if (!divGrp.next()) {
var gr = new GlideRecord('sys_user_group');
gr.addQuery('sys_id', selectedGrp.toString());
gr.query();
if (gr.next()) {
var nextGrp = gr.parent;
grabManager(nextGrp);
}
} else {
result.push(divGrp.manager);
}
return result;
}
Let me know if this answers your question by marking it as correct.