Exclude some item when archiving REQ/RITM/TASK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi,
We currently want to archive REQ and their related records that was closed before 2 years ago.
But we want to exclude from the archive rule some item (catalog item called firewall).
How to do that since there is no "item" field on the request and so we can't filter in the archive rule on it ?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago - last edited 4 hours ago
@Nico12 so under Archival rule you should have "Archive Related Records" for "sc_req_item".
In the "Archive Related Records" there is "Reference table rule". You can create the "Reference table rule" as per your item conditions or you can edit the existing one if you want to keep single rule for request table.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Nico12,
One possible approach here is to first identify all REQs linked to the firewall catalog item through a background script. Since the REQ table itself doesn’t directly store the catalog item reference, you’d need to query through the related RITMs to extract the REQ numbers tied to that item.
Once you have that list of REQ numbers, you can then use it in your archive rule by adding a condition such as “Number is not one of …”. This way, those REQs (and their related records) will be excluded from archival.
It’s not the most elegant solution, but given the absence of a direct catalog item field on the REQ table, this might be the only practical way to achieve the exclusion.
Here’s an example background script that will fetch all REQs associated with the Firewall catalog item.
(function() {
var itemName = "Firewall"; // Catalog Item name
var reqNumbers = [];
// Find all RITMs for the catalog item
var ritmGR = new GlideRecord("sc_req_item");
ritmGR.addQuery("cat_item.name", itemName);
ritmGR.query();
while (ritmGR.next()) {
if (ritmGR.request) {
reqNumbers.push(ritmGR.request.number.toString());
}
}
gs.info("REQs associated with item [" + itemName + "]: " + reqNumbers.join(", "));
})();