File as Record script

cancel
Showing results for 
Search instead for 
Did you mean: 
KT
Partner

File as Record script

Hi 

I have written the following code to file a document as a record after a certain amount of time.It does not work, Can I ask how do I write code to file a document as a record.

here is the code:

var rootFolder = companyhome.childByNamePath("Sites/client-site/documentLibrary/Clients"); // Specify the path to the root folder.
var rmSite = siteService.getSite("rm");
//var recordFolder = rmSite.getContainer("Unfiled Records");
var logfile = companyhome.childByNamePath("Sites/client-site/documentLibrary/logfil.txt");


function declareAsRecord(node) {
  var timeElapsed = (new Date().getTime() - node.properties["cm:created"].getTime()) / (1000 * 60);

  if (node.isDocument && !node.hasAspect("rma:record") && timeElapsed >= 10) {

    var recordNode = rmSite.actionService.declareRecord(node);

  } else if (node.isContainer) {

    var children = node.children;
    for (var i = 0; i < children.length; i++) {
      declareAsRecord(children[i]);

    }
  }
}

declareAsRecord(rootFolder);