Last 12 months used catalog items

Hema koneti
Giga Expert

How can I Know the Catalog Items that have been used for 12 months by using the filter condition/or any way if not filter condition. We can still use reports, though I was unable to retrieve the specific catalog and apply a filter to keep the contents in that catalog. can you guide me on how to do it?

2 REPLIES 2

Robbie
Kilo Patron
Kilo Patron

Hi @Hema koneti,

 

Can you expand on what you mean by "Catalog Items that have been used for 12 months?" - What do you mean by 'used'? Do you mean created?

 

Thinking out loud, and assuming you want to know what Items have been created/ordered (aka "used") over the last 12 months, you can easily run a filter (or report) on the Requested Items table (sc_req_item) that have been created on the last 12 months. Make sure you remove any active status check etc... you should literally just have the filter on created for the last 12 months.

 

No script needed - simply configuration using the table filter or report functionality.

You then group by Item or filter on a specific item if required.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie

Anand Kumar P
Giga Patron
Giga Patron

Hi @Hema koneti ,

 

You can check sc_req_item table to check the catalog item used in last 12 months

function onetest1() { 
var count = 0;
var itemGr = new GlideRecord("sc_cat_item"); 
itemGr.addActiveQuery();
itemGr.query(); 
gs.print("Total Items: "+itemGr.getRowCount());
while (itemGr.next()) { 
var ritmGr = new GlideRecord("sc_req_item"); 
//ritmGr.addEncodedQuery('cat_item='+itemGr.sys_id+'^sys_created_onRELATIVEGT@year@ago@1'); 
ritmGr.addQuery('cat_item', itemGr.sys_id); 
ritmGr.addEncodedQuery('sys_created_onRELATIVEGT@year@ago@1');
ritmGr.query();
if (!ritmGr.next()) { 
gs.info(itemGr.name);
count= count+1;
 } 
}
gs.print("Count: "+count);
 }

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand