Hi,
How to send a email to user in bonita with specific role.
How can I get the email Id in the my process?
Coul someboy help?
Thanks,
Charu
Hi,
How to send a email to user in bonita with specific role.
How can I get the email Id in the my process?
Coul someboy help?
Thanks,
Charu
Hi David,
Thanks for the reply.
The first stpe works for .I get the List of Users(that is the Possible Users List for the specifie role).
But the connector fails at the next step when try to get the profeesional data.
can u plz help
Thanks,
Charu
I already tried this change but still the connctor fails for me.
This line does not wrk for me,
BonitaUsers.getUserProfessionalContactInfo(apiAccessor,u.getId()).getEmail()
I get the userid ,but still when i try to get email Id or professional data or anything else the connector fails
Hi,
First you can get the users in a rol using the identity API and a Bonita Function available on the function section of the Groovy Editor. In the following example I’ll get the email of the first 200 users of a role sorted by last name.
import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.identity.UserCriterion;
String role = “TheRole” //this is the role name
ArrayList possibleUsers = apiAccessor.getIdentityAPI().getUsersInRole(apiAccessor.identityAPI.getRoleByName(role).id, 0, 200, UserCriterion.LAST_NAME_ASC);
ArrayList usersEmail = new ArrayList(); //this list will contain all the email adresses
for(User u : possibleUsers) {
usersEmail.add(BonitaUsers.getUserProfessionalContactInfo(apiAccessor,u.getId()).getEmail());
}
return usersEmail;
This is only an example, you can fit this code (or this idea) to your specific needs.
Bye, David.
Finally this worked for me,
usersEmail.add(apiAccessor.getIdentityAPI().getUserWithProfessionalDetails(u.getId()).getContactData().getEmail());
Thanku so much for your help David
Hi,
I made a mistake on the lines 6 and 9, the correct 6 is:
ArrayList possibleUsers = apiAccessor.getIdentityAPI().getUsersInRole(apiAccessor.identityAPI.getRoleByName(role).id, 0, 200, UserCriterion.LAST_NAME_ASC);
And the correct 9:
usersEmail.add(BonitaUsers.getUserProfessionalContactInfo(apiAccessor,u.getId()).getEmail());
I’ve corrected my original answer.
Hi, try this:
usersEmail.add(apiAccessor.getIdentityAPI().getUserContactData(u.getId(), false).getEmail());
I use the Identity API instead the BonitaFunction.
Bye, David.
I’ve made a big mistake on the line 7, this will fix it.
ArrayList usersEmail = new ArrayList(); //this list will contain all the email adresses
I was declaring the usersEmail as a ArrayList, and the Email data is a String. :P.
Well, please try it and if this does not work please attach the engine log.
PD: I’ve corrected the original answer.
Bye, David.