I want to write the Business rule for RITM State to update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 09:47 PM
Hi,
I written the BR on the Catalog task table, when catalog task state updated based on that RITM State also updated. But RITM got closed when one catalog task closed, it should need to wait till the last catalog task to close and update the RITM State.
Can any one help here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:00 PM
Hi @PRAGHATIESH S ,
instead of write Business rule, you can try flow/workflow. it will easy to sync the state of RITM ,SCTASK and REQ.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:08 PM
Hello @PRAGHATIESH S
To ensure a RITM only closes after all associated Catalog Tasks are closed:
Business Rule Configuration
- Table: sc_task
- When to run: After insert or update
- Condition: State is closed
Updated script in BR:
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item', ritm.sys_id);
tasks.addQuery('state', '!=', 'closed'); // Adjust 'closed' as per your states
tasks.query();
if (!tasks.hasNext()) {
ritm.state = 'closed'; // Adjust 'closed' as per RITM states
ritm.update();
}
}
})(current, previous);
This will trigger when the state in sc_task is closed, checks for the ritm and check all the task associated with this RITM is closed. Then only update the RITM state to closed.
Note: Adjust closed state as per your requirement.
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:31 PM
Hi @PRAGHATIESH S ,
If the RITM close unintendedly you should look into the flow running in the background and not a business rule.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:36 PM
Better make this logic change in Flow/Workflow as part of best practice, BR is not required here to sync states across REQ, RITM and SCTASK.
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************