Define an Action Link in a Template and Post with a Feed Element

Create an action link and action link group and instantiate the action link group from a template.

This example creates the same action link and action link group as the example Define an Action Link and Post with a Feed Element, but this example instantiates the action link group from a template.

  1. From Setup, enter Action Link Templates in the Quick Find box, then select Action Link Templates.

  2. Use these values in a new Action Link Group Template:

    FieldValue
    NameDoc Example
    Developer NameDoc_Example
    CategoryPrimary action
    Executions AllowedOnce per User
  3. Use these values in a new Action Link Template:

    FieldValue
    Action Link Group TemplateDoc Example
    Action TypeApi
    Action URL/services/data/{!Bindings.ApiVersion}/chatter/feed-elements
    User VisibilityEveryone can see
    HTTP Request Body{ “subjectId”:”{!Bindings.SubjectId}”, “feedElementType”:“FeedItem”, “body”:{ “messageSegments”:[ { “type”:“Text”, “text”:”{!Bindings.Text}” } ] } }
    HTTP HeadersContent-Type: application/json
    Position0
    Label KeyPost
    HTTP MethodPOST
  4. Go back to the Action Link Group Template and select Published. Click Save.

This example calls ConnectApi.ActionLinks.createActionLinkGroupDefinition​(communityId, actionLinkGroup) to create an action link group definition.

It calls ConnectApi.ChatterFeeds.postFeedElement(communityId, feedElement) to associate the action link group with a feed item and post it.