Question

I have added a script to send mail whenever a site is created. How to restrict the email notification if the site created is a private site. Here is my java script

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

var node = people.getGroup("GROUP_EMAIL_CONTRIBUTORS");

    if(node){
       var members = people.getMembers(node);         
    }
mail.parameters.from = "Administrator@community.com"
mail.parameters.subject=" A new site called " + document.properties.name+" is created"; 
mail.parameters.text="Click http://sameer_w7:8080/share/page/site/" +   document.properties.name + "/dashboard" + "   to join the site";

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

Solution

You can get the siteVisibility state of a site.

Take a look at the SiteService Wiki page.

Something like this should work:

if (document.properties["st:siteVisibility"] != "PRIVATE"){
<your email action here>
}

Be sure you have selected type is st:site in your rule, otherwise add an extra check on that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top