09-17-2010 11:07 AM
for (i in fileNode.assocs["xel:reviewedby"]){
fileNode.removeAssociation(fileNode.assocs["xel:reviewedby"][i], "xel:reviewedby");
}
09-20-2010 07:56 PM
for (var targetNode in fileNode.assocs["xel:reviewedby"])
{
fileNode.removeAssociation(targetNode, "xel:reviewedby");
}
09-21-2010 02:24 AM
var namesuffix = userhome.children.length; //to make file name unique
var sourceNode = userhome.createNode("testassocsfile"+namesuffix +".txt", "cm:content");
sourceNode.content = "the original text";
sourceNode.addAspect("cm:attachable");
logger.log("LX Created source node");
var destNode = userhome.createNode("attached1-"+namesuffix +".txt", "cm:content");
destNode.content = "Text in attached document";
logger.log("LX Created dest node 1");
sourceNode.createAssociation(destNode, "cm:attachments");
logger.log("LX Created assoc destNode to sourceNode");
var destNode2 = userhome.createNode("attached2-"+namesuffix +".txt", "cm:content");
destNode2.content = "Text in attached document2";
logger.log("LX Created dest node 2");
sourceNode.createAssociation(destNode2, "cm:attachments");
logger.log("LX Created assoc destNode2 to sourceNode");
sourceNode.save();
for (var targetNode in sourceNode.assocs["cm:attachments"])
{
logger.log("LX Removing " + targetNode) //targetNode returns integer here
logger.log("LX Removing name " + targetNode.name) //returns undefined
sourceNode.removeAssociation(targetNode, "cm:attachments");
}
Caused by: org.alfresco.error.AlfrescoRuntimeException: 08210080 Can't find method org.alfresco.repo.jscript.ScriptNode.removeAssociation(string,string). (file:/opt/alfresco/xelerated/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/test/lxtest.get.js#30)
As you can see in my test code, the logging of targetNode in the iteration returns an integer, starting at 0 (and why I tried to use it the way I did, I think…).09-21-2010 02:43 AM
// example iterating array indexes using 'for .. in'
var out1 = "";
for (i in userhome.children)
{
out1 += userhome.children[i].name + "<br>";
}
// example iterating array values using 'for each .. in'
var out2 = "";
for each (n in userhome.children)
{
out2 += n.name + "<br>";
}
09-21-2010 02:56 AM
for each (targetNode in sourceNode.assocs["cm:attachments"])
{
sourceNode.removeAssociation(targetNode, "cm:attachments");
}
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.