Date catalog item was last ordered

User175049
Mega Guru

Hello

I am looking for a way to find out when items of a particular Service Catalog (we have multiple) were last ordered. This would be used to help us determine whether a SC Item should remain in the catalog or removed due to lack of need.

 

Thank you,

M

1 ACCEPTED SOLUTION

Oliver Stammler
Giga Guru

Hey M,

as far as I understood you only need the date so that you can manually deactivate the corresponding catalog items or not, right? 

In this case it is not necessary to write a script, a simple report is enough.
Just create a new report with the source type "Table" and the table "Requested Item [sc_req_item]" (see report1.png attached). Now add the "Created" field to the list in the "Configure" menu item using the "Choose columns" button. (see report2.png attached)

Now you can simply use the filter in the generated report and search for your item.
Via the field "Created" you can now see when the item was last ordered, as you can see in the last screenshot attached.

If I got you wrong and you still need a script, you can use this one:

var grItemsOrdered = new GlideRecord('sc_req_item');
grItemsOrdered.addQuery('cat_item', 'ADD YOUR SYS_ID HERE');
grItemsOrdered.orderByDesc('sys_created_on');
grItemsOrdered.setLimit(1);
grItemsOrdered.query();

if(grItemsOrdered.next()){
gs.print(grItemsOrdered.sys_created_on);
}

Just add your sys_id where I marked it and you can run this script as a background script for example.

Best regards
Oli

View solution in original post

5 REPLIES 5

ersureshbe
Giga Sage
Giga Sage

Hi, I recommend to refer below link. I hope, it will fulfil requirement. It's a knowledge article to achieve through performance analytics.

 

https://www.servicenow.com/community/platform-analytics-articles/measuring-catalog-item-usage-compre...

Regards,
Suresh.