- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 08:27 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 08:46 AM
@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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 08:46 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 09:02 AM
Hi @Sandeep Rajput
Still its not working, Is there any other way we can achieve this?
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 09:13 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 09:13 AM
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🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2024 09:14 AM
@Prajwal G Vaish Great news, now please mark my responses as accepted solution.