Alfresco

Create Folders and Sub-folders on Uploading a CSV File in Alfresco

A typical Document Management System use case in Alfresco would require creating multiple folders while implementing for the first time or any time in future as well. Those folders can be for each employee, branch or project in the organization. Creating them manually is a mundane, time-consuming and prone-to-error task. How if you can create these folders with a mere upload of a CSV file? Sounds interesting?


In this blog, we have provided you a code using which Alfresco developers would be able to set a mechanism for the users who would get the following functionality.


We need to have two folders, one in which we would upload the CSV and the other where the folders will be residing after auto-generation, let’s name it as target folder. We have considered that the auto-generated folder will be renamed as columnAvalue_comunBvalue (by using values in the adjoining columns in the same row of CSV). So, the CSV we upload in this case should have one row for each folder with two columns to be placed as folder names. The sub-folders will be fixed for any auto-generated folder (In this case we have named them child1…child6). You may amend the code as per the business requirements of your client.

Alfresco development related blog: Alfresco QCAD Integration for CAD Files Preview
 

Here are the steps to follow:


Step 1: For creating folders and sub-folders we need to write the script.

So first we create "csvUploadFolderCreation.js" file and put it in "Data Dictionary/Scripts"
 var siteName = document.getSiteShortName();

var path = companyhome.childByNamePath("Sites/"+siteName+"/documentLibrary/Target");

var subFolders = ["child1","child2","child3","child4","child5","child6"];

var col1=null,col2=null;

if(!document.isContainer){

var fileContent = document.getContent();

var csvline = fileContent.split("\n");

var csvLineLength = csvline.length;

for (var i=1 ; i
Step 2: Create a folder (Csv Upload) in your site and go to the action "Manage Rules".

Now create a new rule. Add other info wise requirment and goto to "Perform Action", select execute script and select our custom script.
 

Step 3: Create folder "Target" Which Contains all the folders which are created from csv.
 

Step 4: Now upload the csv file in "CSV Upload" folder.

Sub-folder will be created in Target folder as per the csv data.
 

If you find any challenge in implementing the same, feel free to contact us.
A Preparation Guide for Alfresco Certified Engineer Test

Alfresco

A Preparation Guide for Alfresco Certified Engineer Test

This blog serves as a comprehensive preparation guide for individuals planning to take the Alfresco Certified Engineer test, offering valuable insights, resources, and tips to help them succeed in the certification exam.

Alfresco

Running Alfresco AngularJS Application (0.5.1) without Activiti Explorer

This blog may explain how to run an Alfresco AngularJS application version 0.5.1 independently without the need for Activiti Explorer, offering insights for developers on deploying and utilizing the application in a standalone fashion.

Transform Your Business With Digital Enterprise Solutions

Contact us

Our Offices

country-flag
AHMEDABAD, INDIA

401, One World West, Nr. Ambli T-Junction 200, S P Ring Road, Bopal, Ahmedabad, Gujarat 380058

country-flag
UK

Kemp House 160 City Road, London, United Kingdom EC1V 2NX

country-flag
GERMANY

Nürnberger Str. 46 90579 Langenzenn Deutschland

country-flag
AUSTRALIA

Level 36 Riparian Plaza, 71 Eagle Street, Brisbane, QLD 4000

country-flag
USA

4411 Suwanee Dam road, Bld. 300 Ste. 350 Suwanee GA, 30024

country-flag
SOUTH AFRICA

Cube Work Space, 24 Hans Strijdom Avenue, Cape Town

country-flag
DUBAI, UAE

101-Yes Business Tower, AI Barsha 1 - Dubai United Arab Emirates