- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2019 11:26 AM
Hello,
Facing a deadline for a go-live and am having issues with the User Criteria for a Service Catalog category.
Basically I just want to show the SC Category to users who have a relationship on their user record to any CI with a name starting in "XYZ". The line of script I currently have to do this is not working (highlighted below). Can anybody help?
------------------------------------------------------------------
answer = checkAccess();
function checkAccess(){
var ci_user = new GlideRecord('sys_user');
ci_user.get(gs.getUserID());
var ci_rel_person = new GlideRecord('cmdb_rel_person');
ci_rel_person.addEncodedQuery(ci.namestartsWithXYZ);
ci_rel_person.addQuery('user', ci_user.sys_id);
ci_rel_person.query();
if (ci_rel_person.next()){
return true;
} else {
return false;
}
return true;
}
------------------------------------------------------------------
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2019 11:36 AM
Here you go.
answer = checkAccess();
function checkAccess(){
var ci_user = new GlideRecord('sys_user');
ci_user.get(gs.getUserID());
var ci_rel_person = new GlideRecord('cmdb_rel_person');
ci_rel_person.addQuery('ci.name', 'STARTSWITH', 'XYZ');
ci_rel_person.addQuery('user', ci_user.sys_id);
ci_rel_person.query();
if (ci_rel_person.next()){
return true;
} else {
return false;
}
}
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2019 12:44 PM
@pradeep sharma or anyone who can help:
I need to make one change to the following addQuery line from the above script so it also includes CI's that start with "ABC".
ci_rel_person.addQuery('ci.name', 'STARTSWITH', 'XYZ');
Could somebody please help me with the script for this change?
Thanks!
Mike

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2019 01:32 PM
Use this row instead.
ci_rel_person.addencodedQuery('ci.nameSTARTSWITHXYZ^ORci.nameSTARTSWITHABC');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2019 01:50 PM
Thank you Stewe!! Works perfectly.