cancel
Showing results for 
Search instead for 
Did you mean: 

Sending mail to MA collaborators

Former Member
0 Kudos
94

Hello Expert ,

We have a requirement for sending manual mail to to MA collaborators - which includes normal user and each person added within a group ( in case of group added as collaborator ).

We are trying to create a toolbar script on MA page and with our efforts so far  we are able to send the mail using custom template to normal user added as MA collaborator. However , in case of a group added as collaborator , we are still trying to retrieve each person from group and send them mail  .Can you please help ?

I am pasting piece of code while we trying to retrieve to collaborator group persons . I am able to get only group name .

agreementBean = doc.getRootParentIBean();

CollaboratorCollection = agreementBean.getCollaborators();

collectionsize = CollaboratorCollection.size();

if(collectionsize >0)

{

Collectionbean= CollaboratorCollection.get(2);    // test for retrieving 3rd person which is a group

CollectionName_ObjectRef= Collectionbean.getObjectReference();

UserType= ""+Collectionbean.getCollaboratorType();

if(UserType.equals("user"))

  {

  email=Collectionbean.getCollaboratorEmail();

  }

if(UserType.equals("group"))

  {

  group_name=Collectionbean.getObjectReference();

  a=group_name.getDisplayName();

}

Thanks in advacne

Sudipta

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member207877
Active Participant
0 Kudos

Hello Sudipta,

Its better to get all the users in a group and store them in arrayList and then send a mail to the arraylist as below.

sGroup = new MailTypeEnumType(CollaboratorTypeEnumType.group);

void getCollaborator(IBeanIfc maBean){

ArrayList members = new ArrayList();

userHome= IBeanHomeLocator.lookup(session,NewUserAccountIBeanHomeIfc.sHOME_NAME);

collabs = maBean.getCollaborators();

iter = collabs.iterator();

while (iter.hasNext()){

collaboratorMember = iter.next();

if(!collaboratorMember.getSilent()){

collaboratorType=collaboratorMember.getCollaboratorType();

collaboratorDisplayName = collaboratorMember.getPrincipal().getDisplayName();

if(collaboratorType.equals(sGroup)){

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

groupBean = groupHome.findGroup(collaboratorDisplayName);

groupMembers = groupBean.findGroupMembers();

if(hasValue(groupMembers) @and groupMembers.size() >0){

groupMemberIter = groupMembers.iterator();

while (groupMemberIter.hasNext()){

groupMember = groupMemberIter.next();

memberName = groupMember.getDisplayName();

user = userHome.find(groupMember);

userId = user.getName();

members.add(userId);

}

}

}

}

}

getMemberDetails(members);

}

void getMemberDetails(ArrayList members){

userHome= IBeanHomeLocator.lookup(session,NewUserAccountIBeanHomeIfc.sHOME_NAME);

if(members.size()>0){

for(int i=0; i< members.size(); i++){

memberName = members.get(i);

memberBean= userHome.findByName(memberName.toString());

userName = memberBean.getDisplayName();

userEmail= memberBean.getEmail();

sendEmail(userName, userEmail);

}

}

}

void sendEmail(String user, String userEmail){

params = createMailContent(maName);

sendEmailToMASAO(params, userEmail);

}

and then set all your params and props in mail content.

Regards,

Raj

Former Member
0 Kudos

Thank you very much for your reply Raj.

I have a confusion here in your code I have pasted below

collaboratorDisplayName = collaboratorMember.getPrincipal().getDisplayName();

if(collaboratorType.equals(sGroup)){

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

groupBean = groupHome.findGroup(collaboratorDisplayName);

collaboratorDisplayName is retrieving the group name and not the group ID (external ID) and with the last line you are searching the group with group ID and which is same as group name in your case (I guess ). However , this is possible if group name and ID are same . For my case , these two are different .

Example -  Group name is BASIS Admin and ID is 406.grp.clm_admin


From the RG , I have checked that the method findGroup(String GrpID) searches with group ID and not with name .


Please correct me if I am wrong in understanding your suggestion . Else please help me how to proceed in this case where Group name and ID are different .

former_member207877
Active Participant
0 Kudos

Hello Sudipta,

As there are many methods to recognize the group bean in group home ( ex:- find)

You can get the object reference for the particular collaborator and then you can use in your script as below

if(collabMemType.equalsIgnoreCase("group")){

  collabGroupMemObj= collabMem.getPrincipal();

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

  groupBean= groupHome.find(collabGroupMemObj);

}

If this solves your issue, mark it as correct or helpful

Regards,

Raj

Former Member
0 Kudos

Hello Raj,

Been trying to do something similar, but when I use the "groupBean.findGroupMembers()" function, I am getting a "java.lang.NullPointerException: Null Pointer in Method Invocation". Any idea of why this is pulling null for this field? I do know that there are members in these groups.

Additionally, if this will not work, do you know what table I can create a query on, that may be able to retrieve similar results?

former_member227405
Participant
0 Kudos

Hi Barnett,

Could you please post your piece of code where you are trying to usegroupBean.findGroupMembers().

By De way For getting the member from Group:

FCI_MAS_PURCHASING_GROUP --this is the parent table

FCI_TMP_PGROUP_MEMBER--child table connect the above with Joint.

Thanks

Sonu

Former Member
0 Kudos

Hello,

Thank you for the quick reply.

See below the code up to the point of failure.  This code is based on this thread and https://scn.sap.com/thread/3569534, both giving the same null pointer at when getting to the findGroupMembers.

sGroup = new MailTypeEnumType(CollaboratorTypeEnumType.group);

try {

    collaborators = doc.getCollaborators();

    if(collaborators.size() > 0)

    {

      collabIter = collaborators.iterator();

      while (collabIter.hasNext())

      {

        member = collabIter.next();

if(!member.getSilent()){

        collaboratorType=member.getCollaboratorType();

        collaboratorDisplayName = member.getPrincipal().getDisplayName();

        collaboratorDisplayObjId = member.getPrincipal().getObjectId();

        if(collaboratorType.equals(sGroup)){

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

          groupBean = groupHome.findGroup(collaboratorDisplayName);

          groupMembers = groupBean.findGroupMembers();

Additionally, I saw this table that I was thinking would be the connect table, is there a reason I wouldn't use this?

FCI_UPP_GROUP_REF

Former Member
0 Kudos

FYI,

FCI_TMP_PGROUP_MEMBER is not available in our schema version 7.0.12

former_member227405
Participant
0 Kudos

HI Barnett,

Please try the below code,

collaborators = doc.getCollaborators();

    if(collaborators.size() > 0)

    {

      collabIter = collaborators.iterator();

      while (collabIter.hasNext())

      {

        member = collabIter.next();

if(!member.getSilent())

{

type = member.getCollaboratorType().toString();

if("group".equals(type))

{

collabObjRef = member.getPrincipal();

groupHome = IBeanHomeLocator.lookup(session, collabObjRef);

group = groupHome.find(collabObjRef);

groupMembers = group.findGroupMembers();

}

}

}

}

Thanks

Sonu

Former Member
0 Kudos

Sonu,

The solution above tested successful on my end.

Appreciate your assistance on this.

Do you know why this worked, but the original came back null?  Due to a different version of the system?

Thank you,

Brian

former_member227405
Participant
0 Kudos

Please mark as helpful answer.

Thanks

Sonu