Article

Alfresco JavaScript Console

Alfresco JavaScript Console

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 (opens in new window).

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

Get the thinking,
before everyone else.

One considered email a month. New essays, field notes from live engagements, and the occasional strong opinion. No noise.