cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a email notification when a new site is created

samnaction
Champ in-the-making
Champ in-the-making
Whenever a new site is created the user has to get an email notification as " A new site named sample is created. Click this link to join the site"
I tried to create a rule and execute a script when a particular site is created

var parent = space.getParent();
var siteShortName = space.getSiteShortName();
var siteGroup = "GROUP_EMAIL_CONTRIBUTORS";
var mail = actions.create("mail");
mail.parameters.to_many = siteGroup;

mail.parameters.subject=" A new site called" +siteShortName +"is created";
mail.parameters.text="Login to share to join the site;

//execute action against a document
mail.execute(document);


But I am getting the mail as "A new site callednullis created" as subject‏. It is not showing the site name instead it saying null
16 REPLIES 16

sanket
Champ on-the-rise
Champ on-the-rise
Print the value of "parent" that you get. If parent is not null, then try :

logger.log(parent.properties.name);

I think you are triggering rule that is configured under Company Home/Sites folder.
Can you also print the value of this statement "document.properties.name" and let me know the value ?

logger.log(document.properties.name);

If I understand correctly, replacing the below code

mail.parameters.subject=" A new site called" +siteShortName +"is created";

with

mail.parameters.subject=" A new site called" + document.properties.name +"is created";

should work.

samnaction
Champ in-the-making
Champ in-the-making
That worked but it is sending me two email and any idea how to add the link to particular site to join

sanket
Champ on-the-rise
Champ on-the-rise
Refer the template located under :
Company Home > Data Dictionary > Email Templates > invite > invite-email.html.ftl

Add the below statements before - mail.execute(document);


mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/invite/invite-email.html.ftl");

mail.parameters.text = "some text";


Modify the invite-email.html.ftl based on your requirement.

samnaction
Champ in-the-making
Champ in-the-making
Thanks Sanket, but everytime I am getting two mails instead of one mail. I think it is something to do with rule creation. Any idea why it is sending two mails instead of one?

sanket
Champ on-the-rise
Champ on-the-rise
Need to check. Go to Alfresco explorer (http://localhost:8080/alfresco). Login with admin user.
Go to Company Home/Sites - More Actions - Manage Content Rules.
Edit the rule.
Can you post here - 1) Step 1-Condition selected 2) Step 2-Action selected 3) Step 3- Value of the three checkboxes

On Step 3, uncheck the "Apply rule to subspaces" if selected.

samnaction
Champ in-the-making
Champ in-the-making
I created the rule in share. I attached the image

sanket
Champ on-the-rise
Champ on-the-rise
1) Print something in your email.js file with logger statement.
Is it printing twice ?

2) Try editing the rule and change the condition from - "Description" to "All Items".
   Save the rule. Check

3) Try editing the rule and change the condition from - "Description" to "Content of type or sub-type" is "Folder".
   Save the rule. Check

Let me know the output of above three points.

samnaction
Champ in-the-making
Champ in-the-making
I tried 2,3 and still it is sending two mails

sanket
Champ on-the-rise
Champ on-the-rise
I think you are sending email notification to this group.

var siteGroup = "GROUP_EMAIL_CONTRIBUTORS";
mail.parameters.to_many = siteGroup;

And this group may contain 2 users having same email id.
That is why it should be sending two emails.

Check by just keeping a single user in that group, you should receive only one email.