The CreatorCon Call for Content is officially open! Get started here.

ACL script problem - help needed

hhakkanen
Kilo Explorer

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:  

1 ACCEPTED SOLUTION

Also replace this



while(otherUsers.next())


  {


    users.push(otherUsers.getValue('sys_id'));


    }



with



while(otherUsers.next())


  {


    users.push(otherUsers.getValue('user_name'));


    }


View solution in original post

7 REPLIES 7

Replace



var qc = current.addQuery("sys_created_by", "IN", "filter");




With




var qc = current.addQuery("sys_created_by", "IN", filter);


Also replace this



while(otherUsers.next())


  {


    users.push(otherUsers.getValue('sys_id'));


    }



with



while(otherUsers.next())


  {


    users.push(otherUsers.getValue('user_name'));


    }


Thanks, it worked!