Action Link Template

A

In Action Link Template you can instantiate action link groups with common properties from Chatter REST API or Apex. You can package templates and distribute them to other Salesforce organizations.

An action link is a button on a feed element. Clicking an action link can take a user to a Web page, initiate a file download, or invoke an API call to Salesforce or to an external server. An action link includes a URL and an HTTP method, and can include a request body and header information, such as an OAuth token for authentication. Use action links to integrate Salesforce and third-party services into the feed so that users can take action to drive productivity and accelerate innovation.

 

Steps for Action Link Templates.

  1. From Setup, click Create | Action Link Templates.
  2. Click New.
  3. Enter the Name of the template. This name is displayed in the list of action link group templates.This is the only action link group template value you can edit after the action link group template has been published.
  4. Enter the Developer Name. Use the Developer Name to refer to this template from code. It defaults to a version of the Developer Name without spaces. Only letters, numbers, and underscores are allowed.
  5. Select the Category, which indicates where to display the instantiated action link groups on feed elements. Primary displays action link groups in the body of feed elements. Overflow displays action link groups in the overflow menu of feed elements.If an action link group template is Primary, it can contain up to three action link templates. If an action link group template is Overflow, it can contain up to four action link templates.
  6. Select the number of Executions Allowed, which indicates how many times the action link groups instantiated from this template can be executed. (Action links within a group are mutually exclusive.) If you choose Unlimited, the action links in the group cannot be of type Api or ApiAsync.
  7. (Optional) Enter the Hours until Expiration, which is the number of hours from when the action link group is created until it’s removed from associated feed elements and can no longer be executed. The maximum value is 8760.
  8. Click Save.
  9. Click New to create an action link template.The action link template is automatically associated with an action link group template in a master-detail relationship.
  10. Select the Action Type.Values are:
      • Api—The action link calls a synchronous API at the action URL. Salesforce sets the status to SuccessfulStatus or FailedStatus based on the HTTP status code returned by your server.
      • ApiAsync—The action link calls an asynchronous API at the action URL. The action remains in a PendingStatus state until a third party makes a request to /connect/action-links/actionLinkId to set the status to SuccessfulStatus or FailedStatus when the asynchronous operation is complete.
      • Download—The action link downloads a file from the action URL.
      • Ui—The action link takes the user to a web page at the action URL.
  11. Enter an Action URL, which is the URL for the action link.For a UI action link, the URL is a Web page. For a Download action link, the URL is a link to a file to download. For an Api action link or an ApiAsync action link, the URL is a REST resource.Links to resources hosted on Salesforce servers can be relative, starting with a /. All other links must be absolute and start with https://. This field can contain binding variables in the form {!Bindings.key}, for example, https://www.example.com/{!Bindings.itemId}. Set the binding variable’s value when you instantiate the action link group from the template, as in this Chatter REST API example, which sets the value of itemId to 8675309.
    POST /connect/action-link-group-definitions
    
    {
         "templateId" : "07gD00000004C9r",
         "templateBindings" : [
            {
               "key":"itemId",
               "value": "8675309"
            }
         ]
    }

    This field can also contain context variables. Use context variables to pass information about the user who executed the action link to your server-side code. For example, this action link passes the user ID of the user who clicked on the action link to take a survey to the server hosting the survey.                                                                                                                actionUrl=https://example.com/doSurvey?surveyId=1234&salesforceUserId={!userId}

  12. Enter the HTTP Method to use to make the HTTP request.
  13. (Optional) If the Action Type is Api or ApiAsync, enter an HTTP Request Body.This field can contain binding variables and context variables.
  14. (Optional) If the Action Type is Api or ApiAsync, enter HTTP Headers.This field can contain binding variables and context variables.If an action link instantiated from the template makes a request to a Salesforce resource, the template must have a Content-Type header.
  15. (Optional) To make this action link the default link in the group (which has special formatting in the UI), select Default Link in Group. There can be only one default link in a group.
  16. (Optional) To display a confirmation dialog to the user before the action link executes, select Confirmation Required.
  17. Enter the relative Position of the action link within action link groups instantiated from this template. The first position is 0.
  18. Enter the Label Key. This value is the key for a set of UI labels to display for these statuses: NewStatus, PendingStatus, SuccessfulStatus, FailedStatus. For example, the Post set contains these labels: Post, Post Pending, Posted, Post Failed. This image shows an action link with the Post label key when the value of status is SuccessfulStatus:                                                       Untitled11
  19. (Optional) If none of the Label Key values make sense for the action link, set Label Key to None and enter a value in the Label field.Action links have four statuses: NewStatus, PendingStatus, SuccessStatus, and FailedStatus. These strings are appended to the label for each status:
      • label
      • label Pending
      • label Success
      • label Failed

    For example, if the value of label is “See Example,” the values of the four action link states are: See Example, See Example Pending, See Example Success, and See Example Failed.

    An action link can use either a LabelKey or Label to generate label names, it can’t use both.

  20. Select User Visibility, which indicates who can see the action link group.If you select Only creator’s manager can see, the manager is the creator’s manager when the action link group is instantiated. If the creator’s manager changes after the action link group is instantiated, that change is not reflected.
  21. (Optional) If you selected Only Custom User Can See or Everyone Except Custom User Can See, enter a Custom User Alias.                                                                                                                        Enter a string and set its value when you instantiate an action link group, just like you would set the value for a binding variable. However don’t use the binding variable syntax in the template, just enter a value. For example, you could enter ExpenseApprover. This Chatter REST API example sets the value of ExpenseApprover to 005B0000000Ge16;
    POST /connect/action-link-group-definitions
    
    {
         "templateId" : "07gD00000004C9r",
         "templateBindings" : [
            {
               "key":"ExpenseApprover",
               "value": "005B0000000Ge16"
            }
         ]
    }
  22. To create another action link template for this action link group template, click Save & New.
  23. If you’re done adding action link templates to this action link group template, click Save.
  24. To publish the action link group template, click Back to List to return to the Action Link Group Template list view.You must publish a template before you can instantiate an action link group from it in Apex or Chatter REST API.
  25. Click Edit for the action link group template you want to publish.
  26. Select Published and click Save.

 

About the author

Rohit Dere
By Rohit Dere

Category