Code Snippets

2 Useful Alfresco Javascript Console Examples

 

Here are 2 useful scripts that can be used in the Alfresco Javascript Console. Refer to this blog post for more information.

Users information: retrieves the information of all the users in the repository

var users = people.getPeople(null); 
for each(user in users){ 
     user = search.findNode(user);
     print(user.properties.userName+": " + user.properties.firstName+ " " + user.properties.lastName + "("+user.properties.email+")");
} 

Permissions report: recursive function to get all the permissions for a folder and its children

recurse(companyhome, function(node) {
  for each(permission in node.fullPermissions) {
    if (/;DIRECT$/.test(permission)) {
      logger.log(node.displayPath + "/"+ node.name + ";" + permission);
    }
  }
});

 

 

Resource Tags: