AnsweredAssumed Answered

Alfresco Script : is this algorithm feasible please ? -->

Question asked by aurelien2 on Oct 1, 2007
Latest reply on Oct 4, 2007 by aurelien2
Here is a script in a madeup language. It checks the permissions on the actual document triggered and sends an email alert to all people who can read the file except to the person who triggered the alert (he already knows…) :

user = getcurrentuser();
document = getcurrentdocument();
perms = getpermissions(document);

for each(perms as perm) {
   if (perm["username"] != user.getname()) {
      mail = newmail();
      mail.subject = "new document "" + document.getname() + "" changed";
      mail.to = getPersonFromName(perm["username"]).getemail();
      mail.from = "admin@mysite.com";
      mail.body = "blah blah " + document.geturl() + "blabla. Bye.";
      mail.send();
   }
}

1) Is thi possible using the javascript API? Could you give me a hint on how to implement the "perms = getpermissions" and "for each (perms as perm)" please? I dont know how to parse tokenised string in javascript :s

2) Are discussions nodes taken care of, this way? Is there any way i can detect that the current node is a discussion and mention it in the email?

Any help greatly apreciated !! :)

Aurélien

Outcomes