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

Gagan10
Giga Contributor

Sorry for late response , i was out this weekend .
Something like this will help you


var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('active=true^state=2);
gr.addQuery('sys_updated_on', '<=', gs.daysAgo(10));
gr.get(current.sys_id);

if(gr.state =='2')
{
gr.state ='';//mention state number here
gr.comments_and_work_notes = 'Closing due to inactivity.';
gr.update();

var ga = new GlideRecord('sc_request');
ga.get(gr.getValue('request'));
ga.request_state = 'closed_incomplete';

ga.update();
}


Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,


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.


Thanks,
Ashutosh

HI,


Can Update?

 

Thanks,
Ashutosh

Service_RNow
Mega Sage

Hi,

So, have a Business Rule on sc_task something like this:

Name: Invoke Workflow On RITM

When : onAfter

Order: 800

Condition : current.wf_activity.nil() && (current.state.changesTo(3) || current.state.changesTo(4) || current.state.changesTo(7))

Script:

// Run any workflow(s) so this task's state changes can be checked

runWorkflow_task();

function runWorkflow_task() {

    if (!current.request_item.nil()) {

          var gr = new GlideRecord('sc_req_item');

          gr.addQuery("sys_id",current.request_item.toString());

          gr.query();

          if (gr.next()) {

          new Workflow().broadcastEventToCurrentsContexts(gr, 'update', null);

          }

    }

}

Please mark reply as Helpful/Correct, if applicable. Thanks!