Activity Forums Salesforce® Discussions How to invite people to user chatter via Apex code?

  • How to invite people to user chatter via Apex code?

  • Piyush

    Member
    April 30, 2016 at 5:50 pm

    #Chatter

  • Abhinav

    Member
    May 27, 2016 at 1:20 pm

    Hi Piyush,

    You can do this in Apex by inserting a CollaborationInvitation.

     

    String emailAddress = '[email protected]';
    CollaborationGroup chatterGroup = [SELECT Id
    FROM CollaborationGroup
    WHERE Name='All acme.com'
    LIMIT 1];
    CollaborationInvitation inv = New CollaborationInvitation();
    inv.SharedEntityId = chatterGroup.id;
    inv.InvitedUserEmail = emailAddress;

    try {
    Insert inv;
    } catch(DMLException e){
    System.debug('There was an error with the invite: '+e);
    }

Viewing 1 - 2 of 2 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos