As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Creating a new document would surely work, but is rather unelegant: It would break for example all other associations to that document. Maybe you dont use that now, buts its an rather elegant Alfresco feature….
// Alfresco Server Side Javascript // Script to send "Nag" emails if a document gains an excessive number of revisions // One e-mail to the user who updated the document and a copy to the IT Dept // Script set to run on document updates var textBuffer = "" // Test to see if the document in question is versioned. If not then just bail out if (document.isVersioned) { // Grab the total number of revisions held NbrOfRevs = document.versionHistory.length; // Test below triggers on only 3 revisions for testing purposes // Set this number to something sensible for your environment if (NbrOfRevs > 3) { // create mail action var mail = actions.create("mail"); mail.parameters.to = person.properties.email; mail.parameters.subject = "Large number of document revisions detected."; mail.parameters.from = "alfresco@fake.email.local"; // Uncomment line below if you want to build and use your own // template document for the e-mail. I have not played with this yet. // With no template e-mail it uses the mail.parameters.text // for the message body. //mail.parameters.template = root.childByNamePath("Company Home/Data Dictionary/Email Templates/excessive_revisions_email.ftl"); // Get the document name and the name of the submitting user var DocuName = document.properties.name; var PersonName = person.properties.firstName; // Build a text buffer containing the email body message. // Then assign this buffer to mail.parameters.text // I did try adding text directly to mail.parameters.text with a series of // mail.parameters.text += but got very unpredictable results. textBuffer = "Dear " + PersonName + "\n\n"; textBuffer += "Warning! A document you just updated called:- \n\n"; textBuffer += DocuName + "\n\n"; textBuffer += "has more than 3 revisions currently stored in the Alfresco system.\n\n"; textBuffer += "Could you please contact the IT Department for some instructions\n"; textBuffer += "on how to remove any non essential older revisions of this document.\n\n"; textBuffer += "Our file storage space is not unlimited.\n\n"; textBuffer += "Thankyou.\n"; mail.parameters.text = textBuffer; // Execute action against a document // This sends an e-mail to the person who did the document update mail.execute(document); // There seems to be no support for Cc: or Bcc: e-mails // Nor could I work out how to specifiy multiple To: addresses on the one line. // So to send the same message to the IT dept as well // we reset the mail.parameters.to and then mail.execute again mail.parameters.to = "itadmin@fake.email.address"; // Change e-mail address to the address of your support group mail.execute(document); } }