cancel
Showing results for 
Search instead for 
Did you mean: 

How to get The users from a Collaborator that is type Group.

Former Member
0 Kudos

Hello, I'm trying to get the users (and their emails) of a collaborator inside a Master Agreement that is type group.

I've tried the following methods:

1- Using a IBeanHomeLocator to get the GroupIBeanHomeIfc (with the static variable of sHOME_NAME) and then trying to get the Group with the DocumentId that the colaborator's method (getDocumentId()) returns and the GroupIBeanHome method findGroup().

The result was null

2 - Using exactly the same method as before, but instead of using the DocumentId, I did a query, in order to get the field USER_GROUP_OBJECT_ID,  to get the Id of the group.

The result is still null.

I'm not sure if there is a direct way to get it, or if i'm misusing the GroupIBeanHomeIfc.

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

former_member207877
Active Participant
0 Kudos

Hi Oscar,

In the document collaborator class there is a method getCollaboratorType() which returns CollaboratorTypeEnumType and there are certain values assigned to them.

  1. user - A user collaborator
  2. group - A group collaborator
  3. contact - A user contact

So, hashcode of 2 returns the group.

Please have a look in to the below code.

collaborators = doc.getCollaborators();

     if(collaborators.size() > 0)
  {
 
        collabIter = collaborators.iterator();

          while (collabIter.hasNext())
           {
             member = collabIter.next();
             collabType= member.getCollaboratorType();
             hashValue= collabType.hashCode();
                if(hashValue==2)
                        {
                          collabName= member.getDisplayName();
                          throw new ApplicationException("collabName:" +collabName);
                        }
       
           }
}

In the above code collabName returns the name of the group, with this you can search for the specified group using IbeanHomeLocator for group and then you can get the members in it and their mail Id's

Hope it helps you and let me know if you need any assistance.

Thanks,

Raj.

Former Member
0 Kudos

Hi!

Thanks for the answer!

Actually that second part is the one I'm having trouble with (I forgot to mention I already had separated Groups from Users).

Can I get the Group with IBeanHomeLocator with the group's name and not the group's Id?

If so, I'm guessing the code will be something like this?

//Out of Context being collab a collaborator inside the iterator.

if(collab.getCollaboratorType().toString().equals("group")){

     GroupIBeanHomeIfc groupHome = IBeanHomeLocator(session,GroupIBeanHomeIfc.sHOME_NAME);

     groupName = collab.getDisplayName();

     group = groupHome.findGroup(groupName);

}

is that the way to get it using IBeanHomeLocator?

I think that's the part I'm having trouble with.

Thanks in Advance!

former_member207877
Active Participant
0 Kudos

Hi oscar,

First you have to get the group name by iterating the collaborators in MA and then you have to go to respective  group home, then you have to iterate the members in the group and then you have to create user home and there you will be getting the Email Id's of respective users.

Please see the below code.

collaborators = doc.getCollaborators();

if(collaborators.size() > 0)
{

collabIter = collaborators.iterator();

while (collabIter.hasNext())
{
member = collabIter.next();
collabType= member.getCollaboratorType();
hashValue= collabType.hashCode();
if(hashValue==2)
{
collabName= member.getDisplayName();
groupHome= IBeanHomeLocator.lookup(session,GroupIBeanHomeIfc.sHOME_NAME);
groupBean= groupHome.findGroup(collabName);
groupMemList= groupBean.findGroupMembers();
groupMemItr= groupMemList.iterator();
while(groupMemItr.hasNext())
{
groupMember = groupMemItr.next();
userBeanHome= IBeanHomeLocator.lookup(session, NewUserAccountIBeanHomeIfc.sHOME_NAME);
userBean= userBeanHome.find(groupMember);
userEmail = userBean.getEmail();
//throw new ApplicationException("groupMember:" +userEmail);
}

Please let me know if you need any further assistance.

Thanks,

Raj.

Former Member
0 Kudos

Thanks Raj!

It's good to know I can get the Group with just the name and not necessarily the Id.

Your code really helped me grasp the concept.

Thanks a lot again!

former_member207877
Active Participant
0 Kudos

Welcome Oscar....

Former Member
0 Kudos

Hi,

this is not working fo me:

collabName= member.getDisplayName();

groupBean= groupHome.findGroup(collabName);


groupBeen is allways "null"


The find method from GroupIBeanHomeIfc wants a groupId.

How can i obtain the groupId?


Former Member
0 Kudos

Hi,

findGroup takes object ref.

You can give directly member in place of member.getDipsplayName()

groupBean= groupHome.findGroup(member);

Hope this helps!!

Regards,

Geetika

Former Member
0 Kudos

thank you very much

Former Member
0 Kudos

Hello,

how can i find a group if i have only the group name as String?

findGroup() works only with objects...

regards

Waldemar

former_member207877
Active Participant
0 Kudos

Hello Waldemar,

The below method in group home takes Group ID( String) as input.

GroupIBeanIfc.findGroup(java.lang.String sSearchString)

Find a group using a groupId.

You have to create groups in such a way that Display name equals the External ID


Regards,

Raj

Former Member
0 Kudos

thank you  - it works - i get the group by the groupId

Answers (0)