case_feed_dev_guide
case_feed_dev_guide
Developer Guide
Salesforce, Winter ’25
names and marks. Other marks appearing herein may be trademarks of their respective owners.
CONTENTS
GET STARTED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
OTHER RESOURCES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
GET STARTED WITH THE PUBLISHER AND QUICK ACTION
APIS
Create custom components to interact with the actions on pages in Salesforce Classic and Lightning
EDITIONS
Experience apps. Using Aura components, Visualforce, and Apex, you can customize your app’s
experience, including the case feed. For example, you can use a custom component to let users Available in: Salesforce
send an email with a Knowledge article. Classic and Lightning
The Salesforce Classic Publisher JavaScript APIs, also known as the Case Feed Publisher APIs, and Experience
the Lightning Quick Action JavaScript APIs both interact with page actions. The Publisher APIs work
Available in: Group,
with Visualforce components and pages to interact with publisher actions. The Quick Action APIs Professional, Enterprise,
are called by the lightning:quickActionAPI component to interact with quick actions. Performance, Unlimited,
Note: Starting with API version 43.0 of the Publisher API, the methods used in Visualforce and Developer Editions
components work in Lightning Experience. Just point to the latest version of the Publisher
API script in your Visualforce pages.
To use this guide, it helps if you have a basic familiarity with JavaScript, Visualforce, Apex, Aura components, and the Salesforce user
interface.
SEE ALSO:
How Are the Publisher and Quick Action APIs Different?
Method Parity Between the Publisher API and the Quick Action API
Quick Action APIs in Lightning Experience
Publisher APIs in Salesforce Classic
Customize Case Feed Actions with Visualforce
1
HOW ARE THE PUBLISHER AND QUICK ACTION APIS
DIFFERENT?
The user interface in your org can dictate which development tools you can use to interact with actions. In Salesforce Classic, you use
the Salesforce Classic Publisher JavaScript APIs with Visualforce components to interact with actions. In Lightning Experience, you use
the lightning:quickActionAPI component to call the Lightning Quick Action JavaScript APIs to interact with actions.
Different How? Salesforce Classic Publisher JavaScript APIs Lightning Quick Action JavaScript APIs
Implementation To implement, load the publisher script in your To implement, use the component
Visualforce page or component. For example: lightning:quickActionAPI in your custom
Aura component. For example:
<script
type='text/javascript' <aura:component
src='/canvas/sdk/js/43.0/publisher.js'/> implements="flexipage:availableForRecordHome"
Then you can reference the Publisher APIs through description="My Aura component">
the Sfdc.canvas.publisher object. For
example: <lightning:quickActionAPI
aura:id="quickActionAPI"
Sfdc.canvas.publisher.selectAction({...})
/>
</aura:component>
Supported Actions, Apps, Works with any quick action on a record page in Works with any quick actions on a record page in any
and Pages Salesforce Classic apps for objects that are Lightning Experience app. Supports apps with
feed-enabled. Supports apps with standard standard navigation and console navigation.
navigation and console navigation.
Available Methods Provides the following methods: Provides the following methods:
• publisher.customActionMessage • getAvailableActions
• publisher.invokeAction • getAvailableActionFields
• refresh • getCustomAction
• publisher.selectAction • getSelectedActions
• publisher.setActionInputValues • invokeAction
• refresh
• selectAction
• setActionFieldValues
Lightning Experience and Works in Salesforce Classic and Lightning Experience. Works only in Lightning Experience.
Salesforce Classic Support
Tip: Starting with API version 43.0 of the Tip: Before implementing, review the Quick
Salesforce Classic JavaScript Publisher API, the Action API Considerations.
methods used in Visualforce components and
2
How Are the Publisher and Quick Action APIs Different? Method Parity Between the Publisher API and the Quick Action
API
Different How? Salesforce Classic Publisher JavaScript APIs Lightning Quick Action JavaScript APIs
src="/canvas/sdk/js/43.0/publisher.js"
type="text/javascript">
</script>
IN THIS SECTION:
Method Parity Between the Publisher API and the Quick Action API
The Lightning Quick Action JavaScript API allows you to interact with actions within Aura components similar to how the Salesforce
Classic Publisher JavaScript API allows you to interact with publisher actions within Visualforce pages.
Method Parity Between the Publisher API and the Quick Action API
The Lightning Quick Action JavaScript API allows you to interact with actions within Aura components similar to how the Salesforce
Classic Publisher JavaScript API allows you to interact with publisher actions within Visualforce pages.
This table shows which Quick Action API methods map to Publisher API methods.
Quick Action API Method (in Aura Component) Publisher API Method (in Visualforce)
getAvailableActions N/A
getAvailableActionFields N/A
getCustomAction customActionMessage
getSelectedActions N/A
invokeAction invokeAction
refresh refresh
selectAction selectAction
setActionFieldValues setActionInputValues
3
WORK WITH THE QUICK ACTION AND PUBLISHER APIS
The Lightning Quick Action JavaScript API and the Salesforce Classic Publisher JavaScript API both let you interact with actions. If you’re
building out Aura components in Lightning Experience, use the Quick Action API. This API can interact with all quick actions on a record
page. If you’re writing Visualforce pages in Salesforce Classic, use the Publisher API. This API can interact with any quick actions on record
pages in Salesforce Classic apps for objects that are feed-enabled.
IN THIS SECTION:
Quick Action APIs in Lightning Experience
A lightning:quickActionAPI component allows you to access methods for programmatically controlling quick actions
on record pages. This component is supported in Lightning Experience and supports utility pop-out. This component requires API
version 43.0 and later.
Publisher APIs in Salesforce Classic
The Salesforce Classic Publisher JavaScript API lets your Visualforce pages and components interact with actions you’ve added to a
record page in a Salesforce Classic app for objects that are feed-enabled. The Publisher API works in Salesforce Classic apps with
standard navigation and console navigation. For example, you could develop a component that generates customized, pre-written
text, adds that text to a new post in the Case Feed portal action, and submits the post to the portal, all with one click.
<lightning:quickActionAPI aura:id="quickActionAPI"/>
This component provides similar functionality to the Publisher APIs in Salesforce Classic.
Sample Code
This example creates two buttons that interact with the Update Case quick action on a case record page in Lightning Experience. The
controller code uses the following Quick Action API methods: selectAction, setActionFieldValues, and invokeAction.
Component code:
<aura:component implements="flexipage:availableForRecordHome" description="My Lightning
Component">
<lightning:quickActionAPI aura:id="quickActionAPI" />
4
Work with the Quick Action and Publisher APIs Quick Action APIs in Lightning Experience
<div>
<lightning:button label="Select Update Case Action"
onclick="{!c.selectUpdateCaseAction}"/>
<lightning:button label="Update Case Status Field"
onclick="{!c.updateCaseStatusAction}"/>
</div>
</aura:component>
Controller code:
({
selectUpdateCaseAction : function( cmp, event, helper) {
var actionAPI = cmp.find("quickActionAPI");
var args = { actionName :"Case.UpdateCase" };
actionAPI.selectAction(args).then(function(result) {
// Action selected; show data and set field values
}).catch(function(e) {
if (e.errors) {
// If the specified action isn't found on the page,
// show an error message in the my component
}
});
},
IN THIS SECTION:
Quick Action API Considerations
Before working with the Lightning Quick Action JavaScript API methods, review some considerations that might impact your
implementation.
getAvailableActions
Allows custom components to get a list of the available actions on a record page.
getAvailableActionFields
Allows custom components to get a list of the available fields for a specific action on a record page.
getCustomAction
Allows custom components to access a custom quick action and pass data or messages to it.
5
Work with the Quick Action and Publisher APIs Quick Action API Considerations
getSelectedActions
Allows custom components to access selected quick actions on a record page.
invokeAction
Allows custom components to save or submit the quick action on a record page.
refresh
Refreshes the current record page.
selectAction
Allows custom components to select and focus on a quick action on a record page.
setActionFieldValues
Allows custom components to select a quick action on a record page and then specify field values for that action.
SEE ALSO:
Lightning Component Library: lightning:quickActionAPI
Lightning Components Developer Guide
Tip: The Lightning Quick Action JavaScript APIs can only interact with quick actions that are targetable on the page. Review the
following support.
• Targetable: An action that displays in the highlights panel, including the dropdown action overflow
• Targetable: An action that displays in the publisher, including the More overflow
• Targetable: An action that’s nested in an accordion component section or tab that’s expanded by default
• Not targetable: An action that’s nested in an accordion component section or tab that’s not expanded by default*
*The action becomes targetable after a user opens the accordion section or tab containing the action.
If you use the Lightning Quick Action JavaScript APIs in custom code in a Lightning app, the targeted quick actions must be visible
on the page. If you target an action that isn’t visible on the page, it fails.
6
Work with the Quick Action and Publisher APIs getAvailableActions
The lightning:quickActionAPI component supports utility popout. However, the getCustomAction method doesn’t
work with utility popout yet. The Salesforce Classic Publisher APIs also support utility popout if you place them in a Visualforce page
that’s used in the utility bar. The customActionMessage doesn’t support utility popout either.
The Quick Action APIs don’t support the following items.
• Opportunity products
• Knowledge articles
• Crew Size field on the Service Crew object
• Social quick action in the case feed publisher provided with Social Customer Service
• Experience Cloud sites—the lightning:quickActionAPI component doesn’t work in Experience Cloud sites
getAvailableActions
Allows custom components to get a list of the available actions on a record page.
Arguments
None.
Sample Code
getAvailableActions : function( cmp, event, helper) {
var actionAPI = cmp.find("quickActionAPI");
actionAPI.getAvailableActions().then(function(result){
//All available actions shown;
}).catch(function(e){
if(e.errors){
//If the specified action isn't found on the page, show an error message
in the my component
}
});
}
7
Work with the Quick Action and Publisher APIs getAvailableActionFields
Response
Returns a Promise. Success resolves to a response object. The Promise is rejected on error response.
success: true,
actions:
{actionName: "Case._LightningUpdateCase", recordId: "recordId", type: "QuickAction"}
{actionName: "FeedItem.TextPost", recordId: "recordId", type: "QuickAction"}
{actionName: "Case.LogACall", recordId: "recordId", type: "QuickAction"}
{actionName: "Case.SendEmail", recordId: "recordId", type: "QuickAction"}
errors: []
getAvailableActionFields
Allows custom components to get a list of the available fields for a specific action on a record page.
Arguments
Name Type Description
actionName string The name of the quick action that you want to access.
The actionName parameter starts with the Salesforce object, followed by the quick action name. For example:
actionName: "Case.LogACall"
Sample Code
getAvailableActionFields : function( cmp, event, helper) {
var actionAPI = cmp.find("quickActionAPI");
var args = {actionName :"Case.LogACall", entityName:"Case" };
actionAPI.getAvailableActionFields(args).then(function(result){
//All available action fields shown for Log a Call
}).catch(function(e){
if(e.errors){
//If the specified action isn't found on the page, show an error message
in the my component
}
});
}
Response
Returns a Promise. Success resolves to a response object. The Promise is rejected on error response.
success: true,
fields:
{fieldName: "Subject", type: "textEnumLookup"}
{fieldName: "Description", type: "TextArea"}
8
Work with the Quick Action and Publisher APIs getCustomAction
getCustomAction
Allows custom components to access a custom quick action and pass data or messages to it.
Arguments
Name Type Description
actionName string The name of the quick action that you want to access.
The actionName parameter starts with the Salesforce object, followed by the quick action name. For example:
actionName: "Case.MyCustomAction"
Sample Code
actionApi.getCustomAction(args).then(function(customAction) {
if (customAction) {
customAction.subscribe(function(data) {
// Handle quick action message
});
customAction.publish({
message : "Hello Custom Action",
Param1 : "This is a parameter"
});
}
}).catch(function(error) {
// We can't find that custom action.
});
Response
Returns a Promise. Success resolves to a response object. The Promise is rejected on error response.
success: boolean,
customAction: {
subscribe: function,
publish: function,
unsubscribe: function
},
unavailableAction: boolean,
errors: []
getSelectedActions
Allows custom components to access selected quick actions on a record page.
9
Work with the Quick Action and Publisher APIs invokeAction
Arguments
None.
Response
Returns a Promise. Success resolves to a response object. The Promise is rejected on error response.
success: boolean,
actions: [ {
actionName: "UpdateCase",
recordId: "recordId",
type: "QuickAction"
} ],
errors: []
invokeAction
Allows custom components to save or submit the quick action on a record page.
Arguments
Name Type Description
actionName string The name of the quick action that you want to access.
The actionName parameter starts with the Salesforce object, followed by the quick action name. For example:
actionName: "Case.UpdateCase"
Response
Returns a Promise. Success resolves to a response object. The Promise is rejected on error response.
refresh
Refreshes the current record page.
Arguments
None.
selectAction
Allows custom components to select and focus on a quick action on a record page.
10
Work with the Quick Action and Publisher APIs setActionFieldValues
Arguments
Name Type Description
actionName string The name of the quick action that you want to access.
The actionName parameter starts with the Salesforce object, followed by the quick action name. For example:
actionName: "Case.UpdateCase"
Response
Returns a Promise. Success resolves to a response object. The Promise is rejected on error response.
success: boolean,
unavailableAction: boolean,
targetableFields: [{
fieldName: "Status",
type: "PickList"
}],
actionName: string,
errors: []
setActionFieldValues
Allows custom components to select a quick action on a record page and then specify field values for that action.
Because this method also selects the quick action, you don't need to use the selectAction method. To submit the quick action
updates, pass submitOnSuccess as true.
Arguments
Name Type Description
actionName string The name of the quick action that you want to access.
parentFields Object Optional. The fields that you want to update on the current
record. For example, if you want to set field values on the
Email quick action on the case record page, the case object
is the parent record.
targetFields Object The fields that you want to update on the quick action.
submitOnSuccess boolean Optional. Set to true if you want to save and submit the quick
action after setting the field values. Default is false.
The actionName parameter starts with the Salesforce object, followed by the quick action name. For example:
actionName: "Case.UpdateCase"
11
Work with the Quick Action and Publisher APIs Publisher APIs in Salesforce Classic
The parentFields and targetFields objects contain a list of field names with values for each field. Each field can optionally
specify the insertion behavior using the insertType key, which can be replace (default), cursor, or begin. For example:
var parentFields = { Status: {value: "Closed"},
Subject: {value: "Case subject", insertType: "cursor"} }
var targetFields = { ToAddress: {value: "[email protected]"},
TextBody: {value: "the text body", insertType: "cursor"} }
We recommend that you don’t use this API with the following items:
• Read-only fields
• Encrypted fields
• Fields within social actions
Response
Returns a Promise. Success resolves to a response object. The Promise is rejected on error response.
success: boolean,
actionName: "LogACall",
unavailableAction: boolean,
targetFieldErrors: [{
Status: {message: "error"},
Subject: {message: "error",
}],
errors: []
If you use the JavaScript Publisher API methods in custom code in a Lightning app, the targeted
quick actions must be visible on the page. If you target an action that isn’t visible on the page,
it fails.
12
Work with the Quick Action and Publisher APIs Publisher APIs in Salesforce Classic
publisher.selectAction
Code Sample
This code snippet selects the email action and puts it in focus.
Sfdc.canvas.publisher.publish({name:"publisher.selectAction",payload:{actionName:"Case.Email"}});
publisher.setActionInputValues
• portalPostFields–Available on Case.CaseComment;
the standard available fields on the Case Feed portal action:
– body
– sendEmail (boolean)
13
Work with the Quick Action and Publisher APIs Publisher APIs in Salesforce Classic
– On SocialPostAPIName.SocialPost: content
and insertType (optional). Valid values for
insertType are begin, end, cursor, and
replace . The default value is replace. (Available in
API versions 32.0 and later)
• parentFields—Available on Case.ChangeStatus,
Case.Email, and Case.LogACall; standard and custom
fields on case. Lookup fields aren’t supported.
Code Sample
This code snippet populates the fields on an email message with predefined values, and sets the status of the associated case to
Closed.
Sfdc.canvas.publisher.publish({name:"publisher.setActionInputValues",
payload:{actionName:"Case.Email",parentFields: {Status:{value:"Closed"}},
emailFields: {to:{value:"[email protected]"},cc:{value:"[email protected]"},
bcc:{value:"[email protected]"},
subject:{value:"Your Issue Has Been Resolved"},
body:{value:"Thank you for working with our support department.
We've resolved your issue and have closed this ticket, but
please feel free to contact us at any time if you encounter this
problem again or need other assistance."}}}});
This code snippet inserts the phrase “Hello World” in the body of the Post action at the current cursor position.
Sfdc.canvas.publisher.publish({name:"publisher.setActionInputValues",
payload:{actionName:"FeedItem.TextPost", targetFields:{body:{value:"Hello World",
insertType:"cursor"}}}});
14
Work with the Quick Action and Publisher APIs Publisher APIs in Salesforce Classic
publisher.invokeAction
Code Sample
This code snippet triggers the submit function on the email action, sending an email message and generating a related feed item.
Sfdc.canvas.publisher.publish({name:"publisher.invokeAction",
payload:{actionName:"Case.Email"}});
publisher.customActionMessage
Code Sample
This code snippet passes the Hello world event to the action my_custom_action.
Sfdc.canvas.publisher.publish({name:"publisher.customActionMessage",
payload:{actionName:"my_custom_action", message:"Hello world"}});
This code snippet is what my_custom_action uses to listen to the Hello world event.
Sfdc.canvas.publisher.subscribe([{name : "publisher.customActionMessage", onData :
function(e) {alert(e.message);}}]);
publisher.refresh
Refreshes the current record page. This method has no arguments.
15
Work with the Quick Action and Publisher APIs Publisher APIs in Salesforce Classic
This code sample shows an Apex class containing a custom controller used by the Visualforce page below.
public with sharing class KBController {
public List<FAQ__kav> articles {get; set;}
public KBController() {
articles = [select knowledgearticleid, id, title, content__c from FAQ__kav where
This code sample shows the Visualforce page that’s used as the custom console component in the use case above.
<apex:page sidebar="false" controller="KBController">
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'/>
<style>
.sampleTitle { background-color: #99A3AC;color:#FFFFFF;font-size:1.1em;
font-weight: bold;padding:3px 6px 3px 6px; }
.sampleHeader { }
.sampleArticleList { min-width: 250px; padding: 8px 0 5px 0;}
.sampleUl { padding: 0; margin: 0; list-style: none;}
.sampleLi { display: block; position: relative; margin: 0;}
16
Work with the Quick Action and Publisher APIs Publisher APIs in Salesforce Classic
onclick="emailArticle(document.getElementById
('content_{!article.id}').innerHTML);"/>
<span class="sampleArticle">
<a href="/{!article.knowledgearticleid}"
title="{!article.title}" class="sampleLink">
{!article.title}</a>
</span>
</div>
</li>
</ul>
</apex:repeat>
</div>
</div>
</apex:page>
17
CUSTOMIZE CASE FEED ACTIONS WITH VISUALFORCE
The Salesforce-provided Case Feed Visualforce components enable you to create a customized page within a Salesforce Classic app. To
create custom Salesforce console components that interact with Case Feed actions, publish the Case Feed-related events using the
publish method on the Sfdc.canvas.publisher object in the Salesforce Classic Publisher JavaScript API.
Important: This section of the guides focuses on customizing the Case Feed in a Salesforce Classic console app. However, you
can use the Visualforce components in Salesforce Classic apps with standard navigation that use the case object, too. You can also
use the Case Feed Visualforce components in Lightning Experience. However, there are some issues with refresh for certain
Visualforce components. We recommend that you use these components in Salesforce Classic only.
Requirements
Before customizing Case Feed in the Salesforce console, make sure that:
• Case Feed, Chatter, and feed tracking on cases are enabled in your organization.
• Your organization has at least one Salesforce console app. For more information, see Set Up a Salesforce Console App in Salesforce
Classic.
• You’re familiar with developing with Visualforce. Check out the Visualforce Developer Guide for a comprehensive overview.
Note: Lookup field filters aren’t supported on any of the Case Feed Visualforce components.
Customization Overview
Here are the Case Feed Visualforce components.
apex:logCallPublisher Displays and controls the appearance and functionality of the Case Feed Log a Call action.
support:caseArticles Displays and controls the appearance and functionality of the Articles tool for cases.
support:CaseFeed Replicates the standard Case Feed page, including all standard actions, links, and buttons.
support:portalPublisher Displays and controls the appearance and functionality of the Case Feed Portal action.
18
Customize Case Feed Actions with Visualforce Customizing the Layout and Appearance of Case Feed
In addition, the chatter:feed component has two attributes related to Case Feed.
• feedItemType: Lets you specify how feed items are filtered.
• showPublisher: Lets you display the Chatter publisher on a page.
Here are the Publisher JavaScript APIs.
invokeAction Triggers the submit function (such as sending an email or posting a portal comment) on
the specified action.
setActionInputValues Specifies which fields on the action should be populated with specific values, and what
those values are.
chatter:feed Attributes
feedItemType String The feed item type on which the Entity or 25.0
UserProfileFeed is filtered. See the Type field on the
FeedItem object listing in the API Object Reference Guide
for accepted values.
onComplete String The Javascript function to call after a post or comment 25.0
is added to the feed
rendered Boolean A Boolean value that specifies whether the additional 20.0 global
fields defined in the action layout are displayed.
19
Customize Case Feed Actions with Visualforce Customizing the Layout and Appearance of Case Feed
Use Case
Acme Entertainment creates online games used by more than a million people on multiple platforms. Acme’s 1500 support agents use
desktop computers, laptops, and tablets, and the company wanted to customize the Case Feed page to standardize its look and feel
across different devices. They also wanted to make it easier for agents to track case activities using filters.
Acme used these steps to create a customized Case Feed page:
1. Using the chatter:feed component, they positioned the feed in the sidebar so the publisher and other Case Feed tools are always in
the center of the page.
2. They repositioned the feed filter and auto-selected default filters depending on case origin:
• If the case origin is email,. the default filter is Emails.
• If the case origin is phone, the default filter is Call Logs.
• If the case origin is Web, the default filter is Portal Answers.
20
Customize Case Feed Actions with Visualforce Customizing the Layout and Appearance of Case Feed
Code Sample
This code sample shows a Visualforce page with custom Email, Portal, Log a Call, and Case Details tabs.
<apex:page standardController="Case">
<!-- Repositions publisher tabs to a horizontal arrangement on top of the page -->
<ul class="demoNav" style="list-style: none; overflow: hidden">
<li style="float:left">
<a id="custom_email_tab" class="selected" href="javascript:void(0);"
onclick="getDemoSidebarMenu().selectMenuItem('custom_email_tab');">
<span class="menuItem">Email Customer</span>
</a>
</li>
<li style="float:left">
<a id="custom_log_call_tab" href="javascript:void(0);"
onclick="getDemoSidebarMenu().selectMenuItem('custom_log_call_tab');">
<span class="menuItem">Log Call</span>
</a>
</li>
<li style="float:left">
<a id="custom_portal_tab" href="javascript:void(0);"
onclick="getDemoSidebarMenu().selectMenuItem('custom_portal_tab');">
<span class="menuItem">Portal Answer</span>
</a>
</li>
<li style="float:left">
<a id="custom_detail_tab" href="javascript:void(0);"
onclick="getDemoSidebarMenu().selectMenuItem('custom_detail_tab');">
<span class="menuItem">Case Details</span>
</a>
</li>
</ul>
21
Customize Case Feed Actions with Visualforce Customizing the Layout and Appearance of Case Feed
<!-- Include library for using service desk console API -->
<apex:includeScript value="/support/console/25.0/integration.js"/>
this.selectMenuItem = function(tabId) {
for (var index in menus) {
var tabEl = document.getElementById(index);
var vfEl = document.getElementById(menus[index]);
if (index == tabId) {
tabEl.className = "selected";
vfEl.style.display = "block";
} else {
tabEl.className = "";
vfEl.style.display = "none";
}
}
};
}
var demoSidebarMenu;
var getDemoSidebarMenu = function() {
if (!demoSidebarMenu) {
demoSidebarMenu = new DemoSidebarMenu();
}
return demoSidebarMenu;
};
</script>
<!-- Javascript for firing event to refresh feed in the sidebar -->
<script type="text/javascript">
22
Customize Case Feed Actions with Visualforce Customizing the Layout and Appearance of Case Feed
function refreshFeed() {
sforce.console.fireEvent
('Cirrus.samplePublisherVFPage.RefreshFeedEvent', null, null);
}
</script>
</apex:page>
The following sample shows an Apex class containing a controller extension to be used with the Visualforce page above.
public class MyCaseExtension {
private final Case mycase;
private String curFilter;
This sample shows a Visualforce page with custom feed filters and Chatter feed for cases. You can use this page in the sidebar of a
Salesforce console.
<apex:page standardController="Case" extensions="MyCaseExtension">
23
Customize Case Feed Actions with Visualforce Customizing the Layout and Appearance of Case Feed
id="custom_email_option">Emails</option>
<option value="CaseCommentPost"
id="custom_web_option">Portal Answers</option>
<option value="CallLogPost"
id="custom_phone_option">Call Logs</option>
</select>
</div>
<apex:form >
<!-- actionFunction for refreshing feed when the feed filter is updated -->
<apex:actionFunction action="{!refreshFeed}" name="changeFilter"
reRender="custom_demoFeed" immediate="true" >
<apex:param name="firstParam" assignTo="{!curFilter}" value="" />
</apex:actionFunction>
<!-- actionFunction for refreshing feed when there is an event fired for
updating the feed -->
<apex:actionFunction action="{!refreshFeed}" name="updateFeed"
reRender="custom_demoFeed" immediate="true" />
</apex:form>
<!-- Include library for using service desk console API -->
<apex:includeScript value="/support/console/25.0/integration.js"/>
<!-- Javascript for adding event listener for refreshing feed -->
<script type="text/javascript">
<!-- Javascript for initializing select option based on case origin -->
<script type="text/javascript">
window.onload = function() {
var caseOrigin = "{!case.origin}";
if (!caseOrigin) {
caseOrigin = "all";
} else {
caseOrigin = caseOrigin.toLowerCase();
}
var selectElem = document.getElementById('custom_' + caseOrigin + '_option');
if (selectElem) {
selectElem.selected = true;
24
Customize Case Feed Actions with Visualforce Customizing the Email Action
}
}
</script>
</apex:page>
Note: The apex:emailPublisher component closes a task in Open Activities created by Email-to-Case inbound email.
apex:emailPublisher Attributes
bccVisibility String The visibility of the BCC field can be 'editable', 25.0
'editableWithLookup', 'readOnly', or 'hidden'.
emailBody String The default text value of the email body. 25.0
emailBodyFormat String The format of the email body can be 'text', 'HTML', or 25.0
'textAndHTML'.
enableQuickText Boolean A Boolean value that specifies whether the Quick Text 25.0
autocomplete functionality is available in the action.
entityId id Entity ID of the record for which to display the Email Yes 25.0
action. In the current version, only Case record ids are
supported.
expandableHeader Boolean A Boolean value that specifies whether the header is 25.0
expandable or fixed.
25
Customize Case Feed Actions with Visualforce Customizing the Email Action
onSubmitFailure String The JavaScript invoked if the email is not successfully 25.0
sent.
onSubmitSuccess String The JavaScript invoked if the email is successfully sent. 25.0
rendered Boolean A Boolean value that specifies whether the component 25.0 Global
is rendered on the page. If not specified, this value
defaults to true.
reRender Object The ID of one or more components that are redrawn 25.0
when the email is successfully sent. This value can be
a single ID, a comma-separated list of IDs, or a merge
field expression for a list or collection of IDs.
sendButtonName String The name of the send button in the Email action. 25.0
showAdditionalFields Boolean A Boolean value that specifies whether the additional 25.0
fields defined in the action layout are displayed.
showAttachments Boolean A Boolean value that specifies whether the attachment 25.0
selector is displayed.
showSendButton Boolean A Boolean value that specifies whether the send button 25.0
is displayed.
showTemplates Boolean A Boolean value that specifies whether the template 25.0
selector is displayed.
subjectVisibility String The visibility of the Subject field can be 'editable', 25.0
'readOnly', or 'hidden'.
submitFunctionName String The name of a function that can be called from 25.0
JavaScript to send the email.
title String The title displayed in the Email action header. 25.0
width String The width of the action in pixels (px) or percentage (%). 25.0
26
Customize Case Feed Actions with Visualforce Customizing the Portal Action
Use Case
Cirrus Computers, a multinational hardware company with technical support agents in 10 support centers throughout the world, wanted
to customize the Email action to increase standardization in outgoing messages and to limit the fields agents could edit.
Cirrus used the apex:emailPublisher component to create an Email action that:
• Has read-only To and Subject fields.
• Pre-populates those fields, ensuring consistency and increasing agents’ efficiency when writing email messages.
Code Sample
<apex:page standardController="Case" >
<apex:emailPublisher entityId="{!case.id}"
fromVisibility="selectable"
subjectVisibility="readOnly"
subject="Your Cirrus support request"
toVisibility="readOnly"
toAddresses="{!case.contact.email}"
emailBody=""/>
</apex:page>
support:portalPublisher Attributes
27
Customize Case Feed Actions with Visualforce Customizing the Portal Action
autoCollapseBody Boolean A Boolean value that specifies whether the answer 25.0
body is collapsed when it is empty.
entityId id Entity ID of the record for which to display the Portal Yes 25.0
action. In the current version, only Case record ids are
supported.
onSubmitSuccess String The JavaScript invoked if the answer was successfully 25.0
published to the portal.
rendered Boolean A Boolean value that specifies whether the component 25.0 Global
is rendered on the page. If not specified, this value
defaults to true.
reRender Object The ID of one or more components that are redrawn 25.0
when the answer is successfully published. This value
can be a single ID, a comma-separated list of IDs, or a
merge field expression for a list or collection of IDs.
showSendEmailOption Boolean A Boolean value that specifies whether the option to 25.0
send email notification should be displayed.
showSubmitButton Boolean A Boolean value that specifies whether the submit 25.0
button should be displayed.
submitButtonName String The name of the submit button in the portal action. 25.0
submitFunctionName String The name of a function that can be called from 25.0
JavaScript to publish the answer.
title String The title displayed in the portal action header. 25.0
width String The width of the action in pixels (px) or percentage 25.0
(%).
Use Case
The Wellness Group is a healthcare company with 300 support agents in three tiers of support. Wellness wanted to customize the Portal
action to reduce the amount of standard text, such as greetings and closings, agents had to type when replying to customers, which
would help increase agents’ efficiency and improve the standardization of portal communications.
Wellness used the support:portalPublisher component to create a Portal action that:
28
Customize Case Feed Actions with Visualforce Customizing the Log a Call Action
• Pre-populates the message body with a standard opening (“Hello {name}, and thanks for your question.”) and a standard closing
(“Please let me know if there’s anything else I can do to help.”).
• Lets agents edit the pre-populated text if needed.
Code Sample
<apex:page standardController="Case">
<support:portalPublisher entityId="{!case.id}" width="800px"
answerBody="Hello {!Case.Contact.FirstName}, and thanks for your question.
\n\nPlease let me know if there's anything else I can do to help.">
</support:portalPublisher>
</apex:page>
apex:logCallPublisher Attributes
entityId id Entity ID of the record for which to display the Log Yes 25.0
a Call action. In the current version, only Case record
ids are supported.
29
Customize Case Feed Actions with Visualforce Customizing the Log a Call Action
logCallBodyHeight String The height of the Log a Call body in em. 25.0
onSubmitFailure String The JavaScript invoked if the call is not successfully 25.0
logged.
rendered Boolean A Boolean value that specifies whether the 25.0 Global
component is rendered on the page. If not specified,
this value defaults to true.
reRender Object The ID of one or more components that are redrawn 25.0
when the call is successfully logged. This value can
be a single ID, a comma-separated list of IDs, or a
merge field expression for a list or collection of IDs.
showAdditionalFields Boolean A Boolean value that specifies whether the additional 25.0
fields defined in the action layout should be
displayed.
showSubmitButton Boolean A Boolean value that specifies whether the submit 25.0
button should be displayed.
submitButtonName String The name of the submit button in the Log a Call 25.0
action.
submitFunctionName String The name of a function that can be called from 25.0
JavaScript to publish the call log.
title String The title displayed in the Log a Call action header. 25.0
width String The width of the action in pixels (px) or percentage 25.0
(%).
Use Case
Stellar Wireless is a mobile phone provider with several high-volume call centers, where agents are rewarded both for solving customers’
issues quickly and for keeping detailed, accurate records of customer interactions. Stellar wanted to customize the Log a Call action so
it was open and available to agents at all times, even when they were working with another action, giving them a quick and easy way
of taking notes about incoming calls.
Stellar used the apex:logCallPublisher component to create a Log a Call action that:
• Appears in the footer of the page, replacing the standard interaction log.
• Is open and available by default each time a support agent opens a case.
30
Customize Case Feed Actions with Visualforce Customizing the Log a Call Action
Code Sample
<apex:page standardController="Case">
<apex:logCallPublisher entityId="{!case.id}"
width="100%"
title="Log a Call"
autoCollapseBody="false"
showAdditionalFields="false"
submitButtonName="Save Log" />
</apex:page>
After you create a Visualforce page with this code, follow these steps to use the Log a Call action you create as a replacement for the
standard interaction log:
1. From the object management settings for cases, go to Page Layouts.
2. Select the layout you’re using from the Page Layouts for Case Feed Users list, and then select Edit detail view.
3. Click the Custom Console Components link at the top of the page.
4. In the Subtab Components section, use the lookup to select the page you created as the component to use for the bottom sidebar.
5. Specify the height of the action.
6. Click Save.
7. In the page layout editor, click Layout Properties.
8. Uncheck Interaction Log.
9. Click OK.
10. Click Save.
SEE ALSO:
Salesforce Help: Find Object Management Settings
31
Customize Case Feed Actions with Visualforce Customizing the Articles Tool
support:caseArticles Attributes
attachToEmailEnabled Boolean A Boolean value that specifies whether articles can 25.0
be attached to emails.
bodyHeight String The height of the body in pixels (px) or 'auto' to 25.0
automatically adjust to the height of the currently
displayed list of articles.
caseId id Case ID of the record for which to display the case Yes 25.0
articles.
categories String Data categories to be used to filter the search. The 25.0
format of this value should be:
'CatgeoryGroup1:Category1' where CategoryGroup1
and Category1 are the names of a Category Group
and a Category respectively. Multiple category filters
can be specified separated by commas but only one
per category group.
defaultSearchType String Specifies the default query of the article search form 25.0
when it is first displayed. The value can be 'keyword',
'mostViewed', or 'lastPublished'.
language String The language used for filtering the search if 25.0
multilingual Salesforce Knowledge is enabled.
32
Customize Case Feed Actions with Visualforce Customizing the Articles Tool
onSearchComplete String The JavaScript invoked after an article search has 25.0
completed.
rendered Boolean A Boolean value that specifies whether the 25.0 Global
component is rendered on the page. If not specified,
this value defaults to true.
reRender Object The ID of one or more components that are redrawn 25.0
when the result of the action method returns to the
client. This value can be a single ID, a
comma-separated list of IDs, or a merge field
expression for a list or collection of IDs.
searchFieldWidth String The width of the keyword search field in pixels (px). 25.0
searchFunctionName String The name of a function that can be called from 25.0
JavaScript to search for articles if the widget is
currently in search mode.
showAdvancedSearch Boolean A Boolean value that specifies whether the advanced 25.0
search link should be displayed.
titlebarStyle String The style of the title bar can be 'expanded', 25.0
'collapsed', 'fixed', or 'none'.
Use Case
Cirrus Computers wanted to customize the Case Feed articles tool so agents could more easily find articles to help resolve customers’
issues.
Cirrus used the support:caseArticles component to create an articles tool that:
1. Appears in the right sidebar of the page and is open by default on all case pages.
2. Uses search-as-you-type functionality to show suggested articles quickly.
3. Lets agents attach articles to messages they write with the email action.
4. Displays the most recently published articles when no articles are attached to a case.
33
Customize Case Feed Actions with Visualforce Replicating a Standard Case Feed Page
Code Sample
<apex:page standardController="Case">
<div style="margin-left:-10px;margin-right:-10px;">
<div style="background-color: #99A3AC;color:#FFFFFF;font-size:1.1em;font-weight:
bold;padding:3px 6px 3px 6px;">Articles</div>
<support:caseArticles caseId="{!case.id}"
bodyHeight="auto"
titlebarStyle="none"
searchButtonName="Search"
searchFieldWidth="200px"
defaultSearchType="lastPublished"
/>
</div>
</apex:page>
34
Customize Case Feed Actions with Visualforce Replicating a Standard Case Feed Page
support:CaseFeed Attributes
rendered Boolean A Boolean value that specifies whether the component is 26.0 global
rendered on the page. If not specified, this value defaults to
true.
Use Case
National Foods is a food service company supplying restaurants and corporate cafeterias throughout the United States. National’s support
operations includes both call center agents who work primarily on desktop computers and field agents who work mainly on mobile
devices. The company wanted a simplified Case Feed page that would be easy for its field agents to use, and also wanted to give its call
center agents access to the full Case Feed functionality.
National used the support:CaseFeed component to recreate the standard Case Feed page for its call center agents working on
desktops, and created a custom page for its field agents working on mobile devices.
Code Sample
<apex:page standardController="Case"
extensions="CasePageSelectorExtension" showHeader="true" sidebar="false">
<apex:dynamicComponent componentValue="{!casePage}"/>
</apex:page>
The following sample shows an Apex class containing a controller extension to be used with the Visualforce page above.
public class CasePageSelectorExtension {
boolean isFieldAgent;
35
Customize Case Feed Actions with Visualforce Create Custom Actions
String caseId;
Use Case
Viaggio Italiano is a boutique travel agency specializing in tours of Italy. The company tracks multiple details for each client, including
flights, ground transportation specifics, dietary preferences, and itineraries. Viaggio Italiano’s agents needed the ability to create long
case comments but were limited to 1000 characters for standard case notes. The company wanted a way to bypass this limit.
Viaggio Italiano used Visualforce to create a page that includes the ability to post a case comment, which can be up to 4000 characters
long. The company then added the page as a custom action by editing the Case Feed page layout.
36
Customize Case Feed Actions with Visualforce Create Custom Actions
Code Samples
The following code sample shows a custom Post Case Comment action for an organization that doesn’t have actions in the publisher
enabled, or that has actions in the publisher enabled but uses the Case Feed Settings page, not the page layout editor, to choose and
configure the actions in the Case Feed publisher.
<apex:page standardcontroller="Case"
extensions="CaseCommentExtension" showHeader="false">
<apex:includeScript value="/support/api/26.0/interaction.js"/>
<div>
<apex:form >
<!-- Creates a case comment and on complete notifies the Case Feed page
that a elated list and the feed have been updated -->
<apex:actionFunction action="{!addComment}" name="addComment" rerender="out"
oncomplete="sforce.interaction.entityFeed.refreshObject('{!case.id}',
false, true, true);"/>
<apex:outputPanel id="out" >
<apex:inputField value="{!comment.commentbody}" style="width:98%;
height:160px;" />
</apex:outputPanel>
</apex:form><br />
<button type="button" onclick="addComment();" style="position:fixed; bottom:0px;
This is the code to use for the custom Post Case Comment action if your organization has actions in the publisher enabled and you’ve
opted to use the page layout editor to choose and configure actions in the Case Feed publisher.
<apex:page standardcontroller="Case"
extensions="CaseCommentExtension" showHeader="false">
<!-- Uses publisher.js rather than interaction.js -->
<apex:includeScript value="/canvas/sdk/js/28.0/publisher.js"/>
<div>
<apex:form >
<!-- Creates a case comment and on complete notifies the Case Feed page
that a related list and the feed have been updated -->
<apex:actionFunction action="{!addComment}" name="addComment" rerender="out"
37
Customize Case Feed Actions with Visualforce Create Custom Actions
</div>
</apex:page>
The following sample shows an Apex class containing a controller extension to be used with either version of the Visualforce page above.
public with sharing class CaseCommentExtension {
private final Case caseRec;
public CaseComment comment {get; set;}
Additional Steps
After creating a Visualforce page, make it available to users.
First, give profiles access to the page:
1. From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages.
2. Click Security next to the name of the page you created.
3. Choose the profiles you want to be able to access the page.
4. Click Save.
Then include the page as a custom action. If you’re using the Case Feed Settings page to choose and configure actions:
1. From the object management settings for cases, go to Page Layouts.
2. How you access the Case Feed Settings page depends on what kind of page layout you’re working with..
• For a layout in the Case Page Layouts section, click Edit, and then click Feed View in the page layout editor.
• For a layout in the Page Layouts for Case Feed Users section, click the down arrow and choose Edit feed view. (This
section appears only for organizations created before Spring ’14.)
38
Customize Case Feed Actions with Visualforce Create Custom Actions
SEE ALSO:
Salesforce Help: Find Object Management Settings
39
OTHER RESOURCES
In addition to this guide, there are other resources available for you as you learn how to use the Salesforce Classic Publisher JavaScript
API and Lightning Quick Action JavaScript API.
Use these resources to learn more about Aura components, Visualforce, and Case Feed.
• Lightning Aura Components Developer Guide
• Visualforce Developer Guide
40