- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2015 05:55 AM
I am writing an ACL script to prevent users from other locations to see records.
For example, European users cannot view records created by a user in APAC.
However, I keep running into a weird warning in the system log and the ACL script is not working.
Here is my script:
answer = validateRegion();
function validateRegion()
{
var currentLocation = gs.getUser().getLocation();
var loc = new GlideRecord('cmn_location');
loc.get(currentLocation);
var currentRegion = loc.parent.parent;
var users = [];
var otherUsers = new GlideRecord('sys_user');
otherUsers.addQuery('location.parent.parent',currentRegion);
otherUsers.addQuery('roles', "x_nyrs2_xtra_tasks.user");
otherUsers.addActiveQuery();
otherUsers.query();
while(otherUsers.next())
{
users.push(otherUsers.getValue('sys_id'));
}
if(users.toString().indexOf(gs.getUserID()) > -1)
{
return true;
}
else
{
return false;
}
}
This is in the system log as a warning:
org.mozilla.javascript.EcmaError: undefined is not a function.
Caused by error in <refname> at line 5
2:
3: function validateRegion()
4: {
==> 5: var currentLocation = gs.getUser().getLocation();
6: var loc = new GlideRecord('cmn_location');
7: loc.get(currentLocation);
Can someone point me to the right direction?
Best,
Hena
8:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2015 02:48 AM
Also replace this
while(otherUsers.next())
{
users.push(otherUsers.getValue('sys_id'));
}
with
while(otherUsers.next())
{
users.push(otherUsers.getValue('user_name'));
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2015 02:46 AM
Replace
var qc = current.addQuery("sys_created_by", "IN", "filter");
With
var qc = current.addQuery("sys_created_by", "IN", filter);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2015 02:48 AM
Also replace this
while(otherUsers.next())
{
users.push(otherUsers.getValue('sys_id'));
}
with
while(otherUsers.next())
{
users.push(otherUsers.getValue('user_name'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2015 05:30 AM
Thanks, it worked!