cancel
Showing results for 
Search instead for 
Did you mean: 

Move a document to an historical space

brainscan
Champ in-the-making
Champ in-the-making
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.
2 REPLIES 2

norgan
Champ in-the-making
Champ in-the-making
Hi,
you might think about using an advanced workflow for this kind of work. Or - use the simple workflow, makeing the "effectivity" update via a business rule as well. You might need an "interims" space for aditional rulebased processing, though

best solution, however - download the Record Management AMP and look at the code there, Alfresco does implement such a "date dependency" there already.

Norgan

brainscan
Champ in-the-making
Champ in-the-making
Thank you for your answer Norgan.

Unfortunately, I've seen that Records Management AMP isn't currently supported in Alfresco… until a new version in September… which seems that still is under development.

For the moment, fixing my Javascript would be enough.

Any help will be apreciated 🙂