AnsweredAssumed Answered

Move a document to an historical space

Question asked by brainscan on Sep 10, 2009
Latest reply on Sep 10, 2009 by brainscan
Hello.

I have the following structure in my home space:

Documents
  1 - Draft
  2 - Pending
  3 - Approved
  4 - History

Currently I've created a rule in "1 - Draft" which adds the "Effectivity" value to new documents. When the document is approved (passing from "2 - Pending" to "3 - Approved"), I have created a JavaScript which updates the "Effective from" and "Effective to" of the document, putting in both the current date.

In the "3 - Approved" directory I only want to exist 1 document. If someone approves a new version of the document, then the one which was inside "3 - Approved" must be automatically moved into "4 - History".

I can check which document is old by it's Effectivity.

The problem is that my JavaScript, which should move old documents, doesn't work. Can you look at it?


var activeFolder = space;
var archivedFolder = space.parent.childByNamePath("4 - History");
var i=0;
var today = new Date();

if(activeFolder != null) {
    activeChildren = activeFolder.children;
    activeTotal = activeChildren.length;

    for(i=0; i<activeTotal; i++) {
        child = activeChildren[i];
        if(child.properties["cm:to"] <= today) {
            child.move(archivedFolder);
        }
    }
}

When I try to approve a document, I receive the following error:
No se ha podido aprobar el documento debido a un error del sistema: Unknown Exception in Transaction.

Thanks.

Outcomes