Multiple Email
Hi,
I will explain you all steps:
1) create a global variable in your pool: - variable "allUsersEmailSLS" - type "java.list" In this variable, you store all the users emails from the role "SLS"
Scrypt:
import org.bonitasoft.engine.identity.UserCriterion;
import org.bonitasoft.engine.identity.User;
long idRoleSLS = apiAccessor.getIdentityAPI().getRoleByName("SLS").getId();
ArrayList
2) Transform the list as a string because in the mail connector, you can't put a list for the sender and receiver adress. So, create another variable - type "Text"
Scrypt: String listStringSLS = ""; int nbElementsSLS = allUsersEmailSLS.size(); int compteurSLS = 0; String separateurVirguleSLS = ","; String separateurVideSLS = "";
for (String sSLS : allUsersEmailSLS) { compteurSLS += 1; if(compteurSLS == nbElementsSLS){ listStringSLS += sSLS + separateurVideSLS; } else { listStringSLS += sSLS + separateurVirguleSLS; } } return listStringSLS;
You can't put a list for the sender in an email connector. You must convert your list to a string. That's why there is a second part in my first topic.
==> Create a list to collect your emails from your database and convert it and store it to a variable. Put this new variable for the sender. Can you retrieve the emails from the database to a text field for example?