cancel
Showing results for 
Search instead for 
Did you mean: 

[BUG]Alfresco sending multiple emails depending on the number of user in a group

samnaction
Champ in-the-making
Champ in-the-making
I added a javascript to send an email to a particular group whenever a site is created but the problem is if the group has three members each will receive three mails. If there is 250 members each will receive 250 emails. I dont know what is the problem.

Here is my javascript

var parent = space.getParent();
var siteGroup = "GROUP_EMAIL_CONTRIBUTORS";
var mail = actions.create("mail");
var url = "http://pc1:8080/share/page/site/" + document.properties.name + "/dashboard";
mail.parameters.to_many = siteGroup;
mail.parameters.subject="New Site Created in Community"
mail.parameters.text="Click http://pc1:8080/share/page/site/" + document.properties.name + "/dashboard to join the site"
//execute action against a document
mail.execute(document);
6 REPLIES 6

sanket
Champ on-the-rise
Champ on-the-rise
Yeah. I can replicate this problem on my local environment.
I need to know how many users are you holding in the group EMAIL_CONTRIBUTORS. If it's very less, then you can use the below code as a work around:


var mail = actions.create("mail");

var node = people.getGroup("GROUP_EMAIL_CONTRIBUTORS");
   
    if(node){
       var members = people.getMembers(node);        
    }
  mail.parameters.subject=" A new site called" + document.properties.name+"is created";
mail.parameters.text="Login to share to join the site";

for(var i=0;i<members.length;i++)
{
  mail.parameters.to = members.properties.email;
//execute action against a document
mail.execute(document);
}

samnaction
Champ in-the-making
Champ in-the-making
I have around 250 users can I use this

sanket
Champ on-the-rise
Champ on-the-rise
I don't recommend if there are so many users; but you can check the performance of the system (on your local environment) once this script gets executed. If it doesn't affect the performance much, you can continue with it.

I am trying to find an alternative way, but I am still getting multiple emails. Will update you, if I get something useful.

Refer this link, the last post particularly (if it helps you):
https://forums.alfresco.com/comment/64566#comment-64566

sanket
Champ on-the-rise
Champ on-the-rise
It is a registered bug in alfresco. It should be be fixed in upcoming alfresco version.

https://issues.alfresco.com/jira/browse/MNT-10945

Till then, you can keep using the above suggested approach.

samnaction
Champ in-the-making
Champ in-the-making
Check the answer suggested here http://stackoverflow.com/questions/22654053/how-to-suppress-multiple-email-notification-from-javascr....
I am not able to figure what he is saying

sanket
Champ on-the-rise
Champ on-the-rise
I went through the above link.
There is no point checking if the document type is st:site. By default, you have configured rule on Company Home/Sites.
Any site you create from alfresco share, will have the type st:site.
To verify, just create a new site. Then go to alfresco node browser, traverse to company home > sites > your_site_name.
And check it's type (it is by default st:site). And in this folder (Company Home/Sites), you are only going to create a site (through alfresco
share), not create a folder explicitly.
So, I recommend there is no need to edit share-config-custom.xml or add a subtype.