Close RITM and Request on close of Catalog Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2019 03:56 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019 12:33 AM
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();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019 12:59 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2019 09:06 AM
HI,
Can Update?
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019 01:18 AM
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!