AnsweredAssumed Answered

Javascript API: child.delete() does not work

Question asked by sbroussi on May 30, 2006
Latest reply on Feb 29, 2012 by sburky
Hi,

I'm trying to create a "Inbound" rule to:
- detect all incoming ACP files
- import the ACP in one folder (built-in action)
- remove the ACP file (run a custom script)

I have an error when I invoke "child.delete()"

ERROR [repo.action.ActionServiceImpl] An error was encountered whilst executing the action 'composite-action'.
org.alfresco.service.cmr.repository.ScriptException: Failed to execute script 'workspace://SpacesStore/7b4086cf-efbb-11da-a650-b99
5eb94ad41': missing name after . operator (AlfrescoScript#14)
        at org.alfresco.repo.jscript.RhinoScriptService.executeScript(RhinoScriptService.java:145)

I've tried:

a) to delete the current node (document.delete())"
    (I can imagine that the Node that trigger the rule should
    not be so easily removed during the rule process…)

b) to rename the file "*.toBeRemoved" as for the next time
the script is run, the script removes all old files.


// DELETE DOES NOT WORK FOR THE CURRENT NODE
// document.delete();

// remove all previous document
var childList = space.children;
for (var i=0; i<childList.length; i++)
{
   var child = childList[i];
   if (child.name.indexOf(".ToBeRemoved") > 0)
   {
      child.delete();
   }
}

document.name = document.name + ".ToBeRemoved";
document.save();

=> is it a Bug ? I've read http://wiki.alfresco.com/wiki/JavaScript_API

Outcomes