- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 11:25 AM
I have a requirement where if the Organizational type is division then the manager will be the approver of the change if the organizational
type is not division then it should check the parent group , it should continue until the organizational type is division and then the manager of that group should be approver of the change
Can some one help me with the script
In this example first it will check the assignment group and see if the type is division or not if not it should check for the parent in that group and see for the organizational type ,,
I am stuck with the scripting part in the approval user activity in workflow
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2019 11:09 AM
This fixed my issue after making some changes
var manager = groupOrg(current.assignment_group);
answer = [];
answer.push(manager);
function groupOrg(groupObj){
if(groupObj.u_organizational_type == 'division'){
return groupObj.manager.toString();
}
else if(groupObj.parent != '') {
return groupOrg(groupObj.parent);
}
return;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 12:29 PM
Here is the script that loops till the org type division is found
answer.push(groupOrg(current.assignment_group));
function groupOrg(id){
var gr = new GlideRecord('sys_user_group');
gr.addQuery('sys_id', id);
gr.query();
while(gr.next()){
if(gr.u_organizational_type == 'division')
return gr.manager;
if(gr.parent != '')
groupOrg(gr.parent);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 01:01 PM
Thanks for the code , I am getting this error if i used divisions for parent and parents parent
ex: group a - not a division
group b parent of group a. I marked the Org type as divison and this manager should be approver
Group c which is parent of group B I marked org type as division (it is not displaying any approver)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 01:45 PM
Is your requirement to get approver records for all the division type or just the first one?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 01:57 PM
Just for one , i am testing the worst situation ,but for the normal process it is picking random managers