- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 08:49 AM
Hi all,
I'm trying to restrict the visibility of a catalog item (Available To) to only people that belong to a Cost Center that contains 5471 or 5400. I created a "User Criteria" record tried two ways, (well three if you count me trying to use .name or not using it) and neither seems to work.
NOTE: the field on the user record is cost_center and is a reference to the cmn_cost_center table. Our cost centers look like this: 5471AB, 5471TA, 6520AB, 5400AB, etc..
Tried this
var userCheck = new GlideRecord("sys_user");
userCheck.addQuery("user", gs.getUserID());
userCheck.addQuery("cost_center.name", "CONTAINS" , "5471");
userCheck.addOrCondition("cost_center.name", "CONTAINS", "5400");
userCheck.query();
if (userCheck.hasNext()) {
answer = true;
} else {
answer = false;
}
Doesn't work. Doesn't restrict anyone from seeing it.
and have tried
var userCheck = new GlideRecord("sys_user");
userCheck.addQuery("user", gs.getUserID());
userCheck.addQuery("cost_center", "CONTAINS" , "5471");
userCheck.addOrCondition("cost_center", "CONTAINS", "5400");
userCheck.query();
if (userCheck.hasNext()) {
answer = true;
} else {
answer = false;
}
Doesn't work. NO one can see it (only admins)
and have tried
costCenterVerify();
function costCenterVerify() {
var userCC=gs.getUser().getRecord().getDisplayValue('cost_center');
if (userCC.indexof("5471") > -1 || userCC.indexof("5400") > -1) {
answer = true;
} else {
answer = false;
}
return answer;
}
Doesn't work. NO one can see it (only admins)
Neither working. Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 09:28 AM
I Figured it out...Just needed to keep trying
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.addEncodedQuery('cost_centerLIKE5471^ORcost_centerLIKE5400');
gr.query();
if (gr.hasNext()) {
answer = true;
} else {
answer = false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 09:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 09:28 AM
I Figured it out...Just needed to keep trying
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.addEncodedQuery('cost_centerLIKE5471^ORcost_centerLIKE5400');
gr.query();
if (gr.hasNext()) {
answer = true;
} else {
answer = false;
}