I am thinking to create a rule, possibly a javascript script, which will move documents one folder to another depending on its properties. In the other words, I will always upload documents to folderA
. Alfresco will extract document's property, for example prop1
, and the rule that I define will move this document to folderB
if it has property prop1
, otherwise it will move the document to folderC
. I know how to extract properties but I don't know how to create this rule. I have no idea since I never used javascript. Any help will be appreciated.
Asked
Active
Viewed 2,430 times
1

newzad
- 706
- 1
- 14
- 29
-
Do you want to create rule programmatically? – Naman Apr 30 '15 at 05:23
1 Answers
7
There are some properties which you need to set while credating rule.Explanation of those properties are as below.
1.When the rules will be triggered:
- Items are created or enter this folder
- Items are update
- Items are deleted or leave this folder
2.criteria for the rule to be fired.
3.Define the action you want performed. Here you need to select custom javascript.
When you select this option it will load script from the script folder of Data Dictionary.
In that script you need to write below code.
if(document.properties.prop1=="yourvalues")
{
document.move(folderA);//Where FolderA will be a destination node and not a string
}else{
document.move(folderB);//Where FolderB will be a destination node and not a string
}
object document referes to current object, on which rule is executed.Refer below image.
Below is the script which i have tested and executed.
if(document.properties.title=="demo")
{
document.move(companyHome);
}else{
document.move(userhome);
}

Krutik Jayswal
- 3,165
- 1
- 15
- 38
-
although this answer is really good, there is a more simple version to achieve what you ask. In the criteria you just put a custom property with the value, and use action: Move to.. Basically it's the same thing, for the exception you don't need to create your own script, as Alfresco offers already to move documents with specific property values ootb. – Teqnology Apr 30 '15 at 11:26