09-28-2012 05:06 AM
09-29-2012 02:20 PM
cm:generalclassifiable=”Approval”;
// some code
// get the first document from the workflow package
var document = bpm_package.childFileFolders(true, false)[0];
var oldCategories = document.properties["cm:categories"];
var categoryToAdd = null;
var categories = classification.getRootCategories("cm:generalclassifiable");
var remainingNames = ["Document Review Status", "Approval"];
while(categoryToAdd == null && categories && remainingNames.length > 0){
var idx = 0, max = categories.length, innerCategories = categories;
// reset categories to prevent further iterations if we don't find a match
categories = null;
for(;idx < max; idx++){
var category = categories[idx];
if(category.name.equals(remainingNames[0])){
if(remainingNames.length == 1){
categoryToAdd = category;
}else{
categories = category.getSubCategories();
remainingNames.shift();
break;
}
}
}
}
if(categoryToAdd != null){
var newCategories = oldCategories != null ? oldCategories : [];
newCategories.push(categoryToAdd);
document.properties["cm:categories"] = newCategories;
document.save();
}
// some more code
09-30-2012 10:14 PM
10-01-2012 04:58 AM
10-01-2012 10:38 PM
Hello,
tags are "enhanced categories", i.e. Alfresco provides special interfaces / methods that simplify dealing with tags. Technically, they are of the same nature.
Rules are only for content changes and don't react to workflow events if those events don't actually change anything (approval state in workflow is managed separately from content). This is why you need a script in your workflow.
Regards
Axel
10-09-2012 12:51 PM
var nodeId = document.id;
var theDocument = search.findNode("workspace://SpacesStore/" + nodeId);
var summary = theDocument.properties["cm:summary"];
theDocument.properties["cm:summary"] = "Approved";
theDocument.save();
Hello,
the following statement in your script does not make any sense to me:cm:generalclassifiable=”Approval”;
If you want to add a tag to a document, you need to obtain the document reference first and then call addTag() to add a single tag. But cm:generalclassifiable is not a tag, just a common category, in which case you would need to update the cm:categories property of the document.
Some sample code (NOT directly applicable to your context, just a demonstration - also NOT tested, writtend ad-hoc):
// some code
// get the first document from the workflow package
var document = bpm_package.childFileFolders(true, false)[0];
var oldCategories = document.properties["cm:categories"];
var categoryToAdd = null;
var categories = classification.getRootCategories("cm:generalclassifiable");
var remainingNames = ["Document Review Status", "Approval"];
while(categoryToAdd == null && categories && remainingNames.length > 0){
var idx = 0, max = categories.length, innerCategories = categories;
// reset categories to prevent further iterations if we don't find a match
categories = null;
for(;idx < max; idx++){
var category = categories[idx];
if(category.name.equals(remainingNames[0])){
if(remainingNames.length == 1){
categoryToAdd = category;
}else{
categories = category.getSubCategories();
remainingNames.shift();
break;
}
}
}
}
if(categoryToAdd != null){
var newCategories = oldCategories != null ? oldCategories : [];
newCategories.push(categoryToAdd);
document.properties["cm:categories"] = newCategories;
document.save();
}
// some more code
Regards
Axel
10-10-2012 06:42 AM
10-11-2012 11:26 PM
Hello,
the code looks alright. Have you redeployed your updated process definition and started a new workflow? Only then will a change in a process definition actually lead to a result.
Regards
Axel
10-12-2012 04:42 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.