Close RITM and Request on close of Catalog Task

SNOW46
Tera Contributor

Hi Team,

I have one requirement that when the Catalog Task is closed then automatically the RITM as well as Request will get Closed.

If the state of Task changes to Closed Complete then for RITM as well as Request will also change the state to closed complete.

 

Thanks & Regards,

SNOW@Das

8 REPLIES 8

Ricky Quinn
Kilo Expert

Hi SNOW@Das,

In the workflow, add a set value component after the task and set the stage as completed and state to closed completed.  This will set the item to close complete and there is already a business rule to close out the request when the Requested item is closed.

find_real_file.png

find_real_file.png

 

Service_RNow
Mega Sage

Hi,

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!

Gagan10
Giga Contributor

You can use BR or schedule job or Fix Script for this .

For BR:- 

Create BR on catalog task table which is sc_task and query for parent record from there only , if your task is set to close then close it's parent record .

For Schedule Job:-

If you are looking for something like your all tickets should be closed after some days of inactivity then you can use this method , logic will remain same for this one . 

For Fix Script :-

If there are many closed incomplete tasks present in your instance and you want to close them all in a single shot , then you can opt fix script 

Go to System Definition and search for Fix Script . Put your logic there , save it and select run option and then select proceed in background option .

Fix script is better and suggested way instead of Background Script. 

SNOW46
Tera Contributor

Hi Gagan,

Can you please let me know in brief. As to what will be the conditions and script set for Business Rule.

 

And for rest of the techniques as well. So it will be helpful for me going forward.

 

Thanks,

SNOW@Das