- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 03:58 AM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2025 03:54 AM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 06:02 AM
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'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2025 03:54 AM
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;
}