AnsweredAssumed Answered

Delete Node using WebScript

Question asked by jlabuelo on Sep 22, 2014
Latest reply on Sep 23, 2014 by kaynezhang
Hi all

We are tryting to develop a Script that will be called by an external application by a given URL. The purpose is that our Alfresco configuracion CE V3.0, will receive this URL containing a given NodeRef and the login and password credentials of a given "Non-Admin") user.

This URL must execute this Script we are creating with the Alfresco JavaScript API and delete the given node included in the URL. The node is always stored in a space where the user included in the URL has not "Delete" permission, so first we need to add the "delete" permission to this node, then call the remove().

However, as I said the user that calls (logs in by URL in Alfresco) is the one given in the URL and it is not an Admin user, so the code is failing and we think must be because the user is not an admin user.

Let me show you the easy code we are using in the Script

function custom_Delete( node, user)
{
  node.setPermission("Delete",user);
  node.remove();

}

We just need this, an script that can be executed using a URL call included the node to delete, and the login and password of the user to log in, to delete a given node, (stored in a space with "NO DELETE" permissions for the given user in the URL)

Problem is that this is not working for us,as the error comes in the "node.setPermission()" call. We do not figure out any other way

Any ideas please???. Thanks a lot

Outcomes