How to check value of a catalog variable in user criteria
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2020 04:27 AM
Hi,
I have a variable "is_orderguide" in order guide which I am cascading to the include item.I want to check if the included item is created from order guide and give access to everyone having acess to this order guide.
I have created below user criteria and added to the included item but its not working.Can you please help to understand how to check the value of a variable in user criteria
if(is_orderguide==Yes)
{
answer=true;
}
Regards
Priyesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2020 04:38 AM
Hi there,
Never tried with user criteria. Though if you want to access variables, server side, you could with:
current.variables.your_variable_name
So you could try if below works:
if(current.variables.is_orderguide == "Yes")
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2020 04:46 AM
I believe you can not use current object in User Criteria. You can try using Script Include by passing required variables and get required output in true/false

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2020 04:54 AM
User Criteria is more user-centric than individual request centric and is designed to make orderable items either visible, or not, based on a user's roles or groups. The criteria is processed when they load the Catalog item, but not when they load a RITM.
What it sounds like you are trying to accomplish would be more along the lines or either an ACL or Query business rule; the Business Rule would probably be your easiest option.
You would need to write a Query business rule that would first determine if your user matches the user criteria listed in your order guide. If they match, do nothing. If they do not match, then you would want to do something like:
var strQuery = 'variables.aeab89addb32c01011ccd5f0cf96194e!=Yes^ORvariables.48fc7e30dbeb230011ccd5f0cf9619f0!=Yes';
current.addEncodedQuery(strQuery);
You would build your encoded query in the list view, adding Variables, selecting your item(s), selecting your Variable(s) and then your value to get the query of items you don't want a user to see if they don't pass the criteria check and then right-click and copy query.
The one caveat I've seen to this type of solution is, if the order is placed on-behalf of (and opened under) a user who fails the criteria check (opened by someone who passed it to begin with) then workflows may not initiate as this type of rule (either in a BR or an ACL) can interfere with the default BR that starts a workflow on a RITM.
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2020 05:14 AM
try this link: https://community.servicenow.com/community?id=community_question&sys_id=44738b25dbd8dbc01dcaf3231f96...
Regards,
Mandeep