I'm facing an issue with rules triggering in Alfresco (Community v5.2.0 (r135134-b14) schema 10 005).
In our installation, we are using the rules to:
Communicate to other server components about what happens in Alfresco
Prevent unwanted actions (like deleting some folders)
We faced multiple issues and random behaviors that we fixed with a lot of checks in our JS code but one "unsolvable" case remains.
We have a rule that is used to prevent people to rename or delete folders with a name starting by "_" , this rule only applies to elements that have the custom property 'gofastreventDelete' set to true.
The problem is : When we are doing something on an element in a folder starting by "_", the rules will trigger on the document but also on the parent folder.
A delete request is called :
16:58:31,244 WebDAV request DELETE on path /alfresco/webdav/Sites/_Groups/_Var%20dump%20land/content%20(2).mp4
Rules triggers on the document :
16:58:31,345 ==== STARTING SCRIPT SCRIPT SYNCHRONIZE ==== 16:58:31,346 Script called on content (2).mp4 / 10651e68-7a35-4727-a1d1-f6e889805656 ............................SOME ACTIONS.............................. 16:58:31,423 Request has been sent 16:58:31,423 Drupal answered OK 16:58:31,424 Closing XHR Object 16:58:31,424 ==== ENDING SCRIPT SCRIPT SYNCHRONIZE ====
But just after this, the rule to prevent to delete a folder starting with '_' is called, not on the document but on it's parent folder :
And the transaction is rollbacked.
Do you think it's possible to stop propagation in the first script ?
Are you using the "Items are deleted..." trigger and the "Execute script" action for your rule? I cannot recreate the case where a script gets called twice using that trigger and action for a simple, one-line script that just has a logger.debug statement in it.
Maybe your script logic is triggering the rule twice?
Have you considered using a lower-level behavior rather than a folder rule?