Catch the parent node of a deleted node

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

Catch the parent node of a deleted node

Hello community, i have created a rule in a folder that when users add contents to that folder the rule calls a custom script that prepends to all children nodes in that parent folder a specific char, at this point i catch the parent node based on the "document" var node that fired the rule, this works fine when creating or adding content to the folder that has configured the rule, but i need to make this work when deleting a node in that folder, the problem is that i can't get the parent property of the deleted node, I think it's because it does not exist anymore.

does anyone knows hoy can i make this work without leaving hardcoded the parent folder nodeRef?

4 Replies
Highlighted
Alfresco Employee

Re: Catch the parent node of a deleted node

Use the check "Run the rule in background" to define the rule.

Software Engineer in Alfresco Search Team.
Highlighted
Active Member

Re: Catch the parent node of a deleted node

Thank you for your response Angel Borroy‌, i have set the flag you told me, but it has not worked for me, i'm wondering if the RootScoped Var `document`  is Defined when the rule calls my custom script on node deletion actions, because my script get the parent node based on that variable.

Highlighted
Alfresco Employee

Re: Catch the parent node of a deleted node

I guess that "document" should be considered as a removed node in the JavaScript API when using delete as condition on a rule.

Usually I develop a behaviour for this, but Java is required: Alfresco – Implementing delete behavior | Programming and So 

Software Engineer in Alfresco Search Team.
Highlighted
Active Member

Re: Catch the parent node of a deleted node

nice! i will try using Behaviors, thanks for the reference link!

I want to share with you that i have try using the RootScoped var "Space" this worked for me, this get me the Folder parent of the uploaded Node that triggers the rule, it defines with the node of the folder where the rule is configured it works fine but i have to redefine the same rule in each folder i want the same functionality, if you link the rule to an existing one, this variable always gets defined with the Folder where the rule war originally created.

 think i will continue with the script using this "Space" variable, and if theres no success i will be moving to create a behavior.

Thank you for your help Angel Borroy‌!