have to create a business rule to close the RITM and REQ if the all related tasks got closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2019 02:55 AM
the issue here is , few requests are not getting closed.
so i want to create a busienss rule to check all the related tasks are got closed or not.
if all closed it has to close the RITM and REQ.
if not it should not execute.
please help me with the sample code.
it has to check manual tasks as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2019 07:42 AM
sample script here. You can modify it as per your req.
Script:table "sc_task" and trigger the BR only for the condition state is closed incomplete.
closeItemIfRequired();
function closeItemIfRequired(){
// check to see if any of our peers are currently *not* closed
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.request_item);
gr.addQuery('active', true);
gr.query();
if (!gr.next()) {
// no peer task is currently open
var sc_req_item = new GlideRecord('sc_request_item');
sc_req_item.addQuery('sys_id', current.request_item);
sc_req_item.query();
if(sc_req_item.next())
{
//update the field of sc_req_item
sc_req_item.update();
}}}
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2019 07:42 AM
This should be done via workflow. IN workflow after task activity you should check the state of task which just got closed.
If the state is closed complete then use set Value activity in workflow to set state of RITM to closed complete else in NO flow of If use set value where you will set state to closed incompleted.
OOB once all ritm are closed to either incomplete or complete REQ will be closed automatically.