Restrict Native view of a Service catalog items that belong to specific "Service Catalogs" &"role"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 06:57 AM
Hello All,
I need help with the following requirement.
Service catalog can be opened with the following URL as well "com.glideapp.servicecatalog_cat_item_view/sys_id" which is the native view of Catalog Item from UI page -"com.glideapp.servicecatalog_cat_item_view"
I need help with below points:
1. This native view should be visible only to specific catalog and to users with "cat_security" role only. Need help to achieve the same
Found the below script on UI page but how to incorporate the changes
var answer = true;
var item = GlideappCatalogItem.get(jelly.sysparm_id);
if (item == null || !item.canViewInDomain())
answer = false;
else {
var preview = jelly.sysparm_preview;
if (preview $[AMP]$[AMP] gs.hasRole('catalog_admin'))
answer = true;
else {
if (!gs.nil(jelly.sysparm_cart_edit)) {
var cartItem = new GlideRecord('sc_cart_item');
cartItem.get(jelly.sysparm_cart_edit);
answer = cartItem.canRead() $[AMP]$[AMP] cartItem.cat_item == jelly.sysparm_id $[AMP]$[AMP] item.canView();
}
else
answer = gs.hasRole('catalog_admin') || item.canView();
}
}
answer;
- 541 Views