Alfresco Javascript Uses

Alfresco java script is a very powerful tool available for Alfresco customization to developers. Since the inception of Alfresco share, it is very much essential for developer to know Alfresco javascript and should be able to do customizations based on that. Alfresco script is also a very powerful tool for creating patches for production instances. For instance, if you want to apply any extra property all of the documents reside in Alfresco without taking down the Alfresco instance.

Create alfresco script for that upload that script in alfresco repository under following location.

var props = new Array(1);

props["custom:newprop"] = “testproperty”;

document.addAspect("cusom:customaspect", props);

Data Dictionary>Scripts

Now that script will be available for all the actions and rules so you can create new rules which will execute script on documents.

Once rule is created reapply that rule to existing contents and you are done. For more details on applying rule you can refer this article.

The only thing you need to keep in mind is that rule has to be created on uppermost folder of repository then enable option which allow rule to be apply on subfolders.

There are many more such cases where we require this kind of patches. Alfresco share is created on top of rhino script which support all javascript features and along with that there are other root objects and services readily available within alfresco context which can be used to manipulate repository.

One more example for javascript usage is to count total number of documents under particular space.

Var count=0;

for each (n in space.children){



}else if(n.isDocument){




function iteratenode(node){

var str=’\r\n’;

for each (n in node.children)




}else if(n.isDocument){




return count;


If you are a alfresco developer it would be really helpful if you explore alfresco javascript features you will be amazed how powerful it is. Weather it is applying property to all existing users of modifying some property value throughout repository alfresco share always comes handy. So, I hope this will give you very good starting point to gets familiar with it.

Further Reading:

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight


I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *