create(), delete(), describeSObjects(), query(), retrieve()
Invitations are available if “Allow Invitations” is enabled for your organization.
Invitations are limited to your allowed domain(s) unless the invite is sent from a private group that allows customers. Allowed domains are set by the administrator.
Invitations to customers are available if “Allow Customer Invitations” is enabled for your organization. Users must have the “Invite Customers to Chatter” permission to send invitations to people outside their Chatter domain.
To invite someone to join a CollaborationGroup, you must be either the owner or a manager of the group or a Salesforce system administrator.
The Salesforce system administrator doesn’t need to be a member of the group in order to send invitations using the API.
You can't send invitations to users of the organization the invite was sent from.
Invited users can view profiles, post on their feed, and join groups, but can't see your Salesforce data or records.
If your organization allows groups with customers, owners and managers of private groups with the “Allow Customers” setting, as well as system administrators, can use this object to invite customers.
The following example shows how to send an invitation to join Chatter:
public void invitePeople(String inviterUserId, String invitedEmail) throws Exception { CollaborationInvitation invitation = new CollaborationInvitation(); invitation.setSharedEntityId(inviterUserId);//pass the userId of the inviter invitation.setInvitedUserEmail(invitedEmail);//email of the invited user insert(invitation); }
The following example shows how to send an invitation to a customer user from a group that allows customers:
public void inviteToGroup(String GroupName, String invitedEmail) throws Exception { QueryResult qr = query("select id from collaborationgroup where name = '" + GroupName); //pass the group name String groupId = qr.getRecords()[0].getId(); CollaborationInvitation invitation = new CollaborationInvitation(); invitation.setSharedEntityId(groupId);//pass the groupId invitation.setInvitedUserEmail(invitedEmail);//email of the invited user insert(invitation); }
String emailAddress = 'bob@external.com'; 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); }