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

Chaitanya ILCR
Kilo Patron

HI @sunil maddheshi ,

 

check these and see if those will be of any use to you

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783021

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0999197

 

 

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

Regards,
Chaitanya

 

 

@Chaitanya ILCR 

I can not see anything related to access under this property

Ankur Bawiskar
Tera Patron
Tera Patron

@sunil maddheshi 

check this KB

User Criteria not working on the Standard Change Templates 

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 

I can not see anything related to user access under this property
Annotation 2025-05-13 110042.pngAnnotation 2025-05-13 110129.png