User Criteria: Can you reference the record the user criteria is being run against?

Craig Granier
Kilo Expert

I have a requirement to show/hide a catalog item based on a custom field in the catalog item definition.   Is something like $current available to be used in user criteria scripts?  Seems the whole user criteria system is designed to go look elsewhere (like the user record) and return a true/false w/o regard for where the user criteria is being applied to.

1 ACCEPTED SOLUTION

Craig Granier
Kilo Expert

UPDATE:   My findings after a few days of research.

1.  Using user criteria, there is no way to pass a dynamic variable/object like $current.   As a workaround you will have to create user criteria specific to the file it is associated with (a catalog item in this case) and hardcode a sys_id of the record you need info from in order for your script/script include to do a lookup on.

2.  It appears you can pass pass a $current object to the older entitlement scripts HOWEVER entitlement scripts do not run IF you have user criteria turned on in the Service Catalog properties.  

I didn't want to take away the ability to use user criteria for my entire service catalog(s) so I opted for option #1...which means lots of user criteria.  I'm using a script include to do most of the logic as to reuse as much code as possible. 

 

View solution in original post

9 REPLIES 9

Ahmmed Ali
Mega Sage

Hello,

 

You can use entitlement script in catalog item definition to control the form accessibility.

 

https://community.servicenow.com/community?id=community_question&sys_id=c3186b85db231f042be0a851ca9619f6

 

Hope this helps.

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Craig Granier
Kilo Expert

You sure?  I see no way to reference the calling catalog item definition in the script in any of the samples on the wiki.   

Hello,

 

Hope this thread helps.

https://community.servicenow.com/community?id=community_question&sys_id=82ba8f2ddb5cdbc01dcaf3231f9619d6

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Thanks!  That looks like it would work for me.  

I tried a few tests but the Entitlement Scripts don't seem to run.  It's in the doc that they should.  There are even system properties on the System Properties page to override them for certain roles.

All my test w/ an itil user and using SN own sample script fail.

Based on the doc, this simple script should work

answer = false;
answer;

 

Any chance you've used these since the introduction of User Criteria?