08-01-2011 08:35 AM
Hello,
I'm newbie in BES development but I hope, You can help me.
I have group with 3 users and a I want to get the list of user ids.
1. I found a group:
for (Group itr:result.getGroups()) {
String resultGroupName = itr.getLocaleNameAndDescription().get(0).getName()
if(resultGroupName.equals(groupName)) {
//now I'm trying to get users of group, i will describe it in the next paragraph
}
}
2. I'm trying to get users of group:
GroupUsers groupUsers = itr.getGroupUsers();
but I obtain NullpointerException.
Please, can you help me, where i made a mistake?
3. I also tried to use getgetGroupMember() but I got empty list:
List<GroupMember> groupMembers = itr.getGroupMember();
What's the difference between objects GroupMember and GroupUser?
Solved! Go to Solution.
08-02-2011 08:37 AM
Hi.
This works for me but I am using C# and BES API 5.0.2
//you will need to supply the group ID
int mygroupID = 7;
getGroup GroupRequest = new getGroup();
GroupRequest.groupId = mygroupID;
GroupRequest.locale = "en_US";
GroupRequest.loadGroupChildGroups = false;
GroupRequest.loadGroupDirectAssignments = false;
GroupRequest.loadGroupDirectUsers = true;
GroupRequest.loadGroupParentGroups = false;
getGroupResponse GroupResponse = coreWebService.getGroup(GroupRequest);
GetGroupResult GroupResult = GroupResponse.returnValue;
for (intj = 0; j < GroupResult.group.groupUsers.userId.Length; j++)
{
Console.WriteLine("userID: "+ GroupResult.group.groupUsers.userId[j]);
}
Hope this helps!
Kevin
08-03-2011 03:35 AM
Thank you for your help!
It seems that C# API return correctly group users but Java API return null ![]()
Becaouse I'm trying to get group users and their ids in similary way.
08-03-2011 08:49 AM
When you did the search for the group did you include directusers?
boolean loadGroupDirectUsers=true;
FindGroupsResult result= coreWebService.getGroup(groupId, locale,loadGroupDirectUsers);
08-03-2011 10:29 AM
I didn't use search for the group by ID...
I found all groups by a method:
FindGroupsResult result = coreWebService.findGroups(organizationId, "en_US");
I used an iterator :
for (Group itr:result.getGroups()) {}
By the name i found a group I need:
String resultGroupName = itr.getLocaleNameAndDescription().get(0).getName()
if(resultGroupName.equals(groupName)) {}
And now I want to get users IDs in this group but the object is NULL:
GroupUsers groupUsers = itr.getGroupUsers();
08-03-2011 10:51 AM
Maybe, now that you have found the group, use its ID to do the getgroup again. That should return all the properties of the single group.
int groupID = ?
boolean loadGroupChildGroups=true;
boolean loadGroupParentGroups=true;
boolean loadGroupDirectUsers=true;
boolean loadGroupDirectAssignments=true;
GetGroupResult result = coreWebService.getGroup(groupId, locale, loadGroupChildGroups, loadGroupParentGroups, loadGroupDirectUsers, loadGroupDirectAssignments);
Then you can see any child groups by doing the following:
System.out.println("Child Groups: ");
for(Group itr:group.getGroupChildGroups().getGroup()){
System.out.print(itr.getGroupId()+" ");
}
You should be able to do the same loop to look for members of the group.
Maybe:
System.out.println("Users: ");
for(Group itr:group.getGroupDirectUsers().getGroupUsers()){
System.out.print(itr.getUserId()+" ");
}
Sorry, I'm just guessing here because I don't have a Java compiler.
08-04-2011 07:18 AM
Thank you, it helped me, the problem is solved.
08-04-2011 07:55 AM
Glad to hear that.
Happy to help.