• Fabio Fabiano
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I would like to query the chatter REST API to get the chatter group a person belongs to. How can I query the chatter REST API for chatter groups that a user belongs to where the JSON contains  "myRole" = "StandardMember?" Need to then pass that SalesForce chatter group ID into a subsequent  GET command: /services/data/v39.0/chatter/feeds/record/<SF Group ID>/feed-elements
Hi, I am trying to upsert members to collaboration chatter group but I am receving 
"common.apex.runtime.impl.DmlExecutionException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, User is already a Member of this group" exception.
Can some one suggest how to avoid this.Below is my code
List<DistributionList__c> userID=[SELECT userID__C FROM DistributionList__c where ChatterGroupName__c='testgroup'];
        List<CollaborationGroupMember> CollGroupMembers = new List<CollaborationGroupMember>();
        for(DistributionList__c user : userID)
        {
       
        CollaborationGroupMember member = new CollaborationGroupMember();
        member.MemberId = user.userID__C;
        member.CollaborationGroupId = '0F94D0000004Ebd';
        CollGroupMembers.add(member);
        
        }
        
        try
        {
        
        upsert CollGroupMembers;
        
        }
        catch(DMLException e)
        {
        
        system.debug('The group members werent added properly.  Error: '+ e);
        
        }