Linking 2 RITM raised by 2 separate catalogs

VaibhavM
Tera Contributor

We have below requirement in our instance-


We have 2 catalog items ABC and XYZ , XYZ catalog is called using scratchpad method in first catalog ABC (ie. ABC is Primary catalog and XYZ is Secondary catalog )....I have to link 2 RITM raised by this 2 catalogs....When state of First RITM (ABC catalog) is changed to "approved" then  state of Second RITM (XYZ)  should be chnaged to "approved". Similarly if  state of first RITM is changed to "Rejected" then State of second RITM should be changed to "Rejected"

 

state

RITM1 = "Approved" then RITM2= "Approved"

RITM1 = "Rejected" then RITM2= "Rejected"

 

 

6 REPLIES 6

Ravi Gaurav
Giga Sage
Giga Sage

Hi @VaibhavM 

This script ensures that if the first RITM (ABC) is the parent of the second RITM (XYZ), the state of the second RITM will be updated when the state of the first RITM changes.

(function executeRule(current, previous /*null when async*/) {
// Exit if the current RITM is not a parent
if (current.parent.nil()) {
return;
}

// Query all child RITMs (XYZ catalog items) related to the current RITM (ABC)
var childRITM = new GlideRecord('sc_req_item');
childRITM.addQuery('parent', current.sys_id); // Find all RITMs where the parent matches current RITM
childRITM.query();

while (childRITM.next()) {
// Synchronize the state of the child RITMs with the parent RITM
childRITM.state = current.state;
childRITM.update();
}
})(current, previous);

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

Ankur Bawiskar
Tera Patron
Tera Patron

@VaibhavM 

RITM's are not approved or rejected. The approval records associated for that RITM are either approved or rejected

Few fundamental questions to you

1) How are both the catalog items related

2) Both the RITMs have same REQ?

3) When is 2nd RITM created? what's the trigger? is it from RITM 1?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader