approvals based on variable (referrence field)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 03:59 AM
Hi Experts,
based on the Divison selected , i.e. a (reference field) from the department table, I want to trigger approvals based on the below selections. I'm not able to achieve it and require your help in creating a workflow that checks the current value of the division ( which is fetching from department table) and trigger approvals accordingly.
the conditions are as follows:
Division | LEVEL 1 APPROVER | LEVEL 2 APPROVER |
Australia Commercial | Line Manager( of the requester) | Approval Group Name: Australia Commercial BCD |
Australia Retail | Line Manager( of the requester) | Approval Group Name: Australia Retail BCD |
Corporate Centre and Services | Line Manager( of the requester) | Approval Group Name: Corporate Centre and Services BCD |
Group Services | Line Manager( of the requester) | Approval Group Name: Group Services BCD |
Group Technology | Line Manager( of the requester) | Approval Group Name: Group Tech BCD |
Institutional | Line Manager( of the requester) | Approval Group Name: Institutional BCD |
New Zealand | Line Manager( of the requester) | Approval Group Name: New Zealand BCD |
Pacific | Line Manager( of the requester) | Approval Group Name: Pacific BCD |
Technology COO Domains | Line Manager( of the requester) | Approval Group Name: Technology COO Domains BCD |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 08:11 AM
for workflow I already said you can use script in the advanced section of user/group approval activity
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2023 12:30 AM
You can use code similar to below and return the sys_id of group to be used in group approval (make changes so that field backend names and group names are correct)
var division = current.division.getDisplayValue(); // Division value fetched from the Department table
var answer = [];
var approvalGroup = '';
// Set the appropriate approval group based on the division
switch (division) {
case 'Australia Commercial':
approvalGroup = 'Australia Commercial BCD';
break;
case 'Australia Retail':
approvalGroup = 'Australia Retail BCD';
break;
case 'Corporate Centre and Services':
approvalGroup = 'Corporate Centre and Services BCD';
break;
case 'Group Services':
approvalGroup = 'Group Services BCD';
break;
case 'Group Technology':
approvalGroup = 'Group Tech BCD';
break;
case 'Institutional':
approvalGroup = 'Institutional BCD';
break;
case 'New Zealand':
approvalGroup = 'New Zealand BCD';
break;
case 'Pacific':
approvalGroup = 'Pacific BCD';
break;
case 'Technology COO Domains':
approvalGroup = 'Technology COO Domains BCD';
break;
default:
// No matching division, handle the case if needed
break;
}
var groupSysID = '';
var groupGR = new GlideRecord('sys_user_group');
groupGR.addQuery('name', approvalGroup);
groupGR.query();
if (groupGR.next()) {
groupSysID = groupGR.getValue('sys_id');
}
answer.push(groupSysID);
Add the script to group approval activity like below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 12:15 AM
Hi,
i tried your sript but it is throwing an error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 03:54 AM
You have a typo or undeclared variables in the script you entered in Approval - Group actvity
Check your script for errors
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 03:34 AM
Hi Manmohan,
can you please help here?
Thanks,
Anubhav