 
					
				
		
09-11-2012 06:06 AM
09-11-2012 07:04 AM
 
					
				
		
09-11-2012 07:30 AM
log4j.logger.org.alfresco.repo.jscript=debug
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug
logger.log("whatever");
var thirdParties = document.properties["sp:thirdParties"];
var location = document.properties["sp:location"];
var responsibleEmp = document.properties["sp:responsibleEmp"];
var contractRef = document.properties["sp:contractRef"];
var effectiveDate = document.properties["sp:effectiveDate"];
var mctype = document.properties["sp:mctype"];
var sourceFile = document;
//var sourceFolder = document.parent;
var targetFolder = "";
var success = true;
//Check to see if values are null
if( thirdParties == null || location == "" || responsibleEmp == null || contractRef == null || effectiveDate == null  || location.toString() != "UK" || mctype == null ){
   success = false;
   
}else{
   var effectiveDate = new Date ( document.properties["sp:effectiveDate"] );
   
   //Check if folder exist
   if(checkFolderExists(location, effectiveDate )){
      targetFolder = space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).childByNamePath("MLA and Supplement");
      
   }else{
      success = false; // do not move doc no folder exists
   }
}
if(success){
   var targetFile = targetFolder.childByNamePath(document.name);
   
   if(targetFile == null){
      sourceFile.move(targetFolder);
   }else{
      var targetFileWorkingCopy = targetFile.checkout();
      targetFileWorkingCopy.content = sourceFile.content;
      targetFileWorkingCopy.checkin("",false);
      sourceFile.remove();
   }
}
/**   Function checks if year folder exists if not then it creeates it
 *   @param String location of created doc
 *   @param Date effectiveDate entered in metadata
 */
function checkFolderExists(location, effectiveDate){
   if( !space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()) ){      
      space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").createFolder( effectiveDate.getFullYear().toString() ); //create year folder
      
      if( !space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).childByNamePath("MLA and Supplement") ){
         space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).createFolder("MLA and Supplement"); // create supllement mla folde rin year folder      
      }
      
      return true;
      
   }else if( !space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).childByNamePath("MLA and Supplement") ) {
   
      space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).createFolder("MLA and Supplement"); // create supllement mla folde rin year folder      
   
   }else if ( space.parent.childByNamePath(location.toString()).childByNamePath("Contracts").childByNamePath(effectiveDate.getFullYear().toString()).childByNamePath("MLA and Supplement") ) {
      return true;
      
   }else{
      return false;
   }
}
tail -f /opt/alfresco-4.0.d/tomcat/logs/catalina.out /opt/alfresco-4.0.d/alfresco.log09-11-2012 08:15 AM
 
					
				
		
09-11-2012 09:34 AM
 
					
				
		
11-17-2015 09:59 AM
 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.