- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 05:27 AM - edited 02-09-2024 05:28 AM
How do I populate the RITM Assignment Group from SC Task where Multiple Tasks are triggered?
Hi ServiceNow Community Colleagues,
My client has a requirement, that the RITM Assignment Group is always populated, upon closure, with the Assignment Group from the SC Task.
The challenge we have here, is some RITM's have multiple SC Tasks triggered, with different Assignment Groups.
There is a Business Rule in place currently (please see the script below), but this seems to only work for RITM's where a single SC Task is triggered from the RITM.
How can I amend this Business Rule Script, to ensure is populates for when all the SC Tasks are triggered, perhaps for example, set the RITM Assignment Group to be the same as the SC Task Assignment Group, for the final Task that is fulfilled, before the RITM is set to closed complete state?
So we would make this script always set the RITM Assignment Group, to the same SC Task Assignment Group, that belongs to the last SC Task that is fulfilled, before the RITM goes to closed complete.
The client basically, doesn't want blank Assignment Groups on RITM's, for items where multiple SC Tasks are triggered & fulfilled.
Many thanks as always for any help or guidance on how to achieve this.
Here is the current Business Rule Script (below and screenshot attached) - I need to make this work for the multiple SC Tasks scenario.
(function executeRule(current, previous /*null when async*/) {
var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item',current.sys_id);
grTask.query();
if(grTask.next())
{
//gs.addInfoMessage('Number of Tasks:'+grTask.getRowCount());
if(grTask.getRowCount() == 1)
{
//gs.addInfoMessage('Assignment group:'+grTask.assignment_group);
current.assignment_group = grTask.assignment_group;
}
}
})(current, previous);
Kind Regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 05:37 AM
Hi @WazzaJC, If your business rule is on sc_req_item table and with the conditions 'Before Update' and 'State Changes to Closed Complete', you can try the below script.
(function executeRule(current, previous /*null when async*/) {
var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item',current.sys_id);
grTask.orderByDesc('sys_created_on');
grTask.setLimit(1);
grTask.query();
if(grTask.next())
{
current.assignment_group = grTask.assignment_group;
}
})(current, previous);
Regards,
Sunil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 06:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2024 10:07 PM
Hi Sunil,
I had a same requirement i.e. client basically, doesn't want blank Assignment Groups on RITM's, for items where multiple SC Tasks are triggered & fulfilled.
I tried to implement the same BR but I don't see it's working for me. The RITM assignment group is not populating based on the last closed task assignment group.
I have written the BR on RITM table i.e. Before - Update and with conditions Item is ABC and State changes to Closed Complete
Many thanks as always for any help or guidance on how to achieve this.