- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 07:20 AM
Good evening.!
I have a Catalog Form where the Flow designer is not working properly, as it has lot of Create REQTASK conditions, because of which, sometimes, the RITM remains open, even after the REQTASKs get closed. I don't want to touch the Flow designer, as it is very critical and uses automation.
So, how can we do this using Business rule? Please give the code.
Will the below BR code work for a particular Catalog Form.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 07:23 AM
1 RITM can have multiple sc_task
You can have after update BR on sc_task
Condition: State Changes to Closed Complete or Closed incomplete or Closes Skipped
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);
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 07:23 AM
1 RITM can have multiple sc_task
You can have after update BR on sc_task
Condition: State Changes to Closed Complete or Closed incomplete or Closes Skipped
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);
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 07:28 AM
Hi Ankur. Thanks a lot for this code.
But the code should work only for a particular Catalog item, and not others. Will it work ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2025 07:32 AM
in the BR condition add this along with your existing one
current.request_item.cat_item.name == 'Your Item Name Here'
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