As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
for (i in fileNode.assocs["xel:reviewedby"]){ fileNode.removeAssociation(fileNode.assocs["xel:reviewedby"][i], "xel:reviewedby"); }
for (var targetNode in fileNode.assocs["xel:reviewedby"]) { fileNode.removeAssociation(targetNode, "xel:reviewedby"); }
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)
// 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>"; }
for each (targetNode in sourceNode.assocs["cm:attachments"]) { sourceNode.removeAssociation(targetNode, "cm:attachments"); }