Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sample code: Post Chatter feed with ActionLink
ConnectApi.ActionLinkGroupDefinitionInput defInput = new ConnectApi.ActionLinkGroupDefinitionInput();
defInput.templateId = '07gB00000004CB9'; // Id for ActionLinkGroup
ConnectApi.ActionLinkGroupDefinition def = ConnectApi.ActionLinks.createActionLinkGroupDefinition(null, defInput);
ConnectApi.AssociatedActionsCapabilityInput actionCapabilityInput = new ConnectApi.AssociatedActionsCapabilityInput();
actionCapabilityInput.actionLinkGroupIds = new String[]{def.id};
// Add ActionLink to capability
ConnectApi.FeedElementCapabilitiesInput capabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
capabilitiesInput.associatedActions = actionCapabilityInput;
// MessageBody
ConnectApi.TextSegmentInput text = new ConnectApi.TextSegmentInput();
text.text = 'hoge';
ConnectApi.MessageBodyInput body = new ConnectApi.MessageBodyInput();
body.messageSegments = new ConnectApi.MessageSegmentInput[]{text};
// FeedItem
ConnectApi.FeedItemInput feedItem = new ConnectApi.FeedItemInput();
feedItem.subjectId = 'me';
feedItem.body = body;
feedItem.capabilities = capabilitiesInput;
// Post to Chatter
ConnectApi.ChatterFeeds.postFeedElement(null, feedItem, null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.