cancel
Showing results for 
Search instead for 
Did you mean: 

Rule on 'delete content' does not work

mplebani
Champ in-the-making
Champ in-the-making
Hi all,
I'm new to Alfresco. I'm creating a rule associated to the Site folder that intercept any changes in subfolder and it logs the path where the change happens. For change I mean: creation, deletion, updating, moving.

I created a JS file and I associated it to the Site folder. The rule works if
- I create a folder/content in Site (or subfolder of Site)
- I rename a folder/content in Site (or subfolder of Site)
- I move a folder/content in Site (or subfolder of Site)

but it does NOT work if I delete a content.

Anyone can help me?

– Marco
4 REPLIES 4

sujaypillai
Confirmed Champ
Confirmed Champ
Hi Marco,

Can you please share your .js code associated with the rule, so that we may comment on it?


Thanks,

mplebani
Champ in-the-making
Champ in-the-making
Sure,
here it is.
It is a simple rule that set an attribute in a parent folder with a particular aspect. It seems a dummy rule. Consider that I'm testing some functionalities that I need in my project.

Cheers
– Marco


logger.log("========================");
if (document!=null){

   // DOCUMENT NAME
   logger.log(document.name);

   // A. FIND THE FOLDER WITH mpl:issueFolder ASPECT
   logger.log(" ### Find the folder that has mpl:issueFolder aspect");
   
   var issueFolder = document.parent;
   
   while (issueFolder!= null && !issueFolder.hasAspect("mpl:issueFolder")){
      issueFolder = issueFolder.parent;
      if (issueFolder != null)
         logger.log(issueFolder.name);
   }
   
   if (issueFolder != null){
      // B. INCREASE THE VERSION
      if (issueFolder!=null){
         issueFolder.properties["mpl:param"] += " document.name";
         issueFolder.save();
      }
      
   } else {
      logger.log(" !!! Folder not found");
   }
   logger.log("========================");
} else {
   logger.log("DOCUMENT IS NULL")
}

mrogers
Star Contributor
Star Contributor
rules don't fire on deletion (yes I know its inconsistent - but its been that way for years)  you need to implement a deletion policy rather than a rule.

mplebani
Champ in-the-making
Champ in-the-making
Thanks for your reply.
Can you provide me a link where I can find documentation/sample about deletion policy?