- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2022 03:53 AM
Hi,
in a catalog item i have in not available for a user criteria
if( new uc().haveBtw() && new uc().havelaptop() )
answer = true;
else
answer = false;
in the script include i have
haveBtw: function() {
gr.addEncodedQuery("principal=yes^model_category=27fab026dba43200cd8d7b9dae961948^ORmodel_category=affab026dba43200cd8d7b9dae961947^tagSTARTSWITHBTW^assigned_to=" + session.getClientData('requestor'));
gr.query();
while (gr.next()) return true;
return false;
},
havelaptop: function() {
var portable = "affab026dba43200cd8d7b9dae961947";
var gr = new GlideRecord('hardware');
gr.addQuery('model_category', portable);
gr.addQuery('assigned_to', session.getClientData('requestor'));
gr.query();
while (gr.next()) return true;
return false;
},
when i check the hardware table user have all the condition true principal=yes , category = portable tagSTARTSWITHBTW , the user must not see the item because all the condition are true but i don't know wwhy yser cav view the item and even in user criteria diagnostic i get user can view the item
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2022 05:17 AM
Please check user roles, user criteria always allow admin users to access records.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2022 04:19 AM
Hi,
Can you please update this part?
haveBtw: function() {
var gr= new GlideRecord('table_name'); // missing this line
gr.addEncodedQuery("principal=yes^model_category=27fab026dba43200cd8d7b9dae961948^ORmodel_category=affab026dba43200cd8d7b9dae961947^tagSTARTSWITHBTW^assigned_to=" + session.getClientData('requestor'));
gr.query();
while (gr.next()) return true;
return false;
},
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2022 04:23 AM
And you can improve the script like below:
haveBtw: function() {
var gr = new GlideRecord('tableName'); gr.addEncodedQuery("principal=yes^model_category=27fab026dba43200cd8d7b9dae961948^ORmodel_category=affab026dba43200cd8d7b9dae961947^tagSTARTSWITHBTW^assigned_to=" + session.getClientData('requestor'));
gr.query();
if (gr.hasNext())
return true;
return false;
},
havelaptop: function() {
var portable = "affab026dba43200cd8d7b9dae961947";
var gr = new GlideRecord('hardware');
gr.addQuery('model_category', portable);
gr.addQuery('assigned_to', session.getClientData('requestor'));
gr.query();
if (gr.hasNext())
return true;
return false;
},
No need to use While and you can check presence by using hasNext().
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2022 05:12 AM
hi
Thank you for you reply, I found this problem just with one user I tested with another user when I checked I found the conditions of user criteria true and this second user don't see the item I do not know why the first user can see the item even they have the same conditions principal=yes , category = portable tagSTARTSWITHBTW

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-12-2022 05:17 AM
Please check user roles, user criteria always allow admin users to access records.
Thanks
Anil Lande