Business Rule on RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-14-2023 07:27 AM
Need to add BR on RITM for verifying all the catalog task are closed then only RITM will be closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-14-2023 07:34 AM - edited ā11-14-2023 07:35 AM
Hi @akash12345 ,
Why you need to check this externally, do you have some ad-hoc task which are created outside of running workflow. If yes, then you should apply logic within the specific workflow only. OOTB the running workflow does this check and end after all tasks are closed ( if configured properly ).
Describe the use case in details here, we should not configure the BR just for few catalog item issues as this BR will run on every RITM where it's not needed.
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-14-2023 08:25 PM - edited ā11-14-2023 08:27 PM
HI @akash12345
You can using after update BR to check State change to Resolved or closed
(function executeRule(current, previous /*null when async*/ ) {
//Check if there is any unresolved catalog task status
//Set flag is true if found any unresolved catalog task status and no action
//If all catalog are resolved, the requested item will be resolved
var _flag = false;
var gr_scTask = new GlideRecord('sc_task');
gr_scTask.addActiveQuery();
gr_scTask.addQuery('request_item', current.request_item);
gr_scTask.addQuery('state', '!=', 5); //Resolved
gr_scTask.addQuery('state', '!=', 9); // Cancelled
gr_scTask.query();
if (gr_scTask.hasNext()) {
_flag = true;
} else {
var gr_scReqItem = new GlideRecord('sc_req_item');
gr_scReqItem.addActiveQuery();
gr_scReqItem.addQuery('sys_id', current.request_item);
gr_scReqItem.query();
if (gr_scReqItem.next()) {
gr_scReqItem.state = '5'; //Resolved
gr_scReqItem.stage = 'Resolved';
gr_scReqItem.update();
}
}
})(current, previous);
Please mark this response as correct and helpful if it helps you
Bach Phan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā11-14-2023 08:47 PM
usually we don't close RITM manually.
RITM should ideally get closed once all catalog tasks associated to that RITM is completed.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader