Newer Version Available
CollaborationInvitation
Supported Calls
create(), delete(), describeSObjects(), query(), retrieve()
Special Access Rules
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.
Fields
Usage
Invited users can view profiles, post on their feed, and join groups, but they 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.
Java Samples
The following example shows how to send an invitation to join Chatter:
1public void invitePeople(String inviterUserId, String invitedEmail) throws Exception {
2 CollaborationInvitation invitation = new CollaborationInvitation();
3 invitation.setSharedEntityId(inviterUserId);//pass the userId of the inviter
4 invitation.setInvitedUserEmail(invitedEmail);//email of the invited user
5 insert(invitation);
6}The following example shows how to send an invitation to a customer user from a group that allows customers:
1public void inviteToGroup(String GroupName, String invitedEmail) throws Exception {
2 QueryResult qr = query("select id from collaborationgroup where name = '" +
3 GroupName); //pass the group name
4 String groupId = qr.getRecords()[0].getId();
5 CollaborationInvitation invitation = new CollaborationInvitation();
6 invitation.setSharedEntityId(groupId);//pass the groupId
7 invitation.setInvitedUserEmail(invitedEmail);//email of the invited user
8 insert(invitation);
9}Apex Samples
1String emailAddress = 'bob@external.com';
2CollaborationGroup chatterGroup = [SELECT Id
3 FROM CollaborationGroup
4 WHERE Name='All acme.com'
5 LIMIT 1];
6CollaborationInvitation inv = New CollaborationInvitation();
7inv.SharedEntityId = chatterGroup.id;
8inv.InvitedUserEmail = emailAddress;
9
10try {
11 Insert inv;
12} catch(DMLException e){
13 System.debug('There was an error with the invite: '+e);
14}