cancel
Showing results for 
Search instead for 
Did you mean: 

move function doesn't trigger update rule

savoirfaire
Champ in-the-making
Champ in-the-making
Hello,

In our workflow, we use the following structure :

Approved
\_ tmp

and the following script :

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();
   var content = sourceFile.properties['content'];
   targetFileWorkingCopy.properties['content'].write(content);
        targetFileWorkingCopy.checkin("",false);
        sourceFile.remove();
}

to either move or add a new version to a file in the 'Approved' directory. This script is triggered when a file entered the 'tmp' directory.

In the 'Approved' directory, we have 2 rules :
  • For all items not matching '*.pdf' in the file name, convert to pdf in 'Approved', on Update.

  • For all items matching '*.pdf' in the file name, send email to a group of users, on Update.
When the file 'toto.odt' is approved and doesn't exist in 'Approved', my first rule is not triggered.

If I use the 'Add content' link to add the same file in 'Approved', my first rule is triggered and triggers the second one.

I am using Alfresco Version :Labs - v3.0.0 (e dev @build-number@)

Thank you for your help.

Maxime
1 REPLY 1

savoirfaire
Champ in-the-making
Champ in-the-making
Wanted behaviour obtained by using this script :


var sourceFile = document;
var sourceFolder = document.parent;
var targetFolder = space.parent;
var targetFile = targetFolder.childByNamePath(document.name);

if(targetFile == null)
{
        sourceFile.copy(targetFolder);
        sourceFile.remove();
}
else
{
        var targetFileWorkingCopy = targetFile.checkout();
        var content = sourceFile.properties['content'];
        targetFileWorkingCopy.properties['content'].write(content);
        targetFileWorkingCopy.checkin("",false);
        sourceFile.remove();
}

and having those rules in 'Approved' :
  • For any items not matching *.pdf, convert to pdf on Update

  • For any items not matching *.pdf, convert to pdf on Inbound

  • For any items matching *.pdf, send email to users on Update
I received an email the first time a document is approved and also when a new revision of the same document has been approved.