- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 09:52 AM
Hello Community!
I am working on migrating from Service Portal to Employee Center, and I have a question regarding the migration of our User Criteria.
It seems that User Criteria we have applied directly to a catalog item works just fine. If a criteria is added to the 'Available For' related list on a catalog item, we are able to control access to that item on Employee Center.
The issue I am running into is that most of our User Criteria is set at the 'Category' level instead of the 'Catalog Item' level (e.g. we make an entire category of catalog items 'Available For' a certain set of users). It seems that the criteria we have applied at the category-level is not working on Employee Center like it did on Service Portal.
Is there an easy way to make 'Category' level User Criteria apply on the Employee Center portal? If not, is there an easy way to cascade our 'Category' level criteria to the corresponding catalog items?
Thanks a ton!
Rob
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 10:49 AM - edited 07-04-2023 10:51 AM
Ahhh - OK...I don't believe the "Add content from a category" feature looks to User Criteria for validation like the Service Catalog does. You would have to also add the User Criteria to the actual catalog items which are in the categories...right now, they are not restricted, just "access to them" is. Which, essentially prevents the ability to use them, unless you bypass that -- which is what you're experiencing, you're bypassing the actual catalog and adding direct links to the items in the category.
Think of it like this...the User Criteria you have on the catalog for the categories puts a locked door at the "hallway" for each category of request item (think of the request item as a "room" in the hallway)...
...no one can get into the room because they need access to the hallway, which is locked by a door at the front (via user criteria on catalog categories). So essentially, you have restricted access to each room...but technically you haven't. Those doors have no locks on them, currently.
However, you're now building a new hallway (via "Add content from a catalog category") and the platform isn't putting the same locked door at the front of the hall, and I assume that's because they figured you'd have locks on the doors, if needed.
...so you can "add locks on those doors" via User Criteria on each item in the category in question...or you can modify the hallway that you created...but I think the former is easier (and better practice), as the "hallway creation" was an OOB feature that may be hard to modify and may have unintended outcomes (it doesn't use "user criteria" itself, you'll be building that into the feature that you're using)...
...it might be worth it to raise this as a feature request with ServiceNow via the Ideation features in Now Support, you may find that someone else has even asked for this and you only need to "upvote" the idea.
In my opinion, this is just an oversight with the oob features that ServiceNow build into Employee Centre and likely that feature will be added...so in the mean-time, adding specific user criteria to the individual items would be "best", as it would be easily reversible once this feature is in place and does not modify any oob behaviour.
--
Another option would be to add the items to Employee Centre in a different way (don't use the "Add via category" feature) - instead build a page with a catalog widget right on it (a specific catalog page in employee centre). This feature (the catalog widget or directly linking the catalog, not the category, in Employee Centre) would be subject to the User Criteria that you already have set up on categories of the catalog.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 11:44 AM
hey Rob, were you able to script the criteria migration to the item level from the category level? if so, mind sharing any scripting tips? thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 06:05 AM
I was able to script this!
Here is the code I used:
//find all category user criteria
var gr = new GlideRecord('sc_category_user_criteria_mtom')
gr.query();
while(gr.next())
{
//grab the category the criteria is applied to and find all corresponding catalog items
var category = gr.sc_category+'';
var itemGlide = new GlideRecord('sc_cat_item');
itemGlide.addQuery('category', category+'');
itemGlide.query();
while(itemGlide.next())
{
lookUpUserCriteria(itemGlide);
}
}
//function takes in a catalog item and determines if there is an item-level user criteria applied.
function lookUpUserCriteria(item)
{
var itemID = item.sys_id+'';
var itemCriteria = new GlideAggregate('sc_cat_item_user_criteria_mtom');
itemCriteria.addAggregate("COUNT");
itemCriteria.addQuery('sc_cat_item', itemID+'');
itemCriteria.query();
itemCriteria.next();
var count = itemCriteria.getAggregate("COUNT");
//if there is no user criteria for this item, copy the parent category user criteria to the item
if(count < 1)
{
copyCategoryCriteria(itemID);
}
}
//function takes in a catalog item and copies the user critera from the category-level to the item-level
function copyCategoryCriteria(itemID)
{
var item = new GlideRecord('sc_cat_item');
item.get(itemID+'');
var categoryID = item.category+'';
var categoryCriteria = new GlideRecord("sc_category_user_criteria_mtom");
categoryCriteria.addQuery('sc_category', categoryID+'');
categoryCriteria.query();
//take all criteria in the corresponding category and add it to the item.
while(categoryCriteria.next())
{
var criteriaGroup = categoryCriteria.user_criteria+'';
var newCriteria = new GlideRecord('sc_cat_item_user_criteria_mtom');
newCriteria.initalize();
newCriteria.sc_cat_item = itemID+'';
newCriteria.user_criteria = criteriaGroup+'';
newCriteria.insert();
}
}
This code looks up all of the user criteria applied to a specific category and then looks up each catalog item in that category. The code then checks each catalog item to see if there is an item-level user criteria applied. If no item-level criteria is applied, the script will copy all of the category-level criteria to the item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 04:49 PM
that looks awesome! thank you so much for sharing. have a great weekend 😊