The CreatorCon Call for Content is officially open! Get started here.

SC Categories widget - Hiding a Category

andrewdunn
Giga Expert

Hi Team,

We are on Istanbul and I want to hide a specific category on a cloned SC Categories Widget. While the Widget works as designed I do not want to show "Report an Incident"

I have made "Infrastructure" category only available to ITL users. However, the "Report an Incident" still needs to be available to all users, just not visible on my cloned widget.

I suspect it will be a line of code along the lines of "If category = "Report an Incident" then hide"

However I am not a coder by occupation and would like some assistance if soemone can help.

Cheers

SC Categories Widget.png

3 REPLIES 3

Simon Christens
Kilo Sage

Hi Andrew



If you create a checkbox on sc_category table named something like "hide on SP" and the edit the query in the server script from:


Line 18 and forward



var sc = new GlideRecord('sc_category');


sc.addQuery('sys_class_name', 'sc_category');


sc.addQuery('u_hide_on_sp', true);


sc.addActiveQuery();


sc.orderBy('title');


data.sc_catalog = $sp.getValue('sc_catalog');


if (data.sc_catalog)


  sc.addQuery('sc_catalog', data.sc_catalog);


if (options.category_layout === "Nested")


  sc.addQuery('parent', '');


sc.query();


data.categories = retrieveCategoriesFromGR(sc);



I whould give that a try - though i havent tested this



Regard


Simon


SNOW User8
Giga Guru

Hi Andrew,

How did you solve this? Please share 

 

calvinrawls
Kilo Contributor

In my New York version personal instance, in the server script for the widget 

The fetchCategories function

starting at line 109, I inserted the if statement below using the sys id of the category to hide:

var categoryDetails = getCategoryDetails(categoryJS, 0);
categoryDetails.sys_id = categoriesGr.getUniqueValue();
//Do not show Can We Help
if (categoryDetails.sys_id == 'e15706fc0a0a0aa7007fc21e1ab70c2f')
continue;
categories.push(categoryDetails);