Problem while retrieving e-mail address

I am trying retrive email of the user with below code, but email and address are coming as null.in organization i have added email and address in personal and contact info for the user who belongs to ABC group.  Please help

Thanks in advance

Akhilesh

 

 

 

import org.bonitasoft.engine.identity.ContactData;
import org.bonitasoft.engine.identity.Group;
import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.identity.UserSearchDescriptor;
import org.bonitasoft.engine.search.SearchOptionsBuilder;
import org.bonitasoft.engine.search.SearchResult;
import org.bonitasoft.engine.api.IdentityAPI;


Map<String, String> users = new HashMap<String, String>();
IdentityAPI identityAPI = apiAccessor.getIdentityAPI()

//Get GROUP from path
Group rsa_group = identityAPI.getGroupByPath("/ABC")

SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 100);
builder.filter(UserSearchDescriptor.GROUP_ID, rsa_group.getId());

SearchResult<User> userResults = identityAPI.searchUsers(builder.done());

for (User user : userResults.getResult()) {
    ContactData contact =    identityAPI.getUserContactData(user.id, true);

    users.put(contact.building.toString()+" - "+user.id+" - "+contact.getEmail() +" - "+user.firstName + "- " + user.lastName,user.id);

}

 

Hi Akhilesh,

There are two possible ways to add an email address for a user in the Portal.

When you are editing a user, you can add an email in the business card or in the personal information tab.

In order to retrieve the emails programmatically you will then use this method as you did:

identityAPI.getUserContactData(userId, isPersonnalEmail);

Here, the boolean flag will allow you to retrieve the right email (the one from the business card or from the personal information):

http://documentation.bonitasoft.com/javadoc/api/6.2/org/bonitasoft/engine/api/UserAPI.html#getUserContactData(long, boolean)

Could you please check that you are retrieving the right email?

Hope this helps,

Philippe

 

Thanx for your reply..