User Criteria for custom widget on sc_cat_item page Portal (Condition: Catalog = Service Catalog)

RichardSaunders
Tera Guru

Hello,

I am encountering an issue with creating a User Criteria for my custom Requested For widget. The requirement is for the widget to display only when the catalog is Service Catalog (active=true^sc_catalogs=e0d08b13c3330100c8b837659bba8fb4).

 

The widget should not be visible for the Human Resources Catalog, as it has its own mechanism for identifying the user (e.g., using the subject person).

 

Additionally, I noticed that the Instance Options field is greyed out. I manually created an sp_instance, but the field remains unavailable. I am unsure if this is related to the failure of the User Criteria.

 

Any assistance or suggestions to resolve this issue would be greatly appreciated.

 

Thank you!

 

RichardSaunders_0-1737978208983.png

 

1 ACCEPTED SOLUTION

RichardSaunders
Tera Guru

 

 

Figured it out, added this code to my Widget Server Script. 

 
    var sys_id = $sp.getParameter("sys_id");
    var sc_cat_item = new GlideRecord("sc_cat_item");

    if (sys_id && sc_cat_item.get(sys_id)) {
        var catalog = sc_cat_item.getValue("sc_catalogs"); 
        if (catalog.indexOf("e0d08b13c3330100c8b837659bba8fb4") > -1) {
            data.showWidget = true;
        } else {
            data.showWidget = false;
        }
    } else {
        data.showWidget = false;
    }

 

View solution in original post

2 REPLIES 2

Mark Manders
Mega Patron

Why is there a widget to just do this? Why isn't it a variable set, so you can easily just apply it to the items that need it (not the HR ones)? 

And I also think that User Criteria need to be user related, so identifying the user somehow, not the catalog. It's 'who can view' not 'where can view'.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

RichardSaunders
Tera Guru

 

 

Figured it out, added this code to my Widget Server Script. 

 
    var sys_id = $sp.getParameter("sys_id");
    var sc_cat_item = new GlideRecord("sc_cat_item");

    if (sys_id && sc_cat_item.get(sys_id)) {
        var catalog = sc_cat_item.getValue("sc_catalogs"); 
        if (catalog.indexOf("e0d08b13c3330100c8b837659bba8fb4") > -1) {
            data.showWidget = true;
        } else {
            data.showWidget = false;
        }
    } else {
        data.showWidget = false;
    }