- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 08:11 AM
Has anybody been able to figure out how to leverage User Criteria on service catalog variables? I've searched and I've seen people ask the same thing several times but no answer has been satisfactory. As an example, being able to have a laptop with an i7 and 32 GB RAM as an option for members of the engineering department would be nice.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 12:44 PM
I expanded the search to the web and was able to find this on stack overflow: permissions - How to check if a user belongs to some user criteria at server side? - Stack Overflow and this lead me to: Match some user against some user criteria record (server side)
Knowing what to look for I was able to get to this thread which simple code examples for what I want: Match some user against some user criteria record (server side)
Not keen on using undocumented features but sometimes you do what you gotta do...
For the lazy people who don't want to click links:
You can return a list of user criteria records the the logged in user matches server side using:
SNC.UserCriteriaLoader.getAllUserCriteria()
So you can create a script include to return the sys_id of a user criteria record to do the test:
getUserCritera_name("name_of_user_criteria_record")
And then use it as a condition:
SNC.UserCriteriaLoader.getAllUserCriteria().indexOf(getUserCritera_name("Users at Corporate Locations")) > -1

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 08:19 AM
User criteria are used for complete catalog items and not service catalog variables. You can build custom logic so that only engineering dept users are able to see i7 and 32 GB ram while ordering a laptop or else create a separate catalog item which is only accessible to engineering department.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 12:44 PM
I expanded the search to the web and was able to find this on stack overflow: permissions - How to check if a user belongs to some user criteria at server side? - Stack Overflow and this lead me to: Match some user against some user criteria record (server side)
Knowing what to look for I was able to get to this thread which simple code examples for what I want: Match some user against some user criteria record (server side)
Not keen on using undocumented features but sometimes you do what you gotta do...
For the lazy people who don't want to click links:
You can return a list of user criteria records the the logged in user matches server side using:
SNC.UserCriteriaLoader.getAllUserCriteria()
So you can create a script include to return the sys_id of a user criteria record to do the test:
getUserCritera_name("name_of_user_criteria_record")
And then use it as a condition:
SNC.UserCriteriaLoader.getAllUserCriteria().indexOf(getUserCritera_name("Users at Corporate Locations")) > -1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2020 07:53 AM
I just want to point out to anyone trying to use this that there does appear to be a typo (which I've highlighted) BUT you have to use it as posted.
SNC.UserCriteriaLoader.getAllUserCriteria().indexOf(getUserCritera_name("Users at Corporate Locations")) > -1
Edit: It also seems to cause Warnings in the Log, even though it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 12:54 AM
Please refrain from using getAllUserCriteria() api. It has an ability to bring down the entire node.
Please refer to the deep dive blog on user criteria.