Need to Sync up the REQ state based on order Guide RITMs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 10:32 PM
Hi Community,
I have created order guide with 18 rule bases. When I raise a request, 4 RITMs got created based on conditions set in rule base. Now When I close complete 2 RITM, 2 with Close Incomplete , i want the REQ state to become to closed Incomplete. but REQ remains in Approved.
Scenario is- if any one RITM becomes Closed Incomplete or closed Skipped. the main parent REQ state has to be updated to Closed Incomplete.
I have created a BR to achieve this, but it is not working.
How to achieve state sync for RITM to REQ for Order guide.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 10:43 PM
Hello Neha
I have seen your code , can you please change the code ritmGr.state = " Closed Incomplete" instead of this you will try 3, 4 ritmGr.state = " 4 " its depend on your instance what was the value , if you will paste the code its helpful for me.
Regards
Dushyant Sirohi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 11:11 PM
Hi @Negha1
This is not the best practice, to sync REQ and RITM. REQ is mostly in an approved state, how the system know I need to update REQ to close complete/incomplete if out of 18, 16 are completed and 2 are incomplete? At this place, human intervention is needed every time. So Don't implement this.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 12:41 AM
HI @Negha1 ,
You can create business rule to sync the state.
(function executeRule(current, previous /*null when async*/) {
var parentRequest = current.request; // Get the parent REQ
if (!parentRequest) {
return;
}
// Check if ANY RITM is Closed Incomplete or Closed Skipped
var ritmGR = new GlideRecord('sc_req_item');
ritmGR.addQuery('request', parentRequest);
ritmGR.addQuery('state', '7'); // Closed Incomplete
ritmGR.addOrCondition('state', '8'); // Closed Skipped
ritmGR.query();
if (ritmGR.next()) { // If any matching RITM found
parentRequest.state = '7'; // Set REQ to Closed Incomplete
parentRequest.update();
}
})(current, previous);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------