How to hide a catalog item in service portal

enigmagope
Tera Expert

Hi,

We need to hide certain catalog item from a catalog when it is shown in service portal. Instead of making "Active==false" in maintain items, how to hide it from the widget.

I'm using a "catalog content" widget to show the items in a catalog.

Please help us with a solution.

1 ACCEPTED SOLUTION

enigmagope
Tera Expert

Hi Nawaz,



I have used "nameINabc,xyz" to achieve this.Thank you so much for your help


View solution in original post

7 REPLIES 7

Gurpreet07
Mega Sage

If you want a permanent solution fro this then follow below procedure.


1. Create an additional field on 'sc_cat_item' say 'hide on portal' of type checkbox..


2. Clone the widget and add additional condition in the server code.



var sc = new GlideRecord('sc_cat_item_category');


  if (data.category_id)


  sc.addQuery('sc_category', data.category_id);


sc.addQuery('sc_cat_item.u_hide_on_portal',true);


  sc.addQuery('sc_cat_item.active',true);


  sc.addQuery('sc_cat_item.sys_class_name', 'NOT IN', 'sc_cat_item_wizard');


  sc.orderBy('sc_cat_item.order');


  sc.orderBy('sc_cat_item.name');


  sc.query();



3. Now you just need to check that hide on portal checkbox for the item you want to hide on portal.


Catalog content is not the only widget for catalog items there you may need to modify other widgets as well.. . Sc Category page . You may also need to consider catalog search results.


sarfraz3
Mega Expert

You can add encoded query in the widget where you are querying for cat_items. In the encoded query just say "name!=abc^name!=xyz"



var query="name!=abc^name!=xyz";


var obj=new GlideRecord('table_name');


obj.addEncodedQuery(query);


....


....


...



.obj.query();


Hi Nawaz,


Thank you for your reply. I'm glad it helped us



Regards,


Gopi