Getting the current Cat Item in a User Criteria Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2017 07:13 AM
Is it possible to pull in the current Catalog Item in the advanced script of a User Criteria? Why do I want to do that? The customer has a requirement to be able to block certain users from certain Catalog Items for a period of time. For example, John Smith is restricted from accessing the New Laptop Request until the end of August. My thought is to create a custom "Request Blocking" table with three fields:
1) User: Reference to sys_user
2) Cat Item: Reference to sc_cat_item
3) Block End Date: Date field
Then create a User Criteria that would be added to all the Cat Items. The Script would need to search the custom table for match on the following:
1) user = Current user
2) cat_item = The Cat Item that the User is trying to access
3) block_end_date > today
If it finds a match, it returns an answer of false, (meaning access denied). Ff no match found, return true.
#1 & 3 are easy, but can't figure out how to pull in the Cat Item for #2, or if this is even possible.
Any thoughts?
Thanks,
.ron

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2017 07:45 AM
Hi Ron,
User criteria script will anyway run for the catalog item which executes the script right, hence you can localize this script to the catalog item which needs restriction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2017 08:29 AM
Hi DJ,
Thanks for your response, but I am not clear on what you are recommending. Can you please clarify? Are you suggesting that I should create a separate User Criteria for each Catalog Item? I did think of that, but would prefer to create one User Criteria that can be used across all Cat Items, if possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2017 10:24 AM
Hi Ron
Any solution for your issue. I too had same issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2017 10:45 AM
I never got a answer to this, so my guess is that it is not possible. But I ended up taking a different approach. If I remember correctly, I created a custom table called Black List. It had a reference field to Catalog Item, another reference field to User, and a blackout end date field. I then created a Catalog Client Script, that whenever the Cat Item was opened, it would make an Ajax Call to a method that queries the black_list table for a match on User and Catalog Item, and the Black Out end date is still in the future. If it found a match, it means the use does not have access to that Cat Item at that time. So the script will display a message and redirect the user to the Service Catalog.