Entity view (Content)

Classifying Content in Alfresco

By paladro
May. 26, 2015

This week I want to share with you a very useful tip in Alfresco.

In many projects, Alfresco developers are asked to create a folder structure to keep the archived documents. There is an easy way to do it automatically, we just need to create a rule in the root archive folder and execute this script whenever a document is moved to this folder:


var today = new Date(); 
var year = today.getFullYear();
var month = today.getMonth() +1;
var day = today.getDate();

var yearFolder = space.childByNamePath(year);

if(yearFolder == null || yearFolder == undefined)
yearFolder = space.createFolder(year);
var monthFolder = yearFolder.childByNamePath(month);

if(monthFolder == null || monthFolder == undefined)
monthFolder = yearFolder.createFolder(month);
var dayFolder = monthFolder.childByNamePath(day);
if(dayFolder == null || dayFolder == undefined)
dayFolder = monthFolder.createFolder(day);



So we will have the following folder structure after the rule is executed:

Post Tags: