- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2022 01:37 AM
I need to update the REQ state to closed complete when RITM state is closed complete.
currently if state of sc_task is closed then RITM state is setting as closed complete.
So as well as RITM i need to closed Request also if RITM is closed.
Any help will be appreciated.
Thank you,
Shivprasad
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2022 02:47 AM
Hi,
then add the logic there itself where you are closing RITM
update as this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var closedCompleteCount = 0;
var closedInCompleteCount = 0;
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.request_item);
gr.query();
var totalCount = gr.getRowCount();
while(gr.next()){
if(gr.state == 3){
closedCompleteCount++;
}
if(gr.state == 4){
closedInCompleteCount++;
}
}
var ritm = current.request_item.getRefRecord();
var req = current.request.getRefRecord();
if(totalCount == closedCompleteCount){
ritm.state = 3;
ritm.update();
req.state = 3;
req.update();
}
if(closedInCompleteCount > 0){
ritm.state = 4;
ritm.update();
req.state = 3;
req.update();
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2022 01:41 AM
Hello,
It should work by default, is it not working ?
Regards
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2022 01:45 AM
No it's not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2022 01:49 AM
Check if this BR in active ? should work OOB
https://instance/sys_script.do?sys_id=596fac6bc0a8010a00dca5b76857e592&sysparm_record_target=sys_script&sysparm_record_row=1&sysparm_record_rows=1&sysparm_record_list=active%3DTrue%5EnameSTARTSWITHClose+Parent+if+Required%5EORDERBYDESCsys_updated_on
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2022 01:54 AM
Yeah it is in active state only