Advanced user criteria
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 03:45 AM
I need to define advanced user criteria in ServiceNow that will be used to define 'available for' criteria for catalog item. It has to be an advanced script that will make catalog item visible to users, who belongs to a company (customer_account table) that meets specific criteria. The specific criteria for the customer account is the following:
It has a custom field created - u_technology. It is a string field, and value must be 'GCP'. Dictionary into for this field is: customer_account.u_technology
Others users that belongs to companies that does not meet this criteria, should not see this catalog item and should not be able to access it.
Any ideas if that is possible at all?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2024 06:56 AM
Hi @tomaslevandavic, as per my understanding, you have a reference field called company on user table and this table has a field called 'u_technology'. If the company is 'GCP', you need to allow the catalog item visiblity. If yes, then you can try the below script.
var grUser = new GlideRecord("sys_user");
if (grUser.get(gs.getUserID())) {
var userCompany = grUser.company.u_technology.toString();
if (userCompany == 'GCP') {
answer = true;
}
}
Regards,
Sunil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2025 08:00 AM
"Do not use gs.getUser() or other session APIs since they cause conflict when used in diagnostic tools. Use the pre-defined user_id variable available in the script to get the user id of the user being used to evaluate the script."

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2024 01:58 AM
Hi @tomaslevandavic
I am not so sure on the design you built here. I assume a company eventually will use more than one technology?
In that case, you need to model this either as GlideList (so that the field contains more than 1 entry) or as a m2m table so that a company can be linked to more than one technology.
Just my 2 cents.
If this post was helpful, I would appreciate if you marked it as such - thanks!
Best
Daniel