Today I want to talk about one of the most useful tool for Alfresco developers: the Javascript console. This add-on is a Share administration console component to execute custom Javascript code against the Alfresco repository. You can download it here.

 

Some features:

  • Run scripts with different users 
  • Integrate custom JavaScript functions
  • Code completion via CTRL + SPACE
  • Save & load scripts from Data Dictionary

Here are some useful script examples that could be necessary in some projects:

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);
}
}
});

 

 

Read Next

How to Use Drupal REST Services with AngularJs

07 November, 2014|3 min