AnsweredAssumed Answered

Script to copy documents to a relevant folder

Question asked by anuradha@1994 on Mar 12, 2018
Latest reply on Mar 19, 2018 by anuradha@1994

Hi, I am using Alfresco Community 5.2 and i need to create a script to copy document to a relevant folder. 

 

copy-to-rel-folder.js
 

var createdDate = document.properties["cm:created"];

var dd = createdDate.getDate();
var mm = createdDate.getMonth()+1; //January is 0!

var yyyy = createdDate.getFullYear();
if(dd<10){
dd='0'+dd;
}
if(mm<10){
mm='0'+mm;
}
var today = dd + "-" + mm + "-" + yyyy;

var objDestFolder = companyhome.childByNamePath("Shared/SECRETARY/COMMISSION_MEETINGS/" + today);
document.copy(objDestFolder);

 

Ex: today = 20-03-2018 but I am having folders named 10-03-2018 ,18-04-2018 , 09-03-2017. I need to copy the document into 10-03-2018 folder. I need to select the folder using LIKE mm + "-" + "-" + "yyyy" (not considering the date).

Please help me.

 

Thank you.

Outcomes