Catalog Item Visibility

Prajwal G Vaish
Giga Guru

Hello Team,
I am currently trying to hide a catalog item based on the title of the logged in user and have added Not Available for User criteria and below it the script.
But it seems to be not working

(function() {
    var rec = new GlideRecord("sys_user");
    rec.addEncodedQuery("sys_idSTARTSWITH"+user_id+"^titleLIKEContractor");
    rec.query();
    if(rec.next()){
        return false;
    }else{
        return true;
    }
 
})();


please can anyone let me know how can we achieve this
Thank you very much in advance

Thank you 
Prajwal

1 ACCEPTED SOLUTION

@Prajwal G Vaish Check if the query returns correct response by using gs.info logs. If it returns the correct result and still the catalog item is visible then use cache.do to clear the cache.

 

Here is a support article on the caching of user criteria https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0790108.

 

Hope this helps.

View solution in original post

9 REPLIES 9

@Prajwal G Vaish Check if the query returns correct response by using gs.info logs. If it returns the correct result and still the catalog item is visible then use cache.do to clear the cache.

 

Here is a support article on the caching of user criteria https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0790108.

 

Hope this helps.

Hi @Sandeep Rajput 
Still its not working, Is there any other way we can achieve this?


Thank you

@Prajwal G Vaish Try using the User Criteria Diagnostic https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/product/service-catalog-man... to debug this User Criteria. It may shed some light on why it is not working for specific user.

Hi @Sandeep Rajput ,
Thank you very much for you response, It is working fine.

while testing we need to clear cache and test it then it is working

Thank you🙂

@Prajwal G Vaish Great news, now please mark my responses as accepted solution.