- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week 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,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week 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(", "));
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago - last edited a week 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
You can the request number from this script
var agg = new GlideAggregate('sc_req_item');
agg.addQuery('cat_item.name', 'CONTAINS', 'firewall');
agg.groupBy('request');
agg.query();
while (agg.next()) {
gs.print(agg.getDisplayValue('request'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week 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(", "));
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hi @aruncr0122 ,
Thanks for this approach that looks like what we need.
but there is not "is not one of" filter for the field "Number".
We could make is one of "numbers that are not Firewall" but the query will be huge.
Do you have any suggestion ?
Regards,