I had used this code for auto generation of mails. Now the problem is password shown in the mail is the password as generated by the script. I want the password to be fetched from alfresco new user page, where the admin has created the password for the new user not any random string. Below is the script that i generated for automatic mail generation.
if (document.isContainer && document.displayPath == "/Company Home/User Homes") {
var owner = document.properties["cm:owner"];
var pNode = people.getPerson(owner);
if (pNode!=null && pNode.exists()){
var userName = pNode.properties.userName;
var email = pNode.properties.email;
var randPassword = Math.random().toString(36).substr(2, 30)+"-"+(Date.now());
people.setPassword(userName, randPassword);
logger.debug("Invitation mail: User "+userName+" password has been changed.");
var mail = actions.create("mail");
//mail.parameters.from = "noreply@customdomain";
mail.parameters.to = email;
mail.parameters.subject = "Welcome to the site, login: "+userName+", password: "+randPassword;
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Invite Email Templates/invite_user_email.ftl");
var templateModel = new Array();
templateModel['newPassword'] = randPassword; // use ${newPassword} expression inside template
mail.parameters.template_model = templateModel;
mail.executeAsynchronously(document);
logger.debug("Invitation mail has been sent to "+email);
} else {
logger.warn("Invitation mail: User not found: "+owner);
}
}
Please guide me how to proceed further.