getUnusedCatalogueItems: function (unusedDuration) { var encQuery = 'sys_created_onRELATIVEGE@month@ago@'+ unusedDuration +'^cat_itemISNOTEMPTY'; var cat_items = []; var results = []; var grAggServReq = new GlideAggregate ('sc_req_item'); grAggServReq.groupBy('cat_item'); grAggServReq.addEncodedQuery(encQuery); grAggServReq.query(); while (grAggServReq.next()){ cat_items.push(grAggServReq.getValue('cat_item').toString()); } var grUnusedCatItems = new GlideRecord ('sc_cat_item'); grUnusedCatItems.addActiveQuery(); grUnusedCatItems.addQuery('sys_id', 'NOT IN', cat_items); grUnusedCatItems.addEncodedQuery('type!=bundle^sys_class_name!=sc_cat_item_guide^type!=package^sys_class_name!=sc_cat_item_content^active=true'); grUnusedCatItems.query(); while(grUnusedCatItems.next()){ results.push(grUnusedCatItems.getValue('sys_id').toString()); } return results; },
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter