Help needed for logic — Closing RITMs based on Catalog Task states (Fix Script Cleanup)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi all,
We are working on a data cleanup activity where around 1200 RITMs have 2000+ catalog tasks from the past year. The goal is to run a fix script that will automatically close or cancel RITMs based on the state of their related catalog tasks.
Here’s the logic we are planning to follow:
If an RITM has at least one catalog task in “Closed Complete,” then the RITM should also move to “Closed Complete.”
If an RITM has both “Preparation” and “Fulfillment” tasks, and both are closed, then the RITM should also move to “Closed Complete.”
If all catalog tasks under an RITM are “Cancelled,” then the RITM should be marked as “Cancelled.”
There are also RITMs that have only one catalog task (Preparation, Fulfillment, or On Hold). For these single-task RITMs, the logic needs to determine whether they should be closed complete or cancelled, depending on whether any actual work was done.
We will be looping through RITMs, checking related catalog task states, and updating the parent RITM accordingly. The fix script will be executed in batches of 10 RITMs at a time to avoid performance or timeout issues.
Help needed with the right logic or best approach to handle these different cases in the fix script.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
If all of these target records are within a specific date range, you can use that as a filter in your initial GlideRecord query as to not impact newer records.
As for your scripts... I'd probably start with the more constrained criteria first and gradually move into the more general criteria. You could also split these into three different fix scripts -- one for checking single-task RITMs, one for checking Cancel RITMs, and one for Closing RITMs.
GenAI is a great starting point for writing the scripts. I'd recommend creating a few dummy records and hard-coding them as an encoded query for testing, prior to running against your entire RITM table.
