- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 11:03 PM
Hi All,
How can I close the RITM when all the catalog task are changes to closed using business rule
Thanks
Surbhi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2022 10:35 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
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
‎09-01-2022 11:32 PM
you can use after update BR on sc_task
Condition: State [IS ONE OF] Closed Complete/Closed Incomplete AND Request Item.Item == Your Catalog Item
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item', current.request_item);
gr.addQuery('active', true);
gr.query();
if(!gr.next()){
var ritm = current.request_item.getRefRecord();
ritm.state = 3;
ritm.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
‎09-03-2022 10:35 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
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
‎09-01-2022 11:33 PM
Hello Surbhi,
Please check with below script in your after BR on sc_task table :
put Condition as State changeTo Close complete or Close incomplete
But check what you need to do when state is close incomplete
var grCatTask = new GlideRecord('sc_task');
grCatTask.addQuery("request_item=" + current.getUniqueValue() + "^state!=3");
grCatTask.query();
if(!grCatTask.haNext()){
var grItem=new GlideRecord('sc_req_item');
if (grItem.get(current.getValue("request_item")) {
grItem.state=3;
grItem.update();
}
Please mark this as helpful/correct, if it answer your question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2022 09:24 PM
Hello Surbhi,
Just wanted to check with you, if the above response answered your question. If yes, then please do close this thread/question by marking the appropriate response as correct.
If you still need any further help or guidance on this then please update those on this question.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 11:42 PM
You can try the below logic putting the when to run condition as state is one of closed complete / incomplete an after BR on sc_task table
var gItem = new GlideRecord('sc_task');
gItem.addQuery('request_item', current.request_item);
gItem.addQuery('active', true);
gItem.query();
if(!gItem.next()){
var ritm = current.request_item.getRefRecord();
ritm.state = 3;
ritm.update();
}