- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 09:46 AM
Hi Everyone,
I created a script include to the pull data of "Catalog Items without Recent RITM's requested from past six months" on to a variable. But script is not working can someone help me on this please.
var CatalogItemsWithoutRecentRITM = Class.create();
CatalogItemsWithoutRecentRITM.prototype = {
initialize: function() {},
getItemsWithoutRecentRITM: function() {
var sixMonthsAgo = new GlideDateTime();
sixMonthsAgo.addMonths(-6);
var grCatalogItem = new GlideRecord('sc_cat_item');
grCatalogItem.query();
var itemsWithoutRITM = [];
while (grCatalogItem.next()) {
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('cat_item', grCatalogItem.sys_id);
grRITM.addQuery('sys_created_on', '>=', sixMonthsAgo);
grRITM.query();
if (!grRITM.hasNext()) {
itemsWithoutRITM.push(grCatalogItem.sys_id.toString());
}
}
return itemsWithoutRITM;
},
type: 'CatalogItemsWithoutRecentRITM'
};
Reference Qualifier:
javascript: new CatalogItemsWithoutRecentRITM().getItemsWithoutRecentRITM();
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 10:02 AM - edited 10-22-2024 10:13 AM
When used in a reference qualifier, the format needs to be 'sys_idIN' then the comma-separated list of sys_ids, so you either need to change the reference qualifier to include this before the script call, or just change the script return
return 'sys_idIN' + itemsWithoutRITM.join(',');
This will filter the list of available records on a reference variable. Do you actually want to populate this list of sys_ids into the value or Selected box of a list collector variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 10:02 AM - edited 10-22-2024 10:13 AM
When used in a reference qualifier, the format needs to be 'sys_idIN' then the comma-separated list of sys_ids, so you either need to change the reference qualifier to include this before the script call, or just change the script return
return 'sys_idIN' + itemsWithoutRITM.join(',');
This will filter the list of available records on a reference variable. Do you actually want to populate this list of sys_ids into the value or Selected box of a list collector variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 12:12 AM
Thanks for the Response @Brad Bowman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 10:08 AM
I tested this in PDI and looks like it is working fine. Can you please check if you have any ACL or query BR on the table that is causing issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 12:12 AM
Thanks for the Response @Gangadhar Ravi