cancel
Showing results for 
Search instead for 
Did you mean: 

Transform Copy and new versions.

invantix
Champ in-the-making
Champ in-the-making
I have a transform/copy rule on my "Approved" space. I add a file "myFile.doc"  The file is transformed and copied to my "Published" directory …Great!

Now when I put a new version of "myFile.doc" into the approvedRaw space I get an error and a .tmp file shows up in the published directory that tells me there is no content for the node.

It would be nice if the rule to forced overwriting the transformed file in the published directory (with verioning on it should create a new version).
7 REPLIES 7

invantix
Champ in-the-making
Champ in-the-making
No replies  Smiley Sad   and I still can't figure this one out.  It came up again today.  The approval rule fails if an older version of the file with the same name is there.  The error message is:  Failed to approve the document due to system error: Duplicate child name not allowed: QCF 069.doc

A simple workflow that looks great in the demo but is not so simple in practice.  Am I doung something strange?

jbonjean
Champ in-the-making
Champ in-the-making
Hi,
I have exactly the same problem, did you find any workaround ?
Thanks,

Julien Bonjean

jbonjean
Champ in-the-making
Champ in-the-making
Ok, I found a workaround. The simple workflow moves approved document to a temporary folder in which I made an Inbound rule that executes a little javascript script.
This script check destination folder :
    If document already exists, content is overwritten by new content and version number is incremented (using Alfresco versioning system);
    If not, document is simply moved in destination directory.
If somebody is interrested by this script, please let me know and I will post it.
Regards,

Julien Bonjean

opoplawski
Champ in-the-making
Champ in-the-making
I would be interested in a copy

jbonjean
Champ in-the-making
Champ in-the-making
Ok, it is a really small script. As it's the first time I make a script for Alfresco, it may be weird. Any suggestion is welcome.
The "temporary folder" must be a subfolder of destination space (to prevent space name hardcoding).


//////////////////////////////////////////////////////
// File Name: move_version.js
//
// Purpose : Move a file from a folder to a target
// folder (which must be actually parent folder). If file
// already exists in target folder it uses versioning to
// replace file and increase version number.
//
// Author: Julien Bonjean (julien@bonjean.info)
//
// Creation Date: 2009-02-10
// Last Modified: 2009-02-10 16:26:10 -0500
//////////////////////////////////////////////////////

var sourceFile = document;
var sourceFolder = document.parent;
var targetFolder = space.parent;
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();
}

Hope it can help.
Regards,

Julien

opoplawski
Champ in-the-making
Champ in-the-making
Thanks, that does help a bit.

boucher64
Champ in-the-making
Champ in-the-making
I've use the script and ended up with a problem when the file already exist in the destination folder: the content of the file get broken when the file is a PDF.

To reproduce: Use the file http://tinyurl.com/ann-es-pdf

What happen is when the destination file do exist, the jscript do :targetFileWorkingCopy.content = sourceFile.content;
I suspect that because sourceFile.content is in utf-8, there is a decoding/coding charset problem.
Alfresco exemple in the wiki does not help much as all they do is : targetFileWorkingCopy.content = "here is some content";

I'll try to find a solution next week and post it but if you are more jscript/Alfresco fluent than me and find a solution, please let know.