getting email Id from organization.xml file

1
0
-1

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

5 answers

1
0
-1
This one is the BEST answer!

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<User> possibleUsers = apiAccessor.getIdentityAPI().getUsersInRole(apiAccessor.identityAPI.getRoleByName(role).id, 0, 200, UserCriterion.LAST_NAME_ASC);
ArrayList<String> usersEmail = new ArrayList<String>(); //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.

1
0
-1

Finally this worked for me,

usersEmail.add(apiAccessor.getIdentityAPI().getUserWithProfessionalDetails(u.getId()).getContactData().getEmail());

Thanku so much for your help David

1
0
-1

I get the userid ,but still when i try to get email Id or professional data or anything else the connector fails

Comments

Submitted by dbravo on Mon, 01/26/2015 - 16:37

I've made a big mistake on the line 7, this will fix it.

ArrayList<String> usersEmail = new ArrayList<String>(); //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.

1
0
-1

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()

Comments

Submitted by dbravo on Mon, 01/26/2015 - 16:21

Hi, try this:

usersEmail.add(apiAccessor.getIdentityAPI().getUserContactData(u.getId(), false).getEmail());

I use the Identity API instead the BonitaFunction.

Bye, David.

1
0
-1

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

Comments

Submitted by dbravo on Mon, 01/26/2015 - 16:18

Hi,

I made a mistake on the lines 6 and 9, the correct 6 is:

ArrayList<User> 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.

Notifications