AnsweredAssumed Answered

Delete Content Programatically

Question asked by kpdamm on Jun 2, 2010
Hello,

I'm looking for a solution to delete content programatically from all of my spaces based on that content's attribute, e.g. delete all content in Alfresco that is older than 10 days. Through some early research I imagine the easiest way to do this is to create a business rule and have that rule call a JavaScript that will execute the deletion. I have two questions:
1. How do I 'loop' through all the content within the spaces under Company Home?
    I imagine something like the following will loop through the space in which I created the rule (i.e. Company Home), but how do I run the script in all the sub spaces?
   
    var childList = space.children;
      for (var i=0; i<childList.length; i++)
      {
            var child = childList;
            if (I need to compare the current date with the created date of the content - see question 2)
            {
                     child.remove();
            }
      }
2. How do I compare the 'created' date (cm:created I think) with the current date?

Outcomes