User Criteria not working

ewilks
Giga Expert

I set up a User Criteria that includes users of a particular role.  

Then I went into a catalog item and in the Available For I added the User Criteria that I created above.   Now, everyone can see it.   ServiceNow, for the love of all that is holy, what is the point of doing nonsense this when it doesn't work?

So now I'm left with adding a Not Available For where I will make it unavailable for:

1. Users with ITIL roles (easy to set up)

2. Users without roles - I create a new user criteria and check advanced.   In the code box, I've tried number of different versions of this, but I get this error ("JavaScript parse error at line (2) column (6) problem = invalid return"), so can I get some help?

if(!gs.getUser().hasRoles()){

return true;

} else{

return false;

}

Please, ServiceNow, in the name of all that is holy, explain to me why you would bother replacing something that did work with something that doesn't.   How does that serve anyone, especially ServiceNow?

When I envision the developers at ServiceNow, I see a bunch of people wearing only black, studded leather carrying whips.   It must be the dress code there, correct?

1 ACCEPTED SOLUTION

ewilks
Giga Expert

Created a new user criteria called, "User with no roles"


checked advanced


added the following to the script:


if(!user.HasRoles()) {


condition =false;


}



Added that user criteria to the catalog item's not available for:



Long story short, indicating which user criteria to use to share a catalog item with isn't enough.


View solution in original post

13 REPLIES 13

srinivasthelu
Tera Guru

Available For is working fine in my instance(fuji)



Which version you are running on? .



Can you provide us the screenshots if possible?


Fuji


Hi Eric,


Did you try impersonating with different user accounts?


I remember the same situation was faced by me 2 months ago or so and the same reaction was on my face. But that stood out to be the problem on Admin privileges where user criteria does not get applied I guess which was pointed out by my colleague Shashank Joshi



Your available for criterion should be sufficient enough to restrict the access for other and grant the access to desired ones.


Yes. Thanks Deepak. That was an early lesson, realizing that the admin has all roles.


I've tried impersonating ITIL users, and those without any roles. Everyone can see the Catalog item I'm wishing to share with only one user criteria.



This user criteria seems to work like this example.  


Only give candy to those users wearing Princess Costumes (which has been set up as a user criteria).


ServiceNow system behavior:


Give's candy to everyone.