user criteria not working for standard change template

sunil maddheshi
Tera Guru

Hey everyone, we have standard change template , where we have restricted access based on available for and non-qualified users are not able to access the template on portal but on Native UI still ITIL users able to access this template and created change request from Native UI. Why user criteria not working on native UI.

Annotation 2025-05-13 093343.png

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @sunil maddheshi ,

I see the issue 

var checkAgainstUC = Class.create();
checkAgainstUC.prototype = {
    initialize: function() {},
	
    checkForCatalogItem: function(catalogID) {
        var userCriteria = [];
        var catm2mgr = new GlideRecord('sc_cat_item_user_criteria_mtom');
        catm2mgr.addEncodedQuery('sc_cat_item=' + catalogID);
        catm2mgr.query();
        while (catm2mgr.next()) {
            userCriteria.push(catm2mgr.getValue('user_criteria'));
        }
        return sn_uc.UserCriteriaLoader.userMatches(gs.getUserID(), userCriteria)

    },
    type: 'checkAgainstUC'
};

since users are opening std_change_record_producer record directly in table they are able to access it 

but the user criteria only evaluates in the catalog view

 

I would say hide create standard change ui action from the related link by creating above script include

and append the condition condition new checkAgainstUC().checkForCatalogItem(current.sys_id)

This will make sure the button is hidden from the end users

ChaitanyaILCR_0-1747117521601.png

 

 

2. you can create a deny unless ACL(I won't recommend this since system has to evaluate every record against the user criteria as the no of records in the table increases you may see performance impact)

create the same script include that I have shared 

and create a Deny unless ACL

 

ChaitanyaILCR_1-1747118048297.pngChaitanyaILCR_2-1747118052977.png

 

 

Better go with the first approach of hiding the UI action

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

13 REPLIES 13

@sunil maddheshi 

so user criteria is working fine in portal but not for native?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar Yes user don't have access for the template on portal but he can see the template on native UI and using the buttons in related links he is creating the change requests.

@sunil maddheshi 

try adding some advanced script in user criteria and see if that log comes from native

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 

Hi Ankur, It is strange, For debugging I added that user in not available in template still he is able to access the std change template on native UI, I checked user role as well, he is ITIL user.

@sunil maddheshi 

it means User Criteria is not getting evaluate in native.

Please raise a case with ServiceNow

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader