Alfresco 根据标签添加分类
Alfresco Add Category based on Tag
我想创建一个脚本用作文件夹规则,以根据标签添加类别。
此脚本成功将类别添加到文件。
var catNodeRef = search.findNode("workspace://SpacesStore/XXXXXXXXXXXXXXXXXXXX");
var categories= document.properties["cm:categories"];
if (categories == null ) {
categories = new Array (); }
categories.push(catNodeRef);
document.properties["cm:categories"] = categories;
document.save();
};
但是,当我添加 findTaggedNodes 时,脚本失败了。
var taggedNodes = findTaggedNodes("workspace://SpacesStore/XXXXXXXXXtagnumber");
var taggable= document.properties["cm:taggable"];
if (taggedNodes == "workspace://SpacesStore/XXXXXXXXXtagnumber" )
{
var catNodeRef = search.findNode("workspace://SpacesStore/88b392ce-a50c-4079-a8cb-8a18faafc154");
var categories= document.properties["cm:categories"];
if (categories == null ) {
categories = new Array (); }
categories.push(catNodeRef);
document.properties["cm:categories"] = categories;
document.save();
};
我也试过了
var taggable= document.properties.hastag = "aaf observatory";
if(var taggable)
{
var catNodeRef = search.findNode("workspace://SpacesStore/88b392ce-a50c-4079-a8cb-8a18faafc154");
var categories= document.properties["cm:categories"];
if (categories == null ) {
categories = new Array (); }
categories.push(catNodeRef);
document.properties["cm:categories"] = categories;
document.save();
};
如有任何帮助,我们将不胜感激。 (注意:我不是开发人员)
findTaggedNodes
在 javascript 中不起作用,您可以在 Java 中使用 TaggingService
,在 JavaScript 中您需要使用 search.findNode(TAG_NODE_REF)
获取带有 nodeRef
.
标签的节点
var taggable = document.properties["cm:taggable"];
return 标签集合,不能与字符串值进行比较。您需要一个循环来比较集合是否包含相同的节点并使用 node1.equals(node2)
您在这里找到脚本:
var nodeTag = search.findNode('workspace://SpacesStore/XXXXXXXXXtagnumber');
//Get Tags of document
var documentTags = document.properties["cm:taggable"];
for each(var tag in documentTags) {
if(tag.equals(nodeTag)) {
//Tag is found in document, add the category with function
addCAtegory(document, "workspace://SpacesStore/REF_ID_CATEGORY");
}
}
function addCAtegory(node, categoryNodeRef) {
var catNodeRef = search.findNode(categoryNodeRef);
var categories= node.properties["cm:categories"];
if (categories == null ) {
categories = new Array ();
}
categories.push(catNodeRef);
node.properties["cm:categories"] = categories;
node.save();
}
我想创建一个脚本用作文件夹规则,以根据标签添加类别。
此脚本成功将类别添加到文件。
var catNodeRef = search.findNode("workspace://SpacesStore/XXXXXXXXXXXXXXXXXXXX");
var categories= document.properties["cm:categories"];
if (categories == null ) {
categories = new Array (); }
categories.push(catNodeRef);
document.properties["cm:categories"] = categories;
document.save();
};
但是,当我添加 findTaggedNodes 时,脚本失败了。
var taggedNodes = findTaggedNodes("workspace://SpacesStore/XXXXXXXXXtagnumber");
var taggable= document.properties["cm:taggable"];
if (taggedNodes == "workspace://SpacesStore/XXXXXXXXXtagnumber" )
{
var catNodeRef = search.findNode("workspace://SpacesStore/88b392ce-a50c-4079-a8cb-8a18faafc154");
var categories= document.properties["cm:categories"];
if (categories == null ) {
categories = new Array (); }
categories.push(catNodeRef);
document.properties["cm:categories"] = categories;
document.save();
};
我也试过了
var taggable= document.properties.hastag = "aaf observatory";
if(var taggable)
{
var catNodeRef = search.findNode("workspace://SpacesStore/88b392ce-a50c-4079-a8cb-8a18faafc154");
var categories= document.properties["cm:categories"];
if (categories == null ) {
categories = new Array (); }
categories.push(catNodeRef);
document.properties["cm:categories"] = categories;
document.save();
};
如有任何帮助,我们将不胜感激。 (注意:我不是开发人员)
findTaggedNodes
在 javascript 中不起作用,您可以在 Java 中使用 TaggingService
,在 JavaScript 中您需要使用 search.findNode(TAG_NODE_REF)
获取带有 nodeRef
.
var taggable = document.properties["cm:taggable"];
return 标签集合,不能与字符串值进行比较。您需要一个循环来比较集合是否包含相同的节点并使用 node1.equals(node2)
您在这里找到脚本:
var nodeTag = search.findNode('workspace://SpacesStore/XXXXXXXXXtagnumber');
//Get Tags of document
var documentTags = document.properties["cm:taggable"];
for each(var tag in documentTags) {
if(tag.equals(nodeTag)) {
//Tag is found in document, add the category with function
addCAtegory(document, "workspace://SpacesStore/REF_ID_CATEGORY");
}
}
function addCAtegory(node, categoryNodeRef) {
var catNodeRef = search.findNode(categoryNodeRef);
var categories= node.properties["cm:categories"];
if (categories == null ) {
categories = new Array ();
}
categories.push(catNodeRef);
node.properties["cm:categories"] = categories;
node.save();
}