List of empty Available For - Catalog Items

alberttagle
Tera Contributor

Is it possible to see a list of catalog items which doesn't have an "Available For" set to them?  I'm trying to see all Catalog Items with a specific short description in a list, so I can add an "Available For" all at the same time.
The following conditions is not doing it in the sc_cat_item_user_criteria_mtom table.

find_real_file.png

4 REPLIES 4

SatheeshKumar
Kilo Sage

Logically your search location is wrong, because only the items with available for field is listed in above table i.e only when a avilable for is added to an item a relation record is created . so the records you are searching willnot be available in this table.

 

you need to use a alternative solution

 

1.first you need to get the list of all catalog items in  sc_cat_item(with required filter conditions - active true ,workflow is notempty, short description contains ariba)

2. get the list of catalog items obtained by running the query in sc_cat_item_user_criteria_mtom (with required filter conditions active true ,workflow is notempty, short description contains ariba)

3. now remove the intersecting values by comaring both the list. Now you should get the  required list of items.

 

you can do manual comarison of bith lists or you can implement it through a background script.

 

_Satheesh

This is exactly what I have been doing, just trying to see if there is a way to not manually do this, as there's 100+ items that I have to go into one by one and add the user criteria.

Harsh Vardhan
Giga Patron

you can create here one client callable script include and write a script which will give you the list of catalog item sys id which has not "Available For",  and then call it inside one report, In report add filter condition and there you will call your script include which will give you the list of item name. 

 

Report filter Condition 

 

Sys id | Is one Of | javascript: new global.getITEM().notavl()

 

Script Include:

 

var getITEM = Class.create();
getITEM.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	notavl: function(){


		var array1 = [];
		var array2= [];
		var arrayUtil = new ArrayUtil();

		var gr = new GlideRecord('sc_cat_item_user_criteria_mtom');
		gr.addEncodedQuery('sc_cat_item.active=true^sc_cat_item.sys_class_name!=sc_cat_item_content^sc_cat_item.sys_class_name!=sc_cat_item_guide');
		gr.query();
		while(gr.next()){
			array2.push(gr.sc_cat_item.sys_id.toString());
		}

		var gr1 = new GlideRecord('sc_cat_item');
		gr1.addEncodedQuery('type!=bundle^sys_class_name!=sc_cat_item_guide^type!=package^sys_class_name!=sc_cat_item_content^active=true');
		gr1.query();
		while(gr1.next()){
			array1.push(gr1.sys_id.toString());
		}

		return 'sys_idIN'+arrayUtil.diff(array1, array2);

	},

	type: 'getITEM'
});

 

Filter condition

 

find_real_file.png

 

Note: i have just added the script based on your table name which you have mentioned . this way you can get the catalog item , even you can run this on table list view filter condition. 

 

 

DrewW
Mega Sage
Mega Sage

You can do this simply using the Reporting in the system.  Create a custom report, don't use a list like you are doing.  Then use the related list condition and pick the "Available for" with no filter but you want to set it for Less than or equal to 0 selected table records are related to a record on.

 

See more information here.

find_real_file.png