cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript API: child.delete() does not work

sbroussi
Champ in-the-making
Champ in-the-making
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
11 REPLIES 11

kevinr
Star Contributor
Star Contributor
Neat trick. A function on a javascript object is just a property of the object like any other property and all properties can be accessed using the array notation.

sburky
Champ in-the-making
Champ in-the-making
ok for accessing !! but then to run a method by accessing throw the array …
it's no so secure… but that's this language !