Problem while retrieving e-mail address

1
0
-1

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 users = new HashMap();
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 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);

}

1 answer

1
+1
-1
This one is the BEST answer!

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

Comments

Submitted by akhilesh.pathak on Thu, 03/27/2014 - 00:07

Thanx for your reply..

Notifications