The publisher actions feature lets you create actions and add them to the Chatter publisher on the home page, on the Chatter tab, in Chatter groups, and on record detail pages. Actions also appear in the action tray in Salesforce1.Actions enable users to do more in Salesforce and in Salesforce1, such as create or update records and log calls directly in the Chatter feed or from the users’ mobile devices.
There are several types of actions:
• Standard actions are actions that are automatically included when Chatter is enabled—like Post, File, Link, and Poll. You
can customize the order in which these appear, but you can’t edit their properties.
• Create actions let users create records. They’re different from the Quick Create and Create New features on the Salesforce
home page, because create actions respect validation rules and field requiredness, and you can choose each action’s fields.
• Log a call actions let users record the details of phone calls or other customer interactions. These call logs are saved as
completed tasks.
• Send email actions, available only on cases, give users access to a simplified version of the Case Feed Email action on
Salesforce1.
• Update actions let users make changes to a record from the record’s feed.
• Question actions let users ask and search for questions about the records they’re working with.
• Custom actions are Visualforce pages or canvas apps with functionality you define. For example, you might create a custom action to let users write comments longer than 5000 characters, or one that integrates a video conferencing application so support agents can communicate visually with customers.
For create, log-a-call, and custom actions, you can create either object-specific actions or global actions. Update actions must be object-specific.
Step 1: Enable Publisher Actions
Step 6:Create Object-Specific Actions and Setting Predefined Field values
Step 7:Reorder actions in Global Publisher Layout and Assign to Profiles
There are several types of actions:
• Standard actions are actions that are automatically included when Chatter is enabled—like Post, File, Link, and Poll. You
can customize the order in which these appear, but you can’t edit their properties.
• Create actions let users create records. They’re different from the Quick Create and Create New features on the Salesforce
home page, because create actions respect validation rules and field requiredness, and you can choose each action’s fields.
• Log a call actions let users record the details of phone calls or other customer interactions. These call logs are saved as
completed tasks.
• Send email actions, available only on cases, give users access to a simplified version of the Case Feed Email action on
Salesforce1.
• Update actions let users make changes to a record from the record’s feed.
• Question actions let users ask and search for questions about the records they’re working with.
• Custom actions are Visualforce pages or canvas apps with functionality you define. For example, you might create a custom action to let users write comments longer than 5000 characters, or one that integrates a video conferencing application so support agents can communicate visually with customers.
For create, log-a-call, and custom actions, you can create either object-specific actions or global actions. Update actions must be object-specific.
Step 1: Enable Publisher Actions
Step 2: Default Actions
Step 3: Object Specific Actions and Layouts
Step 4: Add Publisher Actions to Page Layout or Global Publisher Layouts
Step 5:Creating Visualforce Pages to Use as Custom Actions
a)Creating Pages for Object-Specific Custom Actions: Visualforce pages you create to use as object-specific actions need to use one of the standard object controllers.
The following code sample shows a page designed to be used as a custom action on the account object, so it uses the standard Account controller. This action lets users create cases from account detail pages, and it has a different user interface from standard create actions.
public with sharing class CreateCaseExtension { private final SObject parent; public Case theCase {get; set;} public String lastError {get; set;} public CreateCaseExtension(ApexPages.StandardController controller) { parent = controller.getRecord(); theCase = new Case(); theCase.accountId = parent.id; lastError = ''; } public PageReference createCase() { createNewCase(); theCase = new Case(); theCase.accountId = parent.id; return null; } private void createNewCase() { try { insert theCase; FeedItem post = new FeedItem(); post.ParentId = ApexPages.currentPage().getParameters().get('id'); post.Body = 'created a case'; post.type = 'LinkPost'; post.LinkUrl = '/' + theCase.id; post.Title = theCase.Subject; insert post; } catch(System.Exception ex){ lastError = ex.getMessage(); } } } |
<apex:page standardcontroller="Account" extensions="CreateCaseExtension" showHeader="false"> <script type='text/javascript' src='/canvas/sdk/js/publisher.js'/> <style> .requiredInput .requiredBlock, .requiredBlock {background-color: white;} .custompubblock div {display: inline-block;} .custompublabel {width:54px;} </style> <script> function refreshFeed() { Sfdc.canvas.publisher.publish({name : 'publisher.refresh', payload : {feed:true}}); } </script> <div> <apex:form > <apex:actionFunction action="{!createCase}" name="createCase" rerender="out" oncomplete="refreshFeed();"/> <apex:outputPanel id="out" > <div class="custompubblock"> <div class="custompublabel">Account:</div><apex:inputField value="{!theCase.accountId}" style="margin-left:0;"/> <div>Contact: </div><apex:inputField value="{!theCase.contactId}" /> </div> <apex:inputField value="{!theCase.description}" style="width:538px;height:92px;margin-top:4px;" /> <div class="custompubblock" style="margin-top:5px;"> <div>Status: </div><apex:inputField value="{!theCase.status}" /> <div>Priority: </div><apex:inputField value="{!theCase.priority}" /> <div>Case Origin: </div><apex:inputField value="{!theCase.origin}" /> </div> </apex:outputPanel> </apex:form><br/> <button type="button" onclick="createCase();" style="position:fixed;bottom:0px;right:0px;padding:5px 10px; font-size:13px; font-weight:bold; line-height: 18px;background-color:#0271BF;background-image:-moz-linear-gradient(#2DADDC, #0271BF);background-repeat:repeat-x;border-color:#096EB3;" id="addcasebutton">Create Case</button> </div> </apex:page>
b)Pages for Global Custom Actions:
public with sharing class CreateCaseController { public Case theCase {get; set;} public String lastError {get; set;} public CreateCaseController() { theCase = new Case(); lastError = ''; } public PageReference createCase() { createNewCase(); theCase = new Case(); return null; } private void createNewCase() { try { insert theCase; FeedItem post = new FeedItem(); post.ParentId = ApexPages.currentPage().getParameters().get('id'); post.Body = 'created a case'; post.type = 'LinkPost'; post.LinkUrl = '/' + theCase.id; post.Title = theCase.Subject; insert post; } catch(System.Exception ex){ lastError = ex.getMessage(); } } } |
<apex:page controller="CreateCaseController" showHeader="false"> <script type='text/javascript' src='/canvas/sdk/js/publisher.js'/> <style> .requiredInput .requiredBlock, .requiredBlock {background-color: white;} .custompubblock div {display: inline-block;} .custompublabel {width:54px;} </style> <script> function refreshFeed() { Sfdc.canvas.publisher.publish({name : 'publisher.refresh', payload : {feed: true}}); } </script> <div> <apex:form > <apex:actionFunction action="{!createCase}" name="createCase" rerender="out" oncomplete="refreshFeed();"/> <apex:outputPanel id="out" > <div class="custompubblock"> <div>Subject: </div><apex:inputField value="{!theCase.subject}" style="width:500px;" /> </div> <div class="custompubblock"> <div class="custompublabel">Account:</div><apex:inputField value="{!theCase.accountId}" style="margin-left:0;"/> <div>Contact: </div><apex:inputField value="{!theCase.contactId}" /> </div> <apex:inputField value="{!theCase.description}" style="width:500px;height:92px;margin-top:4px;" /> <div class="custompubblock" style="margin-top:5px;"> <div>Status: </div><apex:inputField value="{!theCase.status}" /> <div>Priority: </div><apex:inputField value="{!theCase.priority}" /> <div>Case Origin: </div><apex:inputField value="{!theCase.origin}" /> </div> <div style="color:red;">{!lastError}</div> </apex:outputPanel> </apex:form><br/> <button type="button" onclick="createCase();" style="position:fixed;bottom:0px;right:0px;padding:5px 10px; font-size:13px; font-weight:bold; line-height: 18px;background-color:#0271BF;background-image:-moz-linear-gradient(#2DADDC, #0271BF);background-repeat:repeat-x; border-color:#096EB3;" id="addcasebutton">Create Case</button> </div> </apex:page>
Step 7:Reorder actions in Global Publisher Layout and Assign to Profiles
Step 8:Tips
Use these tips as you set up actions to make the feature easy to use and easy to maintain.
a)Tips for Creating Actions
• Action labels longer than approximately 12-14 characters are shortened when they’re displayed in the Chatter publisher. Keep the names short and descriptive.
• Give your actions task-oriented names that tell your users what they do. Use verbs like New, Create, Share, Update, or Import.
• Use the Description field to create notes for yourself about each action. This is especially useful if you’re creating several similar actions for different record types, for example. The description appears in the list of buttons, links, and actions for object-specific actions, or in the list of global actions, as well as on the detail page for the action. Your notes aren’t visible to users.
• When creating custom actions that are going to be displayed in the Chatter publisher, limit their height to 400 pixels so that they are displayed correctly.
b)Tips for Laying Out Actions
• When customizing action layouts, consider what your users will do with them. Minimalism is key. Include only the fields that are really necessary both for them and for whomever will handle the cases, calls, or records that result from those actions.
• To create a single-column layout, such as for display on mobile devices, add fields only in the left column.
• Use predefined field values to set standard values for common fields. For example, on an action that lets users create
opportunities, you might set Prospecting as the predefined value for the Stage field. All new opportunities created through
that action will automatically be assigned to the prospecting stage.If you predefined
values for fields on object records created through an action, you don’t need to add those fields to the action layout.
• Use the Preview As... button on the Action Layout Editor to see how an action layout will appear to different user profiles.
c)Tips for Adding Actions to Publishers
• Because adding too many actions can cause the page to load slowly, we recommend including no more than nine actions total in each publisher, including any standard actions.
• In the full Salesforce site, if you include five or more actions in a publisher, three are shown and the rest are added to the publisher’s More menu. If you include four or fewer actions, they’re all shown.
• In Salesforce1, the first six actions show up on the first page of the actions tray.