The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Exclude some item when archiving REQ/RITM/TASK

Nico12
Mega Sage

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,

1 ACCEPTED SOLUTION

aruncr0122
Kilo Guru

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(", "));

})();

View solution in original post

7 REPLIES 7

aruncr0122_0-1758117886436.png

Hi @Nico12 ,

 

I found that you can include the Item field in the condition. In the condition dropdown, first select "Show related fields". Then navigate to Universal Request → Task fields → Requested Item → Item. From there, you can add the condition Item is not "Firewall".

Just a GUI navigation. for reference

mujeebqasimi_0-1758125195567.png

mujeebqasimi_1-1758125223644.png

mujeebqasimi_2-1758125297735.pngmujeebqasimi_3-1758125323993.png

 

 

 

Thanks, 

 

We ended use the first solution (with script include) but inverted the logic to "number / is one of / result of script include.

 

Works well !

 

Regards,