AnsweredAssumed Answered

removing children

Question asked by abruzzi on May 16, 2014
Latest reply on May 16, 2014 by abruzzi
I need to bulk create a bunch of spaces (Alfresco Explorer 3.1.2) that are exactly modeled on other spaces.  Unfortunately the spaces being duplicated are full of stuff, so I was trying to script it.  I was testing a single copy like so:


var newNode = document.copy(document.parent, false);
newNode.name = "1909";


var arrayLength = newNode.children.length;
   
for (var i = 0; i < arrayLength; i++) {

   newNode.removeNode(newNode.children[i]);

}

The newNode by itself contains child associations to the files in the original node.  So the for loop is an attempt to break those association.  However I get the following error:

[blockcode]
16:48:13,982 ERROR [org.alfresco.web.ui.common.Utils] Failed to run Actions due to error: Failed to execute script 'workspace://SpacesStore/e7467042-7167-4b2c-8b07-11a74e348d87': Can't find method org.alfresco.repo.jscript.ScriptNode.removeNode(org.mozilla.javascript.Undefined). (workspace://SpacesStore/e7467042-7167-4b2c-8b07-11a74e348d87#9)
org.alfresco.scripts.ScriptException: Failed to execute script 'workspace://SpacesStore/e7467042-7167-4b2c-8b07-11a74e348d87': Can't find method org.alfresco.repo.jscript.ScriptNode.removeNode(org.mozilla.javascript.Undefined). (workspace://SpacesStore/e7467042-7167-4b2c-8b07-11a74e348d87#9)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:228)
   at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:187)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   …
[/blockcode]

Any idea what I'm doing wrong?

Outcomes