How do I add an email notification when comments are added?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2016 06:33 PM
I would like to create a new notification that is sent to the author of the document and the commenter when a new comment is added on a document. Can anyone let me know how I can achieve this?
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2016 04:04 AM
You can develop a custom behaviour for that.
Listen to 'onContentUpdate' event for 'ForumModel.TYPE_POST' types and send the email by using an action 'MailActionExecuter.NAME'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2016 04:16 AM
Probably the easiest way to do this is to create a rule that is configured to run a script when the document is updated.
From the script you can then use the mail action e.g.
var template = "Data Dictionary/Email Templates/Notify Email Templates/xxxxx.ftl";
var mail = actions.create("mail");
var creator = document.properties["cm:creator"];
var peep = people.getPerson(creator);
mail.parameters.to = peep.properties["cm:email"];
mail.parameters.subject="Document changed: "+document.properties.title;
mail.parameters.template = companyhome.childByNamePath(template);
mail.execute(document);
You don't need to use a template but it's nicer if you do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2016 04:18 AM
Interesting, where do you include such rule? At 'Repository > Sites'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2016 04:48 AM
I think the original question was asking about a document rather than a discussion post.
If adding the rule to site discussions then, yes in Repository > Sites ....
I've wrapped up Discussions notifications in an add on GitHub - malariagen/alfresco-discussions: Customizations to Alfresco Site Discussions that does rather more than just send out an email.
I'm not sure of the pros and cons of behaviour vs rule but in this case I think a rule gives more flexibility.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2016 04:58 AM
In fact, a document comment is modelled as a discussion post: they both are sharing content model.
So, I have to add that the behaviour should check if the new POST is happening inside 'documentLibrary' component.
IMO, behaviours are more efficient than rules, as they are only listening to events inside node lifecycle. However, rules must consider all containing folder hierarchy also as triggering condition, which in the end can involve too much overload for the system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2016 05:20 AM
Interesting about the shared content model.
I wouldn't think it's a good idea to use a rule everywhere, so I agree a behaviour is probably better in that case.
It might be easier to check if the post is not in a discussion.
