RITM should get close once all catalog tasks are closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 06:14 AM
Hi Community,
I want the RITM should get close only once all the catalog tasks are closed. I have written the business rule for this after update with the condition as state is closed complete. But it's not working as per requirement. Can anyone please help on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 06:18 AM
Hi @tulasi8
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);
if your issue is resolved, mark as helpful and accept the solution
Thanks regards
Badrinarayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 06:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 06:28 AM - edited 07-10-2025 06:30 AM
Hi,
The script is working fine on my end. Please review it once and also check the backend values, specifically for statuses like Closed Complete and Incomplete.
Also, I noticed you're using hasNext() to check for records. It's better to use next() instead, as it both checks for the existence of a record and moves the pointer forward.
Thanks & Regards,
Badri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 06:34 AM
@Badrinarayan these are the actions i have given in flow designer, are these actions after creating task is needed even after writing the business rule ?
