Example: Define Template Action Links

This example creates an action link template, instantiates the action link group, and associates the action link group with a feed element and posts the feed element.

Just like radio buttons, action links must be nested in a group. Action links within a group share the properties of the group and are mutually exclusive (you can click only one action link within a group). Even if you define only one action link, it must be part of an action link group. The same is true for action link templates and action link group templates.

This example uses one action link in an action link group. When a user clicks the action link, an HTTP POST request is made to a Connect REST API resource, which posts a feed item to Chatter. The HTTP Request Body field holds the request body for the Action URL resource, including the text of the new feed item. In this example, the new feed item includes only text, but it could include other capabilities such as a file attachment, a poll, or even action links.

  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:
Field Value
Name Doc Example
Developer Name Doc_Example
Category Primary action
Executions Allowed Once per User
  1. Use these values in a new Action Link Template:
Field Value
Action Link Group Template Doc Example
Action Type Api
Action URL /services/data/{!Bindings.ApiVersion}/chatter/feed-elements
User Visibility Everyone can see
HTTP Request Body {"subjectId": "{!Bindings.SubjectId}","feedElementType": "FeedItem","body": {"messageSegments": [{"type": "Text","text": "{!Bindings.Text}"}]}}
HTTP Headers Content-Type: application/json
Position 0
Label Key Post
HTTP Method POST
  1. Go back to the Action Link Group Template and select Published. Click Save.

    Make a note of the Action Link Group Template ID and skip to Step 3.

If you have access to the action link group template in Setup, you can get the Action Link Group Template ID and skip to Step 3.

GET

q—A SOQL query string.

An array of query result records.

Use the action link group template ID to instantiate the action link group.

/connect/action-link-group-definitions

POST

Action Link Group Definition Input

This Action Link Group Definition Input request body includes a templateBindings property that is a collection of Action Link Template Binding Input request bodies. In this example, the Action Link Template Binding Input request body includes three template bindings.

To use cURL to make the request, enter the following and substitute your Developer Edition instance name, and OAuth information.

Action Link Group Definition

Associate the action link group with a feed element and post it. You can associate up to 10 action link groups with a feed element.

/chatter/feed-elements

POST

Feed Item Input

This Feed Item Input request body includes a body property that is a Message Body Input request body. In this example, the Message Body Input request body includes a messageSegments property that has one Message Segment Input: Text request body.

This Feed Item Input request body also includes a capabilities property that is a Feed Element Capabilities Input request body. In this example, the Feed Element Capabilities Input includes an associatedActions property that is a Associated Actions Capability Input request body.

Grab the action link group ID from the id property of the Action Link Group Definition response from step 3.

To use cURL to make the request, enter the following and substitute the action link group ID returned in step 2, your Developer Edition instance name, and your OAuth information.

Feed Item