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
Get in touch and let’s get started.

We are a full service digital consultancy with experience and capacity to meet the needs of even the largest most complex of organizations in the world. Our services portfolio enables us to offer clients the best of experiences when working with our teams so as to make sure we keep the focus on their needs, customers and delivering tangible value to the business. End to end services; endless ideas. 

Three easy ways to get in touch. Complete the form to request a consultation, email us your inquiry, specs and/or RFP to contact@appnovation.com OR call one of our many, global office locations and tell us how we can help.