Extend Salesforce with Clicks, Not Code
Salesforce, Winter ’22
@salesforcedocs Last updated: September 15, 2021 © Copyright 2000–2021 salesforce.com, inc. All rights reserved. Salesforce is a registered trademark of salesforce.com, inc., as are other names and marks. Other marks appearing herein may be trademarks of their respective owners. CONTENTS
Extend Salesforce with Clicks, Not Code ...... 1 Customize Your Salesforce Org ...... 2 Set Up Your Data Your Way ...... 143 Manage Your Notifications with Notification Builder ...... 461 Define and Manage Platform Events ...... 468 Manage Your Domains ...... 472 Build Your Own Web Site ...... 488 Extend the Reach of Your Organization ...... 710 Build Your Own Salesforce App ...... 942 Lightning App Builder ...... 961 Resources for the Point & Click Administrator ...... 1016
Index ...... 1018
EXTEND SALESFORCE WITH CLICKS, NOT CODE
Ready to go beyond the basics of Salesforce administration? Want to customize your org, push its boundaries, and enhance its functionality? You can do that and so much more without writing a single line of code. All you need is your mouse and a sense of adventure. Enhance your objects, data, and fields, customize your org’s look and feel, augment your business processes, create websites, and even create apps—all using point-and-click tools.
Customize Your Salesforce Org You can customize each of the standard tabs and types of records, including adding custom fields and setting page layouts. You can also customize search, tagging, and user interface options for your org. In addition, every Contact Manager, Group, Professional, Enterprise, Unlimited, and Performance Edition user can customize various personal display options. Set Up Your Data Your Way Optimize your Salesforce data to fit the unique needs of your users. You can create your own objects with data that fits together in the ways that make the most sense for you. Manage Your Notifications with Notification Builder Keep your users in the know with timely notifications, whether they’re at their desks or on the go. Choose whether standard Salesforce notifications, like Chatter notifications, appear on desktop, mobile, or at all. Create custom notifications to give your users new information and reminders, or replace a standard notification. Define and Manage Platform Events Use platform events to connect business processes in Salesforce and external sources through the exchange of real-time event data. Platform events are secure and scalable. Define fields to customize your platform event data. Manage Your Domains You can configure domains and their site associations to suit your organization’s unique needs. For example, you can set up a single domain to host your Experience Cloud, Lightning Platform, and Site.com sites. Or perhaps you want a single site on more than one domain. Build Your Own Web Site You can use Experience Builder or Salesforce Sites to build out your Salesforce organization with custom pages and apps. Extend the Reach of Your Organization Sometimes your users need to work with data and services that are outside your Salesforce org. There’s a variety of ways you can provide seamless access across org boundaries. Build Your Own Salesforce App An app is a collection of items that work together to serve a particular function. Salesforce apps come in two flavors: Classic and Lightning. Classic apps are created and managed in Salesforce Classic. Lightning apps are created and managed in Lightning Experience. You can customize both types of app to match the way your users work. Resources for the Point & Click Administrator In addition to online help, Salesforce creates guides and tip sheets to help you learn about our features and successfully administer Salesforce.
1 Extend Salesforce with Clicks, Not Code Customize Your Salesforce Org
Customize Your Salesforce Org
You can customize each of the standard tabs and types of records, including adding custom fields EDITIONS and setting page layouts. You can also customize search, tagging, and user interface options for your org. In addition, every Contact Manager, Group, Professional, Enterprise, Unlimited, and Available in: both Salesforce Performance Edition user can customize various personal display options. Classic and Lightning Watch a Demo: Creating a Workflow Rule (Salesforce Classic) Experience Quick demo of how to customize the way Salesforce looks for your organization. The available customization options vary according to To tailor Salesforce for your org, you can customize the display of the various tabs and other items. which Salesforce Edition you Select a link to get started on any task. have.
Find Object Management Settings USER PERMISSIONS Salesforce lets you personalize your object model with features like custom fields, page layouts, and validation rules. Depending on which experience of Salesforce you have enabled, these To view setup options: customizations are located in different areas of Setup. • View Setup and Control User Access to Fields Configuration Use field-level security to control user access to fields. Use page layouts to control the layout To customize your org: and organization of detail and edit pages in Salesforce, the Self-Service Portal, and the Salesforce • Customize Application Customer Portal. Custom Help Content Tailor help so that users understand how to work within your unique implementation of Salesforce. You can add learning in the flow of work in several ways. Add custom help for a page, app, object, or org level, or provide links to help in the Utility Bar, Path, or as a text box on the page. Show users custom resources in a Lightning Experience welcome mat when they first log in. Or, add micro-learning prompts and walkthroughs to your app to reach users with important news, training, and on-boarding information. Tailor Business Processes to Different Users Using Record Types Record types let you offer different business processes, picklist values, and page layouts to different users. You might create record types to differentiate your regular sales deals from your professional services engagements, offering different picklist values for each. Or you might display different page layouts for your customer support cases versus your billing cases. Manage Your Translations If your Salesforce org has multiple languages enabled, manage translations so that your global users can use Salesforce in their language.
Find Object Management Settings Salesforce lets you personalize your object model with features like custom fields, page layouts, and validation rules. Depending on which experience of Salesforce you have enabled, these customizations are located in different areas of Setup.
Find Object Management Settings in Lightning Experience Salesforce lets you customize your object model with features like custom fields, page layouts, and validation rules. Most objects are available from the Object Manager in Setup. Find Object Management Settings in Salesforce Classic Salesforce lets you personalize your object model with features like custom fields, page layouts, and validation rules. Depending on which type of object you want to find, these customizations are located in different areas of Setup.
2 Extend Salesforce with Clicks, Not Code Find Object Management Settings
Standard Object Limits Standard object limits include usage details for object customizations, such as the custom fields you’ve added or sharing rules you’ve applied to an object. Quick Access Menu The quick access menu offers handy shortcuts to customization features. App Setup Overview
Find Object Management Settings in Lightning Experience
Salesforce lets you customize your object model with features like custom fields, page layouts, and EDITIONS validation rules. Most objects are available from the Object Manager in Setup. Standard Objects and Custom Objects Available in: Lightning A standard object, such as Account or Contact, comes out of the box with your Salesforce Experience organization. A custom object is an object that you or another administrator created. Available in: All editions From Setup, at the top of the page, select Object Manager. Select one of the objects in the list, and then select a specific customization from the left pane.
For example, to add a custom field to the Account object, select Object Manager from the top of the Setup page. Next, select Account, and then Fields & Relationships. Select New.
3 Extend Salesforce with Clicks, Not Code Find Object Management Settings
Note: If you’ve renamed any objects or fields, the Object Manager uses their assigned custom names.
Other Standard Objects Some standard objects aren’t housed in the Object Manager. Standard objects with more specific purposes and customizations can be found in Setup using the Quick Find box. From Setup, enter the object name in the Quick Find box, then select the customization. Custom Objects You can also create custom objects from the Object Manager. From Setup, at the top of the page, select Object Manager. Then select New Object.
External Objects An external object is similar to custom objects, except that it maps to data that’s stored outside your Salesforce organization. From Setup, enter External Objects in the Quick Find box, then select External Objects. Next, click one of the external objects in the list. Then scroll to the section for the specific customization. For example, to add a custom field to the Orders external object, enter External Objects in the Quick Find box, then select External Objects. Click Orders, and then scroll to Custom Fields and Relationships.
SEE ALSO: Point-and-Click Customization: What’s Different or Not Available in Lightning Experience
Find Object Management Settings in Salesforce Classic
Salesforce lets you personalize your object model with features like custom fields, page layouts, EDITIONS and validation rules. Depending on which type of object you want to find, these customizations are located in different areas of Setup. Available in: Salesforce Standard Objects Classic A standard object, such as Account or Contact, comes out of the box with your Salesforce Available in: All editions organization.
4 Extend Salesforce with Clicks, Not Code Find Object Management Settings
From Setup, enter the name of the appropriate object in the Quick Find box, then select the specific customization. For example, to add a custom field to the Case object, enter Case in the Quick Find box, then select Fields under Cases. Custom Objects A custom object is an object that you or another administrator created. From Setup, enter Objects in the Quick Find box and select Objects. Next, click one of the custom objects in the list. Then scroll to the section for the specific customization. For example, to add a custom field to the Job Applications object, enter Objects in the Quick Find box, then select Objects. Click Job Applications, and then scroll to Custom Fields and Relationships. External Objects An external object is similar to custom objects, except that it maps to data that’s stored outside your Salesforce organization. From Setup, enter External Objects in the Quick Find box, then select External Objects. Next, click one of the external objects in the list. The scroll to the section for the specific customization. For example, to add a custom field to the Orders external object, enter External Objects in the Quick Find box, then select External Objects. Click Orders, and then scroll to Custom Fields and Relationships.
Standard Object Limits
Standard object limits include usage details for object customizations, such as the custom fields EDITIONS you’ve added or sharing rules you’ve applied to an object. The list varies depending on the object. When a customization exceeds the allowed limit for the Available in: both Salesforce object, or reaches 75% of the limit, a tip displays that suggests what you can do next. Classic and Lightning Experience Refer to the standard object limits page when you’re planning to customize a particular standard object or to monitor the usage and limits of customizations on that object. Available in: All Editions To see an object’s usage: except Database.com • If you’re using Lightning Experience, from Setup, open the Object Manager, click the name of the object you want to see the usage for, and then go to Object Limits. • If you’re using Salesforce Classic, from Setup, enter the object name in the Quick Find box, and then select Limits under that object.
Note: The object limit percentages are truncated, not rounded. For example, if your org uses 95.55% of the limit for a particular customization, the object limit displays 95%.
5 Extend Salesforce with Clicks, Not Code Find Object Management Settings
Quick Access Menu
The quick access menu offers handy shortcuts to customization features. EDITIONS When you're working on apps or objects, use this menu to jump to relevant app customization features. It's available from object list view pages and record detail pages. Available in: Salesforce Classic (not available in all Note: If drag-and-drop scheduling on list views is enabled, the quick access menu isn't visible orgs) for list views on accounts, contacts, and custom objects. Available in: Contact • To expand or collapse the menu, click (or press ALT+;). Manager, Group, • To scroll down the list of the menu, press TAB. Professional, Enterprise, • To select an option on the menu, press ENTER. Performance, Unlimited, and Developer Editions • To remove the menu from all list views and record pages, click Turn off menu. To restore the quick access menu: USER PERMISSIONS 1. From your personal settings, enter Advanced User Details in the Quick Find box, then select Advanced User Details. No results? Enter Personal Information in the To view the quick access Quick Find box, then select Personal Information. menu: • Customize Application 2. Click Edit. 3. Select the Quick Access Menu checkbox. 4. Click Save.
SEE ALSO: Personalize Your Salesforce Experience
6 Extend Salesforce with Clicks, Not Code Rename Object, Tab, and Field Labels
Rename Object, Tab, and Field Labels
You can change the name of almost any object, field, or tab in Salesforce. This simple adjustment EDITIONS lets you continue using the terminology your users already know and helps them transition to using Salesforce. However, Salesforce Help and most pages in Setup always display the original names Available in: both Salesforce for standard objects, fields, and tabs. Classic and Lightning For example, you can change the name label for the "Accounts" object and related "Accounts" tab Experience to "Companies", and change the field "Account Name" to "Company Name." When you rename an Available in: Essentials, object, tab, or field, the new name appears on all pages the user sees, in Salesforce for Outlook, and Professional, Enterprise, in Connect Offline. Performance, Unlimited, Before renaming tabs, objects, fields, and other related labels, review the implementation tips for and Developer Editions administrators. If you use person accounts in your Salesforce org, see Renaming Person Account Labels. USER PERMISSIONS 1. From Setup, enter Rename Tabs and Labels in the Quick Find box, then select To rename a tab and field: Rename Tabs and Labels. • Customize Application 2. Select your default language from the Select Language drop-down list at the top of the OR page. Manage Translation Note: In Hebrew, we recommend keeping tab renaming to a minimum because variable OR gender in verbs is not supported and verbs can lose gender agreement. If you are designated as a translator, you need: 3. Click Edit next to the tab you want to rename. Click Reset to revert to a tab’s original name. View Setup and Note: You can’t reset custom object tab names. Configuration
To reset renamed tabs: 4. Enter the singular and plural forms of the new tab name. Also, if applicable for the language, • Customize Application select Starts with a vowel sound for labels that start with a vowel to ensure that Salesforce uses the proper article (such as “a” or “an”). Then click Next. OR When you rename a tab or an object, you can’t use the name of another standard tab, custom Manage Translation object, external object, or custom tab. When you rename an object, a field, or a tab, you can’t OR use include these characters: #, $, %, ;, <, =, >, [, ], ^, `, |, and ~. If you are designated as a translator, you need: 5. Enter your labels for the standard field labels and other user interface elements. Be sure to enter View Setup and both a singular and plural form for each label that requires it. Select Starts with a vowel sound Configuration for labels that start with a vowel.
Note: Some standard fields, such as Created By and Last Modified By, are purposely omitted from renaming because they track system information. EDITIONS
6. Click Save. Available in: Salesforce Repeat this procedure to translate labels into all other languages used in your organization. Classic (not available in all orgs) Tip: After renaming a tab or object, rename any custom reports, dashboards, profiles, permission sets, custom fields, and list views that contain the original name. You can modify Person accounts available labels using the Translation Workbench. To rename a standard report, click Save As and save in: Enterprise, Performance, it to a folder designed for your new name. Unlimited, and Developer Editions Other tab customization options include: • Individual users can control which tabs and related lists display for their own logins.
7 Extend Salesforce with Clicks, Not Code Rename Object, Tab, and Field Labels
• In addition to the standard tabs provided by Salesforce, users can create entirely new custom tabs depending on their Edition. For more information, see Custom Tabs. • In Enterprise, Unlimited, Performance, and Developer Edition organizations, you can override the tab home page that is displayed when a user clicks a standard, custom, or external object tab. For more information, see Override Standard Buttons and Tab Home Pages on page 785.
Renaming Person Account Labels If your org uses person accounts, you can rename these standard fields.
Field Tab Description Business Account Accounts An account that is not a person account because it does not have a record type specific to person accounts. This label is primarily used to clarify the type of accounts you are importing.
Person Account Accounts A person account.
Business Contact Contacts A contact that is associated with a business account. This label is primarily used to clarify the type of accounts you are importing.
When you rename the Person Account field label, the renamed label appears in Salesforce: • As a prefix to differentiate person account fields such as Birthdate and Home Phone from business account fields. For example, Person Account: Birthdate is available as an account column in opportunity reports. • In the name of the Is Person Account field and icon. For example, if you rename the Person Account field to “Consumer,” then Is Person Account becomes Is Consumer.
Note: The Person Account and Business Account field labels are independent from actual record type names. • To customize person account record types, from the object management settings for person accounts, go to Record Types. • To customize business account record types, from the object management settings for accounts, go to Record Types.
SEE ALSO: Considerations for Renaming Tab and Field Labels Rename the Chatter Tab Find Object Management Settings
8 Extend Salesforce with Clicks, Not Code Rename Object, Tab, and Field Labels
Considerations for Renaming Tab and Field Labels
Before renaming standard and custom tabs and fields, learn how those changes affect your users. EDITIONS • Most standard tabs and objects can be renamed but not all. For example, the Forecasts tab is not available for renaming. From Setup, enter Rename Tabs and Labels in the Quick Available in: both Salesforce Find box, then select Rename Tabs and Labels to view a list of the tabs and objects you Classic (not available in all can rename. orgs) and Lightning Experience • The renamed labels appear on all user pages in Salesforce including Personal Setup. In Lightning Experience, all pages in the Setup area use the renamed labels. In Salesforce Classic, the Setup Available in: Professional, pages in the Setup area use the default, original labels. Enterprise, Performance, • Some standard fields, such as Created By and Last Modified By, are purposely Unlimited, and Developer omitted from renaming because they track system information. Editions • When you rename a tab or an object, you can’t use the name of another standard tab, custom object, external object, or custom tab. USER PERMISSIONS • When you rename a tab, a field, or an object, you can’t use include these characters: #, $, %, To rename tab and field ;, <, =, >, [, ], ^, `, |, and ~. labels: • After renaming tabs, objects, or fields, check the following additional items that may need • Customize Application manual updates: To reset renamed tabs: – Review all list view names. List view names continue to display the original object name • Customize Application until you change them manually. – Check standard report names and descriptions for the objects you renamed. – Update the titles and descriptions of any email templates that contain the original object or field name. – Manually change any other items you customized with the new object or field name. For example, custom fields, page layouts, and record types may contain the original tab or field name.
• Connect Offline, the Outlook integration, the Gmail integration, and Salesforce for Outlook use your new names. • If you have renamed tabs, objects, or fields, you can also replace the Salesforce Help with another URL. Users can view this URL whenever they click on any context-sensitive help link on an end-user page or within their personal settings. After you replace the help, the Help & Training link at the very top of every page and all Setup pages will continue to display the Salesforce Help. For instructions on replacing the online help, see Define Org-Level Help in Salesforce Classic on page 99. • In Hebrew, we recommend keeping tab renaming to a minimum because variable gender in verbs is not supported and verbs can lose gender agreement.
SEE ALSO: Rename Object, Tab, and Field Labels
9 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Control User Access to Fields
Use field-level security to control user access to fields. Use page layouts to control the layout and EDITIONS organization of detail and edit pages in Salesforce, the Self-Service Portal, and the Salesforce Customer Portal. Available in: both Salesforce Important: When you use page layouts to hide fields from detail and edit pages, users can Classic and Lightning still see these fields via reports, search results, list views, and the API. To restrict field access, Experience use field-level security. Search doesn’t return results for records with fields protected by field Page layouts and search level security. In some rare situations, when search terms match field values protected by layouts available in: All field-level security, the associated records are returned but without the protected fields and Editions their values. Don’t use page layouts to secure data. For example, removing the Edit button Field-level security available from a page layout doesn’t prevent users from using inline editing. To prevent users from in: Enterprise, Performance, editing data, use sharing rules, field-level security, page layout field properties, validation Unlimited, Developer, and rules, object permissions, and Visualforce pages. Database.com Editions
Field-Level Security • Restrict users’ access to view and edit fields. For example, restrict access in reports, search results, list views, related lists, email, and mail merge templates, custom links, Connect Offline. Also restrict API access and when synchronizing data or importing personal data. • Override less-restrictive field access settings in page layouts and mini page layouts. For example, if a page layout requires a field that’s read-only in field-level security settings, the field remains read-only for the user. • Override less-restrictive field settings in search layouts. For example, if a field is visible in the search layout but hidden via field-level security settings, the field remains hidden.
Page Layouts • Control the layout and organization of detail and edit pages. • Control which fields, related lists, and custom links users see, on detail and edit pages only. • Control which standard and custom buttons display on detail pages and related lists. • Determine whether fields are visible, read only, or required, on detail and edit pages only. • Determine the fields that users can import data into. • In Personal, Contact Manager, Group, and Professional Editions, page layouts control which fields users can access in: – related lists and list views – reports – Connect Offline – email and mail merge templates – custom links Page layouts also control field access when synchronizing data. • In Professional, Enterprise, Unlimited, Performance, and Developer Editions, determine aspects of mini page layouts, including: – record type – profile associations – related lists – fields and field access settings
10 Extend Salesforce with Clicks, Not Code Control User Access to Fields
The visible fields and related lists of the mini page layout can be further customized. But other items inherited from the associated page layout can’t be changed on the mini page layout. Mini page layouts display selected fields and related lists of records in the mini view of the console.
Tip: To automatically add a field to all page layouts and make it visible and required everywhere regardless of field-level security, make it a universally required field.
Feed-based Layouts Overview Feed-based page layouts make it easier to work with records by providing two separate views: one for the record’s feed, and one for its details, including related lists. Create Page Layouts With the enhanced page layout editor, you can tailor record page layouts to the needs of your users. Add, remove, or reorder actions, buttons, fields, and sections on a record’s detail page. Create Feed-based Page Layouts Make it easier for your users to work with account, contact, lead, opportunity, custom, and external object records by creating feed-based layouts. These layouts include two separate views: one for the record’s feed and one for its details. Page Layouts Page layouts control the layout and organization of buttons, fields, s-controls, Visualforce, custom links, and related lists on object record pages. They also help determine which fields are visible, read only, and required. Use page layouts to customize the content of record pages for your users. Compact Layouts A compact layout displays a record’s key fields at a glance in the Salesforce mobile app, Lightning Experience, and in the Outlook and Gmail integrations. Select Which Fields Appear in the Recently Viewed List As a Salesforce admin, you can customize the Recently Viewed list that appears on the home page for most standard and custom objects. Choose and order the fields to display so that your users see the information that’s most important for your company.
SEE ALSO: Page Layouts Customize Search Results Layouts
Feed-based Layouts Overview Feed-based page layouts make it easier to work with records by providing two separate views: one for the record’s feed, and one for its details, including related lists.
Available in: Enterprise, Performance, Unlimited, and Developer Editions
Unlike standard page layouts, which include all of a record’s information—the feed, details, and related lists—on one page, feed-based layouts let you switch between the feed view and the details view so you can focus on the type of information you need at any given moment. For example, to see comments others have made about a record or to create a new record that’s related to it, you’d use the feed view. To delve into the record’s related lists, attachments, and other in-depth information, you’d use the details view. Feed-based layouts are available on account, asset, case, contact, lead, opportunity, custom, and external objects.
11 Extend Salesforce with Clicks, Not Code Control User Access to Fields
The feed view in these layouts includes: 1. Tabs or, if you’re working in the Salesforce console, toggle buttons ( ) to switch between the feed view and the detail view. 2. The publisher, which might include actions that let you do things like create related records or log calls, depending on how your administrator has set up your organization. 3. The record feed, which shows activity on the record, such as comments others have made about it. 4. Any custom buttons and links your administrator has added. 5. A follow button ( ) or following indicator ( ) and a list of people who follow the record. Depending on how your administrator has set up the page, these might appear on the left side or on the right side. 6. Feed filters, which let you choose which information from the feed you see. Depending on how your administrator has set up the page, the filters might appear on the left side of the page, in the center, or on the right. Detail views show in-depth information about the record, including related lists.
12 Extend Salesforce with Clicks, Not Code Control User Access to Fields
SEE ALSO: Create Feed-based Page Layouts
Create Page Layouts
With the enhanced page layout editor, you can tailor record page layouts to the needs of your users. EDITIONS Add, remove, or reorder actions, buttons, fields, and sections on a record’s detail page. 1. From the management settings for the object that you want to edit, go to Page Layouts. Available in: Salesforce Classic (not available in all 2. Click New. orgs) and Lightning 3. Optionally, choose an existing page layout to clone. Experience
4. Type a name for the new layout. Available in: Enterprise, 5. Optionally, select Feed-Based Layout to create a layout that includes separate tabs for Performance, Unlimited, a record’s feed and detail pages. and Developer Editions 6. Click Save. 7. Modify the layout. USER PERMISSIONS 8. Assign the new layout to user profiles. To create page layouts: • Customize Application
13 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Tip: You can also create a new page layout by cloning an existing one using Save As from within the layout.
SEE ALSO: Edit Page Layouts for Standard Objects Edit Page Layouts for Custom and External Objects Control User Access to Fields Feed-based Layouts Overview Find Object Management Settings
Create Feed-based Page Layouts
Make it easier for your users to work with account, contact, lead, opportunity, custom, and external EDITIONS object records by creating feed-based layouts. These layouts include two separate views: one for the record’s feed and one for its details. Available in: Salesforce Feed-based layouts offer a more streamlined way of working with records, and don’t require users Classic (not available in all to scroll through information they’re not interested in to find what they’re looking for. Users can orgs) easily switch back and forth between the feed view, which includes the publisher and important Available in: Group, events on the record, shown in chronological order, and the details view, which shows in-depth Professional, Enterprise, information about the record, including related lists. Performance, Unlimited, You can create feed-based layouts for account, asset, contact, lead, opportunity, custom, and external Contact Manager, and objects. To create feed-based layouts for cases, use Case Feed. Developer Editions 1. Be sure feed tracking is enabled for the object on which you want to create a feed-based layout. To enable feed tracking, from Setup, enter Feed Tracking in the Quick Find box, USER PERMISSIONS then select Feed Tracking. To create, edit, and delete 2. Create a new page layout and select Feed-Based Layout. page layouts: • Customize Application Note: Only new page layouts can be feed-based; you can’t change an existing standard layout to a feed-based layout.
3. Click Edit next to your layout and use the enhanced page layout editor to configure it. You can’t configure feed-based layouts with the original page layout editor.
4. On the main page layout editor page, customize the publisher to include the actions you want to make available to users, and add any custom buttons or links. 5. Click Feed View in the page layout editor header to customize what appears on the feed page. You can: • Enable full-width feed so the feed expands horizontally when users view records in Salesforce console tabs or subtabs. • Turn on compact feed so users see a cleaner, more streamlined feed view when working with records in Salesforce console tabs or subtabs. • Choose to automatically collapse the publisher when it’s not in use so users can see more of the information below it on the page. • Add custom components, which are Visualforce pages with functionality you define. • Choose where on the page custom buttons and links and standard components like the Follow button and followers list appear. • Hide the standard sidebar.
14 Extend Salesforce with Clicks, Not Code Control User Access to Fields
• Choose which feed filters are available, and where they appear.
6. Assign the page layout to user profiles.
SEE ALSO: Feed-based Layouts Overview Use Case Feed in Salesforce Classic Feed Tracking Enable Feed Updates for Related Records
Page Layouts
Page layouts control the layout and organization of buttons, fields, s-controls, Visualforce, custom EDITIONS links, and related lists on object record pages. They also help determine which fields are visible, read only, and required. Use page layouts to customize the content of record pages for your users. Available in: both Salesforce Page layouts can include s-controls and Visualforce pages that are rendered within a field section Classic and Lightning when the page displays. You can control the size of the s-controls and Visualforce pages, and Experience determine whether or not a label and scroll bars display. Page layouts are available Salesforce has two drag-and-drop tools for editing page layouts: the original page layout editor in: All Editions and an enhanced page layout editor. The enhanced page layout editor is enabled by default, and Creation and deletion of provides all the functionality of the original editor, as well as additional functionality and an page layouts is available in: easier-to-use WYSIWYG interface. Professional, Enterprise, You can enable the original page layout editor in the User Interface settings. Your Salesforce org Performance, Unlimited, can use only one page layout editor at a time. and Developer Editions From within a page layout, you can access a mini page layout. The mini page layout defines the hover details that display when you mouse over a field on an object’s detail page in the Agent USER PERMISSIONS console or in the Recent Items section of the sidebar in Salesforce Classic. To create, edit, and delete For Personal, Contact Manager, Essentials, and Group Edition orgs, every user views the same layout. page layouts: Professional, Enterprise, Unlimited, Performance, and Developer Edition orgs can create different • Customize Application page layouts for use by different profiles and record types and set field-level security settings to further restrict users’ access to specific fields. In Professional, Enterprise, Performance, Unlimited, and Developer Editions, you can set the mini page layouts and related objects that appear in the Console tab.
Usage Considerations Starting in Winter ’20, layout changes made by administrators for record pages don't appear immediately in Lightning Experience. The record page displays the updated layout about 15 minutes later when you reload the page. This change is a tradeoff to significantly improve performance of record pages. To see your changes immediately, log out and log back in. Other users don't see the change until up to 1 hour later when they reload the page. This change impacts record pages for the following objects. • Account • Case • Contact • Lead
15 Extend Salesforce with Clicks, Not Code Control User Access to Fields
• Opportunity • Custom objects This change also applies to record layouts updated through the page layout editor, compact layouts, and Lightning pages. For example, the layout is changed when you add a custom field to an object and add that field to the page layout. For changes to a Lightning page, such as via the Lightning App Builder, administrators continue to see their changes immediately after a page reload. However, other users and other browsers don’t see the change up to 1 hour later when they reload the page. To see the changes immediately, users can log out and log back in.
Edit Page Layouts for Standard Objects Change the look and feel of page layouts for standard Salesforce objects. Edit Page Layouts for Custom and External Objects Change the look and feel of page layouts for custom and external objects. Customize Page Layouts with the Enhanced Page Layout Editor The enhanced page layout editor is a WYSIWYG tool for customizing your page layouts in Salesforce, the Self-Service Portal, and the Salesforce Customer Portal. The enhanced page layout editor has all the functionality of the original page layout editor, but has more features and an easier-to-use interface. Customize Salesforce Classic Home Tab Page Layouts You can customize the Home tab in Salesforce Classic to include components such as sidebar links, a company logo, a dashboard snapshot, or custom components that you create. A dashboard snapshot is a clipping of the top row of a dashboard’s components. Just like other tabs, you can also assign different home page layouts to different users based on profile. Set Page Layouts and Field-Level Security Assign Page Layouts to Profiles or Record Types Assign Page Layouts from a Customize Page Layout or Record Type Page Edit Multi-Line Layouts for Opportunity Products Build Page Layouts for Custom Objects How Page Layouts Work in the Salesforce Mobile App Use the enhanced page layout editor to customize the layout of an object’s record detail pages, configure actions, and adjust which fields and related lists appear in the Salesforce mobile app. Page Layouts in Lightning Experience When you customize your page layouts in Salesforce Classic, those changes can affect the content of object record pages in Lightning Experience. However, in Lightning Experience, the page elements display differently and some aren’t supported. Tips for Optimizing Page Layouts for the Salesforce Mobile App Here are some tips and tricks for making your existing page layouts more mobile-friendly. Manage Mobile Cards in the Enhanced Page Layout Editor Add expanded lookups, components, and Visualforce pages to the Mobile Cards section of your page layout to have them show up as mobile cards in the Salesforce mobile app. Customize Related Lists You can customize the buttons, columns displayed, column order, and record sort order of related lists on record detail pages in Salesforce and the Salesforce Customer Portal. Customize Detail Page Buttons
16 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Customize Page Layouts with the Original Page Layout Editor Use the original page layout editor to customize page layouts in Salesforce, the Self-Service Portal, and the Salesforce Customer Portal.
SEE ALSO: Control User Access to Fields
Edit Page Layouts for Standard Objects
Change the look and feel of page layouts for standard Salesforce objects. EDITIONS From the management settings for the appropriate object, go to Page Layouts. Alternately, if you’re using the Enhanced Page Layout Editor, which is enabled by default, you can Available in: both Salesforce Classic and Lightning customize a standard object’s page layout by clicking Edit Layout on the object’s detail page. Experience
SEE ALSO: Available in: All Editions Page Layouts Control User Access to Fields USER PERMISSIONS Customize Page Layouts with the Original Page Layout Editor To customize page layouts: Customize Page Layouts with the Enhanced Page Layout Editor • Customize Application To view page layouts: • View Setup and Configuration
Edit Page Layouts for Custom and External Objects
Change the look and feel of page layouts for custom and external objects. EDITIONS 1. From the management settings for the object whose page layout you want to edit, go to Page Layouts. Available in: both Salesforce Classic and Lightning 2. Complete one of the following. Experience a. If you have “Customize Application” permission, open the page layout that you want to customize for edit. Available in: All Editions b. If you have the “View Setup and Configuration” permission, click the page layout that you want to view. USER PERMISSIONS
To customize page layouts: SEE ALSO: • Customize Application Page Layouts To view page layouts: • View Setup and Control User Access to Fields Configuration Customize Page Layouts with the Original Page Layout Editor Customize Page Layouts with the Enhanced Page Layout Editor Find Object Management Settings
17 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Customize Page Layouts with the Enhanced Page Layout Editor
The enhanced page layout editor is a WYSIWYG tool for customizing your page layouts in Salesforce, EDITIONS the Self-Service Portal, and the Salesforce Customer Portal. The enhanced page layout editor has all the functionality of the original page layout editor, but has more features and an easier-to-use Available in: both Salesforce interface. Classic (not available in all The enhanced page layout editor has two parts: a palette on the upper portion of the screen and orgs) and Lightning the page layout on the lower portion of the screen. The palette contains the user interface elements Experience that you can add to your page layout, such as fields, actions, buttons, links, and related lists. Available in: All Editions Note: Currently, you can't change the location of Chatter feeds. However, in Salesforce Classic, users can click the Hide Chatter link in a Chatter feed to hide the feed, and the USER PERMISSIONS Show Chatter link to show the feed. To customize page layouts: When working with the enhanced page layout editor: • Customize Application • To select multiple elements individually, use Ctrl+click. To select multiple elements as a group, To view page layouts: use Shift+click. • View Setup and • To change the properties of an element on the page layout, double-click the element or click Configuration the wrench icon ( ) next to it. You can’t change the properties of elements in the palette. • To make a field read-only or required, double-click the field in the page layout and select the appropriate checkbox. • To access the other layouts for an object with multiple page layouts, click the page layout name at the top of the page and select another layout to view. • To change the name of the page layout, add personal and public tags if available, and display standard object checkboxes on the page layout, click Layout Properties.
Note: You can’t rename a page layout if you’re using Salesforce Professional Edition.
• In Enterprise, Unlimited, Performance, and Developer Editions, you can select a profile to preview how the pages will look for users with that profile. Most related lists’ columns preview without data. • If you’re working with a feed-based page layout, click Feed View to customize the tools and components that appear when users are working in the feed on a record. • To choose which fields display on the record detail page and the order in which they appear, click Edit Multi-Line Layout. • The mini page layout defines the hover details that display when you mouse over a field on an object’s detail page, in the Agent console, or in the Recent Items section of the sidebar in Salesforce Classic. To customize the fields in the mini page layout, click Mini Page Layout at the top of the palette. • When you’re done customizing the page layout, save it. If you navigate away from your page layout before saving, you lose your changes.
Note: Changes to user layouts override the global publisher layout on user profile pages and the Chatter home page.
User Interface Elements for the Enhanced Page Layout Editor Guidelines for Using the Enhanced Page Layout Editor Page Layout Tips Here are a few tips to keep your page layouts organized and easy to use.
18 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Page Layout Considerations Keep these considerations in mind when working with page layouts in the enhanced page layout editor.
SEE ALSO: Guidelines for Using the Enhanced Page Layout Editor Customize Related Lists Feed-based Layouts Overview Page Layouts
User Interface Elements for the Enhanced Page Layout Editor
This list describes the enhanced page layout editor user interface elements and how you can use EDITIONS them in your page layout. To add elements, drag them from the palette to the layout. Valid drop locations show up in green. To remove elements, drag them off the layout and back to the palette. Available in: both Salesforce Important: The Mobile Cards section of the page layout editor is no longer supported as of Classic and Lightning Spring ’20. Items in the Mobile Cards section, such as components and expanded lookups, Experience no longer display in the Salesforce mobile app. For more information, see Mobile Cards Are Available in: All Editions Not Available in the New Salesforce Mobile App in the Salesforce Spring ’20 release notes. Actions USER PERMISSIONS Mobile smart actions appear as a single action element in the page layout editor. In the Salesforce mobile app, the Mobile Smart Actions element expands to distinct create actions that enable To customize page layouts: users to create records directly from the action bar. The create actions included in the set of • Customize Application mobile smart actions vary depending on the page layout’s object. To view page layouts: Note: If you delete an action, the action is removed from all layouts that it’s assigned to. • View Setup and Configuration Einstein Analytics Assets You can add and move an Analytics dashboard to any section on the page layout, except Mobile Cards. For an Analytics dashboard element, use field mapping to map data fields in the dashboard to the object’s fields so that the dashboard shows only the data that’s relevant for the record being viewed. For more about field mapping or filtering Analytics dashboards, see Embed Analytics Dashboards in Lightning Pages or Embed Analytics Dashboards in Salesforce Classic Pages. Blank Spaces You can add and move blank spaces to any section on the page layout, except Mobile Cards. Use blank spaces to visually align and distinguish elements on the page.
Note: If you use the original page layout editor to view a page layout that was created in the enhanced page layout editor, the original page layout editor shows the blank spaces that you added. You can’t move or add blank spaces in the original page layout editor, but you can remove them by dragging them to the box on the right. Buttons You can control which standard and custom buttons are displayed and the order in which the custom buttons appear. You can’t rearrange standard buttons. Standard and custom buttons are available as actions in the Salesforce mobile app and Lightning Experience. Canvas Apps For the Canvas Apps category to appear in the palette, set the canvas app location to Visualforce Page when you create the canvas app in Salesforce.
19 Extend Salesforce with Clicks, Not Code Control User Access to Fields
If you add a canvas app to any section other than the Mobile Cards section, the canvas app appears in the page layout in the full Salesforce site. Canvas apps added as mobile cards don’t appear in the Salesforce mobile app. To have a canvas app appear on a mobile record page, add it to the page as a component using the Lightning App Builder. Components and Expanded Lookups Components and expanded lookups added as mobile cards don’t appear in the Salesforce mobile app. Expanded lookups are no longer supported in mobile as of Spring ’20. To have a News or Twitter component appear on a mobile record page, add it to a Lightning page using the Lightning App Builder. Fields A field can display one or more of these icons: • The field must have a value to save the record, but isn’t required on the page layout itself. • The field must be included on the page layout because an administrator configured the field as universally required or Salesforce automatically requires the field. Although you can’t remove such fields, you can move them to different locations. • The field is a controlling field. • The field is a dependent field. • The field is read-only. To set which fields are required and read-only, select one or more fields and click on any selected field. • You can’t change the field properties of some standard fields. You can change custom fields only if they aren’t universally required fields. • Administrators and users with the Edit Read Only Fields permission can always edit fields marked as read-only. • If you make a picklist field read-only, all new records contain the default value for that picklist. • Auto-number fields are always read-only. • If you mark the opportunity Probability field as read-only, the Probability value is still updated when a user changes the Stage value of an opportunity. When working with fields: • In Personal, Contact Manager, and Group Editions, page layouts control which fields users can access in related lists, list views, reports, Connect Offline, email and mail merge templates, custom links, and when synchronizing data. In Professional, Enterprise, Unlimited, Performance, and Developer Editions, field-level security controls this access. Field-level security settings override field properties that you set on the page layout if the field-level security is more restrictive than the page layout setting. • Users can import values into a field only if they have read and edit access. User permissions, page layout assignments, and field-level security settings determine field access. Related Lists A page layout can have up to 100 related lists. You can place related lists at the bottom of the page layout. To move a related list on the page layout, drag the handle located above the related list. To customize a related list, double-click the related list handle or click inside the handle. Use the related list properties to: • Specify which fields display as columns on the related list, the order in which they appear, and the sort order of the records in the related list. In Professional, Enterprise, Unlimited, and Performance Editions, you can also opt to apply the column information to other page layouts for the same type of object. • Specify which standard and custom buttons appear on the related list. When working with related lists on page layouts, note the following: • The View All button only displays up to 2,000 items in a related list.
20 Extend Salesforce with Clicks, Not Code Control User Access to Fields
• Some related lists aren’t customizable because they link to data rather than store it. Related lists that aren’t customizable are indicated on the page layout. • You can’t add related lists to the page layouts for the User object. • You can enable related list hover links so that record detail pages include links for each related list at the top of the page. Users can hover over the link to display the corresponding related list in an interactive overlay to view and manage the related list items. Users can also click the link to jump to the content of the related list without scrolling down the page. • In Professional, Enterprise, Unlimited, Performance, and Developer Edition, individual users can customize which related lists display for their personal use. Administrators can overwrite these user customizations and apply the related list configuration in the page layout to all users, even if they already customized their display. To overwrite users' related list customizations, click Yes on the Overwrite Users’ Customized Related Lists window, which appears when saving a page layout if you moved or added a related list. • Related lists show up on the record’s related information page in the Salesforce mobile app. Report Charts Report charts are supported in both Salesforce Classic and Lightning Experience. Custom S-Controls A page layout can have up to 20 s-controls. To change the properties of an s-control, double-click the s-control or click its wrench icon ( ) and set the following attributes: • Width sets the horizontal size in pixels or a percent. • Height sets the vertical size in pixels. • Show scrollbars determines whether the iFrame in which the s-control displays contains scroll bars when necessary. • Show label determines whether the page layout includes the Label of the custom s-control. Remove the label to display the s-control in a wider area. S-controls aren’t supported in Lightning Experience. Sections You can add and move sections anywhere above the related lists on the page layout. The sections you add can contain fields, s-controls, and blank spaces. In addition, each page layout has a default section that can only contain custom links and blank spaces. You can change the location of the custom link section, but you can’t remove it from the page. The Section user interface element is the second option in the palette when you select the Fields or Custom S-Controls category on the palette. To change the attributes of a section, double-click the section or select its associated wrench icon ( ). You can: • Enter a name for the section. Names of some standard page sections can’t be changed. • Specify whether the section has one or two columns. • Specify the order in which users can tab through the items in that section. • Specify whether the section heading is shown on the detail and edit pages. Tags If tags are enabled, click Layout Properties and configure personal and public tags in the header section of the page layout. Users can’t tag a record if personal or public tags aren’t included in the header section. Also, the positioning of personal and public tags in the header can’t be modified. Tags aren’t supported in Lightning Experience. Visualforce Pages You can add Visualforce pages to any section on the page layout, except for sections reserved for custom links and related lists. A page layout can have up to 20 Visualforce pages.
21 Extend Salesforce with Clicks, Not Code Control User Access to Fields
You can add a Visualforce page to a page layout only if the standard controller on the Visualforce page is set to the object for which you’re creating the page layout. If you don’t have any Visualforce pages with a standard controller set to that object, the Visualforce Pages category doesn’t appear in the palette. Visualforce pages added as mobile cards in the page layout editor don’t appear in the Salesforce mobile app. To have a Visualforce page appear on a mobile record page, add it to the page as a Visualforce component using the Lightning App Builder.
SEE ALSO: Guidelines for Using the Enhanced Page Layout Editor Customize Page Layouts with the Enhanced Page Layout Editor
Guidelines for Using the Enhanced Page Layout Editor
• Elements that are already on the page layout still appear on the palette but are inactive. When EDITIONS you click an inactive element on the palette, Salesforce highlights the element on the page layout. Available in: Salesforce • Removing a field from a page layout doesn’t remove it from the object’s compact layout. The Classic and Lightning two layout types are independent. Experience
• If the original page layout editor is enabled, users can click the page layout name to access the Available in: All Editions detail page of the page layout. The enhanced page layout editor doesn’t have detail pages, as all the detail page functionality is always available on the enhanced editor. Salesforce displays a read-only version of the enhanced page layout editor to users with the “View Setup and USER PERMISSIONS Configuration” permission. To customize page layouts: Note: The read-only view of the page layout doesn’t display field types and lengths in • Customize Application hover details. To view page layouts: • View Setup and • The Custom Links, Custom S-Controls, and Visualforce Pages categories appear in the palette Configuration only if you’ve defined those types of elements for the object for which you’re defining a page layout. When you create a custom link for an object, you add it to the Custom Links section on that object’s page layout. In non-English Salesforce orgs, the “Custom Links” section title isn’t translated from English automatically for the Territory and Territory Model objects, but you can edit the section title. • The Canvas Apps category appears in the palette only if you defined at least one canvas app with a location of Visualforce Page. • The Components category appears in the palette only if the available components are supported by the object for which you’re defining a page layout. For example, the Twitter component is supported only on account, contact, and lead page layouts. • When you edit an account page layout for use in Salesforce Classic, the following applies: – On business accounts, you can display a Copy Billing Address to Shipping Address link. On the page layout, in the Address Information section, select the option to display the section header on the Edit page. Next to the Billing Address field, add the Shipping Address field. – You can also display a link on person accounts. On the page layout, in the Address Information section, select the option to display the section header on the Edit page. Next to the Billing Address field, add the Shipping Address or the Mailing Address field. The link says Copy Billing Address to Shipping (or Mailing) Address. – Contact fields and related lists are available on person account page layouts, but contact custom links and custom buttons are not.
• This table lists standard objects with checkboxes that are specific to page layouts for that object. To configure how Salesforce displays the checkboxes, when customizing the page layout, click Layout Properties. Use the Select by default option associated with a checkbox if you want Salesforce to automatically select the option when a user accesses the edit page.
22 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Object Checkboxes
Account Evaluate this account against territory rules on save checkbox — Displays the Evaluate this account against territory rules on save checkbox on account edit pages. Territory assignment rules run automatically when the Select by default checkbox is selected. If both Show on edit page and Select by default are selected, users can uncheck the Evaluate this account against territory rules on save checkbox on the account edit page, and territory assignment rules will not be run.
Case – Case assignment checkbox — Displays the Assign using active assignment rules checkbox on case edit pages. Case assignment rules run automatically when the Select by default checkbox is selected. If both Show on edit page and Select by default are selected, the assignment checkbox is selected by default, but users can deselect it to override the assignment rule.
– Email notification checkbox — Displays the Send notification email to contact checkbox on case edit pages.
Case Close – Solution information section — Displays the solution information section on the case close edit pages. – Notify Contact — Displays the Notify Contact checkbox on case close edit pages.
Lead Lead assignment checkbox — Displays the Assign using active assignment rule checkbox appears on the lead edit page. Lead assignment rules run automatically when the Select by default checkbox is selected. If both Show on edit page and Select by default are selected, the assignment checkbox is selected by default, but users can deselect it to override the assignment rule.
Person Account Evaluate this account against territory rules on save checkbox — Displays the Evaluate this account against territory rules on save checkbox on person account edit pages. Territory assignment rules run automatically when the Select by default checkbox is selected. If both Show on edit page and Select by default are selected, users can uncheck the Evaluate this account against territory rules on save checkbox on the account edit page, and territory assignment rules will not be run.
23 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Task Email notification checkbox — Displays the Send Notification Email checkbox appears on the task edit page.
Note: A user’s personal preference for defaulting the state of the checkbox takes precedence over the organization-wide setting.
SEE ALSO: User Interface Elements for the Enhanced Page Layout Editor Customize Page Layouts with the Enhanced Page Layout Editor
Page Layout Tips
Here are a few tips to keep your page layouts organized and easy to use. EDITIONS • Use field-level security to restrict users’ access to fields; then use page layouts to organize detail and edit pages within tabs. This reduces the number of page layouts for you to maintain. Available in: both Salesforce Field-level security settings override the visible and read-only settings on the page layout if the Classic and Lightning field-level security has a more restrictive setting than the page layout. Experience • Remove unnecessary fields. Page layouts are available • Keep the number of required fields to a minimum. in: All Editions • Group similar fields with sections. Creation and deletion of • Think about the right TAB key order for each section. page layouts is available in: Professional, Enterprise, • Check your layouts in Read and Edit modes. Performance, Unlimited, • Add help and description text to custom fields. Use it to explain to users what data you’re and Developer Editions looking for in the field. • In Professional, Enterprise, Performance, Unlimited, and Developer Editions, use record types to provide unique layouts for different records. • Optimize related lists—adjust their overall order, the sorting of the records, and display of relevant columns and buttons. • If you want to customize the user profile layout in the Salesforce mobile app, create a new layout or edit an existing layout in the User Profile Page Layouts section. • If a dependent lookup is above its controlling field on a page layout, make its lookup filter optional or redesign the page layout. Placing a required dependent lookup above its controlling field on a page layout could confuse users who typically start from the top of the page when entering data. • A background process periodically runs that cleans up metadata associated with deleted custom fields. This process will affect the Last Modified Date and Last Modified By fields on page layouts, record types, and custom objects. • Salesforce recommends creating no more than 200 page layouts. Although there is no limit, it can be difficult to manage your page layouts if you have more than 200.
24 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Page Layout Considerations
Keep these considerations in mind when working with page layouts in the enhanced page layout EDITIONS editor. Available in: both Salesforce Page Layouts Classic and Lightning Experience • You can’t rename a page layout if you’re using Salesforce Professional Edition. • You can drag up to 20 s-controls, 20 Visualforce pages, 20 expanded lookups, and 100 related Page layouts are available lists onto a page layout. There are no limits on custom links. in: All Editions Creation and deletion of Note: You can’t place a Visualforce page more than once on a page layout. page layouts is available in: Professional, Enterprise, • In Lightning Experience, page layouts support up to 55 lookup fields. In Salesforce Classic, page Performance, Unlimited, layouts support up to 40 lookup fields. and Developer Editions • Don’t add more than four external lookup fields to your page layout. On Lightning Experience record pages, a Record Detail component that contains more than four external lookup fields breaks the page at runtime. • You can add one dashboard per page layout. • Page layouts for the user object only include custom fields, custom links, s-controls, and Visualforce pages. Tagging, related lists, custom buttons, and standard field customizations aren’t included on page layouts for the user object. Also, field-level security is only available for custom fields on the user object. Only standard Chatter actions appear on the user profile page, regardless of which actions are assigned to the User Page Layout or the global publisher layout. • You can edit only certain attributes when you’re working with a page layout that was installed from a managed app. Some changes that you make to managed page layouts, such as adding components, work when you’re editing the page layout but aren’t reflected on the record detail page. • Chatter group layout changes affect the Salesforce mobile app only. Changes to the group publisher (actions and layout) reflect in both the full Salesforce site and the Salesforce mobile app.
Related Lists • You can include up to 10 fields per related list. • In Lightning Experience, the related list type determines how many fields are displayed in a related list. The Basic List related list type displays only the first four fields of a related list. The Enhanced List type shows up to 10 fields, lets you resize and sort columns, perform mass actions, and wrap text. To change the related list type, customize the related list component in the Lightning App Builder. • You can’t move the first field of a related list, because it’s a unique identifier for the record. • You can add custom fields of the long text area type to a related list. However, you can’t add some standard fields of the long text area type. For example, you can’t add the Description field on an Opportunity to a related list. • The default sort order varies per record. The Sort By dropdown isn’t available for activities and opportunity products. • Lookup fields aren’t available for display on their corresponding lookup related list. For example, the case lookup field on an account page layout isn’t available when editing the cases related list. • You can’t customize the History related list because it links to data stored elsewhere.
Mini Page Layouts • You can’t choose Mini Console View for the Close Case layout, Log a Case page, or View Cases page layouts on the Self-Service Portal. You can’t choose Mini Console View for opportunity team page layouts.
25 Extend Salesforce with Clicks, Not Code Control User Access to Fields
• Field properties on the page layout determine field properties on the mini page layout. For example, if a field is read-only on the page layout, that same field is read-only on the mini page layout. To change the field properties of fields on the mini page layout, you must change the field properties of fields on the page layout. • You can’t define mini page layouts for the Close Case layout, Log a Case page, or View Cases page layouts on the Self-Service Portal. You can’t define mini page layouts for opportunity team page layouts. • You can define mini page layouts for the user object; however, you cannot add standard fields or related lists. Also, a customized mini page layout won’t display in the Agent console. • Overrides for the Edit and View buttons for an object don’t affect the Edit and View buttons in mini page layouts. • Fields marked Always Displayed or Always on Layout on page layouts are automatically included on the mini page layout and can’t be removed unless they’re removed from the page layout.
Knowledge Layouts • Authoring actions that you add to the Salesforce Mobile and Lightning Experience Actions section of the page layout appear in the highlights panel on record pages in Lightning Experience and the Salesforce mobile app. • To use inline edit with Knowledge, add the Publication Status field to your standard page layout. The Publication Status field must be in the standard page layout, not in a compact layout. However, the field can appear in both the standard and compact layouts.
Tip: If the Publication Status field is in a collapsed layout section, you must expand the section to load the edit icons before you can use inline editing. To increase the accessibility of inline editing, add the Publication Status field to a layout section that is likely to always be open.
• The Title and URL Name standard fields are required. You can’t remove them from the layout. • To control which audiences can view an article, add these fields to the page layout: Visible in Internal App; Visible to Customer; Visible to Partner; and Visible in Public Knowledge base. The fields appear as checkboxes in the record.
Customize Salesforce Classic Home Tab Page Layouts
You can customize the Home tab in Salesforce Classic to include components such as sidebar links, EDITIONS a company logo, a dashboard snapshot, or custom components that you create. A dashboard snapshot is a clipping of the top row of a dashboard’s components. Just like other tabs, you can Available in: Salesforce also assign different home page layouts to different users based on profile. Classic You can add components to the sidebar or the main panel. You can also determine if custom sidebar Available in: All Editions components appear only on the Home tab or on all Salesforce pages.
USER PERMISSIONS Create Custom Home Page Components Use custom components to configure the Salesforce Classic home page for your users. Add To view home page layouts: HTML, images, links, and more to enhance your users’ productivity. • Customize Application Design Home Page Layouts in Salesforce Classic To create or change home After creating the components you want displayed on the Home tab, design your home page page layouts: layouts. You can design your layouts based on your unique organizational and user needs. • Customize Application Visualforce Area Home Page Components Use Visualforce Area home page components to add dynamic content to your home page. For example, you can present content from partner apps, display charts with the Reports and Dashboards REST API, or add a canvas app to the home page. Home Page Components Tips and Considerations Keep these considerations in mind when creating custom components that you want displayed on the Salesforce Classic Home tab.
26 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Assign Home Tab Page Layouts to Profiles Your home page layouts are only visible to users after you assign them to a user profile.
Create Custom Home Page Components
Use custom components to configure the Salesforce Classic home page for your users. Add HTML, EDITIONS images, links, and more to enhance your users’ productivity. Before you begin: Available in: Salesforce Classic • If you’re creating custom link components, define your Home tab custom links first. See Custom Buttons and Links on page 774. Available in: All Editions • If you’re creating an image component, upload your image to the Documents tab first. • If you’re creating a Visualforce Area component, create your Visualforce page first. USER PERMISSIONS 1. From Setup, enter Home Page Components in the Quick Find box, then select To create or change home Home Page Components. page layouts: 2. Click New. • Customize Application 3. Enter a name for the component. For custom links, this name is displayed as the section heading in the sidebar on the Home tab. 4. Choose the type of component. 5. Click Next, and then complete one or more of these steps. • For links, select the appropriate custom links, and then click Add. • For images, click Insert an image, choose the document folder, and then select the image file. The image file must be in a public folder and Externally Available must be enabled on the document’s properties so that users can view the image.
Tip: Keep your image size smaller than 20 KB for optimum performance.
• For an HTML Area component, choose where to display it—in the wide or narrow column—and then enter your content in the box below.
Note: HTML Area home page components don’t support JavaScript, CSS, iframes, and some other advanced markup. To use JavaScript or other advanced HTML elements in your home page component, we recommend that you use a Visualforce Area component instead.
• For a Visualforce Area component, choose where to display it—in the wide or narrow column—then select the Visualforce page, and assign it a height.
6. Click Save. After creating the home page component, you need to add it to a home page layout. See Design Home Page Layouts in Salesforce Classic on page 28.
Note: Components in the narrow column are displayed in the sidebar. They aren’t displayed in the sidebar on other pages in Salesforce unless you specify that in your user interface settings or by assigning the “Show Custom Sidebar On All Pages” permission.
SEE ALSO: Visualforce Area Home Page Components Home Page Components Tips and Considerations
27 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Design Home Page Layouts in Salesforce Classic
After creating the components you want displayed on the Home tab, design your home page EDITIONS layouts. You can design your layouts based on your unique organizational and user needs. 1. From Setup, enter Home Page Layouts in the Quick Find box, then select Home Available in: Salesforce Page Layouts. Classic 2. Click to edit an existing layout or create one. Alternately, select a layout to copy and click Clone. Available in: All Editions 3. If you create a layout, give it a name and then click Save. 4. Select the components to display on the layout. USER PERMISSIONS
• To add the Find Articles component, select Article Search. This component is only available To view home page layouts: for Salesforce Knowledge users. • View Setup and • To add the Customer Portal component, select Customer Portal Welcome. If the My Configuration Profile site Visualforce page has been enabled, this component contains a personalized To create or change home welcome message and a link to the portal user’s profile. The My Profile page enables users page layouts: logged into either your Salesforce site, or your Customer Portal from Salesforce sites, to • Customize Application update their own contact information. When they make changes to this page, the corresponding portal user and contact records are updated. • To allow your users to resume flow interviews that they’ve paused, select Paused Flow Interviews. This component displays only flow interviews that the user has paused.
Note: You can add up to 20 components to a home page layout.
5. Click Next. 6. Customize the order in which the narrow and wide components appear. Move a component by selecting it and using the arrow buttons. 7. Click Save.
SEE ALSO: Assign Home Tab Page Layouts to Profiles Customize Salesforce Classic Home Tab Page Layouts
Visualforce Area Home Page Components
Use Visualforce Area home page components to add dynamic content to your home page. For EDITIONS example, you can present content from partner apps, display charts with the Reports and Dashboards REST API, or add a canvas app to the home page. Available in: Salesforce The Visualforce page that you choose for the component can use a standard or custom controller. Classic (not available in all You can include JavaScript in your Visualforce page, but because the component is rendered in an orgs) iframe on the home page layout, the JavaScript can’t interact with the page that contains the Available in: All Editions component.
Sample Usage If your Visualforce Area home page component displays in the sidebar, you can dynamically get the record ID and top-level URL of the page that the component is being displayed on by using the $CurrentPage global variable in your Visualforce markup.
28 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Using $CurrentPage, you can access the query string parameters for the page by specifying the parameters attribute, after which you can access each individual parameter:
$CurrentPage.parameters.parameter_name
The parameters for record ID and top-level page URL are, respectively, id and sfdcIFrameOrigin. For more information, see “Getting Query String Parameters” in the Visualforce Developer's Guide.
Home Page Components Tips and Considerations
Keep these considerations in mind when creating custom components that you want displayed EDITIONS on the Salesforce Classic Home tab. • Standard components without an Edit link are read only. Available in: Salesforce • The components that you select for the narrow column display in the sidebar. They don’t display Classic in the sidebar on other pages within Salesforce unless you specify that in your user interface Available in: All Editions settings. If you only want certain users to view sidebar components on all pages, grant those users the “Show Custom Sidebar On All Pages” permission. • When editing the standard Messages & Alerts component, enter the text that you want to display to users. If entering HTML code for your message, make sure that it’s self-contained, well-formed HTML.
Note: Standard Messages & Alerts home page components don’t support JavaScript, CSS, iframes, and some other advanced markup.
• When editing the standard Custom Links home page component, enter the link text to display to users in the Bookmark field. In the URL field, enter the complete website address, such as http://www.yahoo.com. To link to a Salesforce page, enter only the part of the URL after salesforce.com, for example, /00Ox0000000esq4. These links always open within the main Salesforce window, not in a popup window. • The standard Custom Links home page component is a quick way to add links to the sidebar, but it doesn’t support merge fields, functions (such as URLFOR), executing JavaScript, or customizable window opening properties. If you need this additional functionality: 1. From Setup, enter Home in the Quick Find box, then select Custom Links, and then create your home page custom links on that page. 2. From Setup, enter Home in the Quick Find box, then select Home Page Components, and then create a custom home page component of type Links on that page that includes the custom links that you created in the first step. Creating a custom home page component for your links doesn’t change the visual styling for your end users.
• The Dashboard Snapshot component displays the top three components of the last dashboard the user accessed. Users can view a dashboard snapshot on their Home tab if they have access to at least one dashboard. • When designing home page layouts for your Customer Portal, we recommend adding the following components: Search, Solution Search, Recent Items, Customer Portal Welcome, and a custom HTML Area component that includes your corporate branding in the wide column. • You can add up to 20 components to a home page layout.
SEE ALSO: Create Custom Home Page Components
29 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Assign Home Tab Page Layouts to Profiles
Your home page layouts are only visible to users after you assign them to a user profile. EDITIONS 1. From Setup, enter Home Page Layouts in the Quick Find box, then select Home Page Layouts. Available in: Salesforce Classic 2. Click Page Layout Assignment. 3. Click Edit Assignment. Available in: All Editions 4. Choose the appropriate page layout for each profile. Initially, all users, including Customer Portal users, are assigned to the Home Page Default layout. USER PERMISSIONS
5. Click Save. To assign home page layouts: Tip: Users can customize the dashboard settings on their Home tab in their personal settings. • Customize Application
Set Page Layouts and Field-Level Security
Use field-level security as the means to restrict users’ access to fields; then use page layouts primarily EDITIONS to organize detail and edit pages within tabs. This reduces the number of page layouts for you to maintain. For example, if a field is required in the page layout and read only in the field-level security Available in: both Salesforce settings, the field-level security overrides the page layout and the field will be read only for the user. Classic and Lightning Experience
For Personal, Contact Manager, and Group Editions Page layouts and search 1. Create custom fields. layouts available in: All Editions 2. Create any custom buttons or links. Field-level security available 3. Create any custom s-controls. in: Professional, Enterprise, 4. Define page layouts. All users automatically use the same page layout for each object. Performance, Unlimited, and Developer Editions 5. Set the related objects and the mini page layouts that display in the console. 6. Define search layouts. All users use the same search layouts.
For Professional, Enterprise, Unlimited, Performance, and Developer Editions 1. Create custom fields. 2. Create any custom buttons or links. 3. Create any custom s-controls. 4. Create any custom profiles. 5. Create record types for different business scenarios. 6. Assign which record types are available to users with different profiles. 7. Set the field-level security for each profile to restrict users’ access to specific fields. 8. Define page layouts to organize your pages. 9. Set the related objects and the mini page layouts that display in the console. 10. Assign page layouts to users based on profiles and record types. 11. To verify that all field access settings are correct, check the field accessibility grid. 12. Define search layouts. All users use the same search layouts.
30 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Tip: Click Preview while editing a page layout to see how the page will look for users with different profiles. This preview includes any extra security that is set in field-level security.
SEE ALSO: Field-Level Security
Assign Page Layouts to Profiles or Record Types
After defining page layouts, assign which page layouts users see. A user’s profile determines which EDITIONS page layout he or she sees. In addition, if your organization is using record types for a particular object, the combination of the user’s profile and the record type determine which page layout is Available in: both Salesforce displayed when a user views records for that object. Classic and Lightning You can assign page layouts from: Experience • The object's customize page layout or record type page Page layouts are available • The original or enhanced profile user interface. in: All Editions To verify that users have the correct access to fields based on the page layout and field-level security, Record types are available you can check the field accessibility grid. From Setup, enter Field Accessibility in the in: Professional, Enterprise, Quick Find box, then select Field Accessibility. From this page, choose a particular object to view Performance, Unlimited, and then select whether you want to check access by profiles, record types, or fields. and Developer Editions
SEE ALSO: Page Layouts Assign Page Layouts in the Original Profile User Interface Assign Record Types and Page Layouts in the Enhanced Profile User Interface Tailor Business Processes to Different Users Using Record Types Control User Access to Fields
31 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Assign Page Layouts from a Customize Page Layout or Record Type Page
1. From the management settings for the appropriate object, go to Page Layouts or Record Types. EDITIONS 2. Click Page Layout Assignment. 3. Click Edit Assignment. Available in: Salesforce Classic and Lightning 4. Use the table to specify the page layout for each profile. The table displays the page layout Experience assignments for each profile. If your organization uses record types, a matrix displays a page layout selector for each profile and record type. Page layouts are available in: All Editions When selecting page layout assignments: Record types are available • Click a cell, column, or row heading to select all the table cells in that column or row. in: Professional, Enterprise, • Press SHIFT+click to select multiple adjacent table cells, columns, or rows. Performance, Unlimited, • Press CTRL+click to select multiple nonadjacent table cells, columns, or rows. and Developer Editions • Click any cell and drag to select a range of cells. • Click Next or Prev to view another set of record types. USER PERMISSIONS
Selected page layout assignments are highlighted. Page layout assignments you change are To assign page layouts: italicized until you save your changes. • Manage Profiles and Permission Sets 5. If necessary, select another page layout to assign from the Page Layout To Use drop-down list and repeat the previous step for the new page layout. 6. Click Save.
SEE ALSO: Assign Page Layouts to Profiles or Record Types
Edit Multi-Line Layouts for Opportunity Products
You can customize the columns that display when you click Edit All in the Products related list of EDITIONS an opportunity detail page. 1. From the object management settings for opportunity products, go to Page Layouts. Available in: Lightning Experience and Salesforce 2. Next to the name of an opportunity product page layout, click Edit. Classic (not available in all 3. Click Edit Multi-Line Layout. orgs)
4. Move fields between Available Fields and Selected Fields. Available in: Professional, • To customize which fields display in the layout, select one or more fields in Available Fields Enterprise, Performance, and click Add or Remove. Unlimited, and Developer Editions • To sort fields in the layout, select one or more fields in Selected Fields and click Up or Down. • To select multiple fields individually, use CTRL+click. USER PERMISSIONS • To select multiple fields as a group, use SHIFT+click.
Note: Product and Quantity fields are required and can’t be removed from the layout. To edit multi-line layouts for opportunity products: • Customize Application 5. Click Save.
32 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Build Page Layouts for Custom Objects
Page layouts define which fields users can view and edit when entering data for a custom object EDITIONS record. You can use the default page layout that is created automatically when you create a custom object. You can also build your own page layout with related lists and custom links. If you do not Available in: both Salesforce use any page layout with your custom object, you can still interact with it by using the Lightning Classic (not available in all Platform API to manage custom data or build a custom user interface. orgs) and Lightning Experience
Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To define page layouts for custom objects: • Customize Application
1. From the object management settings for a custom object, go to Page Layouts. 2. In the Page Layouts related list, open an existing page layout for edit, or create a new page layout. 3. If creating a new page layout, enter a name for it, and select an existing page layout to clone, if desired. 4. Edit the page layout just as you would any other page layout. 5. Click Save.
SEE ALSO: Page Layouts Find Object Management Settings
33 Extend Salesforce with Clicks, Not Code Control User Access to Fields
How Page Layouts Work in the Salesforce Mobile App
Use the enhanced page layout editor to customize the layout of an object’s record detail pages, EDITIONS configure actions, and adjust which fields and related lists appear in the Salesforce mobile app. In the Salesforce mobile app, page layouts drive these areas of the mobile experience. Available in: both Salesforce Classic and Lightning Record Related Information and Detail Pages Experience When you view a record in the mobile app, you see the fields, Visualforce pages, and related lists that are based on the record type and the user’s profile. Related lists show up as single-line Available in: All editions cards containing the name of the page or related list. Tapping the related list card displays its except Database.com details. Actions Actions in the Salesforce Mobile and Lightning Experience Actions section of a page layout appear in the action bar and action menu on the object’s record pages. Here are the record details, related lists, and action menu for a sample account, Edge Communications:
Page Layouts in Lightning Experience
When you customize your page layouts in Salesforce Classic, those changes can affect the content EDITIONS of object record pages in Lightning Experience. However, in Lightning Experience, the page elements display differently and some aren’t supported. Available in: Lightning If your org supports multiple page layouts, you can create a page layout from the Page Layouts Experience related list on any object in the Object Manager. You can also edit or delete an object’s page layouts Page layouts are available by clicking on a page layout in the Page Layouts related list. in: All Editions
Here’s a sample contact record in Lightning Experience. The highlights panel contains key record Creation and deletion of fields and is the only part of a record page that you can’t customize using the page layout editor. page layouts is available in: The fields in the highlights panel are customized using a compact layout. Enterprise, Performance, Unlimited, and Developer Editions
34 Extend Salesforce with Clicks, Not Code Control User Access to Fields
These page layout elements are supported in Lightning Experience. Actions Actions display in different places, such as the highlights panel, Activity tab, and the Chatter tab. The actions are derived from the list of actions in the Salesforce Mobile and Lightning Experience Actions section of the page layout. Some actions aren’t supported in Lightning Experience. For more information, see Actions in Lightning Experience on page 754. Blank Spaces Blank spaces are supported in Lightning Experience. Canvas Apps Canvas apps are supported in Lightning Experience. Custom Links Custom links display under the Details tab. Fields Fields display under the Details tab. You can remove or reorder fields on a page layout only via the page layout editor. The top-down tab-key order, which allows users viewing a record detail page to move through a column of fields from top to bottom before moving focus to the top of the next column of fields, isn’t supported in Lightning Experience. Even if a page layout is configured for a top-down tab-key order, tabbing moves from left-to-right through field columns in Lightning Experience. Related Lists Related lists are included as Lightning components in Lightning Experience. Not all related lists are supported in Lightning Experience. In Lightning Experience, the related list type determines how many fields are displayed in a related list. The Basic List related list type displays only the first four fields of a related list. The Enhanced List type shows up to 10 fields, lets you resize and sort columns, perform mass actions, and wrap text. To change the related list type, customize the related list component in the Lightning App Builder. Report Charts Report charts that you add to a page layout appear under the Details tab in Lightning Experience. When you add a report chart to a page layout, it can take a few moments before the chart appears on Lightning record pages. Sections Sections appear along with fields under the Details tab. A section with no header is incorporated into the section above it.
35 Extend Salesforce with Clicks, Not Code Control User Access to Fields
The Detail Page visibility setting controls whether the section header appears for both the detail page and the edit page. If the section header is set to display (or hide) on the detail page, the header also displays (or hides) on the edit page. Standard and Custom Buttons Standard and custom buttons are treated as actions in Lightning Experience, just like in the Salesforce mobile app.
Important: Custom buttons that call JavaScript aren’t supported in Lightning Experience.
Visualforce Pages Visualforce pages that you added to the page layout appear under the Details tab. Only Visualforce pages with Available for Lightning Experience, Experience Builder sites, and the mobile app enabled display in Lightning Experience on Lightning pages, utility bars, and the Salesforce mobile app. These page layout elements aren’t supported in Lightning Experience. • Expanded lookups • Mobile cards • S-controls • Section header visibility for Edit Page • Tags
Note: You can’t use the enhanced page layout editor to customize the layout of Lightning Experience record home pages.
SEE ALSO: Add Send an Email, Log a Call, New Event, and New Task Buttons to the Activity Composer Customize Record Page Settings
Tips for Optimizing Page Layouts for the Salesforce Mobile App
Here are some tips and tricks for making your existing page layouts more mobile-friendly. EDITIONS Page layouts containing dozens of fields and lots of related lists might be manageable when viewing records on a computer screen, but on a small mobile device, viewing that same record can be Available in: both Salesforce overwhelming. People accessing information using a mobile device are looking for a quick way to Classic and Lightning get what they need, and making your users sift through hundreds of fields and related lists just Experience doesn’t make sense. Available in: All editions When optimizing a page layout, consider: except Database.com • What are the important things to see at a glance? • What are the important moments for your users when they’re working in the Salesforce mobile app? • What actions or processes can you automate so that your users don’t have to manually do them?
The Key: Organize and Minimize Fields • Use sections to organize information logically, putting the most important things at the top of the page so they show up first. Your users don’t want to search for fields individually. Organizing similar fields in sections will help your users find what they need. They can then easily scroll down the page to the section they care about. • For accounts, contacts, and leads, you don’t need to put phone or email fields near the top. They’re already quickly accessible via the and icons on each record page’s action bar.
36 Extend Salesforce with Clicks, Not Code Control User Access to Fields
• You don't need to keep fields in one column, as the page will render dynamically. Salesforce for iOS or Android will reorder the fields into a single column, while web browsers can show two columns. • Put the most important fields into the compact layout—which drives record highlights and record preview cards in the mobile app—so they’re available right up front, and so your mobile users don’t have to drill into the record detail. We’ll get into compact layouts in more detail soon. • Keep the number of required fields to a minimum. Setting a field to required means it must appear on the detail page of all page layouts, so consider whether each field is truly required. You might have to convince stakeholders that a field isn’t actually necessary for a record to be saved. • If available in your organization, think about using record types so that fields that aren’t common to all records don’t have to appear on all records. • To reduce the number of fields on a screen, consider using default values for new records instead of having the user enter the data.
Manage Mobile Cards in the Enhanced Page Layout Editor
Add expanded lookups, components, and Visualforce pages to the Mobile Cards section of your EDITIONS page layout to have them show up as mobile cards in the Salesforce mobile app.
Important: The Mobile Cards section of the page layout editor is no longer supported as of Available in: both Salesforce Spring ’20. Items in the Mobile Cards section, such as components and expanded lookups, Classic and Lightning no longer display in the Salesforce mobile app. For more information, see Mobile Cards Are Experience Not Available in the New Salesforce Mobile App in the Salesforce Spring ’20 release notes. Available in: All editions except Database.com
USER PERMISSIONS
To customize page layouts: • Customize Application To view page layouts: • View Setup and Configuration
Customize Related Lists
You can customize the buttons, columns displayed, column order, and record sort order of related EDITIONS lists on record detail pages in Salesforce and the Salesforce Customer Portal. 1. Access the page layout editor. Available in: both Salesforce Classic and Lightning 2. To edit a related list, double-click its tab. If you’re using the enhanced page layout editor, you Experience can also click the wrench icon ( ). Available in: All Editions Note: You can’t customize the History related list because it links to data stored elsewhere. except Database.com
3. Select which fields to include in the related list, define the order in which the fields display, and select the record sort order. The default sort order is by record ID. You can include up to 10 USER PERMISSIONS fields per related list. To display more than four fields in Lightning Experience, edit the related To customize related lists: list component in the Lightning App Builder and choose Enhanced List as the related list type. • Customize Application 4. If desired, select other page layouts to apply your related list customizations to.
37 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Only layouts that include this related list appear in the list. Layouts that include related lists with the same customizations as the current layout had when you opened it are selected by default.
5. Click + in the Buttons section to customize which standard and custom buttons are displayed in the related list.
Note: The custom button must be defined for the object contained in the related list, not the parent object, and the button Type must be List Button. For example, to display a custom button on the Contacts related list of an account, define the custom button for contacts, not accounts.
6. If necessary, click Revert to Defaults to undo any customizations and use the default Salesforce settings in the related list. 7. Click OK to store your customizations. Changes aren’t saved until you save the page layout. 8. Select Overwrite users’ customized related lists to apply the related lists in the page layout to all users, even if they’ve already customized their display. 9. Save the page layout.
Note: You can enable related list hover links so that record detail pages include links for each related list at the top of the page. Users can hover over the link to display the corresponding related list in an interactive overlay to view and manage the related list items. Users can also click the link to jump to the content of the related list without scrolling down the page.
SEE ALSO: Control User Access to Fields Knowledge Article: Unable to Edit a Related List
Customize Detail Page Buttons
When customizing page layouts, you can control which standard and custom buttons are displayed EDITIONS and the order in which the custom buttons are shown. To customize the buttons on record detail pages: Available in: both Salesforce 1. From the management settings for the object whose page layout you want to customize, go Classic and Lightning to Page Layouts. Experience 2. Click Edit next to the page layout you want to customize. Available in: All Editions 3. Do one of the following. • In the original page layout editor, double-click the Detail Page Buttons item in the Button USER PERMISSIONS Section. To customize detail page – To hide any standard button, deselect the checkbox next to the button name. buttons: – To add or remove a custom button, select the button in the Available Buttons list, and • Customize Application click Add or Remove. – Sort custom buttons by selecting them and clicking Up or Down. – To undo your customizations and restore default settings, click Revert to Defaults. – Click OK to close the popup when you are done.
• In the enhanced page layout editor, select the Buttons category on the palette and drag one or more buttons from the palette to the buttons section on the page layout. Standard buttons must go in the standard buttons area, and custom buttons must go in the custom buttons area. To remove a standard or custom button from the page layout, drag the button to the palette.
4. Click Save on the page layout.
38 Extend Salesforce with Clicks, Not Code Control User Access to Fields
5. Click Save.
SEE ALSO: Override Standard Buttons and Tab Home Pages Define Custom Buttons and Links Find Object Management Settings
Customize Page Layouts with the Original Page Layout Editor
Use the original page layout editor to customize page layouts in Salesforce, the Self-Service Portal, EDITIONS and the Salesforce Customer Portal.
Note: We recommend using the enhanced page layout editor instead of the original page Available in: Salesforce layout editor because it offers more features and an easier-to-use interface. Classic 1. Access the page layout editor. Available in: All Editions • Edit Page Layouts for Standard Objects • Edit Page Layouts for Custom and External Objects USER PERMISSIONS
2. If tags are enabled, specify whether personal and public tags should be included in the header To customize page layouts: section of the page layout. Users can tag a record only if personal or public tags are included • Customize Application here. • To add personal or public tags, select Header Items from the View dropdown list and then drag the Personal Tags or Public Tags items to the header section. You can’t change the order in which personal and public tags appear when both are in the header section at the same time. • To remove tags, drag the Personal Tags and Public Tags items from the header section to the area under the View dropdown list.
3. To customize buttons, double-click Detail Page Buttons in the Button section. 4. To arrange fields, custom s-controls, Visualforce pages, custom links, and related lists on the layout, select one or more items from the box on the right and drag them to the desired location. You can drag up to 20 s-controls, 20 Visualforce pages, 20 expanded lookups, and 100 related lists onto a page layout. There are no limits on custom links.
Note: You can add a Visualforce page to a page layout only if the standard controller on the Visualforce page is set to the object for which you’re creating the page layout. If you don’t have any Visualforce pages with a standard controller set to that object, the Visualforce Pages category doesn’t appear in the palette.
5. To set which fields are required and read only, select one or more fields and click Edit Properties. • You can change custom fields only if they are not universally required fields. • Fields marked as read only are always editable by administrators and users with the Edit Read Only Fields permission. • If you make a picklist field read only, all new records contain the default value for that picklist. • Auto-number fields are always read only. • If you make the opportunity Probability field read only, the Probability value still updates automatically when a user changes the Stage value of an opportunity. • In Professional, Enterprise, Unlimited, Performance, and Developer Editions, field-level security settings override the field properties you set here if the field-level security is more restrictive than the page layout setting.
6. To change the properties of an s-control or Visualforce page, double-click it and set the following attributes.
39 Extend Salesforce with Clicks, Not Code Control User Access to Fields
• Width sets the horizontal size in pixels or a percent. • Height sets the vertical size in pixels. • Show scrollbars determines whether the iFrame in which the s-control displays contains scrollbars when necessary. • Show label determines whether the page layout includes the label of the custom s-control. Remove the label to display the custom s-control in a wider area.
7. To organize the page using sections, click Edit next to an existing page section, or click Create New Section. 8. To customize related lists on the page layout, double-click a related list in the Related List section. Some related lists aren’t customizable because they link to data rather than store it. You can move your cursor over any related list section to see if it is customizable. Also, lookup fields are not available for display on their corresponding lookup related list. For example, the case lookup field on an account page layout isn’t available when editing the cases related list.
9. To apply the related lists in the page layout to all users, even if they’ve already customized their display, select Overwrite users’ customized related lists. 10. To review the page layout, click Preview. From the preview in Enterprise, Unlimited, Performance, and Developer Editions, select a profile to see how the pages look for users with different profiles. Most related lists’ columns preview without data. 11. Click Save to finish. Alternatively, click Quick Save to save and continue editing the page layout. In Professional, Enterprise, Unlimited, Performance, and Developer Editions: • To choose which related records display in the Console tab’s mini view, click Mini Console View. • To define the mini page layouts of the records that appear in the Console tab’s mini view, click Mini Page Layout.
Note: You can’t define mini console views or mini page layouts for the Close Case Layout or the Log a Case Page and View Cases Page layouts on the Self-Service Portal. In Enterprise, Unlimited, Performance, and Developer Editions: • You can assign page layouts for different profile and record type combinations. • You can set field-level security to restrict field access further.
Notes on Using the Original Page Layout Editor
SEE ALSO: Notes on Using the Original Page Layout Editor Customize Related Lists Page Layouts
Notes on Using the Original Page Layout Editor
• When customizing page layouts for tasks, you can select the following checkboxes. (These EDITIONS options are unavailable when user control over task assignment notifications is enabled.) – Show Task Email Notification checkbox displays the Send Available in: Salesforce Notification Email checkbox when users create or edit a task. Classic – Select Task Email Notification checkbox by default selects the Available in: All Editions Send Notification Email checkbox by default when users create or edit a task. Note that a user's personal preference for defaulting the state of the checkbox takes precedence over the organization-wide setting.
40 Extend Salesforce with Clicks, Not Code Control User Access to Fields
• When customizing page layouts for cases, you can select the following checkboxes. (These options are unavailable when user control over task assignment notifications is enabled.) – Show on edit page Case Assignment checkbox displays the Assign using active assignment rules checkbox when users create or edit a case. – Default Case Assignment checkbox automatically runs case assignment rules. If both Show on edit page and Select by default are selected, the assignment checkbox is selected by default, but users can deselect it to override the assignment rule.
– Show Case Email Notification checkbox displays the Send Notification Email checkbox when users create or edit a case. – Select Case Email Notification checkbox by default selects the Send Notification Email checkbox by default when users create or edit a case.
• Page layouts for the user object only include custom fields, custom links, s-controls, and Visualforce pages. Tagging, related lists, custom buttons, and standard field customizations are not included on page layouts for the user object. Also, field-level security is available only for custom fields on the user object. • You can define mini page layouts for the user object; however, you cannot add standard fields or related lists. Also, a customized mini page layout won’t display in the Agent console. • Users can import values into a field only if they have read and edit access. User permissions, page layout assignments, and field-level security settings determine field access. • In Personal, Contact Manager, and Group Editions, page layouts control which fields users can access in related lists, list views, reports, Connect Offline, email and mail merge templates, custom links, and when synchronizing data. In Professional, Enterprise, Unlimited, Performance, and Developer Editions, this access is controlled by field-level security. • In Professional, Enterprise, Unlimited, Performance, and Developer Edition, individual users can customize which tabs and related lists display for their personal use. • When editing a person account page layout, if you add Shipping Address next to Billing Address in the Address Information section, a link will display on the person account edit page that allows you to copy the billing address to the shipping address. Also, an equivalent link appears if you add Other Address to the Address Information section. • Some items can only be moved to certain sections on the page layout. For example, you can drag a custom s-control to any field section on the page layout but not a related list section or button section. • Create the appropriate buttons before editing your page layout. For example, create an account custom button for the detail page and a contact custom list button before putting them both on an account page layout. • If you use the original page layout editor to view a page layout that was created in the new page layout editor, the original page layout editor will show any blank spaces you added. You cannot move or add blank spaces in the original page layout editor, but you can remove them by dragging them to the box on the right.
SEE ALSO: Customize Page Layouts with the Original Page Layout Editor
41 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Compact Layouts
A compact layout displays a record’s key fields at a glance in the Salesforce mobile app, Lightning EDITIONS Experience, and in the Outlook and Gmail integrations. Creating and customizing compact layouts for objects isn't required, because system defaults are Available in: Salesforce provided out of the box. However, we recommend using compact layouts to put important fields Classic (not available in all into object record headers—and elsewhere—to help your users get the information they need orgs) and Lightning quickly. Experience In the Salesforce mobile app, the fields that you assign to a compact layout appear in: Available in: All editions except Database.com • An object record’s highlights area (shows up to ten fields) • Expanded lookup cards on a record’s related information page (shows the first four fields) In Lightning Experience, up to the first seven fields in a compact layout appear in the highlights panel of an object record. (On smaller screens, the highlights panel displays fewer fields.) When a user hovers over a lookup relationship field on the object record page, a highlights panel for that field also displays the first seven fields from the compact layout. Highlights panels display the first field from the compact layout at the top in an accented font.
In the Outlook and Gmail integrations, up to the first three fields in a compact layout appear for records related to an email or event. As with page layouts, there are separate compact layouts for each object. By default, each object derives its record highlight fields, preview cards, and action-related feed items from the predefined set of fields in the object’s read-only, system default compact layout.
42 Extend Salesforce with Clicks, Not Code Control User Access to Fields
You can create custom compact layouts on an object-by-object basis. After you create one or more custom compact layouts, you set one as the primary compact layout for the object. The primary compact layout is then used as the new default for that object. If you have record types associated with an object, you can override the object’s primary compact layout and assign different compact layouts to some or all the record types. Each record type can have only one compact layout assigned to it. Event and task compact layouts determine the fields that appear in the details section when you expand an activity in the activity timeline in Lightning Experience. When you change the compact layout for tasks in the activity timeline, you also impact the fields that show up in the highlights area on tasks, in tasks lists, and everywhere else the compact layout is used.
Create Compact Layouts Use compact layouts to customize the fields that display for object records when viewed in the Salesforce mobile app and Lightning Experience. Assign Compact Layouts to Record Types As with page layouts, there are separate compact layouts for each object. By default, each object derives its record highlight fields, preview cards, and action-related feed items from the predefined set of fields in the object’s read-only, system default compact layout. You can create custom compact layouts on an object-by-object basis. After you create one or more custom compact layouts, you set one as the primary compact layout for the object. The primary compact layout is then used as the new default for that object. Compact Layout Limitations and Considerations Keep these limitations and considerations in mind when using compact layouts.
SEE ALSO: Activity Timeline Customization Considerations
Create Compact Layouts
Use compact layouts to customize the fields that display for object records when viewed in the EDITIONS Salesforce mobile app and Lightning Experience. 1. From the management settings for the object that you want to edit, go to Compact Layouts. Available in: both Salesforce Classic and Lightning 2. Create a new compact layout and give it a label. Experience 3. Add up to 10 fields. Available in: All editions Tip: Put the object’s Name field first to provide context for your users when they view a except Database.com record.
4. Sort the fields by selecting them and clicking Up or Down. USER PERMISSIONS
The order you assign to the fields determines the order in which they display. To customize compact 5. Save the layout. layouts: • Customize Application 6. To set the compact layout as the primary compact layout for the object, click Compact Layout To view compact layouts: Assignment. • View Setup and Example: Here’s a sample compact layout edit page for the Account object. It shows the Configuration name of the layout and a list of fields to display.
43 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Here’s the related page for the same account object in Lightning Experience, displaying six of the eight fields assigned to the compact layout. You can see the account’s name, phone number, business hours, website, owner, and type at the top of the page.
And here’s what that same account record looks like in the mobile app.
44 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Note: Up to ten fields on your compact layout populate the record highlights section at the top of each record view in the Salesforce mobile app. The record highlights section in Lightning Experience uses the first seven fields on the compact layout. However, the number of fields that display can vary based on the width of your screen, which record page is being viewed, and the permissions of the user.
SEE ALSO: Customize Case Hovers in Lightning Experience
Assign Compact Layouts to Record Types
As with page layouts, there are separate compact layouts for each object. By default, each object EDITIONS derives its record highlight fields, preview cards, and action-related feed items from the predefined set of fields in the object’s read-only, system default compact layout. You can create custom compact Available in: both Salesforce layouts on an object-by-object basis. After you create one or more custom compact layouts, you Classic and Lightning set one as the primary compact layout for the object. The primary compact layout is then used as Experience the new default for that object. Compact layouts are If you have record types associated with an object, you can override the object’s primary compact available in: All editions layout and assign different compact layouts to some or all the record types. Each record type can except Database.com have only one compact layout assigned to it. Record types are available 1. From the management settings for the object that you want to edit, go to Compact Layouts. in: Professional, Enterprise, Tip: For Salesforce Knowledge articles, from Setup, enter Knowledge Article Performance, Unlimited, Types in the Quick Find box, then select Knowledge Article Types, click the name of and Developer Editions an article type, then scroll down to the Compact Layouts related list. USER PERMISSIONS 2. Click Compact Layout Assignment. 3. Select a compact layout to use as the primary compact layout for this object. To customize compact layouts: 4. In the Record Type Overrides section, select one or more record types to which you want to • Customize Application assign a compact layout. To view compact layouts: If you don’t have record types set for the object, you won’t see this section. If you don’t set any • View Setup and record type overrides, all record types use the object’s primary compact layout by default. Configuration
45 Extend Salesforce with Clicks, Not Code Control User Access to Fields
Some record types in the list might be inactive. You can assign a compact layout to an inactive record type.
5. Select a compact layout from the Compact Layout To Use drop-down list to assign it to the selected cells. 6. Click Save.
SEE ALSO: Find Object Management Settings
Compact Layout Limitations and Considerations
Keep these limitations and considerations in mind when using compact layouts. EDITIONS
Considerations Available in: Salesforce Classic (not available in all • Up to ten fields on your compact layout populate the record highlights section at the top of orgs) and Lightning each record view in the Salesforce mobile app. The record highlights section in Lightning Experience Experience uses the first seven fields on the compact layout. However, the number of fields that display can vary based on the width of your screen, which record page is being viewed, Available in: All editions and the permissions of the user. except Database.com • Changes you make to a compact layout are reflected in both Lightning Experience and the Salesforce mobile app. • Each record type can have only one compact layout assigned to it. However, the same compact layout can be associated with multiple record types. • Compact layouts aren’t assigned to profiles or individual users. To display different sets of fields in records by use case or role, create record types for the object, then assign the appropriate custom compact layout to each record type. • If a user doesn’t have access to one of the fields that you assign to a compact layout, the next field on the layout is used. • A compact layout must contain at least one field. • Don’t make the primary field a lookup field. Doing this could result in navigation issues in Lightning Experience and the Salesforce mobile app. • Removing a field from a page layout doesn’t remove it from the object’s compact layout. The two layout types are independent. • If you change a field on a compact layout to an unsupported type, the field is removed from the compact layout. • Before you can delete a compact layout that’s set as the primary compact layout for the object, you must choose another compact layout to replace it. • In the Salesforce mobile app, tasks automatically show whether a task is open or closed and the due date (depending on a user’s access to activity dates). When customizing a task compact layout, you don’t have to add these fields to the Selected Fields list. • Compact layouts installed from a managed package are editable. However, we recommend against editing compact layouts installed from a package, as doing so can cause destructive changes to your org. Instead, clone the installed compact layout and make your changes to the clone. • Compact layout assignments are subscriber controlled. If a user installs a managed package that contains a compact layout and then changes the compact layout’s assignment in their org, the compact layout’s assignment isn’t overridden when they later upgrade the package. • These considerations apply to Chatter: – In the full Salesforce site, a compact layout determines which fields appear in the Chatter feed item that appears after a user creates a record with a quick action.
46 Extend Salesforce with Clicks, Not Code Control User Access to Fields
– To avoid inadvertent sharing of information through the feed, the Task page layout determines the fields shown in the Chatter feed items for tasks created using a quick action. – Primary compact layouts determine which fields are shown in Chatter personal digest emails.
Limitations • A compact layout can only contain fields from its object, including a formula field that is a cross-object reference to another object. • Fields that aren’t available in SOAP API don’t show up on compact layouts in the Salesforce mobile app. • Compact layouts support all field types except: – text area – long text area – rich text area – multi-select picklist
SEE ALSO: Create Compact Layouts Compact Layouts Customize Case Hovers in Lightning Experience
Select Which Fields Appear in the Recently Viewed List
As a Salesforce admin, you can customize the Recently Viewed list that appears on the home page EDITIONS for most standard and custom objects. Choose and order the fields to display so that your users see the information that’s most important for your company. Available in: Lightning Experience Note: These steps work in Lightning Experience. If you see the App Launcher icon ( ) on the left side of the navigation bar at the top of your screen, you're in Lightning Experience. If Available in: Essentials, not, you're in Salesforce Classic. Group, Professional, Enterprise, Performance, For most list views, your users can select which fields to display and how to order the view columns. Unlimited, and Developer However, they can’t edit the recent records quick list on object home pages. Only Salesforce admins Editions can select and order the fields to display for the recent records quick list. Admins can’t make any other changes to this default list. USER PERMISSIONS 1. From Setup, at the top of the page, select Object Manager. 2. Click the label name of the object for the Recently Viewed list you want to modify. To customize recent records list 3. From the menu of links at the top of the page, click Search Layouts. • Customize Application 4. In the far right of the Search Results row, click and select Edit. Recently viewed lists use the Search Results search layout in Lightning. In Classic, recently viewed lists use the Tab search layout.
5. To add columns to the Recently Viewed list, select one or more fields from Available Fields and click Add. To remove columns, select one or more fields from Selected Fields and click Remove. 6. Order columns by selecting one or more fields from Selected Fields and clicking Up or Down. 7. Click Save.
47 Extend Salesforce with Clicks, Not Code Custom Tabs
Example: Your users collaborate on opportunities. To make it easy to see who worked on a recent opportunity last, select Last Modified By from the Available Fields list. Click Add to move it to Selected Fields. Now this information appears on the Recently Viewed list on the Opportunities home page. In the Salesforce mobile app, the Recently Viewed list is the same list view as the desktop list view, with a few differences. • The Recently Viewed list shows up to two fields for each record. To see more than two fields, tap . • The fields shown come from the search results layout for the object. Any user with the Edit user permission for an object can add up to 10 fields. On desktop, go to Setup > Customize > {Object Name} > Search Layouts > Search Results. A user’s changes also affect which fields are shown on the search results page.
Note: In the Salesforce mobile app, a Recent list appears below the list views on an object’s home page. It’s an automatically generated list of recently accessed records. It isn’t a list view and can’t be modified.
Custom Tabs
Custom tabs let you display custom object data or other web content in Salesforce. When you add EDITIONS a custom tab to an app in Salesforce Classic, it appears as a tab. When you add a custom tab to an app in Lightning Experience, it appears as an item in the app’s navigation bar and in the App Available in: both Salesforce Launcher. Classic (not available in all Custom tabs show custom object data or other web content embedded in the app. You can create orgs) and Lightning any of these types of custom tabs. Experience Custom Object Tabs Custom Object Tabs and Custom object tabs (available only at an app level and not on subtab apps) show the data of Web Tabs available in: your custom object. Custom object tabs look and function just like standard tabs. Contact Manager, Group, Professional, Enterprise, Web Tabs Performance, Unlimited, Custom web tabs show any external web-based application or web page. You can design web and Developer Editions tabs to include the sidebar or span the page without the sidebar. Visualforce Tabs available Visualforce Tabs in: Contact Manager, Visualforce tabs show data from a Visualforce page. Visualforce tabs look and function just like Group, Professional, standard tabs. Enterprise, Performance, Lightning Component Tabs Unlimited, and Developer Lightning component tabs make Lightning components available in the Salesforce mobile Editions apps and in Lightning Experience. Lightning components aren’t supported in Salesforce Classic. Lightning Page Tabs available in: All Editions Note: To expose Lightning components via Lightning component tabs, you must enable except Database.com and deploy My Domain. Lightning Page Tabs Lightning page tabs let you add Lightning app pages to the Salesforce mobile app and Lightning USER PERMISSIONS Experience navigation bars. To create and edit custom In Salesforce Classic, Lightning page tabs don’t appear on the All Tabs page when you click . tabs: Lightning page tabs also don’t appear in the Available Tabs list when you customize the tabs • Customize Application for your apps. Subtab apps support only web tabs and Visualforce tabs. Delegated administrators who can manage specified custom objects can also create and customize tabs for those custom objects.
48 Extend Salesforce with Clicks, Not Code Custom Tabs
In Lightning Experience, Lightning page tabs, Visualforce tabs, and Lightning component tabs have a fixed, friendly URL structure of /lightning/n/customTabDevName.
SEE ALSO: Create Custom Apps for Salesforce Classic What is a Subtab App?
Create Web Tabs
Build web tabs so that your users can use your web applications or other websites from within the EDITIONS application. 1. From Setup, enter Tabs in the Quick Find box, then select Tabs. Available in: both Salesforce Classic (not available in all 2. Click New in the Web Tabs related list. orgs) and Lightning 3. Choose a layout for the new tab. The full page width spans across the entire page without the Experience sidebar, while the column style allows users to view the sidebar. Custom Object Tabs and 4. Click Next. Web Tabs available in: 5. Enter a label to display on the tab. Contact Manager, Group, Professional, Enterprise, 6. Click the Tab Style lookup icon to display the Tab Style Selector. Performance, Unlimited, If a tab style is already in use, a number enclosed in brackets [] appears next to the tab style and Developer Editions name. Hover your mouse over the style name to view the tabs that use the style. Click Hide Visualforce Tabs available styles which are used on other tabs to filter this list. in: Contact Manager, Group, Professional, 7. Click a tab style to select the color scheme and icon for the custom tab. Optionally, click Create Enterprise, Performance, your own style on the Tab Style Selector dialog to create a custom tab style if your org has Unlimited, and Developer access to the Documents tab. To create your own tab style: Editions a. Click the Color lookup icon to display the color selection dialog and click a color to select Lightning Page Tabs it. available in: All Editions b. Click Insert an Image, select the document folder, and select the image you want to use. except Database.com c. Select a file and click OK. The New Custom Tab wizard reappears.
8. Change the content frame height if necessary. USER PERMISSIONS 9. Enter a description of the tab, if desired, and click Next. To create and edit custom tabs: 10. Enter the URL or choose the custom s-control that you want to display in the tab. Optionally, • Customize Application copy and paste any merge fields for data that you want dynamically replaced in the link. Click Preview Web Tab to display your web tab.
Note: Only User, organization, and API merge fields are supported for web tabs.
11. For a URL, choose an encoding setting and click Next. 12. Add the web tab to the appropriate profiles. Choose Default On, Default Off, or Tab Hidden to determine whether the custom tab is visible to users with that profile. You can change this setting later. 13. Click Next. 14. Specify the custom apps that should include the new tab. 15. Select Append tab to users' existing personal customizations to apply the tab visibility settings to all users.
49 Extend Salesforce with Clicks, Not Code Custom Tabs
16. Click Save.
Create a Custom Object Tab
Create a custom object tab to give your users access to custom object data and records in an app. EDITIONS Custom object tabs are available only at the app level, not on subtab apps. Custom object tabs look and function just like standard tabs. Available in: both Salesforce When you add a custom object tab to an app in Salesforce Classic, it appears as a tab. When you Classic (not available in all add a custom object tab to an app in Lightning Experience, it appears as an item in the app’s orgs) and Lightning navigation bar and in the App Launcher. Experience 1. From Setup, in the Quick Find box, enter Tabs, then select Tabs. Custom Object Tabs and Web Tabs available in: 2. Click New in the Custom Object Tabs related list. Contact Manager, Group, 3. Select the custom object to appear in the custom tab. If you haven’t created the custom object, Professional, Enterprise, click create a new custom object now and follow the instructions in Create a Custom Object Performance, Unlimited, on page 146. and Developer Editions The label of the new tab is the same as the plural version of the custom object label. Visualforce Tabs available in: Contact Manager, 4. Click the Tab Style lookup icon to show the Tab Style Selector. Group, Professional, If a tab style is already in use, a number enclosed in brackets [] appears next to the tab style Enterprise, Performance, name. Hover over the style name to view the tabs that use the style. Click Hide styles which Unlimited, and Developer are used on other tabs to filter this list. Editions Lightning Page Tabs 5. Click a tab style to select the color scheme and icon for the custom tab. available in: All Editions If your org has access to the Documents tab, click Create your own style on the Tab Style except Database.com Selector dialog to create a custom tab style.
a. Click the Color lookup icon to show the color selection dialog and click a color to select it. USER PERMISSIONS b. Click Insert an Image, select the document folder, and select the image you want to use. To create and edit custom Alternatively, click Search in Documents, enter a search term, and click Go! to find a tabs: document file name that includes your search term. • Customize Application Note: This dialog only lists files in document folders that are under 20 KB and have the Externally Available checkbox selected in the document property settings. If the document used for the icon is later deleted, Salesforce replaces it with a default multicolor block icon ( ).
c. Select a file and click OK. The New Custom Tab wizard reappears.
6. Optionally, choose a custom link to use as the introductory splash page when users initially click the tab. 7. Enter a description of the tab, if desired, and click Next. 8. Choose the user profiles that you want to have access to the new custom tab. For Professional Edition users and Salesforce Platform One license users, tab visibility is set to Default On.
Note: A custom object that's associated with a custom tab is searchable (by default), even if users don't add the tab for display.
9. Specify the custom apps that should include the new tab.
50 Extend Salesforce with Clicks, Not Code Custom Tabs
10. Select Append tab to users' existing personal customizations to add the tab to your users’ customized display settings if they have customized their personal display. 11. Save the tab. Depending on the visibility settings you selected, you see the tab right away.
SEE ALSO: Custom Tabs Make Search Faster
Create Lightning Page Tabs
Before you can include a Lightning app page in the Salesforce mobile apps or in a Lightning app, EDITIONS you must create a custom tab for it. When you first activate an app page in the Lightning App Builder, a tab is created for the page as Available in: both Salesforce part of the activation process. You can also create a tab for the page manually in Setup before you Classic (not available in all activate it. orgs) and Lightning Experience You can create a custom tab only for an App Page type of Lightning page. 1. From Setup, enter Tabs in the Quick Find box, then select Tabs. Available in: All editions 2. Click New in the Lightning Page Tabs related list. USER PERMISSIONS 3. Choose a Lightning page for the tab. 4. Enter a label. To create and edit custom tabs: This text is used as the display name for the Lightning page. • Customize Application 5. Select a tab style to set a color scheme and icon for the Lightning page tab. 6. Enter a description of the tab, if desired, and click Next. 7. Choose the user profiles the new custom tab is available for.
Note: In Salesforce Classic, the Default On and Default Off options for Lightning page tabs don’t work the same way as for other custom tabs. The Lightning page menu item appears for the selected profiles in Salesforce for Android and Salesforce for iOS whether you choose Default On or Default Off. Select the Tab Hidden option to hide the Lightning page for the selected profiles.
8. Click Save.
51 Extend Salesforce with Clicks, Not Code Custom Tabs
Tip: When creating a custom icon for your Lightning page tab, follow these image guidelines. The icon should: • Be less than 10k in size • Be 120 x 120 pixels • Be a PNG with a transparent background • Have a resolution of 72 dpi • Not include a color background • Not include outer shadows on the inner icon graphic
Custom Tab Considerations
When working with custom tabs, keep these considerations in mind. EDITIONS • The custom tabs limit is a fixed number based on edition and can’t be increased. For more information, contact Salesforce. Available in: both Salesforce • If you choose Default On or Default Off when setting custom object tab visibility, an option is Classic (not available in all added to the Create New dropdown list in the Salesforce Classic sidebar so that users with the orgs) and Lightning Experience Create permission can quickly create a record. For example, if the custom object displayed in the custom tab is named Expenses, an Expense option appears in this list. Custom Object Tabs and • A custom object that's associated with a custom tab is searchable (by default), even if users Web Tabs available in: don't add the tab for display. Contact Manager, Group, Professional, Enterprise, • A Web tab or custom link could display a blank page if the embedded site: Performance, Unlimited, – Has been set to deny the loading of its content in a frame. and Developer Editions – Has been set to allow the loading of its content in a frame only if the same site is delivering Visualforce Tabs available the content. in: Contact Manager, – Contains a mix of secure and unsecure content, and the user’s browser has been configured Group, Professional, to block mixed active content. Enterprise, Performance, Unlimited, and Developer To resolve this issue, try these workarounds. Editions – Set your custom link to either open in a new window or display in the existing window Lightning Page Tabs without the sidebar or header. available in: All Editions – Move the URL from a Web tab into a custom link instead, and set the URL to either open except Database.com in a new window or display in the existing window without the sidebar or header. – If the site you’re embedding has an HTTP prefix and mixed active content, try changing the prefix to HTTPS. If the embedded site has a valid security certificate and it hasn’t blocked itself from being displayed in frames, using HTTPS as the prefix allows the site to display.
• In Salesforce Classic, Lightning page tabs don’t display on the All Tabs page when you click . Lightning page tabs also don’t appear in the Available Tabs list when you customize the tabs for your apps. • In Salesforce Classic, the Default On and Default Off options for Lightning page tabs don’t work the same way as for other custom tabs. The Lightning page menu item appears for the selected profiles in Salesforce for Android and Salesforce for iOS whether you choose Default On or Default Off. Select the Tab Hidden option to hide the Lightning page for the selected profiles.
52 Extend Salesforce with Clicks, Not Code Custom Help Content
Custom Help Content Tailor help so that users understand how to work within your unique implementation of Salesforce. You can add learning in the flow of work in several ways. Add custom help for a page, app, object, or org level, or provide links to help in the Utility Bar, Path, or as a text box on the page. Show users custom resources in a Lightning Experience welcome mat when they first log in. Or, add micro-learning prompts and walkthroughs to your app to reach users with important news, training, and on-boarding information.
Help Salesforce Classic Lightning Experience Field-Level Help—Detail the purpose and function of a standard or custom field.
Object-Level Help in Salesforce Classic—Help your users by providing object-level help for all custom objects and external objects.
Learning Paths—Create a personalized and always-available learning experience for your users.
Customize the Help Menu in Lightning Experience—Supplement the recommended resources by adding a section with links to your own content.
In-App Guidance—Use prompts to reach users directly with news, training, and on-boarding messages.
Welcome Mat—Provide resources the first time that users log in to Lightning Experience.
Utility Bar—Use the Notes component to add links to custom help.
Rich Text Component—Add simple HTML to your Lightning page.
Guidance for Success on Path—Give key coaching details to support users.
In-Dashboard Videos for Einstein Not applicable - cloud-based platform Not applicable - cloud-based platform Analytics—Provide customized instruction that helps users get the most out of dashboards.
Custom Notification from a Process—Alert an account owner if a new support case is logged while trying to close a deal, or send a notification for a workflow built entirely with custom objects.
53 Extend Salesforce with Clicks, Not Code Custom Help Content
Help Salesforce Classic Lightning Experience
myTrailhead—Your company’s content and Not applicable Not applicable brand on Trailhead. You can offer the same bite-size, skill-based, gamified learning experience as Salesforce Trailhead.
Field-Level Help Field-level help lets you provide help text detailing the purpose and function of any standard or custom field. Before defining field-level help, review these implementation tips and best practices. Custom Help in Lightning Experience In Lightning Experience, in-app guidance allows you to use prompts and walkthroughs to reach users directly with news, training, and onboarding messages. Customizing the Help Menu allows you to supplement the recommended resources by adding a section with links to your own content. Admins customize the Learning Paths panel by selecting learning content and assigning it to a specific audience and location in the app. Custom Help in Salesforce Classic In Salesforce Classic, object-level help replaces the links for a custom object or external object page. Replace built-in Salesforce Help with documentation that’s customized for your users.
Field-Level Help Field-level help lets you provide help text detailing the purpose and function of any standard or custom field. Before defining field-level help, review these implementation tips and best practices.
Implementation Tips • Field-level help is enabled by default for all editions. • Field-level help isn’t available for some standard fields, including fields on the User object, system read-only fields, auto-number fields, multi-currency fields, Ideas fields, and Experience Cloud site fields. • The help text for a field is automatically added to a package when you add the associated field to any AppExchange package. • In a managed package, the help text is locked to the developer, giving installers full capabilities to change it.
Best Practices • Because your custom help text displays on both edit and detail pages, avoid instructions for entering data. Instead, construct help text that defines the field's purpose, such as: The maximum discount allowed for this account.
• Provide information in your help text about the attributes of the field, such as: A detailed description of the purpose for the expense report. Up to 32 KB of data are allowed. Only the first 255 characters display in reports.
• Provide examples in your help text that help users understand the field's meaning clearly, such as: The four-digit promotional code used to determine the amount charged to the customer, for example, 4PLT (for level-four platinum pricing).
• If your org uses more than one language, provide translations for your Help Text using the Translation Workbench.
54 Extend Salesforce with Clicks, Not Code Custom Help Content
Define Field-Level Help Define custom help text for your organization’s fields to provide users with a helpful description. Help text can be defined for standard and custom fields on all detail and edit pages where the field displays. Users can view the field-level help text by hovering over the Info icon next to the field.
SEE ALSO: Custom Help Content
Define Field-Level Help
Define custom help text for your organization’s fields to provide users with a helpful description. EDITIONS Help text can be defined for standard and custom fields on all detail and edit pages where the field displays. Users can view the field-level help text by hovering over the Info icon next to the field. Available in: both Salesforce 1. From the management settings for the field’s object, go to Fields. Classic and Lightning Experience 2. Click Edit next to the field. 3. In the Help Text field, enter the text you want displayed. The text displays when a user Available in: All Editions hovers the mouse over the Info icon that appears next to the field on a detail or edit page. You except Database.com can enter up to 510 characters. 4. Click Save. USER PERMISSIONS
Note: If the object you’re modifying is exposed in an Experience Cloud site, field-level help To define or change is visible to site members, including unlicensed users, partners, and customers. Make sure field-level help: the information you provide in field-level help accounts for all audiences and doesn’t contain • Customize Application business-sensitive information.
SEE ALSO: Custom Help Content Field-Level Help Find Object Management Settings
Custom Help in Lightning Experience In Lightning Experience, in-app guidance allows you to use prompts and walkthroughs to reach users directly with news, training, and onboarding messages. Customizing the Help Menu allows you to supplement the recommended resources by adding a section with links to your own content. Admins customize the Learning Paths panel by selecting learning content and assigning it to a specific audience and location in the app.
If you... Then consider...
Have a few, key resources to share with your users. Help Menu Provide a space for users to access critical resources anytime, anywhere in the org. Add a custom section to the Help Menu with links to your FAQs, Trailhead mixes, Salesforce Help documents, and more. Centralize learning resources in the Help Menu, which users can access by clicking the ? in the global header.
55 Extend Salesforce with Clicks, Not Code Custom Help Content
If you... Then consider...
Have dozens of resources to share with your users. Learning Paths Require users to complete training by a certain date. Manage, assign, and track all your longform in-depth learning Have training created for specific pages or specific users. resources. Display public Trailhead and myTrailhead modules or URLs to resources in specific locations for specific users with a contextual learning panel. Apply a due date and track completion metrics. Centralize all learning resources on the Learning homepage. Earn Trailhead and myTrailhead badges inside the app.
Want to nudge, prompt, or remind users of important In-App Guidance announcements or features. Provide targeted, micro-learning moments to boost feature adoption. Pick from targeted, floating, and docked prompts or walkthroughs. Design the guidance, select the target audience, and specify where it appears and for how long. Add links to internal wikis, training, or PDFs for a custom call to action. Use built-in engagement tracking.
In-App Guidance in Lightning Experience In Lightning Experience, add prompts and walkthroughs to your app to share information, train, or onboard users. Write the content, select the target audience, and specify where it appears and for how long. You can add multiple items to the same page, but they don’t appear at the same time. By default, a user sees only one item per 24 hours, per app. Salesforce shows it again or cancels scheduled recurrences based on whether the user interacts with or ignores the prompt or walkthrough. Best Practices for Learning Paths and the Help Menu Whether you have minimal time to devote to end-user training or your company has a full-fledged training program, Help Menu and Learning Paths can help. Learn how to define an in-app help strategy and get tips for customizing Learning Paths. Learning Paths Bring all the fun of Trailhead inside the workspace to create a personalized and always-available learning experience for your users. The Learning Paths icon in the global header is visible to all users. It opens a panel where users can read Trailhead and myTrailhead content and earn badges inside the app. Admins customize the panel by selecting learning content and assigning it to a specific audience and location in the app. Choose modules from Trailhead or myTrailhead and add links to other training resources for the ultimate custom training experience. Admins can let other stakeholders, such as trainers or sales team managers, assign and manage learning items. Customize the Help Menu in Lightning Experience The Help icon in the header opens a menu of contextual help topics, Trailhead modules, videos, and more items chosen by Salesforce. You can supplement the recommended resources by adding a section with links to your own content. Your section appears at the top of the Help Menu on each page. There’s only one custom Help Menu section per org. You can’t add links to the Getting Started, Help For This Page, or More Resources sections.
56 Extend Salesforce with Clicks, Not Code Custom Help Content
In-App Guidance in Lightning Experience In Lightning Experience, add prompts and walkthroughs to your app to share information, train, or onboard users. Write the content, select the target audience, and specify where it appears and for how long. You can add multiple items to the same page, but they don’t appear at the same time. By default, a user sees only one item per 24 hours, per app. Salesforce shows it again or cancels scheduled recurrences based on whether the user interacts with or ignores the prompt or walkthrough. Watch the video to learn how to navigate the In-App Guidance Setup page and builder. Get Started with In-App Guidance in Lightning Experience
In-App Guidance Best Practices in Lightning Experience From writing engaging titles to choosing the right resources, review Salesforce recommendations for creating more effective prompts and walkthroughs. Get inspired with examples for common use cases such as onboarding and training. Considerations for In-App Guidance in Lightning Experience Before creating prompts and walkthroughs for your users, understand the settings and their behavior. Define Walkthroughs in Lightning Experience Create a hands-on interactive tour to guide users through onboarding or feature introduction with a series of step-by-step prompts. Define Prompts in Lightning Experience Reach users inside the app with small windows displaying news, training, feature adoption, and onboarding messages. Test In-App Guidance in Lightning Experience Testing lets you log in as specific users to verify that they see the correct prompt or walkthrough. While in test mode, Salesforce ignores the schedule settings and timed delay so you can test more than one item at a time. User interactions aren’t logged, so metrics aren’t affected. Monitor In-App Guidance in Lightning Experience Learn how to resolve and clear in-app guidance errors and warnings. Use metrics to fine-tune the location, position, content, and schedule settings. Salesforce In-App Content in Lightning Experience Learn about the valuable in-app content that appears in Salesforce.
SEE ALSO: Video: Get Started with In-App Guidance Video: Create Prompts Video: Create Walkthroughs Trailhead: User Engagement Knowledge Article: In-App Guidance Prompts FAQ
In-App Guidance Best Practices in Lightning Experience From writing engaging titles to choosing the right resources, review Salesforce recommendations for creating more effective prompts and walkthroughs. Get inspired with examples for common use cases such as onboarding and training.
Getting Started Resources Available from AppExchange For example prompts, install the In-App Guidance: Boost Sales User Productivity in Lightning Experience or In-App Guidance: Boost Service User Productivity in Lightning Experience packages.
57 Extend Salesforce with Clicks, Not Code Custom Help Content
For example walkthroughs, install the In-App Guidance Walkthroughs: Getting Started for Sales Users package. For monitoring user engagement of in-app guidance with prebuilt, customizable reports and dashboards, install the packages for prompts and walkthroughs.
Choosing the Right In-App Guidance Consider these high-level recommendations when choosing the in-app guidance type for your use case. For more information, take the User Engagement Trailhead module. Floating Prompt Use a short message, an optional image of your choosing, and an action button to enhance feature discovery. Pros: You can place floating prompts at nine positions around the page, allowing you to link the prompt content to what the user sees on the screen. The short length means that the user gets the information and gets on with their workday quickly. Cons: The user can easily overlook the floating prompt because it’s smaller and disappears when a user navigates off the page. But that’s when scheduling more recurrences comes in handy.
Example: Here’s a floating prompt for feature discovery and adoption. The goal is to make sure that all users are familiar with the latest productivity-boosting feature: the ability to pin a favorite list view.
Targeted Prompt Enjoy the same benefits as a floating prompt without being confined to nine placement positions. Connect a targeted prompt to a specific page element to show your users exactly what you’re referring to. Pros: You can place targeted prompts on targetable page elements. Further customize the position and alignment relative to your chosen element by choosing from 12 positions around the element. Or use smart positioning and let Salesforce determine the best location based on the user’s page configuration. Cons: Page configurations can change and so can user’s access to an app or a page. If a user doesn’t have access to the element the targeted prompt points to, the prompt shows a warning to the user and in the In-App Guidance Setup page and the In-App Guidance Builder. Also, if the element is no longer on the page, the targeted prompt also switches to a floating prompt.
Example: Here’s a targeted prompt pointing to a path element on an opportunity. The goal is to make sure users notice that the path element tracks their progress as they complete steps.
58 Extend Salesforce with Clicks, Not Code Custom Help Content
Docked Prompt Take advantage of more room to include an optional image or embed a video, or include step-by-step directions for completing a task. Doing so assists with feature adoption, deeper learning, and training. Pros: Users can maximize, minimize, or keep the docked prompt open while they navigate around the app, making it ideal for instructions the user can follow as they work. Cons: Although there’s more room for content, too much information can overwhelm users and cause them to not complete your call to action. Focus on the most important information, and take advantage of the option to add a video.
Example: Here’s a docked prompt to highlight configuration changes. The goal is to alert users that you’re changing the page layout of the Account record.
59 Extend Salesforce with Clicks, Not Code Custom Help Content
Walkthrough Provide a step-by-step, guided educational experience on a single page or across multiple pages by stringing together a series of floating, targeted, and docked prompts. Walkthroughs provide in-context training that’s perfect for onboarding and feature adoption. Pros: Instead of just reading instructions, users see the steps in their own workspace. It’s a great way for new users to learn more about how to use the app. Cons: Users must invest time to fully comprehend and complete walkthroughs. Although you can add up to 10 steps, Salesforce recommends roughly five steps for higher completion rates. If you drafted a longer walkthrough, consider breaking it up into two walkthroughs.
Tip: Salesforce recommends floating and targeted prompts for most walkthrough steps. Docked prompts are recommended only for the final step to include more information and calls to action.
Example: Here’s part of a walkthrough for onboarding training. The goal is to train new sales team members on how to use Path.
60 Extend Salesforce with Clicks, Not Code Custom Help Content
Writing Engaging In-App Guidance Content In general, use a conversational but concise tone when writing in-app guidance. For more voice and tone information, check out the Salesforce Voice and Tone Guidelines, the User Engagement Trailhead module, and the Writing Style Trailhead module. Consider these tips for each part of the prompt when writing in-app guidance. Header (Docked Prompt) The header follows the title, so use it to indicate to the user what type of information is in the prompt. For example, Important Changes, New Feature, or List View Tips. Title Use keywords that emphasize the purpose and value of the feature or process to users. Avoid excessive exclamation marks. For single prompts, format your title using imperative phrases. For example, “Create shortcuts to favorite pages” instead of “Favorites are a way to create shortcuts” or “New feature: Favorites.” For walkthroughs, your title varies with each step. • The first step of the walkthrough welcomes the user and explains where users are headed. • The middle steps can be either instructional to describe how to complete an action or conceptual to provide information that helps users understand the use case, benefit, or purpose. • The last step gives users encouragement for taking the walkthrough.
61 Extend Salesforce with Clicks, Not Code Custom Help Content
Body Elaborate on the title without restating it. Provide more information about the feature or process, mention the problem that the solution solves, or include common use cases. Write in a minimal and straightforward style. Include content that’s directly relevant to the current task. Don’t include anything that users must refer to later. Focus on writing content that’s easy to understand and to execute. For walkthroughs, the body varies with each step. • The first step of the walkthrough clearly states the goal and the benefits to the user before they start. • The middle steps provide more details about the process or concept. • The last step can include next steps or resources to keep the user engaged with the feature. Media Upload images to floating, targeted, and docked prompts or embed a video in a docked prompt. Make your in-app guidance more engaging by adding a .jpg, .jpeg, .png, or .gif file. Animated .gifs can further articulate the guidance in a prompt.
Note: Animated .png files aren’t supported and don’t include a play/pause button.
Or embed a video in docked prompts.
Note: You can only include an image or an embedded video. If you include an embedded video and then include an image, the image shows in the docked prompt. Buttons Keep button names consistent. Salesforce recommends Dismiss for the dismiss button and Tell Me More for the action button or link to a help resource. The action button label indicates where users are going before they click. When choosing a resource to link to, think about a resource that helps users complete the task or is part of the call to action. In-app guidance is engaging because it keeps users in the app, so don’t direct them to help stored outside the app unnecessarily.
SEE ALSO: Define Prompts in Lightning Experience Define Walkthroughs in Lightning Experience Considerations for In-App Guidance in Lightning Experience
62 Extend Salesforce with Clicks, Not Code Custom Help Content
Considerations for In-App Guidance in Lightning Experience
USER PERMISSIONS EDITIONS
To add, edit, and manage prompts and Modify All Data OR Customize Application In-App Guidance available walkthroughs as an admin in: Lightning Experience
To add, edit, and manage prompts and Manage Prompts AND View All Profiles (if In-App Guidance available walkthroughs as a designated user profile filtering is enabled) in: Essentials, Group, Professional, Enterprise, Note: An admin can manage Performance, Unlimited, prompts without adding more user and Developer Editions permissions. Assign these permissions to non-admin users who In-App Guidance not want to manage prompts. If you don’t available for: Chatter have access to an item, such as an External and Chatter Free object or app, some actions aren’t user licenses available to you. myTrailhead available in: Only users with the View All Data or Enterprise, Performance, Modify All Data permissions can see and Unlimited Editions another user’s errors, views, and completions.
To view more than three active custom View Walkthroughs walkthroughs as a user outside of the In-App Note: The View Walkthroughs user Guidance Builder permission is part of the Walkthroughs Note: If some users in an org have a permission set license. The myTrailhead subscription, users who myTrailhead subscription includes this don’t have the subscription can’t see feature. For pricing details, contact in-app guidance. your Salesforce account executive.
Before creating prompts and walkthroughs for your users, understand the settings and their behavior. In-App Guidance isn’t supported in the Salesforce mobile app.
In-App Guidance Packages Create You can package prompts and walkthroughs into a managed package. For details and considerations, see: • SOAP API Developer Guide: Prompt and PromptVersion • ISVforce Guide: Create a Package and Components Available in Managed Packages You don’t have to purchase a license to create, preview, or package walkthroughs. Note the restrictions on user visibility of the walkthroughs you create in the Install and Manage section. Install and Manage If the package includes a custom profile that isn’t part of your Salesforce org, the in-app guidance is installed. However, it doesn’t include those custom items. For example, you install a prompt with several custom profiles not included in your org. The prompts are installed without those custom profiles. If the package includes a custom permission that isn’t a part of your Salesforce org, the installation fails.
63 Extend Salesforce with Clicks, Not Code Custom Help Content
If the package includes a standard app that isn’t part of your Salesforce org, the in-app guidance is installed, but it’s not usable. The Package column indicates the in-app guidance installed from packages. The name of the admin who installed the package is listed under the Created By column. The publish status set by the package owner is retained. For example, a prompt marked as active in the package is active after installing it in your org. After installation, you can change the publish status at any time from the In-App Guidance Setup page. If the owner included translated labels, they can be installed from the package. For walkthrough packages: • If a managed or unmanaged package includes walkthroughs for standard apps, walkthroughs are installed. However, production orgs can have only three active walkthroughs at a time without subscribing to myTrailhead. • If a security-reviewed, first-generation managed package includes walkthroughs with at least one step on a page within a custom app, users can see the walkthroughs without a subscription to myTrailhead. Always consult the package owner for specific details about the package containing in-app guidance. Edit and Clone In-app guidance cloned from managed packages doesn’t receive updates from the package owner. For in-app guidance installed from packages, you can edit only the schedule, profiles, permissions, and status settings. You can’t add, remove, or reorder steps from a walkthrough installed from a managed package. For cloned prompts and walkthroughs, you can edit any setting except the in-app guidance type (prompt or walkthrough).
Create Custom In-App Guidance In-App Guidance Limits
In-App Guidance Limit Salesforce Recommendation Walkthroughs installed from the No limit currently. An enforceable limit is 500 AppExchange possible in future releases.
Walkthroughs created in your org 500 No specific recommendation
Prompts installed from the AppExchange No limit currently. An enforceable limit is 500 possible in future releases.
Prompts created in your org 500 No specific recommendation
You can add up to 10 steps in a walkthrough. In-App Guidance and Prompt Types The floating and targeted prompts disappear when the user navigates away from the page. Use the Prompt Position settings to indicate where to place a floating or targeted prompt. Make sure that you’re not blocking important information. However, users can move the prompt. The floating and targeted prompt types include a snooze icon and a dismiss button, and you can optionally add an action button. The docked prompt type doesn’t include a dismiss button, but you can optionally add an action button. Users can maximize, minimize, or keep the docked prompt open while they navigate around the app or use the snooze icon. Walkthroughs consist of up to 10 floating, targeted, or docked prompts. There are some differences between single prompts and prompts included in a walkthrough. Each step includes a progress button labeled Next, except for the final step, which is labeled Finish. Instead of an action button, there’s an optional action link on the last step of the walkthrough. Each prompt indicates which step is shown. For example, Step 1/4.
64 Extend Salesforce with Clicks, Not Code Custom Help Content
Custom Theme Color Make your in-app guidance complement or contrast your org or app theme color. Salesforce suggests up to four colors to choose from. The colors are derived from your org’s current settings, which can be changed from the Themes and Branding Setup page or Lightning App Builder. • Org brand color • Page background color • Header background color • App brand color (if the app has a custom theme) Salesforce ensures that the colors are accessible by darkening the color or by increasing the contrast color ratio. We recommend previewing the prompt to ensure that the copy is visible. The custom theme is specified only on the first step of a walkthrough but is applied to all steps of a walkthrough. The custom theme color doesn’t affect in-app content created by Salesforce. Custom theme color isn’t supported in the Internet Explorer 11 browser. Media Images make prompts more engaging for users. Add a .jpg, .jpeg, .png, or .gif file, or further articulate the guidance in a prompt by adding an animated .gif file.
Note: Animated .png files aren’t supported and don’t include a play/pause button.
Keep these tips in mind when adding images to in-app guidance: • In floating and targeted prompts, you can add the image above, below, to the right of, or to the left of the body text. • In docked prompts, you can add the image above or below the body text. • For images above or below body text, maximum size is 324 x 132 pixels. For images to the right or left of the body text, maximum size is 148 x 148 pixels. • Large images are resized and maintain their aspect ratio. • Maximum file size is 5 MB. • Include alt text to represent the image to blind or low-vision users. Include a video to explain more complex ideas.
Note: You can include an image or an embedded video. If you first include an embedded video and then include an image, the image replaces the video in the docked prompt. If a video doesn’t load, check your browser privacy settings. For example, YouTube provides the Privacy-Enhanced Mode. Users watch the video within the docked prompt, in the expanded docked prompt, or in full screen mode. The video player actions vary depending on the video host. When adding a video to a docked prompt, enter the URL specified in the src attribute listed in the embed code from the video host.
Tip: To find the embed code for a video, follow the instructions from the video host site. Usually you can find the steps by searching for the name of the site and “embed video.” For example, here’s what the embed code looks like for YouTube: Then you enter the URL found in the src attribute. For the example used, enter https://www.youtube.com/embed/di6iwHhrH6.
65 Extend Salesforce with Clicks, Not Code Custom Help Content
To ensure that videos embed properly, use trusted sites. YouTube, Vidyard, and Vimeo are trusted websites for In-App Guidance. If videos from others sites don’t appear correctly, try making those sites trusted. For more information, see Create CSP Trusted Sites to Access Third-Party APIs in Salesforce Help.
Permission and Profile If the in-app guidance doesn’t apply to a specific group of users, select the No restrictions radio button. If the in-app guidance applies to a specific group, define the audience using standard and custom permissions and profiles. If you apply multiple permissions, the prompt or walkthrough appears only to users who have all the permissions specified. If you apply multiple profiles, the in-app guidance appears to users who have any of the profiles specified. You can select a combination of up to 10 profiles and permissions for each in-app guidance. If you select multiple items, the prompt or walkthrough appears to users who have all the permissions specified and any of the profiles specified.
Note: If any of the profiles or permissions assigned to the prompt or walkthrough are deleted, a warning appears in the In-App Guidance Setup page, the In-App Guidance Builder, and in the Customize In-App Guidance window on the Profile and Permission steps. Review the selected profiles or permissions to ensure that the correct users see the prompt or walkthrough. If all profiles or permissions assigned to a prompt or walkthrough are deleted, an error appears. To save your prompt or walkthrough, update the profile or permission selections. Schedule To specify when to make the in-app guidance appear, specify a date range. The default start date is the current date. For recurring in-app guidance, use Frequency to specify the number of times to show the in-app guidance and the days in between occurrences. Repeat the same prompt or walkthrough multiple times to ensure that users understand or take a desired action on the content. You can repeat in-app guidance up to 30 times, with up to 30 days in between. Consider the date range when deciding how many days between each repeat. By default, a 24-hour delay, or cooling off period, between instances ensures that a user sees only one prompt or walkthrough per day per app. Change the amount of time for the delay between all in-app guidance, even in-app content created by Salesforce, under Settings on the In-App Guidance Setup page. Choose a value 0–99 hours and 0–59 minutes. Or choose to ignore the delay for a single in-app guidance by checking Show when the page loads when creating. The specified Schedule still applies for each in-app guidance, including the start date, times to show, and days in between. A single prompt or walkthrough appears no more than once every 24 hours even if you adjust the global time delay or set it so that the in-app guidance shows when the page loads. The in-app guidance that you create for your org is prioritized over prompts and other in-app content created by Salesforce, except for some important announcements or onboarding content, such as welcome mats. Salesforce detects how users interact with in-app guidance. If a user acknowledges the content, Salesforce stops showing the prompt or walkthrough to the user, even if you scheduled more occurrences. Salesforce continues showing in-app guidance until users acknowledge the in-app guidance or until the specified end date, even if you set up the prompt or walkthrough to show only once. The table summarizes when Salesforce continues or stops showing in-app guidance based on the user’s interaction.
User Interaction Floating and Targeted Docked Prompt Walkthrough Prompts User didn’t click a button. Show the prompt again. Show the prompt again. Show the walkthrough again.
User clicked the X to close the Not applicable. This type of • If there’s no action button, Show the walkthrough again. prompt. prompt doesn’t have a dismiss stop showing the prompt. button. • If there’s an action button, show the prompt again.
66 Extend Salesforce with Clicks, Not Code Custom Help Content
User Interaction Floating and Targeted Docked Prompt Walkthrough Prompts
User selected a snooze option. Show the prompt again after Show the prompt again after Show the walkthrough again the snooze time expires, the the snooze time expires, the after the snooze time expires, next time the user navigates to next time the user navigates to the next time the user the page. the page. navigates to the page.
User clicked the dismiss button. • If there’s only a dismiss Not applicable. This type of Show the walkthrough again. button, stop showing the prompt doesn’t have a dismiss prompt. button. • If there’s a dismiss button and action button, show the prompt again.
User clicked the action button Stop showing the prompt. Stop showing the prompt. Stop showing the walkthrough. (prompt) or action link (walkthrough).
User clicked the finish button. Not applicable for prompts. Not applicable for prompts. Stop showing the walkthrough.
Note: Watching a video doesn’t register as a user interaction.
Action Button and Link Action buttons in floating and targeted prompts and docked prompts and action links in walkthroughs are optional. When adding an action button or link, you can enter a relative URL or a fully qualified URL with an http:// or https:// prefix. Usually, clicking the action button or link opens a new tab. But if you add a URL for a flow, clicking the action button or link refreshes the current tab the user is on. Shareable URL Share a direct link to in-app guidance with users or add to the custom section of the Help Menu. Or, string multiple walkthroughs together by using the URL as the action link. If you use the URL as the action button or link, the prompt opens in a new tab and the walkthrough refreshes the page. Access the shareable URL from Settings inside the In-App Guidance Builder or from the row-level action menu on the Setup page. When you edit the API Name or delete a record that the in-app guidance was added to, the URL changes. When you make any other change to the in-app guidance, the URL remains the same. The URL opens the in-app guidance on a record that the prompt or walkthrough was added to. If the user doesn’t have access to that specific record, the in-app guidance opens on a record of the same object type and record type, if a specific record type was defined. The URL opens even if the user previously viewed or closed the in-app guidance, clicked the action button, or isn’t a part of the profile or permission set. The URL also ignores all schedule settings, such as the start date, end date, number of times to show, and days to wait in between occurrences. If the in-app guidance is inactive, the URL doesn’t open.
Note: If you deselect Custom In-App Guidance in the Settings accessed from the In-App Guidance Setup page, users can’t open links to custom in-app guidance. Keyboard Shortcuts Use these handy keyboard shortcuts for Mac and Windows to quickly navigate around the builder.
67 Extend Salesforce with Clicks, Not Code Custom Help Content
Action Mac Windows
Keyboard Help Press ?+Shift+/ Press ?+Shift+/
Switch focus to different regions (move Press Cmd+F6 Press Ctrl+F6 focus around areas of the In-App Guidance Builder, such as the header, right sidebar, and left sidebar)
Switch focus to the builder (move focus Press Cmd+F7 Press Ctrl+F7 from the canvas (preview of app) to the In-App Guidance Builder)
Select the next element in the canvas Press Ctrl+Alt+t Press Ctrl+Alt+t
Select the previous element in the canvas Press Cmd + Option + Shift + t Press Ctrl+Alt+Shift+t
Add a targeted prompt to the selected Press Cmd+Option+a Press Ctrl+Alt+a element
SEE ALSO: Define Prompts in Lightning Experience Define Walkthroughs in Lightning Experience Monitor In-App Guidance in Lightning Experience Test In-App Guidance in Lightning Experience Knowledge Article: In-App Guidance Prompts FAQ
Define Walkthroughs in Lightning Experience
USER PERMISSIONS EDITIONS
To add, edit, and manage prompts and Modify All Data OR Customize Application In-App Guidance available walkthroughs as an admin in: Lightning Experience
To add, edit, and manage prompts and Manage Prompts AND View All Profiles (if In-App Guidance available walkthroughs as a designated user profile filtering is enabled) in: Essentials, Group, Professional, Enterprise, Note: An admin can manage Performance, Unlimited, prompts without adding more user and Developer Editions permissions. Assign these permissions to non-admin users who In-App Guidance not want to manage prompts. If you don’t available for: Chatter have access to an item, such as an External and Chatter Free object or app, some actions aren’t user licenses available to you. myTrailhead available in: Only users with the View All Data or Enterprise, Performance, Modify All Data permissions can see and Unlimited Editions another user’s errors, views, and completions.
68 Extend Salesforce with Clicks, Not Code Custom Help Content
To view more than three active custom walkthroughs as a View Walkthroughs user outside of the In-App Guidance Builder Note: The View Walkthroughs user permission is part Note: If some users in an org have a myTrailhead of the Walkthroughs permission set license. The subscription, users who don’t have the subscription myTrailhead subscription includes this feature. For can’t see in-app guidance. pricing details, contact your Salesforce account executive.
Create a hands-on interactive tour to guide users through onboarding or feature introduction with a series of step-by-step prompts.
Tip: You can activate up to three custom walkthroughs for free and an unlimited number of active walkthroughs in a Developer Edition org. For more details, see Considerations for In-App Guidance in Lightning Experience in Salesforce Help. Watch the video to see how to add a walkthrough. Create Walkthroughs in Lightning Experience 1. From Setup in Lightning Experience, in the Quick Find box, enter In-App Guidance, and then select In-App Guidance. 2. Click Add. The In-App Guidance Builder opens in a new browser tab. 3. Inside the builder canvas, navigate to the app and page where you want to add the walkthrough, and then click Add. You remain in the builder while you navigate. The builder shows information about your page location, other in-app guidance on the page, and your next step.
Note: You can place walkthroughs on object record pages, object home pages such as Home, and on new, edit, and clone record pages, including dialogs. The Add button is disabled when you can’t add a walkthrough to the page. For record pages, you can’t add a walkthrough step to a specific record. Instead, a step is added to a record page type. The step takes users to a record they have access to. If a new or clone record page has multiple record types, you can choose if you want in-app guidance to appear for all or only a specific record type. You can’t place in-app guidance on task record pages when using the split view, the prompt appears on the Task home page.
4. Follow the instructions in the right side panel to choose Walkthrough. Then specify the type and position of the prompt and the content. A left side panel appears for you to view, reorder, or delete steps in the walkthrough. Add a step using the builder header actions.
Tip: The In-App Guidance Builder shows errors and warnings related to authoring in-app guidance. For example, a page doesn’t support a prompt. Or a page that contained a prompt is now missing, the author doesn’t have access to the page, or there’s a field-level error. Errors that users encountered when viewing a walkthrough are noted on the In-App Guidance Setup page.
Warning: Walkthroughs don’t appear correctly when the split view list view is open. Close split view before adding a step. The first step of a walkthrough can instruct the user to close the split view before continuing with the walkthrough.
5. To specify the tile, body, and button text, select Next. You can also include an image, or for docked prompts, embed a video. 6. Save your work. A window appears to complete more settings for an action link, schedule, profile, permissions, active status, and name. The walkthrough is active by default. 7. Click Done. To edit a walkthrough, click Edit from the In-App Guidance Setup page row-level action menu or the In-App Guidance Builder header. Move a walkthrough step by navigating to a different page and saving. To edit more settings, click the gear icon in the header of the builder. To quickly create in-app guidance for different users, consider cloning. You can clone any prompt or walkthrough, including prompts installed from packages, by clicking Clone from the row-level action menu. Edit any setting except the type.
69 Extend Salesforce with Clicks, Not Code Custom Help Content
Activate or deactivate a single prompt or walkthrough from the row-level action menu. Use Translation Workbench to maintain your translated labels in your org. Look for the Prompt and PromptVersion setup component to get started. Open Settings on the In-App Guidance Setup page to: • Turn off or turn on all in-app guidance created or installed in your Salesforce org. • Turn off or turn on all in-app guidance created by Salesforce. • Change the delay between in-app guidance appearances.
Assign Walkthrough Permissions in Lightning Experience To have more than three custom walkthroughs active at a time, subscribe to myTrailhead and assign the Walkthrough permission set license and the Access Walkthroughs permission set to selected users.
SEE ALSO: Plan Your myTrailhead Solution Manage Your Translations Considerations for In-App Guidance in Lightning Experience Test In-App Guidance in Lightning Experience Monitor In-App Guidance in Lightning Experience Knowledge Article: In-App Guidance Prompts FAQ
Assign Walkthrough Permissions in Lightning Experience
USER PERMISSIONS EDITIONS
To add, edit, and manage prompts and Modify All Data OR Customize Application In-App Guidance available walkthroughs as an admin in: Lightning Experience
To add, edit, and manage prompts and Manage Prompts AND View All Profiles (if In-App Guidance available walkthroughs as a designated user profile filtering is enabled) in: Essentials, Group, Professional, Enterprise, Note: An admin can manage Performance, Unlimited, prompts without adding more user and Developer Editions permissions. Assign these permissions to non-admin users who In-App Guidance not want to manage prompts. If you don’t available for: Chatter have access to an item, such as an External and Chatter Free object or app, some actions aren’t user licenses available to you. myTrailhead available in: Only users with the View All Data or Enterprise, Performance, Modify All Data permissions can see and Unlimited Editions another user’s errors, views, and completions.
70 Extend Salesforce with Clicks, Not Code Custom Help Content
To view more than three active custom walkthroughs as a View Walkthroughs user outside of the In-App Guidance Builder Note: The View Walkthroughs user permission is part Note: If some users in an org have a myTrailhead of the Walkthroughs permission set license. The subscription, users who don’t have the subscription myTrailhead subscription includes this feature. For can’t see in-app guidance. pricing details, contact your Salesforce account executive.
To have more than three custom walkthroughs active at a time, subscribe to myTrailhead and assign the Walkthrough permission set license and the Access Walkthroughs permission set to selected users. You can activate up to three custom walkthroughs at a time for your users without subscribing to myTrailhead. To see how many are available, go to the In-App Guidance Setup page. 1. From Setup in Lightning Experience, in the Quick Find box, enter Users, and select Users.
Tip: To mass-assign permission set licenses, you can use the Data Loader. You can also assign permission set licenses by assigning the permission sets first. When you assign the permission sets to users, the permission set license is automatically assigned to those users.
2. Click a user’s name, go to the Permission Set License Assignments section, and then click Edit Assignments. Check Walkthroughs. 3. From Setup in Lightning Experience, in the Quick Find box, enter Permission Sets, and select Permission Sets. 4. Select the Access Walkthroughs permission set. Click Manage Assignments, and then Add Assignments. Select the checkboxes next to the names of the users you want assigned to the permission set, and click Assign.
SEE ALSO: Plan Your myTrailhead Solution Permission Set Licenses Permission Sets
71 Extend Salesforce with Clicks, Not Code Custom Help Content
Define Prompts in Lightning Experience
USER PERMISSIONS EDITIONS
To add, edit, and manage prompts and Modify All Data OR Customize Application In-App Guidance available walkthroughs as an admin in: Lightning Experience
To add, edit, and manage prompts and Manage Prompts AND View All Profiles (if In-App Guidance available walkthroughs as a designated user profile filtering is enabled) in: Essentials, Group, Professional, Enterprise, Note: An admin can manage Performance, Unlimited, prompts without adding more user and Developer Editions permissions. Assign these permissions to non-admin users who In-App Guidance not want to manage prompts. If you don’t available for: Chatter have access to an item, such as an External and Chatter Free object or app, some actions aren’t user licenses available to you. myTrailhead available in: Only users with the View All Data or Enterprise, Performance, Modify All Data permissions can see and Unlimited Editions another user’s errors, views, and completions.
To view more than three active custom View Walkthroughs walkthroughs as a user outside of the In-App Note: The View Walkthroughs user Guidance Builder permission is part of the Walkthroughs Note: If some users in an org have a permission set license. The myTrailhead subscription, users who myTrailhead subscription includes this don’t have the subscription can’t see feature. For pricing details, contact in-app guidance. your Salesforce account executive.
Reach users inside the app with small windows displaying news, training, feature adoption, and onboarding messages. Watch the video to see how to add a prompt. Create Prompts in Lightning Experience 1. From Setup in Lightning Experience, in the Quick Find box, enter In-App Guidance, and then select In-App Guidance. 2. Click Add. The In-App Guidance Builder opens in a new browser tab. 3. Inside the builder canvas, navigate to the app and page where you want to add the prompt, and then click Add. You remain in the builder while you navigate. The builder shows information about your page location, other in-app guidance on the page, and your next step.
Note: You can place prompts on object record pages, object home pages such as Home, and on new, edit, and clone record pages, including dialogs. The Add button is disabled when you can’t add a prompt to the page. For record pages, you can’t add a prompt to a specific record. Instead, a prompt is added to a record page type. The prompt takes users to a record they have access to. If a new or clone record page has multiple record types, you can choose if you want in-app guidance to appear for all or only a specific record type. You can’t place in-app guidance on task record pages when using the split view, the prompt appears on the Task home page.
4. Follow the instructions in the right side panel to choose Single Prompt. Then specify the type and position of the prompt and the content.
72 Extend Salesforce with Clicks, Not Code Custom Help Content
Tip: The In-App Guidance Builder shows errors and warnings related to authoring in-app guidance. For example, a page doesn’t support a prompt. Or, a page that contained a prompt is now missing, the author doesn’t have access to the page, or there’s a field-level error. Errors that users encountered when viewing a prompt are noted on the In-App Guidance Setup page.
5. When you’re done creating the prompt, click Save. A window appears to complete more settings for an action button, schedule, profile, permissions, active status, and name. The prompt is active by default. 6. Click Done. To edit a prompt, click Edit from the In-App Guidance Setup page row-level action menu or the In-App Guidance Builder header. Move a prompt by navigating to a different page and saving. To edit more settings, click the gear icon in the header of the builder. To quickly create in-app guidance for different users, consider cloning. You can clone any prompt, including prompts installed from packages, by clicking Clone from the row-level action menu. Edit any setting except the prompt type. Activate or deactivate a single prompt or walkthrough from the row-level action menu. Use Translation Workbench to maintain your translated labels in your org. Look for the Prompt and PromptVersion setup component to get started. Open Settings on the In-App Guidance Setup page to: • Turn off or turn on all in-app guidance created or installed in your Salesforce org. • Turn off or turn on all in-app guidance created by Salesforce. • Change the amount of time for the global delay between in-app guidance.
SEE ALSO: Manage Your Translations Test In-App Guidance in Lightning Experience Monitor In-App Guidance in Lightning Experience Knowledge Article: In-App Guidance Prompts FAQ
Test In-App Guidance in Lightning Experience
USER PERMISSIONS EDITIONS
To add, edit, and manage prompts and Modify All Data OR Customize Application In-App Guidance available walkthroughs as an admin in: Lightning Experience
To add, edit, and manage prompts and Manage Prompts AND View All Profiles (if In-App Guidance available walkthroughs as a designated user profile filtering is enabled) in: Essentials, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
In-App Guidance not available for: Chatter External and Chatter Free user licenses
myTrailhead available in: Enterprise, Performance, and Unlimited Editions
73 Extend Salesforce with Clicks, Not Code Custom Help Content
Note: An admin can manage prompts without adding more user permissions. Assign these permissions to non-admin users who want to manage prompts. If you don’t have access to an item, such as an object or app, some actions aren’t available to you. Only users with the View All Data or Modify All Data permissions can see another user’s errors, views, and completions.
To view more than three active custom walkthroughs as a View Walkthroughs user outside of the In-App Guidance Builder Note: The View Walkthroughs user permission is part Note: If some users in an org have a myTrailhead of the Walkthroughs permission set license. The subscription, users who don’t have the subscription myTrailhead subscription includes this feature. For can’t see in-app guidance. pricing details, contact your Salesforce account executive.
Testing lets you log in as specific users to verify that they see the correct prompt or walkthrough. While in test mode, Salesforce ignores the schedule settings and timed delay so you can test more than one item at a time. User interactions aren’t logged, so metrics aren’t affected. 1. From Setup in Lightning Experience, enter In-App Guidance in the Quick Find box, and then select In-App Guidance. 2. Click Start Testing. 3. Log in as a specific user, and navigate to the page where the in-app guidance appears. If you see anything that needs updating, edit the in-app guidance by clicking Open In-App Guidance Builder from the testing bar at the top of the screen. 4. When you’re done, click Exit Testing in the testing bar. There are two other ways to test in-app guidance. • Take a quick look at in-app guidance. Click Preview from the In-App Guidance Setup page row-level action menu. A new tab opens with the in-app guidance in preview mode in the builder. • See in-app guidance in action in a sandbox environment. If you don’t see prompts and walkthroughs, turn on Adoption Assistance in Sandbox Orgs on the Adoption Assistance setup page in your sandbox org.
SEE ALSO: Define Prompts in Lightning Experience Define Walkthroughs in Lightning Experience Considerations for In-App Guidance in Lightning Experience
74 Extend Salesforce with Clicks, Not Code Custom Help Content
Monitor In-App Guidance in Lightning Experience
USER PERMISSIONS EDITIONS
To add, edit, and manage prompts and Modify All Data OR Customize Application In-App Guidance available walkthroughs as an admin in: Lightning Experience
To add, edit, and manage prompts and Manage Prompts AND View All Profiles (if In-App Guidance available walkthroughs as a designated user profile filtering is enabled) in: Essentials, Group, Professional, Enterprise, Note: An admin can manage Performance, Unlimited, prompts without adding more user and Developer Editions permissions. Assign these permissions to non-admin users who In-App Guidance not want to manage prompts. If you don’t available for: Chatter have access to an item, such as an External and Chatter Free object or app, some actions aren’t user licenses available to you. myTrailhead available in: Only users with the View All Data or Enterprise, Performance, Modify All Data permissions can see and Unlimited Editions another user’s errors, views, and completions.
To view more than three active custom View Walkthroughs walkthroughs as a user outside of the In-App Note: The View Walkthroughs user Guidance Builder permission is part of the Walkthroughs Note: If some users in an org have a permission set license. The myTrailhead subscription, users who myTrailhead subscription includes this don’t have the subscription can’t see feature. For pricing details, contact in-app guidance. your Salesforce account executive.
Learn how to resolve and clear in-app guidance errors and warnings. Use metrics to fine-tune the location, position, content, and schedule settings.
Resolve In-App Guidance Errors and Warnings If a user can’t access a walkthrough step or the assigned profiles or permissions were deleted, you see an error or a warning on the In-App Guidance Setup page, the In-App Guidance Builder, and the In-App Guidance Settings window. A common error is when a walkthrough is added to a page that was later deleted or the targeted user doesn’t have access to the page. You can’t delete a custom app that contains in-app guidance. To resolve errors and warnings: 1. From Setup in Lightning Experience, in the Quick Find box, enter In-App Guidance, and then select In-App Guidance. An icon on the left side of the number column indicates in-app guidance that has errors or warnings. Click the icon to review details. 2. From the row-level action menu, click Edit to open the In-App Guidance Builder. 3. Resolve the error or warning.
75 Extend Salesforce with Clicks, Not Code Custom Help Content
Tip: The In-App Guidance Builder shows errors and warnings mostly related to authoring prompts—not errors users encountered. For example, a page doesn’t support a prompt, a page that contained a prompt was deleted, the author doesn’t have access to the page, or there’s a field-level error.
4. Back on the In-App Guidance Setup page, click Clear Errors in the row-level action menu. Only perform this action after you confirmed that the error is resolved. To troubleshoot a walkthrough to determine the cause of the error, create a report. 1. Set up a custom report type using the Prompt Actions object. 2. Add the Step Number, Last Display Date, Last Result (look for the Error valid value), Name, and User: Full Name fields as columns in the report.
Tip: Missing fields when you create or edit a report? You can design the field layout for reports created from a custom report type. From the Report Types Setup page, select the custom report type you want to edit. Click Edit Layout on the Fields Available for Reports section.
Keep Track of User Engagement There are three ways to monitor in-app guidance user engagement: • Look at the metrics on the In-App Guidance Setup page. • Create a custom report type. • Download a Salesforce Labs package of prebuilt, customizable reports and dashboards.
Look at the metrics on the In-App Guidance Setup page To track user interactions per org, review the standard usage metrics. From Setup in Lightning Experience, in the Quick Find box, enter In-App Guidance, and then select In-App Guidance. Look for the Views and Completes columns. • Views represent the total number of unique users who saw the prompt or walkthrough. • Completes is the percentage of viewers who clicked the action button (prompt) or link (walkthrough) or clicked the finish button on the last step of a walkthrough. Video views aren’t tracked. From the row-level action menu, click Reset Metrics to restart metrics values at zero. For instance, you made significant changes to a prompt and you want to restart the metrics tracking. If the end date hasn’t passed and the in-app guidance is active, users see the prompt or walkthrough again after resetting the metrics.
Create a custom report type 1. Set up a custom report type using the Prompt Actions object. 2. Add the Last Display Date, Last Result, Name, Times Action Taken, Times Dismissed, Times Displayed, and User: Full Name fields. If you’re reviewing walkthrough data, consider adding the Step Count and Step Number fields. You can use the Step Number divided by the Step Count to create a progress percentage formula field. Here’s a list of the Prompt Actions fields. See the PromptAction and PromptVersion API objects for more information.
76 Extend Salesforce with Clicks, Not Code Custom Help Content
Fields Description
Active Date The date the in-app guidance was activated. If part of a package, the active date is the date when the package was installed.
API Type The type of in-app guidance. Valid values are Docked Prompt, Floating Prompt, Targeted Prompt, and Walkthrough.
Last Display Date The date the in-app guidance was last showed to the user.
Last Result The most recent user interaction. Valid values are Error, Not Seen, No Action, Dismiss, Finish (walkthroughs only), and Custom Action. No Action represents the user clicking the close button.
Last Result Date The date the in-app guidance was last interacted with.
Name The name of the in-app guidance.
Step Count The total number of steps in the walkthrough.
Step Number The number of the last step the user viewed or interacted with in a walkthrough.
Times Action Taken The number of times that the user acted upon on the in-app guidance.
Times Dismissed The number of times that the user dismissed the in-app guidance.
Times Displayed The number of times that the in-app guidance was shown to the user.
User: Full Name The full name of the user who viewed the in-app guidance.
Download a Salesforce Labs package of pre-built, customizable reports and dashboards Visit AppExchange to install the free packages for prompts and walkthroughs. Find more information about the package on AppExchange listing pages, including user guides.
SEE ALSO: Create a Custom Report Type Design the Field Layout for Reports Created from Your Custom Report Type Build a Formula Field Define Prompts in Lightning Experience Define Walkthroughs in Lightning Experience Considerations for In-App Guidance in Lightning Experience
Salesforce In-App Content in Lightning Experience Learn about the valuable in-app content that appears in Salesforce.
77 Extend Salesforce with Clicks, Not Code Custom Help Content
Experience Cloud Sites
Type Description Welcome mat Introduces users to the Experience Cloud Mobile Experience.
Essentials
Type Description Docked prompt Highlights commonly used features including chat, messaging, and dialer. Only shown to admins.
Docked prompt Notifies admins that the trial period has expired. Only shown to admins.
Survey Asks for product feedback.
Welcome mat Provides resources for new users. Users see the welcome mat after the survey. This welcome mat also appears in trial orgs.
Welcome mat Highlights the Pocket Guide, which is the go-to place for questions while users work. Users see the welcome mat after the new users welcome mat.
Walkthrough Educates users on the importance of accounts and the basics of an account record. Shown in the Sales and Service apps.
Walkthough Educates users on the importance of tasks and activities and how to create tasks and log a call. Shown in the Sales and Service apps.
Walkthrough Educates users on the importance of opportunities and how to move them forward in the pipeline. Shown in the Sales and Service apps.
Marketing
Type Description Docked prompt Highlights tips and best practices for managing benefits.
Docked prompt Highlights tips and best practices for managing promotions.
Docked prompt Highlights tips and best practices for managing vouchers.
Feature popover Highlights the Pardot Setup Assistant within the Marketing Setup App. Only shown to admins.
Platform
Type Description Docked prompt Highlights the display density feature.
Docked prompt Highlights simple record home. For admins, the prompt recommends enabling the feature. For users, the prompt educates them about the feature.
78 Extend Salesforce with Clicks, Not Code Custom Help Content
Type Description
Docked prompt Provides information about building pages for Lightning on Mobile.
Docked prompt Encourages admins to enable the Enhanced Related List feature. Only shown to admins.
Docked prompt Encourages admins to use Dynamic Forms and highlights the localization feature.
Docked prompt Encourages users to download the Salesforce mobile app if they haven't used it yet and they're in a mobile-enabled org.
Docked prompt Notifies admins that Mobile Home is the new landing page for the Salesforce mobile app. Only shown to admins.
Docked prompt Notifies admins to add Mobile Home to a Lightning App or to the Mobile Only navigation for users to access it in their menu. Only shown to admins.
Floating prompt Highlights the Recycle Bin feature.
Floating prompt Reminds admins to try the Multi-Factor Authentication Assistant and guides them through stages if they left before completing the implementation path.
Floating prompt Highlights release readiness materials. Only shown to admins.
Floating prompt Highlights sandbox readiness materials. Only shown to admins.
Series of floating Highlights a series of features, such as Chatter, Home, Reports, List Views, and Opportunities, and how to customize and docked them. Also listed inside the Guidance Center. Only shown to admins with new Salesforce orgs. prompts
Feature popover Highlights the list view pin feature.
Feature popover Highlights the list view filtering features.
Docked prompt Encourages admins to turn on the Enhanced Related List feature. Only shown to admins.
Feature popover Encourages users to customize the navigation bar in console apps.
Feature popover Encourages users to customize the navigation bar in standard apps.
Feature popover Highlights the Help Menu and the ability to view Salesforce documentation inside a docked composer.
Feature popover Encourages admins to use the Guidance Center in the Learning Paths. Only shown to admins.
Feature popover Highlights the Learning Paths panel.
Feature popover Encourages users to employ the global actions menu.
Feature popover Highlights the features of the Einstein Bots Builder. Only shown to admins.
Welcome mat Provides resources for working more productively in Lightning Experience. Users see the welcome mat when they’re automatically switched from Salesforce Classic to Lightning Experience.
Survey Asks for product feedback. Shown to a small, random sampling of users to complete optionally.
79 Extend Salesforce with Clicks, Not Code Custom Help Content
Sales
Type Description Docked prompt Highlights the benefits of planning territories in Salesforce Maps and then integrating them with Enterprise Territory Management.
Docked prompt Introduces admins to Salesforce CPQ when they’re interacting with quotes. Only shown to admins.
Docked prompt Highlights the benefits of Pipeline Inspection to users.
Docked prompt Reminds admins to enable the Einstein Conversation Insights feature, which is included for orgs that have both High Velocity Sales and Lightning Dialer. Only shown to admins.
Docked prompt Explains how to use Pipeline Inspection, and highlights key features.
Feature popover Highlights the filter button in the Add Products dialog on opportunity records.
Feature popover Highlights the Opportunity Score feature, if added to a record page.
Feature popover Highlights the Opportunity Score feature, if added to a list view.
Feature popover Asks admins and end users for feedback about Einstein Opportunity Scoring.
Feature popover Highlights target status filters used to organize work queue items with two separate popovers.
Feature popover Encourages admins to configure custom insights for Einstein Conversation Insights from the Call Insights Setup page.
Floating prompt Encourages sales managers to try out the Einstein Conversation Insights feature within the High Velocity Sales app.
Floating prompt Provides tips and best practices for using Pipeline Inspection.
Welcome mat Encourages admins to enable Sales Cloud Einstein. If not enabled, floating prompts in a series appear as reminders. Only shown to admins.
Welcome mat Provides resources for new users of the High Velocity Sales app. Users see the welcome mat when they first view the app. If the app was installed but the user hasn’t viewed it, a floating prompt encourages users to visit the app.
Welcome mat Provides resources for getting started with Pardot and Salesforce.
Welcome mat Introduces admins to Pipeline Inspection. Only shown to admins.
Welcome mat Introduces users to Pipeline Inspection.
Search
Type Description Feature popover Encourages admins to enable Einstein Search for their entire org.
Feature popover Highlights Einstein Search and recommends enabling the features. If only personalization is enabled, another feature popover encourages admins to turn on the rest of the Einstein Search capabilities.
Feature popover When Einstein Search is turned on, a feature popover educates users about the feature.
Feature popover Highlights Einstein Search for all orgs. Only shown to admins.
80 Extend Salesforce with Clicks, Not Code Custom Help Content
Service
Type Description Feature popover Introduces and walks users through setting up Macros.
Feature popover Introduces and walks users through using Quick Text.
Floating prompt Reminds admins to return to the Service Setup Assistant to finish setting up the org. A second prompt notifies admins that changes to the org require returning to the assistant. Only shown to admins.
Floating prompt Introduces users to the case list view created by the Service Setup Assistant.
Walkthrough Introduces users to the case record page layout created by the Service Setup Assistant.
Walkthrough Introduces users to the default help center created by the Service Setup Assistant.
Walkthrough Introduces users to the Lightning email templates created by the Service Setup Assistant.
Walkthrough Introduces users to the default surveys created by the Service Setup Assistant.
Setup
Type Description Welcome mat Highlights the org setup assistant. Only shown to admins.
Docked prompt Reminds admins how to prepare their data before importing. Only shown to admins.
Walkthrough Highlights In-App Guidance to admins. Only shown to admins.
Other
Type Description Floating prompt Remind admins of the open IdeaExchange prioritization period. Only shown to admins.
Turning Off All Salesforce In-App Content To turn off all the Salesforce-created prompts, popovers, and welcome mats: 1. From Lightning Experience Setup, in the Quick Find box, enter In-App Guidance, and then select In-App Guidance. 2. Click Settings. 3. Deselect Salesforce Standard In-App Guidance.
Best Practices for Learning Paths and the Help Menu Whether you have minimal time to devote to end-user training or your company has a full-fledged training program, Help Menu and Learning Paths can help. Learn how to define an in-app help strategy and get tips for customizing Learning Paths.
81 Extend Salesforce with Clicks, Not Code Custom Help Content
Benefits Easily accessible resources within the app are crucial to help users do their jobs efficiently and effectively inside their workspace. Learn more about the onboarding and troubleshooting stages of the in-app journey by taking the User Engagement Trailhead module. Without training, end-user productivity declines, as can trust and feature adoption. With sufficient training and on-demand troubleshooting resources, users quickly find answers to their questions so they can get unblocked and back to work. Such resources also are a time saver so that admins don’t repeatedly field the same questions from their users. The Help Menu provides Salesforce-suggested resources directly to end users and admins just for this reason. But because apps are so often customized, Salesforce resources don’t always reflect the actual user experience. Many admins add links to resources to offer their users help that reflects the company’s unique processes and guidelines. There are several ways to integrate custom help inside the app, but the Help Menu and Learning Paths are great additions to your admin toolbox.
Similarities and Differences Learning Paths and the Help Menu are accessible from the global header. The Help Menu offers Salesforce-suggested resources and a section for admins to add links to their own content that their users can see anywhere in the app. Learning Paths offer admins not only a panel to add contextual help per page, but also a way to assign learning to users, with optional due dates. Users see all their assignments on a single page. Check out Find Help in Lightning Experience for more details about Help Menu and Learning Paths features and behavior. This table lists the main differences between Learning Paths and the Help Menu.
Feature Learning Paths Help Menu
Hide completely Yes, from the Learning Paths Setup page Yes, from the Help Menu Setup page
Hide individual sections No Yes, from the Help Menu Setup page
Add URLs as learning items Add up to 500 learning items Add up to 30 URLs
Add help for a specific page, app, or org Resources for the object home or record are Resources for an org are shown in the global shown under Learning for You. The Ways custom resource section at the top of the to Learn More section includes resources Help Menu. Admins can’t specify per page assigned to all objects for all apps or for a or per app. specific app.
Specify a required due date to complete Yes No
Specify user-level visibility Yes, either specify by users or by public No groups
View Trailhead modules inside the app Yes, users can read and earn badges for No, all URLs open in a new tab. Links to multiple choice challenges inside the app Salesforce documentation under Help for This Page do show inside the app.
View suggestions from Salesforce For admins, suggestions are shown under Suggestions are shown under Help for This Learning for You on several, key pages. For Page for most pages in the app, including end users, three suggested modules are Setup. Global links for search, support, only visible by default, or on pages when keyboard shortcuts, and release notes are assigned content isn’t visible. under More Resources.
82 Extend Salesforce with Clicks, Not Code Custom Help Content
Strategy As you plan your in-app help strategy, think of adding layers of customization to address the needs of your users and, if applicable, your existing training program. The Help Menu offers a default in-app help experience by suggesting related resources for a page. Recommended resources are helpful for companies that don’t have much guidance available to users. All admins can direct users to the Help Menu for general onboarding questions and help with troubleshooting common issues. If you find that some sections of the Help Menu aren’t working for your users, simply hide them. You can add resources to the custom section of the Help Menu. To further customize the in-app help experience, add Learning Paths to get more robust features, such as due dates. And Learning Paths has more targeted assignment functionality, available now and in upcoming releases. It’s as easy to assign learning items across Salesforce as it is to assign items to a specific page for specific users. If you have myTrailhead or use public Trailhead modules as part of onboarding, users can read through modules assigned to them and earn badges right inside the app. Be sure to let users know that they can access these resources from the Trailhead icon in the global header or from the Learning object. To make Learning home easier to find, add Learning to the navigation bar.
Tips to Get Started Here are some ideas to help you plan which resources to add to Learning Paths. • Add an onboarding module such as Salesforce User Basics, Salesforce User Tour, or Salesforce CRM (CRM for Lightning Experience). • Replicate the modules you added to the global custom section of the Help Menu. • Check out the Help Menu (under Help for This Page) for inspiration on what modules or other documentation to add. • Add your company’s myTrailhead modules, videos, wiki pages, quick start guides, or other custom resource. • Assign shorter modules that users can complete in less than a half hour to facilitate learning as the user works. • Assign only one or two items to a specific page in the app to avoid overwhelming the user. • Add due dates to give users a better sense of when to complete the learning item. • Scope out what to add by listing the learning item, location, audience, and, optionally, due date. Here are some resources to consider adding. All learning items are Trailhead modules, except as noted.
Onboarding
Learning Item App Let’s Take Lightning Experience for a Spin (video) All
Searching in Salesforce (video) All
Working with List Views (video) All
Trailhead: Quick Look All
Salesforce User Basics All
Salesforce User Tour All
Salesforce CRM (CRM for Lightning Experience) All
83 Extend Salesforce with Clicks, Not Code Custom Help Content
Working from Anywhere
Learning Item App Virtual Meeting Setup: Quick Look All
Virtual Collaboration All
Virtual Whiteboarding: Quick Look All
Effective Emails: Quick Look All
Relationship Building All
Emotional Intelligence All
Fearless Teaming All
Sales
Learning Item App Sales Cloud: Quick Look Sales
Prospecting for Better Sales Sales
Daily Productivity Tips for Sales Sales
Productive Sales Without Digital Distraction Sales
Demo Delivery Essentials Sales
Demo Storytelling Sales
Design Thinking for Sales Sales
Service
Learning Item App Service Cloud: Quick Look Service
Service Cloud Agent Experience Service Console
Communication Skills for Customer Service Agents Service
Wellbeing
Learning Item App The Power of Movement All
The Value of Sleep All
84 Extend Salesforce with Clicks, Not Code Custom Help Content
Learning Item App
Mindful Living with the Plum Village Monastics All
SEE ALSO: Find Help in Lightning Experience Custom Help in Lightning Experience
Learning Paths
Bring all the fun of Trailhead inside the workspace to create a personalized and always-available EDITIONS learning experience for your users. The Learning Paths icon in the global header is visible to all users. It opens a panel where users can read Trailhead and myTrailhead content and earn badges inside Available in: Lightning the app. Admins customize the panel by selecting learning content and assigning it to a specific Experience audience and location in the app. Choose modules from Trailhead or myTrailhead and add links to other training resources for the ultimate custom training experience. Admins can let other Available in: Developer, stakeholders, such as trainers or sales team managers, assign and manage learning items. Professional, Enterprise, Performance, and Learning Paths isn’t available in sandbox environments. Unlimited Editions This feature is on by default in Salesforce, but you can turn it off from the Learning Paths page in Not Available for: Chatter Setup. When you disable Learning Paths, admins with the Modify All Data or Customize Application External, Chatter Free, or permissions can still see the icon in the global header. The icon gives admins access to the Guidance Communities (now known Center (1), which offers personalized recommendations for setting up, customizing, and enhancing as Experience Cloud) user Salesforce. licenses
myTrailhead Available in: Enterprise, Performance, and Unlimited Editions
In the side panel on certain pages in the Sales, Service, and Setup apps, admins also can see some Trailhead modules suggested by Salesforce (2). These modules remain in the panel even after you customize Learning Paths, but end users can’t see them unless you assign the modules to them. When you customize Learning Paths, you can choose whom to assign a learning item to—individuals, public groups, or all users. You can choose whether to associate the learning item with a particular app or page in Salesforce. And you can choose whether to apply a due date to each learning item. Learning items with a due date are required. Learning items without a due date can be helpful but aren’t required. When you assign a learning item to a page, end users see the item in the Learning for You section of the side panel. Learning items that you assign to all apps, or to all objects and records within an app, are included in the Ways to Learn More section of the panel. A learning item that’s assigned to an app or a page is visible in the side panel only when users are in the associated app.
85 Extend Salesforce with Clicks, Not Code Custom Help Content
All users have access to the Learning Home page in their Salesforce org. On Learning Home, users can see all their required and suggested learning items. They also can see which learning items they have in progress and which are completed. Admins get an extra page on Learning Home: Manage Learning Assignments. From there, they can customize Learning Paths.
Until you assign a learning item to a user, the user sees three Salesforce-suggested Trailhead modules in the panel. After you assign learning content to a user, those modules appear in the panel only on pages in Salesforce that have no learning items associated with them.
Note: As long as your Salesforce-related accounts are part of your Trailblazer.me profile, badges that you earn while inside Lightning Experience are included in your profile. See Trailblazer.me and Trailhead. If your company has myTrailhead, you don’t necessarily have a Trailblazer.me profile, but you can create one. See Create a Trailhead Account, and log in with the username and password that you use to log in to Salesforce. If your company uses Salesforce Identity for myTrailhead to authenticate myTrailhead users, the Salesforce Trailhead badges that you earn in-app appear on your Trailblazer.me profile. The myTrailhead badges that you earn don’t appear on your Trailblazer.me profile. See How Can I Tell Which Authentication Provider I Use to Access myTrailhead?
Considerations for Using Learning Paths As you prepare to customize Learning Paths for your users, keep these details in mind. Assign a Learning Item for Learning Paths You can assign a Trailhead or myTrailhead module or a custom learning item such as a video, tutorial, or reference guide. You can assign a learning item to individuals, public groups, or all users. And you can associate a learning item with an app and a particular object and page within the app. Until you assign content to a user, the user sees a few modules suggested by Trailhead in the learning panel and on Learning Home. Monitor Learning Paths (Beta) Use custom reports and dashboards to track user engagement with Learning Paths, Trailhead, and myTrailhead.
86 Extend Salesforce with Clicks, Not Code Custom Help Content
Considerations for Using Learning Paths
As you prepare to customize Learning Paths for your users, keep these details in mind. EDITIONS You can create a learning item with a Trailhead or myTrailhead module or a link to a custom resource such as a video, tutorial, or reference guide. You can assign learning items to individuals, public Available in: Lightning groups, or a combination of both. You also can assign a learning item to all users. There are some Experience limits to the assignments that you can make. Available in: Developer, Professional, Enterprise, Assignments Maximum Performance, and Learning items 500 Unlimited Editions
Assignments per learning item 100 Not Available for: Chatter External, Chatter Free, or Communities (now known as Experience Cloud) user An assignment to a public group counts as one assignment. licenses
myTrailhead Available in: Assigning a Learning Item Enterprise, Performance, You can assign Trailhead modules that contain quizzes, but not modules that contain hands-on and Unlimited Editions challenges. You can’t assign Trailhead projects. You can’t create more than one learning item with the same Trailhead or myTrailhead module. When you assign a learning item to a particular app or page, the item is visible in the side panel only to users who are in that app. It’s visible on Learning Home to all users, regardless of which app a user is in. To assign a learning item to a group, use a public group. You can't assign learning items to Roles and Subordinates or Roles and Internal Subordinates public group member types. You can’t assign learning items to permission set groups, personal groups, or Chatter groups. When you assign a Trailhead or myTrailhead module via Learning Paths, the module assignment appears in the learning panel and on Learning Home. It doesn’t appear on an assignee’s myTrailhead home page.
Modifying a Learning Item After you save a learning item, you can’t change its module, custom link, or due date. Delete the learning item and create another one with the module, link, or due date that you want to assign. To add more assignees to a learning item, use the Add Assignments feature on Learning Home. If a module is deleted from Trailhead or myTrailhead, any learning item that you created with that module remains in Learning Paths. To avoid confusing users, delete the learning item.
SEE ALSO: Assign a Learning Item for Learning Paths Monitor Learning Paths (Beta)
87 Extend Salesforce with Clicks, Not Code Custom Help Content
Assign a Learning Item for Learning Paths
You can assign a Trailhead or myTrailhead module or a custom learning item such as a video, tutorial, EDITIONS or reference guide. You can assign a learning item to individuals, public groups, or all users. And you can associate a learning item with an app and a particular object and page within the app. Available in: Lightning Until you assign content to a user, the user sees a few modules suggested by Trailhead in the Experience learning panel and on Learning Home. Available in: Developer, 1. To open the panel, click the icon for Learning Paths in the global header. Professional, Enterprise, Performance, and Unlimited Editions
Not Available for: Chatter External, Chatter Free, or 2. At the bottom of the panel, click Go to Learning Home. Communities (now known You can also get to Learning Home via the App Launcher. Add Learning Home to your navigation as Experience Cloud) user bar for easy access. licenses
3. On Learning Home, click Manage Learning Assignments, then click New. Only admins or myTrailhead Available in: users with the Manage Learning user permission have access to the Manage Learning Enterprise, Performance, Assignments page. and Unlimited Editions 4. In the New learning item window, select a content type, then search for a Trailhead or myTrailhead module or enter the URL for a custom link. USER PERMISSIONS
To manage as an admin • Modify All Data OR Customize Application To manage as a designated trainer • Manage Learning
When users click the link for a Trailhead or myTrailhead module in the side panel or on Learning Home, the item opens in the app. Custom links open in a new browser tab. If you like, you can put custom links that you previously included in the Help Menu in Learning Paths instead. 5. Under Location, specify where the learning item appears in the app by selecting an app and, if you like, an object and record.
• To make the learning item appear across Salesforce, select All for App and Object and Record.
88 Extend Salesforce with Clicks, Not Code Custom Help Content
• To make the learning item show up on every page in an app, select an app in the App picklist and select All in the Object and Record picklist. • To make the learning item show up for a specific object in an app, select a value in both the App and the Object and Record picklists. • To have the learning item show up for the same object across Salesforce, select All in the app picklist and select a value in the Object and Record picklist. • To add a module to a specific Setup page, enter a URL. If you don’t specify a URL, the module shows up on all pages in Setup.
6. Under Assignments, specify which users and public user groups see the module. If you don’t assign the module to at least one user or public group, it doesn’t show up in the app.
When you assign a learning item to a public group, the assignment also applies to members that you subsequently add to the group. The assignment is removed for members that you remove from the group. 7. To make the learning item required, include a due date.
8. Save your changes. 9. On the Manage Learning Assignments page, you can expand a row in the Name column to see all the users and groups that the learning item is assigned to.
Use the row-level actions for a learning item to edit, delete, or add assignees to the item. • To change the page that a learning item is assigned to, select Edit from the actions menu for the learning item. • To assign a learning item to another individual or group, select Add Assignments from the actions menu for the learning item. • To remove all assignments, select Unassign All in the row-level actions menu for the learning item. • To delete a particular assignment, select Remove Assignment from the row-level action menu for an individual or group.
89 Extend Salesforce with Clicks, Not Code Custom Help Content
We suggest that you let your users know about Learning Paths so they can watch for required content.
SEE ALSO: Considerations for Using Learning Paths Best Practices for Learning Paths and the Help Menu Find Help in Lightning Experience Customize the Help Menu in Lightning Experience Get Personalized Guidance While Setting Up and Enhancing Salesforce Plan Your myTrailhead Solution Your Trailblazer.me Profile Merge Trailblazer.me Accounts Personalize the Navigation Bar in Lightning Experience Personalized Navigation Considerations Add and Customize Tabs on Lightning Pages Using the Lightning App Builder What Is a Group? Create and Edit Groups
Monitor Learning Paths (Beta)
USER PERMISSIONS EDITIONS
To create custom reports and dashboards Manage Learning Reporting Available in: Lightning for Learning Paths Experience
To create and update custom report types Legacy Folder Sharing Available in: Developer, Create and Customize Reports Professional, Enterprise, Performance, and AND Unlimited Editions Manage Custom Report Types Not Available for: Chatter Enhanced Folder Sharing External, Chatter Free, or Create and Customize Reports Communities (now known AND as Experience Cloud) user licenses Manage Custom Report Types myTrailhead Available in: To delete custom report types Legacy Folder Sharing Enterprise, Performance, Create and Customize Reports and Unlimited Editions AND Manage Custom Report Types AND Modify All Data Enhanced Folder Sharing Create and Customize Reports AND
90 Extend Salesforce with Clicks, Not Code Custom Help Content
Manage Custom Report Types AND Modify All Data
Use custom reports and dashboards to track user engagement with Learning Paths, Trailhead, and myTrailhead.
Note: As a beta service, Monitoring Learning Paths is subject to the Beta Services terms at: https://www.salesforce.com/company/legal/agreements.jsp. Use this feature at your sole discretion, and make your purchase decisions only on the basis of generally available products and features. Salesforce doesn’t guarantee general availability of this feature within any particular time frame or at all, and we can discontinue it at any time. This feature is for evaluation purposes only, not for production use. It’s offered as is and isn’t supported, and Salesforce has no liability for any harm or damage arising out of or in connection with it. All restrictions, Salesforce reservation of rights, obligations concerning the Services, and terms for related Non-Salesforce Applications and Content apply equally to your use of this feature.
Use Cases for Reporting on Learning Paths Learning Paths comes with four objects. Two of them give you information about Trailhead and myTrailhead, and two give you information about your assignments in Learning Paths. You can: • Track the number of Trailhead and myTrailhead modules completed, including total points earned and how long it took each user to complete each module. • Identify the modules that are the most popular with your users by tracking how many people complete each one. • Track the number of assigned modules that your users started but haven’t completed to get an idea of how helpful that learning item is. • Track how many learning items you assign in a given month and how many are in progress, overdue, or completed. • Filter your reports by user fields such as username, profile, role, manager, or locale. Here are examples of how you can use the four objects to track your users’ progress on learning items. Set up a custom report type using one of the following objects to monitor Learning Paths.
Object Pulls Data from... Create a Report Showing... Learning Content Trailhead and myTrailhead How many Trailhead or myTrailhead modules exist, by module title, and how many points a user can earn for each
Learning Content Progress Trailhead and myTrailhead How many Trailhead and myTrailhead modules your users completed Which users completed a particular Trailhead or myTrailhead module and how long it took them to finish How many myTrailhead modules are in progress How many total points earned company-wide
91 Extend Salesforce with Clicks, Not Code Custom Help Content
Object Pulls Data from... Create a Report Showing...
Learning Learning Paths How many individual users you assigned a learning item to and how many of those users completed the item
Learning Assignment Progress Learning Paths Which users you assigned a learning item to, which users have it in progress, and which users completed it Which users have an overdue learning assignment The percentage of your users that completed an assigned learning item
For example, create a report that associates the Learning Content object with the Learning object and Learning Assignments Progress object. Then you can review data on the modules that you assign to specific users and those users' progress on the assigned modules.
After you create reports, you can create a dashboard that shows key data.
1. Number of Trailhead and myTrailhead modules completed company-wide, by week 2. Most popular Trailhead and myTrailhead modules
92 Extend Salesforce with Clicks, Not Code Custom Help Content
3. Number of Trailhead and myTrailhead modules completed company-wide 4. Number of hours spent reading Trailhead and my Trailhead modules company-wide 5. Number of points earned company-wide 6. Number of Trailhead and myTrailhead modules that your users have started but not yet finished
Considerations for Monitoring Learning Paths You can track user engagement with Trailhead and myTrailhead modules, but not with custom links. Reports using the Learning Content and Learning Content Progress objects show a maximum of 1,000 rows. You can filter a report on the Learning Content Progress object by the date when a user began a module, but not when a user completed the module. You can’t filter a report on the Learning Assignment Progress object by the date when a user completed a module. To report on users' learning assignment progress, filter your report on the Title field from the Learning Content object. You can't create a report that shows users' progress on all assigned Trailhead modules. You can’t track how many public groups or public group members you assigned a learning item to. For more details on limitations for reports on Learning Paths, see Limits on Report Types and Report Considerations for Salesforce Connect—All Adaptors in Salesforce Help.
SEE ALSO: Assign a Learning Item for Learning Paths Create a Custom Report Type Limits on Report Types Manage Custom Report Types Build a Lightning Experience Dashboard Reports
Customize the Help Menu in Lightning Experience
The Help icon in the header opens a menu of contextual help topics, Trailhead modules, videos, EDITIONS and more items chosen by Salesforce. You can supplement the recommended resources by adding a section with links to your own content. Your section appears at the top of the Help Menu on each Available in: Lightning page. There’s only one custom Help Menu section per org. You can’t add links to the Getting Started, Experience Help For This Page, or More Resources sections. Available in: Group, 1. From Setup in Lightning Experience, in the Quick Find box, enter Help Menu, and then select Professional, Enterprise, Help Menu. Performance, Unlimited, 2. Enter a title for the custom section. Salesforce recommends naming the section so that users and Developer Editions understand that the resources are custom help for your org or company. For example, Acme Company Help. Labels aren’t translated and appear as you’ve entered them. USER PERMISSIONS 3. Tip: List the most important resources first. Only the first two resources are shown in To create custom help: each section. Users can view all resources by clicking the section name or the arrow. • Customize Application OR Modify All Data
93 Extend Salesforce with Clicks, Not Code Custom Help Content
Add labels and URLs for the resources. For example, Sales Tips and https://www.acmecustomhelp.com/pdf/salestips.pdf. You can add up to 30 resources. Items are listed in the Help Menu in the order that they appear on the setup page. 4. Save your changes. 5. Turn on Customize the Help Menu. You can hide sections and links to content created by Salesforce from users. Under the Salesforce Help Content section, turn off the sections and links that you want to hide. As an admin with the Customize Application or Modify All Data user permission, you always see all resources, including a link to the release notes. If you turn off the link to Get Support, the corresponding link in the Salesforce feedback form is also not displayed to users.
Important: If you install a package with custom Help Menu resources, they don't appear in your Help Menu Setup page or in the Help Menu user interface. To add resources per the package suggestions, use the CustomHelpMenuItem and CustomHelpMenuSection SOAP API objects to view the information contained in the package. Then manually add any resources to the Help Menu Setup page. The Help Menu isn’t supported in the Salesforce mobile app.
SEE ALSO: Find Help in Lightning Experience
Custom Help in Salesforce Classic In Salesforce Classic, object-level help replaces the links for a custom object or external object page. Replace built-in Salesforce Help with documentation that’s customized for your users.
Object-Level Help in Salesforce Classic Help your users by providing object-level help for all custom objects and external objects. This way, when your users click the Help for this Page link on your custom object, they’ll find useful information that’s relevant to your custom object. When you add custom help to a custom or external object, the Help for this Page link on those object pages displays your custom help instead of generic help. Your users can access the custom help content from the object home (overview), detail, and edit pages, list views, and related lists.
Object-Level Help in Salesforce Classic Help your users by providing object-level help for all custom objects and external objects. This way, when your users click the Help for this Page link on your custom object, they’ll find useful information that’s relevant to your custom object. When you add custom help to a custom or external object, the Help for this Page link on those object pages displays your custom help instead of generic help. Your users can access the custom help content from the object home (overview), detail, and edit pages, list views, and related lists.
Note: If you don’t create object-level help, the Help for this Page link provides information about standard objects that won’t be relevant to your custom object. You can override the Help for this Page links for a custom object or external object with help content contained in a Visualforce page. But don’t worry! You don’t have to learn Visualforce to add help content to your custom objects.
94 Extend Salesforce with Clicks, Not Code Custom Help Content
Define Org-Level Help in Salesforce Classic If you rename standard tabs, objects, fields, and other related user interface labels, you can also replace the built-in Salesforce Help with documentation that’s customized specifically for your users. To replace the built-in help, simply provide a URL to your custom help. This feature is available for Salesforce Classic only.
SEE ALSO: Custom Help Content Define Object-Level Help in Salesforce Classic Object-Level Help Considerations in Salesforce Classic
Define Object-Level Help in Salesforce Classic
Object-level help overrides the Help for this Page links for a custom object or external object with EDITIONS your own help content contained in a Visualforce page. To make object-level help available to all your users, create a Visualforce page that contains your help content. Then edit the custom or Available in: Salesforce external object definition to reference the page. Object-level help becomes available to all your Classic users instantly. Custom objects are 1. Create a Visualforce page that contains your help content. available in: Contact 2. Edit the custom object definition or external object definition that uses the custom help when Manager, Group, users click the Help for this Page link. Professional, Enterprise, Performance, Unlimited, 3. For Context-Sensitive Help Setting, select Open a window using a Visualforce and Developer Editions page. Salesforce Connect external 4. Select the Visualforce page that contains your help content. objects are available in: 5. Save you work. Developer Edition and for an extra cost in: Enterprise, Performance, and SEE ALSO: Unlimited Editions Object-Level Help in Salesforce Classic Custom Help Content USER PERMISSIONS
To define or change object-level help: • Customize Application
95 Extend Salesforce with Clicks, Not Code Custom Help Content
Create a Custom Object Help Page with Static Content in Salesforce Classic
If you know HTML, it’s easy to add help to your custom objects by writing the content in HTML and EDITIONS saving it in a Visualforce page. No need to learn Visualforce. Just use the template that we provide. 1. From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Available in: Salesforce Pages. Classic 2. Click New. Custom objects are The Visualforce page editor opens with a new page. available in: Contact 3. Complete the following fields. Manager, Group, Professional, Enterprise, Performance, Unlimited, Field Description and Developer Editions Label The human-friendly name of the page used to identify the page in Salesforce Connect external Setup tools. objects are available in: Developer Edition and for Tip: It’s a great idea to have a naming convention for your an extra cost in: Enterprise, custom help pages. For example, start all custom help pages Performance, and with “Help_” and then the object name. Unlimited Editions
Name The API name for the page. You can use the auto-filled value. Visualforce is available in: Contact Manager, Group, Description An optional description of the page. Professional, Enterprise, Performance, Unlimited, Available for Select this option if your custom object is available in the Salesforce and Developer Editions Lightning Experience, mobile app. Experience Builder sites, and the mobile USER PERMISSIONS app To define or change object-level help: • Customize Application 4. Click Quick Save. To create or edit Visualforce 5. In the Visualforce Markup tab code editor, select the default code and delete it. pages: 6. Paste the following help template code into the code editor. • Customize Application
Help for {YourObjectName} Object
Your custom help message here.
7. Click Quick Save. 8. Edit the template to add your help content. To add formatting to your page, use HTML markup. You can also use Visualforce markup if you know it.
9. Click Save.
96 Extend Salesforce with Clicks, Not Code Custom Help Content
You can now add this page as custom help. When users click Help for this Page, they see this page in the Help & Training window.
SEE ALSO: Define Object-Level Help in Salesforce Classic Create Custom Object Help with a PDF File in Salesforce Classic Object-Level Help Considerations in Salesforce Classic
Create Custom Object Help with a PDF File in Salesforce Classic
Add help to your custom objects by creating Visualforce pages that redirect to PDF help files or a EDITIONS URL. No need to learn Visualforce. Just use the template that we provide. You can write your help content in an authoring tool such as Microsoft Word and convert it to a Available in: Salesforce PDF file. Classic 1. Upload your PDF file as a static resource. Custom objects are Users see this PDF file when they request help with the custom object. available in: Contact Manager, Group, 2. From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Professional, Enterprise, Pages. Performance, Unlimited, 3. Click New. and Developer Editions The Visualforce page editor opens with a new page. Salesforce Connect external objects are available in: 4. Complete the following fields. Developer Edition and for an extra cost in: Enterprise, Field Description Performance, and Label The human-friendly name of the page used to identify the page in Unlimited Editions Setup tools. Visualforce is available in: Contact Manager, Group, Tip: It’s a great idea to have a naming convention for your Professional, Enterprise, custom help pages. For example, start all custom help pages Performance, Unlimited, with “Help_” and then the object name. and Developer Editions
Name The API name for the page. You can use the auto-filled value.
Description An optional description of the page. USER PERMISSIONS
Available for Select this option if your custom object is available in the Salesforce To define or change Lightning Experience, mobile app. object-level help: • Customize Application Experience Builder sites, and the mobile To create or edit Visualforce app pages: • Customize Application
5. Click Quick Save. 6. In the Visualforce Markup tab code editor, select the default code and delete it. 7. Paste the following help template code into the code editor.
97 Extend Salesforce with Clicks, Not Code Custom Help Content
Redirecting to help content...
8. Replace YourCustomHelpResource in the action attribute with the name of the static resource that you uploaded. 9. Click Save. You can now add this page as help. When users click Help for this Page, they’re redirected to the resource you set in the action attribute.
Note: The user’s browser controls the behavior of a PDF link, not your Visualforce page. The PDF content might display in the browser or be downloaded as a PDF file.
SEE ALSO: Define Object-Level Help in Salesforce Classic Create a Custom Object Help Page with Static Content in Salesforce Classic Object-Level Help Considerations in Salesforce Classic
Object-Level Help Considerations in Salesforce Classic
Before defining object-level help text for your custom or external objects, review these best practices EDITIONS and implementation considerations. Available in: Salesforce Best Practices Classic (not available in all orgs) • The window that displays your object-level help has the same height and width dimensions as the standard Salesforce Help & Training window. To increase the usability of your help content, Custom objects are size and style your content appropriately. available in: Contact Manager, Group, • Your Visualforce help content pages can use merge fields or other functions to make the Professional, Enterprise, experience more personalized. For example, you can design the help to add the user’s name Performance, Unlimited, when the help page is displayed. and Developer Editions Salesforce Connect external Advanced Implementation Considerations objects are available in: • Create custom help Visualforce pages without a controller, or use a custom controller. You can’t Developer Edition and for use a standard controller. an extra cost in: Enterprise, Performance, and • If you have defined object-level help for an object that you add to a Salesforce AppExchange Unlimited Editions package, Salesforce adds the Visualforce page or static resource referenced in your Context-Sensitive Help Settings for that object. Visualforce is available in: Contact Manager, Group, • In managed packages, object-level help is locked to the developer, giving installers the ability Professional, Enterprise, to change it if needed. Performance, Unlimited, and Developer Editions SEE ALSO: Define Object-Level Help in Salesforce Classic Object-Level Help in Salesforce Classic
98 Extend Salesforce with Clicks, Not Code Tailor Business Processes to Different Users Using Record Types
Define Org-Level Help in Salesforce Classic
If you rename standard tabs, objects, fields, and other related user interface labels, you can also EDITIONS replace the built-in Salesforce Help with documentation that’s customized specifically for your users. To replace the built-in help, simply provide a URL to your custom help. This feature is available Available in: Salesforce for Salesforce Classic only. Classic (not available in all Users can view this URL whenever they click on any context-sensitive help link on an end-user page orgs) or within their personal settings. After you replace the help, the Help & Training link at the very Available in: All Editions top of every page and all Setup pages will continue to display the Salesforce Help. except Database.com 1. From Setup, enter Help Settings in the Quick Find box, then select Help Settings. 2. Enter the complete URL for your help file that you would like to replace the Salesforce Help. 3. Click Save.
Considerations for Replacing the Salesforce Help • When you replace the Salesforce Help with your own help file, the Help & Training link still displays Salesforce Help. However, other than within Setup, the Help for this Page links on all pages are no longer context-sensitive. That is, your help file will open at the same place regardless of which page the user is viewing when they click the link. • You can make your help context-sensitive by taking advantage of the context-specific parameters that are passed with each help link. For example, the help link from the Opportunities tab home page is constructed as follows (without any line breaks): http://your_help_file.com?loc=help&body=%2Fhelp%2Fdoc%2Fen%2Fhelp2.jsp &target=opp_overview.htm§ion=Opportunities The values of the target and section parameters are unique for every page within the application. You can parse these parameters to display context-sensitive help content for your users.
Tailor Business Processes to Different Users Using Record Types
Record types let you offer different business processes, picklist values, and page layouts to different EDITIONS users. You might create record types to differentiate your regular sales deals from your professional services engagements, offering different picklist values for each. Or you might display different page Available in: both Salesforce layouts for your customer support cases versus your billing cases. Classic and Lightning Example: Here’s an example of how record types can work in your org. Let’s say you have Experience two sales divisions, hardware and consulting, and only your consulting division receives leads Available in: Professional, through seminars. You can choose to display the Seminar contact lead source for the consulting Enterprise, Performance, division only. Unlimited, and Developer Step 1: Manage master picklists Editions Define a list of contact Lead Source picklist values that contains all the values used by both the Hardware and Consulting divisions, including Seminar. USER PERMISSIONS Step 2: Create record types To create or change record Create two contact record types: one called Hardware and another called Consulting. types: This step includes adding master picklist values to the record types. • Customize Application Step 3: Add record types to profiles Add the Hardware record type to the profiles for all users in the hardware sales division. Add the Consulting record type to the profiles of all users in the consulting sales division.
99 Extend Salesforce with Clicks, Not Code Tailor Business Processes to Different Users Using Record Types
Step 4: Set personal options for record types Allow users of both the hardware and consulting sales divisions to bypass the prompt that asks them to select a record type when creating a contact. If you have users that create contact records for both sales divisions, they can customize their personal settings to always prompt them to select a record type.
Considerations for Creating and Updating Record Types and Picklists Keep these considerations in mind when working with record types and business process picklists. Create Record Types Edit Picklists for Record Types and Business Processes Customize the values in record type or business process picklists based on your organization’s unique needs. Limitations for Creating and Updating Record Types and Picklists Keep these limitations in mind when working with record types and business process picklists. Managing Multiple Business Processes Use multiple business processes to display different picklist values according to each user’s profile. Use multiple business processes to track separate sales, support, and lead lifecycles. Create Multiple Business Processes
SEE ALSO: How Is Record Type Access Specified?
Considerations for Creating and Updating Record Types and Picklists
Keep these considerations in mind when working with record types and business process picklists. EDITIONS
General Available in: both Salesforce Classic and Lightning • If each profile is associated with a single record type, users will never be prompted to select a Experience record type when creating records. Available in: Professional, • Don’t name your record type Master because it’s reserved for record types. Enterprise, Performance, • Don’t use record types as an access control mechanism. Profile assignment governs create and Unlimited, and Developer edit access for an object but doesn’t govern read access. For example, a user assigned to a Editions profile that isn't enabled for a particular record type can't create records with that record type, but can access records associated with that record type. Users with access to an object can read all record type information for that object. • We strongly recommend against storing sensitive information in the record type description, name, or label. Instead, store sensitive information in a separate object or fields to which you applied appropriate access controls. • A user can be associated with several record types. For example, a user who creates marketing campaigns for both US and European divisions can have both US and European campaign record types available when creating campaigns. • When creating and editing record types for accounts, opportunities, cases, contacts, or custom objects, check for criteria-based sharing rules that use existing record types as criteria. A record type change may affect the number of records that the rule shares. For example, let's say you have a record type named Service, and you created a criteria-based sharing rule that shares all Service record types with your service team. If you create another record type named Support, and you want these records shared with your service team, update the sharing rule to include Support record types in the criteria. • Deleting a record type also deletes the related path.
100 Extend Salesforce with Clicks, Not Code Tailor Business Processes to Different Users Using Record Types
• Business and person accounts require at least one active record type. • Deleting campaign member record types updates the Campaign Member Type field on campaign and campaign member records. • Person accounts are account records to which a special record type has been assigned. These record types are called person account record types. Person account record types allow contact fields to be available on the account and allow the account to be used as if it were a contact. A default person account record type named Person Account is automatically created when person accounts are enabled for your org. You can change the name of this record type, and you can create more person account record types. • From the UI, you can change an account’s record type from a business account to a business account or from a person account to a person account. However, to change an account’s record type from a business account to a person account, or vice versa, you must use the API. • When users convert, clone, or create records, these special considerations apply. – When a user converts a lead, the new account, contact, and opportunity records use the default record type for the owner of the new records. The user can choose a different record type during conversion. – When a user clones a record, the new record has the record type of the cloned record. If the user’s profile doesn’t have access to the record type of the cloned record, the new record adopts the user’s default record type. – When a user creates a case or lead and applies assignment rules, the new record can keep the creator’s default record type or take the record type of the assignee, depending on the case and lead settings specified by the administrator.
• Changing a record type causes Lightning pages to refresh.
Deactivating Record Types Consider these guidelines if you are deactivating a record type. • Deactivating a record type doesn’t remove it from any user profiles or permission sets. • Deactivating a record type means that no new records can be created with the record type. However, any records that were previously created with the record type are still associated with it and with its associated page layout. • To deactivate all record types from an object, remove all record types from all the profiles and deactivate the record types. Then create one new record type and activate it, but don’t add it to any profiles. One record type must exist to enable existing records that used the deactivated record types to display properly. If you encounter any issues inline editing a record in Lightning Experience after deactivating a record type, edit the Page Layout Assignment so that another layout on the object, such as the default layout, is used for the custom record type. Otherwise, consider reactivating the disabled record type.
Record Types and Picklists • Before creating record types, include all the possible record type values in your master list of picklists. The master picklist is a complete list of picklist values that can be used in any record type. • The master picklist is independent of all record types and business processes. If you add a picklist value to the master picklist, you must manually include the new value in the appropriate record types. If you remove a picklist value from the master, it is no longer available when creating records, but records assigned to that value are unchanged.
101 Extend Salesforce with Clicks, Not Code Tailor Business Processes to Different Users Using Record Types
• When you create a record type without cloning an existing one, the new record type automatically includes the master picklist values for both standard and custom picklists. You can then customize the picklist values for the record type.
SEE ALSO: Tailor Business Processes to Different Users Using Record Types Create Record Types Limitations for Creating and Updating Record Types and Picklists
Create Record Types
Tip: Before creating record types, include all of the possible record type values in your master EDITIONS list of picklists. The master picklist is a complete list of picklist values that can be used in any record type. Available in: both Salesforce 1. From the management settings for the appropriate object, go to Record Types. Classic and Lightning Experience 2. Click New. Available in: Professional, 3. Select Master from the Existing Record Type dropdown list to copy all available picklist values, Enterprise, Performance, or choose an existing record type to clone its picklist values. Unlimited, and Developer Note: When you create a record type without cloning an existing one, the new record Editions type automatically includes the master picklist values for both standard and custom picklists. You can then customize the picklist values for the record type. USER PERMISSIONS
4. Enter a Record Type Label that's unique within the object. To create or change record types: Important: Don’t name your record type Master because it’s reserved for record types. • Customize Application
5. Enter a Record Type Name. The Record Type Name refers to the component when using the Web services API and prevents naming conflicts on package installation in managed packages. 6. For opportunity, case, lead, and solution record types, select a business process to associate with the record type. 7. Enter a description. 8. Select Active to activate the record type. 9. Select Make Available next to a profile to make the record type available to users with that profile. Select the checkbox in the header row to make it available for all profiles.
Tip: If each profile is associated with a single record type, users will never be prompted to select a record type when creating records. Users assigned to a record type can still view and edit records associated with record types not enabled for their profiles.
10. For selected profiles, select Make Default next to a profile to make it the default record type for users of that profile. Select the checkbox in the header row to make it the default for all profiles. 11. Click Next. 12. Choose a page layout option to determine what page layout displays for records with this record type: • To apply a single page layout for all profiles, select Apply one layout to all profiles and choose the page layout from the dropdown list. • To apply different page layouts based on user profiles, select Apply a different layout for each profile and choose a page layout for each profile.
102 Extend Salesforce with Clicks, Not Code Tailor Business Processes to Different Users Using Record Types
13. Click Save to edit the values of the standard and custom picklists available for the record type, or click Save and New to create another record type.
SEE ALSO: Tailor Business Processes to Different Users Using Record Types Considerations for Creating and Updating Record Types and Picklists Limitations for Creating and Updating Record Types and Picklists
Edit Picklists for Record Types and Business Processes
Customize the values in record type or business process picklists based on your organization’s EDITIONS unique needs. 1. Select a record type or business process and click Edit next to the picklist field to change its Available in: both Salesforce values. Classic and Lightning Experience 2. Add or remove values as needed. Users can choose from these values when creating or editing records. Record types are available 3. Optionally, choose a default picklist value. Some picklists require a default value. The default in: Professional, Enterprise, Performance, Unlimited, value in a dependent field is ignored. and Developer Editions 4. Click Save. Business processes are available in: Enterprise, SEE ALSO: Performance, Unlimited, Custom Fields and Developer Editions
USER PERMISSIONS
To create or change record types: • Customize Application To create or change business processes: • Customize Application
Limitations for Creating and Updating Record Types and Picklists
Keep these limitations in mind when working with record types and business process picklists. EDITIONS • These special picklist fields aren’t available for record types because they are used exclusively for sales processes, lead processes, support processes, and solution processes: Available in: both Salesforce Classic and Lightning – Opportunity Stage Experience – Case Status Available in: Professional, – Solution Status Enterprise, Performance, – Lead Status Unlimited, and Developer You can use these fields to provide different picklist values for different record types by assigning Editions a different process to each record type. • These campaign member picklists aren’t available for record types:
103 Extend Salesforce with Clicks, Not Code Tailor Business Processes to Different Users Using Record Types
– Status – Salutation – Lead Source
• You can’t edit or delete a record type for an object if the object is referenced in Apex. • You can’t deactivate a record type if it is in use by an email routing address for Email-to-Case or On-Demand Email-to-Case. • Record types can only be assigned to campaign members using the Campaign Member Type field on new or existing campaigns. To assign record types to campaign members, add the Campaign Member Type field to the campaign page layout. You must have the Marketing User user permission to change the campaign member type. You can also add a read-only Campaign Member Type field to the campaign members page layout. • We recommend creating no more than 200 record types. While there is no limit, orgs may have difficulty managing their record types if they exceed 200.
SEE ALSO: Create Record Types Considerations for Creating and Updating Record Types and Picklists
Managing Multiple Business Processes
Use multiple business processes to display different picklist values according to each user’s profile. EDITIONS Use multiple business processes to track separate sales, support, and lead lifecycles. Sales Processes Available in: both Salesforce Create different sales processes that include some or all of the picklist values available for the Classic and Lightning opportunity Stage field. Experience Lead Processes Available in: Enterprise, Create different lead processes that include some or all of the picklist values available for the Performance, Unlimited, Lead Status field. and Developer Editions Support Processes Create different support processes that include some or all of the picklist values available for USER PERMISSIONS the case Status field. To create or change Solution Processes business processes: Create different solution processes that include some or all of the picklist values available for • Customize Application the Status field. After creating a sales, support, lead, or solution process, assign the process to a record type. The record type determines the user profiles that are associated with the business process. To view a list of business processes, from Setup, enter Processes in the Quick Find box, then select the appropriate link.
SEE ALSO: Edit Picklists for Record Types and Business Processes
104 Extend Salesforce with Clicks, Not Code Manage Your Translations
Create Multiple Business Processes
Follow these steps to create sales processes, support processes, lead processes, and solution EDITIONS processes. 1. From Setup, enter Processes in the Quick Find box, then select the appropriate link. Available in: both Salesforce Classic and Lightning 2. Click New. Experience 3. Choose an existing process to copy its picklist values into the new process. Select Master to copy all available picklist values. Available in: Enterprise, Performance, Unlimited, 4. Enter a name and description for the new process. The name must be unique within the tab. and Developer Editions 5. Click Save. All of the available values in the picklist are displayed. Choose the values that you would like USER PERMISSIONS included in the new business process. To create or change Next, add the new business process to a record type, and then make the record type available to business processes: users based on profile. • Customize Application
Manage Your Translations
If your Salesforce org has multiple languages enabled, manage translations so that your global users EDITIONS can use Salesforce in their language.
Note: Standard objects aren’t available in Translation Workbench. Use the rename tabs and Metadata translation labels interface for standard object translation. available in: Salesforce Classic (not available in all orgs) and Lightning Metadata Translation Experience When you enable multiple languages in your Salesforce org, Salesforce translates some labels Data translation available in: for you, based on the language type. For labels without a default translation, you can localize Lightning Experience your apps and custom functionality for any Salesforce supported language through metadata translation. Available in: Professional, Data Translation Enterprise, Performance, Unlimited, and Developer When data translation is enabled, the data stored in the B2B Commerce Product and Product Editions Category objects’ Name and Description fields is available for translation. You can also enable data translation for custom text and URL fields on those objects. Data translation applies to: B2B Commerce Translation Workbench Use Translation Workbench to maintain translated values for metadata and data labels in your Salesforce org. Specify languages for translation and assign translators for each language. Manage translated values for any Salesforce supported language. Translators can maintain translations directly through the workbench, or you can export translation files for bulk translation imports. Translation Considerations Review considerations for managing your translations and translating flows.
105 Extend Salesforce with Clicks, Not Code Manage Your Translations
Metadata Translation
When you enable multiple languages in your Salesforce org, Salesforce translates some labels for EDITIONS you, based on the language type. For labels without a default translation, you can localize your apps and custom functionality for any Salesforce supported language through metadata translation. Available in: Salesforce Salesforce-provided translations vary by language type. Classic (not available in all orgs) and Lightning Language Type Translations Provided by Salesforce Experience Fully supported languages Metadata labels for all standard features, plus Available in: Professional, Help. Enterprise, Performance, Unlimited, and Developer End-user languages Metadata labels for all standard objects and Editions pages, except admin pages and Setup. No translations for Help.
Platform-only languages None
In situations where Salesforce doesn’t provide default translations, metadata translation allows you to localize apps and custom functionality that you build in Salesforce. You can translate items such as custom labels, custom objects, and field names.
Metadata Available for Translation You can translate metadata labels only for certain Salesforce Setup components. Flow Components for Metadata Translation Flow components are the parts of a flow you can translate.
SEE ALSO: Supported Languages Translation Workbench
Metadata Available for Translation
You can translate metadata labels only for certain Salesforce Setup components. EDITIONS Note: Standard objects aren’t available in Translation Workbench. Use the rename tabs and labels interface for standard object translation. Available in: Salesforce Classic (not available in all To view the translatable metadata labels in your Salesforce organization, first enable Translation orgs) and Lightning Workbench. Then, from the Translate Setup page, select a Setup component. If needed, select Experience Object, Custom Report Type Entity, Flow, Flow Type, Flow Component, or Aspect. Available in: Professional, You can translate the following components. Enterprise, Performance, • Action Unlimited, and Developer • Address Country Editions • Address State • Apex Sharing Reason • App • Button and Link Label
106 Extend Salesforce with Clicks, Not Code Manage Your Translations
• Chatter Extension • Custom Field • Custom Report Type • Data Category • Data Category Group • Division • Feed Filter • Field Set • Flow • Global Value Set • Layout Section • Lookup Filter • Managed Content Node Type • Managed Content Type • Navigation Menu Item (for Experience Cloud sites) • Path Step Rich Text • Picklist Value • Prompt • Prompt Version • Record Type • Reputation Level (for Experience Cloud sites) • S-Control • Solution Category • Stamp • Standard Field Help • Validation Error Message • Web Tab (also includes Lightning component and Visualforce tabs) • Workflow Task
Important: Visualforce pages supersede s-controls. Organizations that haven’t previously used s-controls can’t create them. Existing s-controls are unaffected, and can still be edited.
SEE ALSO: Supported Languages Translation Workbench
107 Extend Salesforce with Clicks, Not Code Manage Your Translations
Flow Components for Metadata Translation
Flow components are the parts of a flow you can translate. EDITIONS
Flow Description Where Translation Appears Available in: Salesforce Component Classic (not available in all Definition The flow name The flow interview’s title bar. orgs) and Lightning Experience Version The version label of a flow The active flow version label is the flow Available in: Professional, definition label by default, so it appears Enterprise, Performance, in the flow interview's title bar. When Unlimited, and Developer you enter the flow definition and its Editions translation manually, the translated definition label overrides the active flow version label. When the flow definition label doesn't have a translation, the translated version label appears as the flow interview's title.
Screen Info Aspect includes help text and paused Help text and paused messages for the messages overall screen.
Screen Field Aspect includes labels, description, help Field-level text on a screen. The text, and error messages for screen description aspect is the text for screen components that don't require output components. Lightning runtime
Choice Aspect includes field labels, help text, Field-level text for choice components. text input labels
Stage Stage labels Screen components that can reference stage labels, including Display Text components and attributes for screen components that require Lightning runtime.
Text Template Aspect includes text in a text template All the pages of a survey. Available only in Salesforce Surveys.
SEE ALSO: Metadata Translation Translation Workbench Considerations for Translating Flows
108 Extend Salesforce with Clicks, Not Code Manage Your Translations
Data Translation
When data translation is enabled, the data stored in the B2B Commerce Product and Product EDITIONS Category objects’ Name and Description fields is available for translation. You can also enable data translation for custom text and URL fields on those objects. Available in: Lightning Note: Data translation requires API version 48.0 or later. Experience Available in: Enterprise, Performance, and Enable Data Translation Developer Editions Allow translation of data stored within the Name and Description fields on the Product and Product Category objects. Applies to: B2B Commerce Enable Data Translation for Custom Fields Allow translation of data stored in custom fields on the Product and Product Category objects. You can enable data translation on custom fields with a type of Text, Text Area, Text Area (Long), Text Area (Rich), and URL.
Enable Data Translation
Allow translation of data stored within the Name and Description fields on the Product and Product EDITIONS Category objects.
Note: Before enabling data translation, note these important considerations: Available in: Lightning Experience • Data translation requires API version 48.0 or later. Available in: Enterprise, • Data translation counts against your Salesforce org’s storage limits. Performance, and 1. From Setup, in the Quick Find box, enter Company Information, and then select Developer Editions Company Information. Applies to: B2B Commerce 2. In the Organization Detail section, click Edit. 3. Select Enable Data Translation. USER PERMISSIONS 4. Click Save. To view company Data translation is now available for the Name and Description fields through the Translation information: tab within Product. You can also manage your data translations through the Export and Import • View Setup and options within Translation Workbench. Configuration
5. Optional: Enable data translation for custom fields. To change company information: • Modify All Data SEE ALSO: Translation Workbench B2B Commerce on Lightning Experience Create Product Data Translations for B2B Stores Data and File Storage Allocations
109 Extend Salesforce with Clicks, Not Code Manage Your Translations
Enable Data Translation for Custom Fields
Allow translation of data stored in custom fields on the Product and Product Category objects. You EDITIONS can enable data translation on custom fields with a type of Text, Text Area, Text Area (Long), Text Area (Rich), and URL. Available in: Lightning Before enabling data translation for custom fields, you must enable data translation. Experience
Note: Data translation requires API version 48.0 or later. Available in: Enterprise, Performance, and 1. From Setup, in the Quick Find box, enter Data Translation Settings, and then Developer Editions select Data Translation Settings. Applies to: B2B Commerce 2. Select an object to enable data translation for its custom fields. Only objects that support data translation are listed. USER PERMISSIONS 3. Select the custom fields that you want to make available for data translation. To change data translation Data translation can only be enabled on custom fields with a type of Text, Text Area, Text Area settings: (Long), Text Area (Rich), and URL. • Customize Application 4. Click Save. AND If your B2B Commerce Store supports multiple languages, data translation is now available for the Modify All Data selected custom fields through the Translation tab within Product and Product Category. You can also manage your data translations through the Export and Import options within Translation Workbench.
SEE ALSO: B2B Commerce on Lightning Experience Create Product Data Translations for B2B Stores Translation Workbench
Translation Workbench
Use Translation Workbench to maintain translated values for metadata and data labels in your EDITIONS Salesforce org. Specify languages for translation and assign translators for each language. Manage translated values for any Salesforce supported language. Translators can maintain translations Metadata translation directly through the workbench, or you can export translation files for bulk translation imports. available in: Salesforce Note: Translation Workbench is only available for multi-language orgs. If you aren’t sure Classic (not available in all orgs) and Lightning whether you have a single-language or multi-language organization, contact Salesforce Experience Customer Support. Data translation available in: Lightning Experience Enable or Disable Translation Workbench Translation Workbench allows you to specify languages for translation, assign translators, and Available in: Professional, manage your translations through the workbench or bulk translation. Enterprise, Performance, Unlimited, and Developer Add Translated Languages and Translators Editions Add languages for translation, assign translators for each language, and activate or deactivate a language’s translations. Data translation applies to: B2B Commerce
110 Extend Salesforce with Clicks, Not Code Manage Your Translations
Translate Metadata Labels Create and update metadata translations for customizations you make to your Salesforce organization, such as custom picklist values and custom field labels. Override Translations in Second-Generation Managed Packages and Unlocked Packages You can override metadata translations for custom objects in namespaced unlocked packages and second-generation managed packages. For example, override the label on a custom field or workflow task. Export Metadata Translation Files Create files for your translators that contain your Salesforce org’s translatable metadata. Examples of translatable metadata include custom field labels, report type names, and picklist values. Export Data Translation Files If data translation is enabled in your Salesforce org, you can create files for your translators that contain your org’s data translations. Examples of translatable data include B2B Commerce Product names and data stored in custom fields. Work with Translation Files Translate metadata labels or data translation text, or review existing translations, with XML Localization Interchange File Format (.xlf) or Salesforce Translation Format (.stf) files. Import Translated Files Import and update the translations for your Salesforce org’s metadata, such as custom fields, report types, and picklist values. Or import and update data translations, such as Product names. Typically, you export translation files from Salesforce, then send them to outside translators or a translation agency for bulk translation activities. You then import the translated files. Common Errors with Exporting and Importing Translation Files Troubleshoot issues you can encounter while exporting and importing files in Translation Workbench.
SEE ALSO: Supported Languages Rename Object, Tab, and Field Labels
Enable or Disable Translation Workbench
Translation Workbench allows you to specify languages for translation, assign translators, and EDITIONS manage your translations through the workbench or bulk translation. Available in: Salesforce Enable Translation Workbench Classic (not available in all orgs) and Lightning Translation Language Settings 1. From Setup, in the Quick Find box, enter , and Experience then select Translation Language Settings. Available in: Professional, 2. On the welcome page, click Enable. Enterprise, Performance, Enabling Translation Workbench makes these changes to your Salesforce org. Unlimited, and Developer • The Manage Translation systems permission is available in permission sets. Editions • You must edit picklist values individually. You can’t mass-edit existing picklist values, but you can still mass-add new values. USER PERMISSIONS
• When picklist values are sorted alphabetically, the values are alphabetical by the org’s default To enable and disable language. Translation Workbench: • Modify All Data
111 Extend Salesforce with Clicks, Not Code Manage Your Translations
• Reports have a Filter Language dropdown list in the Filters pane of the report builder. Selecting a language filters on translated strings for any filter criteria that use the starts with, contains, or does not contain operator. • Import files have a Language dropdown list, and all records and values within the import file must be in the selected language. • Web-to-Lead and Web-to-Case have a Language dropdown list before you generate the HTML. If a customized component doesn’t have a translated value, the component uses the org’s default language. When you deactivate a language, all translations for that language are still available in Translation Workbench. However, users with that language selected see the org’s default language values.
Disable Translation Workbench To disable Translation Workbench, from Setup, in the Quick Find box, enter Translation Language Settings, and then select Translation Language Settings. Click Disable.
Note: In a Developer org with a managed package containing translations, Translation Workbench can’t be disabled after it is enabled.
SEE ALSO: Supported Languages Select Your Language, Locale, and Currency Rename Object, Tab, and Field Labels
Add Translated Languages and Translators
Add languages for translation, assign translators for each language, and activate or deactivate a EDITIONS language’s translations.
Note: The Manage Translation permission is enabled by default in the System Administrator Available in: Salesforce profile. Classic (not available in all orgs) and Lightning Before adding a language for translation, you must select languages for your org and enable Experience Translation Workbench. Available in: Professional, Translation Language Settings 1. From Setup, in the Quick Find box, enter , and Enterprise, Performance, then select Translation Language Settings. Unlimited, and Developer 2. To activate a new language, click Add. Or to change an existing supported language, click Edit. Editions 3. If adding a language, choose a language. 4. To make the entered translations available to your users, select Active. Users can change USER PERMISSIONS their personal language anytime, regardless of whether it's active in the Translation Workbench. To add or edit languages: Active Selecting makes the translations available to the users in that language. • Manage Translation We recommend that you don't make a language active until the translators have translated all To assign translators: values. • Manage Translation Note: If you installed a managed package that includes translations, those translated values appear to users regardless of whether the language is active on the Translation Language Settings Setup page. To override metadata translations delivered by a managed package for custom objects, see Override Translations in Second-Generation Managed Packages and Unlocked Packages.
112 Extend Salesforce with Clicks, Not Code Manage Your Translations
5. To assign translators for this language, select them from the Available List, and click Add. If you don’t see the member that you want to add, enter keywords in the search box, and click Find.
Important: Ensure that all translators have the View Setup and Configuration permission so that they can begin translating. Users can only translate languages that they're assigned to.
6. Save your changes.
SEE ALSO: Select Languages for Your Org Enable or Disable Translation Workbench Override Translations in Second-Generation Managed Packages and Unlocked Packages
Translate Metadata Labels
Create and update metadata translations for customizations you make to your Salesforce EDITIONS organization, such as custom picklist values and custom field labels.
Note: Entering translations through Translation Workbench has limitations, so note the Available in: Salesforce following. Classic (not available in all orgs) and Lightning • Use the rename tabs and labels interface for standard object translation. Standard objects Experience and custom object names aren’t available in Translation Workbench. Available in: Professional, • Manage data translations through the Translation tab within Product or through the Enterprise, Performance, Export and Import options in Translation Workbench. Only metadata translations are Unlimited, and Developer available for translation via the Translate Setup page. Editions Before translating metadata labels, you must select languages for your org, enable Translation Workbench, and add translated languages and translators. USER PERMISSIONS 1. From Setup, in the Quick Find box, enter Translate, and then select Translate. To translate terms: 2. Select the Language you're translating into. • View Setup and 3. Select a Setup Component. See Metadata Available for Translation for a list of translatable Configuration components. AND 4. Depending on the setup component, select the next options. Be designated as a translator The aspect is a part of the setup component that you can translate. For example: • Workflow tasks have an object (for example, Account or Contact) and aspect (Subject or Comment). • Custom Report Types have a custom report type entity (Custom Report Type, Custom Report Type Column, or Custom Report Type Layout Section) and aspect (field label or description). • Flows have a flow type (Flow and Autolaunched Flow), a flow name, and a flow component (Definition, Version, Screen Info, Screen Field, and Choice). Flow components can have a flow version, screen, or aspect. For global value sets and picklist values, you can translate inactive values by selecting Show Inactive Values.
5. To enter new values, double-click in the translation column. You can press Tab to advance to the next editable field or Shift+Tab to go to the previous editable field.
113 Extend Salesforce with Clicks, Not Code Manage Your Translations
Note: The Out of Date column indicates the possibility that the label needs translating because the primary label has been updated. When editing a button or link label, you see the Button or Link Name column, which is used to refer to the component when using SOAP API.
6. Click Save. If a customized component doesn’t have a translated value, the component uses the org’s default language. When you deactivate a language, all translations for that language are still available in Translation Workbench. However, users with that language selected see the org’s default language values.
SEE ALSO: Select Languages for Your Org Translation Workbench Rename Object, Tab, and Field Labels Metadata Available for Translation
Override Translations in Second-Generation Managed Packages and Unlocked Packages
You can override metadata translations for custom objects in namespaced unlocked packages and EDITIONS second-generation managed packages. For example, override the label on a custom field or workflow task. Available in: Salesforce Note: Overriding translations in second-generation managed packages and unlocked Classic (not available in all packages has limitations: orgs) and Lightning Experience • You can’t override translations for standard objects in packages. Available in: Professional, • You can’t override data translations. Enterprise, Performance, If you installed a managed package that includes translations, those translated values appear to Unlimited, and Developer users regardless of whether the language is active on the Translation Language Settings Setup Editions page. Before you can override those translations, you must select languages for your org and enable Translation Workbench. USER PERMISSIONS 1. From Setup, in the Quick Find box, enter Override, and then select Override. To override metadata 2. Select the Package that you’re overriding. translations: 3. Select the Language that you're entering your overrides in. • View Setup and Configuration 4. Select a Setup Component. See Metadata Available for Translation for a list of translatable AND components. Customize Application 5. Depending on the setup component, select the next options. The aspect is a part of the setup component that you can translate. For example: • Workflow tasks have an object (for example, Account or Contact) and aspect (Subject or Comment). • Custom Report Types have a custom report type entity (Custom Report Type, Custom Report Type Column, or Custom Report Type Layout Section) and aspect (field label or description). • Flows have a flow type (Flow and Autolaunched Flow), a flow name, and a flow component (Definition, Version, Screen Info, Screen Field, and Choice). Flow components can have a flow version, screen, or aspect. For global value sets and picklist values, you can translate inactive values by selecting Show Inactive Values.
114 Extend Salesforce with Clicks, Not Code Manage Your Translations
6. To enter new values, double-click in the translation column. You can press TAB to advance to the next editable field or SHIFT-TAB to go to the previous editable field.
Note: The Out of Date column indicates the possibility that the term needs translation because the primary label has been updated. When editing a button or link label, you see the Button or Link Name column, which is used to refer to the component when using SOAP API.
7. Click Save.
SEE ALSO: Select Languages for Your Org Enable or Disable Translation Workbench Metadata Available for Translation
Export Metadata Translation Files
Create files for your translators that contain your Salesforce org’s translatable metadata. Examples EDITIONS of translatable metadata include custom field labels, report type names, and picklist values.
Note: You need the Manage Translation AND Create Documents user permissions to import Available in: Salesforce or export translation files. If you attempt either operation without both user permissions, it’s Classic (not available in all possible to navigate to the import or export page, but the operation itself fails. orgs) and Lightning Experience Before you can export metadata translation files, you must enable Translation Workbench. Available in: Professional, Tip: When exporting metadata translation files, individual uncompressed files are limited to Enterprise, Performance, 5 MB each. If your org’s metadata translations exceed 5 MB, the system exports multiple files. Unlimited, and Developer If multiple .zip files are required, each file name is date-stamped and incremented. For example, Editions Outdated and untranslated 2020–09–20 05:13_part 1 of 2.zip. 1. From Setup, in the Quick Find box, enter Export, and then select Export. USER PERMISSIONS 2. If data translation is enabled in your org, select the Metadata Translation Type. To export or import 3. Select which labels you want to export. translation files • Source–Used as the initial source for creating translations. • Manage Translation AND Creates a single file that contains a list of all your translatable customizations. Create Documents • Outdated and untranslated–Used to make updates. Creates a set of files that contain only metadata labels that have not been translated, including new and modified labels. One file is created for each language. These files are then compressed into .zip files.
• Bilingual–Used for reference and reviewing all your untranslated and translated customizations. Creates a list of all the translatable metadata labels in their current translated or untranslated state. One file is created for each language. These files are then compressed into .zip files. The content in each file is divided into Untranslated and Translated sections. Each translatable label is in the Untranslated or the Translated section, according to its translation state. The Translated section includes the out-of-date status for each label.
Note: Exported translation file content is in your org's default language.
115 Extend Salesforce with Clicks, Not Code Manage Your Translations
4. Select a format. Salesforce recommends the XML Localization Interchange File Format (XLIFF) because it contains more information than the .stf format, like the field width. 5. Click Export. A status message tells you that the export is being processed. Wait for it to finish before submitting another export request. When the export is complete, an email is sent to the email address specified in your profile.
6. Locate the exported .stf, .xlf, or .zip file. Go to Your name > Documents > Document Folders > My Personal Documents > Go!. All exported files indicate the Export option used to create them and are date and time stamped. Individual files end with the .stf or .xlf extension. Multiple files are grouped into .zip files. If you have many documents in your personal documents area, find the exported files under the sort letter: • B—Bilingual export option, for example: Bilingual_2020-01-23_11:20.zip. • S—Source export option, for example: Source_en_US_2020-01-23_11:20.stf. • O—Outdated and untranslated export option, for example: Outdated_and_untranslated_2020-01-23_11:20.zip.
7. Save the files for translation by your translators or translation agency. Click View > Save File > OK. The file is saved to the location specified by your browser. For example, C:/Users/username/Downloads.
8. Send the files to your outside translators or translation agency for bulk translation activities, then use Import to update your labels.
SEE ALSO: Translation Workbench Salesforce Developer Doc: Translations
Export Data Translation Files
If data translation is enabled in your Salesforce org, you can create files for your translators that USER PERMISSIONS contain your org’s data translations. Examples of translatable data include B2B Commerce Product names and data stored in custom fields. To export or import translation files Available in: Lightning Experience • Manage Translation AND Available in: Enterprise, Performance, and Developer Editions Create Documents Applies to: B2B Commerce
Note: You need the Manage Translation AND Create Documents user permissions to import or export translation files. If you attempt either operation without both user permissions, it’s possible to navigate to the import or export page, but the operation itself fails. Before you can export data translation files, you must enable Translation Workbench and data translation.
Important: Each data translation export request is limited to 1 GB of data and 100,000 records. If your requested export exceeds either of those limits, only a partial file is exported. To reduce the amount of data exported, use the language filter, available for
116 Extend Salesforce with Clicks, Not Code Manage Your Translations
the Outdated and translated and Bilingual export types. If your org’s data translations for a single object and language exceed either of those limits, use BULK API. 1. From Setup, in the Quick Find box, enter Export, and then select Export. 2. Select Data as the Translation Type. 3. Select the objects for data translation. 4. Select which labels you want to export. • Source–Used as the initial source for creating translations. Creates a set of files by object with all translatable text.
• Outdated and untranslated–Used to make updates. Creates a set of files, by language and then by object, including text changed after the last translation and text that is not yet translated. These files are then compressed into .zip files.
• Bilingual–Used for reference and reviewing all your untranslated and translated customizations. Creates a set of files, by language and then by object, including all the translatable text in its current translated or untranslated state. These files are then compressed into .zip files. The content in each file is divided into Untranslated and Translated sections. Each translatable text element is in the Untranslated or the Translated section, according to its translation state. The Translated section includes the out-of-date status for each text element.
5. If you selected the Outdated and untranslated or Bilingual export type, select at least one language. 6. Select a file format. Salesforce recommends the XML Localization Interchange File Format (XLIFF) because it contains more information than the .stf format, like the field width. 7. Click Export. A status message tells you that the export is being processed. Wait for it to finish before submitting another export request. When the export is complete, an email is sent to the email address specified in your profile. The email includes a link to a .zip file with your exported translation files.
Note: When exporting data translation files, individual uncompressed files are limited to 25 MB. If multiple files are required, each file name is date stamped and incremented. For example, Bilingual_de_Product2_2020-10-20 0836_1.xlf and Bilingual_de_Product2_2020-10-20 0836_2.xlf.
8. Send the files to your outside translators or translation agency for bulk translation activities, then use Import to update your data translations.
SEE ALSO: Enable Data Translation Translation Workbench Salesforce Developer Doc: Translations
117 Extend Salesforce with Clicks, Not Code Manage Your Translations
Work with Translation Files
Translate metadata labels or data translation text, or review existing translations, with XML EDITIONS Localization Interchange File Format (.xlf) or Salesforce Translation Format (.stf) files. Translation files can contain metadata translations or data translations. Metadata translations are Metadata translation for customizations that you made to your Salesforce organization, such as custom picklist values available in: Salesforce and custom field labels. Data translations are for the data stored within fields, such as the text in Classic (not available in all the Product object’s Name and Description fields. orgs) and Lightning Experience For metadata and data translation files, there are three file types. Data translation available in: • Source: Use to translate labels for the first time. Lightning Experience • Outdated and untranslated: Use to translate labels after the first translation pass. Available in: Professional, • Bilingual: Use to review and edit translations. Enterprise, Performance, Translation files are identified with either the .xlf or .stf extension. Salesforce recommends the XML Unlimited, and Developer Localization Interchange File Format (.xlf) for translation files. Editions
Data translation applies to: Considerations for Working with Translation Files B2B Commerce Review some important considerations to ensure that your edited translation file can be successfully imported. Source Translation Files Use the Source file to translate an organization's labels or data for the first time. The Source file contains labels for all of a Salesforce org's translatable metadata or data in the org's default language. Outdated and Untranslated Translation Files Use the Outdated and untranslated file to translate labels or data that need translation. The file includes labels or data changed since the last translation and labels that haven't been translated. One Outdated and untranslated file is generated for each language. When multiple files are generated, they're exported to a .zip file containing a file for each translation language. Bilingual Translation Files Use the Bilingual file to review translations, edit existing translations, and add translations for labels or data that haven't been translated. One Bilingual file is generated for each translation language. Translation File IDs and Keys Each translatable item has a unique identifier in the translation file. In .xlf files, it is the id within a trans-unit tag. In .stf files, it is the key. The structure of these identifiers differs for metadata and data translation files. Flow Identifiers in Translation Files In a translation file exported from Translation Workbench, a unique key or trans-unit ID attribute identifies a flow metadata label.
SEE ALSO: Export Metadata Translation Files Export Data Translation Files Import Translated Files
118 Extend Salesforce with Clicks, Not Code Manage Your Translations
Considerations for Working with Translation Files
Review some important considerations to ensure that your edited translation file can be successfully EDITIONS imported. Metadata translation General Considerations available in: Salesforce Classic (not available in all • Translation files are identified with the .stf or .xlf extension. Don't change the file extension. orgs) and Lightning • Salesforce recommends the XML Localization Interchange File Format (.xlf) for translation files. Experience
• All translation files are language-specific. Data translation available in: • A translation file name includes the name of the export option used to create it, the language Lightning Experience code for the file's content, and a date stamp. Data translation file names also include the name Available in: Professional, of the object. Enterprise, Performance, • Deleting a translation value, row, or trans-unit tag in the file doesn't remove the translation Unlimited, and Developer after the file is imported. To delete a translation, replace the translated text with <> in an .stf Editions file or <> in an .xlf file. When the file is imported, the label reverts to its primary label value. See Outdated and Untranslated Translation Files and Bilingual Translation Files in Salesforce Data translation applies to: B2B Commerce Help for examples.
Note: See the following Data Translation File Considerations for important notes about deleting the data translation for a record’s Name field.
Exported Translation File Limits • When exporting metadata translation files, individual uncompressed files are limited to 5 MB each. If your org’s metadata translations exceed 5 MB, the system exports multiple files. If multiple .zip files are required, each file name is date-stamped and incremented. For example, Outdated and untranslated 2020–09–20 05:13_part 1 of 2.zip. • Each data translation export request is limited to 1 GB of data and 100,000 records. If your requested export exceeds either of those limits, only a partial file is exported. To reduce the amount of data exported, use the language filter, available for the Outdated and translated and Bilingual export types. If your org’s data translations for a single object and language exceed either of those limits, use BULK API. • When exporting data translation files, individual uncompressed files are limited to 25 MB. If multiple files are required, each file name is date stamped and incremented. For example, Bilingual_de_Product2_2020-10-20 0836_1.xlf and Bilingual_de_Product2_2020-10-20 0836_2.xlf.
Translation File Import Limits • When importing metadata translation files, individual uncompressed files are limited to 10 MB each. • If data translation isn’t enabled in your org, each imported .zip file is limited to 10 MB. If data translation is enabled, each imported .zip file is limited to 1 GB. • When importing data translation files, individual uncompressed files are limited to 50 MB each. • When zipping data translation files for import, each .zip file can contain up to 100,000 total translation records within up to 2 GB of uncompressed files.
Data Translation File Considerations A translated value for the data in the record’s Name field is required to translate data in other fields for that record. For example, you must provide a German translation for the name of a Product before you can translate its description into German.
119 Extend Salesforce with Clicks, Not Code Manage Your Translations
There are two ways to delete the translated values for all fields related to a record. Because translation files are language-specific, this action is per language. • Delete translated text for all of the record’s fields. For example, a Product has German translated values for its name and description. To remove all German data translations for that Product, replace the translated text for that Product record’s Name and Description fields with <> in an .stf file or <> in an .xlf file. • Delete the translated text for the record’s Name field, and remove the rows or trans-unit tags for the record’s other fields. For example, a Product has German translated values for its name and description. To remove all German data translations for that Product, replace the translated text for that Product record’s Name fields with <> in an .stf file or <> in an .xlf file. Also delete the row or trans-unit tag for that Product’s Description field.
Note: You can restore deleted data translation values through the recycle bin.
If an imported translation file deletes the translated value for a record’s Name and includes a translated value for another field, no action is taken. For instance, you delete the translated value for a Product’s name but leave the translation key for that Product’s description unchanged in a translation file for German. When you import that translation file, no changes are made to that Product’s translated values for German.
XML Localization Interchange File Format (.xlf) File Considerations The .xlf format is the recommended export type because it contains more information than the .stf format, like the field width. • .xlf translation file content is organized into translation units. Translation units for translated labels contain a target tag with the translated value. Untranslated labels have a source tag, but no target tag. • Translators must create a target tag for each untranslated label to store the translated value. Otherwise, don't add tags to or remove tags from the .xlf file. • The file tag’s attributes define details about the translation file , such as the source language, target language, and the translation type. • The trans-unit tags’ attributes define details about the translation unit, such as the id and the field width.
Salesforce Translation Format (.stf) File Considerations The .stf format behaves like a .csv file, with content organized into tab-delimited columns. • If you don’t use a standard translation tool such as Trados, edit the file using an application that supports tabs and word wrap, such as WordPad. • Don't add columns to or remove columns from the translation file. • If you use tabs, new lines, or carriage returns in your text for translation, they are represented with special characters in the .stf file format. Tabs are \t, new lines are \n, and carriage returns are \r. To ensure consistency between your language versions, ensure that these characters are maintained in your translations. • If you use Microsoft Excel to enter translations in an .stf file, your file format can be corrupted. MS Excel automatically adds quotation marks around entries that have commas. We recommend that you open your files in a text editor before importing them and remove these quotation marks. The import fails if these quotation marks are not removed.
Translating Rich Text Fields Fields with a type of Text Area (Rich) allow special formatting, such as bolding text or adding an image. When rich text fields are exported for translation, the translatable text for those fields includes encoded HTML tags.
120 Extend Salesforce with Clicks, Not Code Manage Your Translations
If your translators edit raw translation files, make sure that they understand HTML tags and their encoding. When translating the text, HTML tags are not required. However, if HTML tags are included in a translated value, they must be valid and in the same format as the exported tags. If the tags are incorrect, the translation import fails.
Note: The HTML tags are visible in the raw files. Many translation tools handle the conversion of mark-up languages like HTML for you. All rich text field translations must be contained within an HTML paragraph (
) tag with the appropriate HTML encoding for that file type. If the translation value contains only plain text, the required paragraph tag is added upon import. This table provides examples of exported rich text field content.
Rich Text Field Content Format Exported Text Available in women’s shoe sizes .stf
Available in women’s shoe sizes 5-13.
5–13. .xlf <p>Available in women’s shoe sizes 5-13.</p>15% discount available for .stf
15% discount available for veterans. veterans.
Verification required.
Verification required. .xlf <p>15% discount available for veterans. </p><p><b>Verification required.</b></p>
Features: .stf
Features:
- Leather
- LImported
- Rubber • Leather sole
- Lightweight
- Flexible sole
See more information at this .stf
See more information at this reference site.
.xlf <p><a href="https://www.example.com">this reference site</a>.</p>
SEE ALSO: Export Metadata Translation Files Export Data Translation Files Import Translated Files View, Restore, and Manage the Recycle Bin in Salesforce Classic
121 Extend Salesforce with Clicks, Not Code Manage Your Translations
Source Translation Files
Use the Source file to translate an organization's labels or data for the first time. The Source file EDITIONS contains labels for all of a Salesforce org's translatable metadata or data in the org's default language.
Note: Salesforce recommends the XML Localization Interchange File Format (.xlf) for Metadata translation translation files. See Considerations for Working with Translation Files for tips on editing available in: Salesforce translation files and how to translate rich text field content. Classic (not available in all orgs) and Lightning To prepare the translation file for your translators: Experience
• Create one copy of the Source file for each language you are translating into. Data translation available in: • In the header of each Source file, change the language code from the organization's default Lightning Experience language to the translation language. For example, replace en_US for English (US) with es Available in: Professional, for Spanish. Enterprise, Performance, Unlimited, and Developer XML Localization Interchange File Format (.xlf) Source Translation Files Editions Source .xlf translation file content is organized into translation units. Translation units for translated Data translation applies to: labels contain a target tag with the translated value. Untranslated labels have a source tag, B2B Commerce but no target tag. Tell your translators to add a target tag containing the translated value after each source tag. If a target tag exists and the translation is out of date, tell them to replace the text in the target tag. Outdated labels have a value of outOfDate="true" within the trans-unit tag.
Important: A translated value for the data in the record’s Name field is required to translate data in other fields for that record. For example, you must provide a German translation for the name of a Product before you can translate its description into German.
Tag Description Edit Options trans-unit Translation unit. Contains unique identifiers Do not edit. for the label, including the label’s id, maximum width, and out-of-date indicator.
source Label or text in the org’s default language. Do not edit.
target The current translation that is visible to end Enter the translated value. Add a target tag users selecting the target language as their if needed. personal language.
note Description of the metadata label, if defined, Do not edit. Translatable field descriptions in the source language. each have a separate trans-unit tag.
For example, if you build a custom Nickname field on the Account object, the original file contains the following trans-unit tag in the exported Source .xlf file.
122 Extend Salesforce with Clicks, Not Code Manage Your Translations
To translate this label, add a target tag containing the translated value to the corresponding trans-unit tag after the source tag.
Salesforce Translation Format (.stf) Source Translation Files
Note: Salesforce doesn’t recommend the STF format for translation files. If you choose to use this format, we don’t recommend editing the file with Microsoft Excel. For more information and restrictions, see Considerations for Working with Translation Files. Tell your translators to replace the untranslated values in the LABEL column with translated values.
Important: A translated value for the data in the record’s Name field is required to translate data in other fields for that record. For example, you must provide a German translation for the name of a Product before you can translate its description into German.
Column Description Edit Options KEY Unique identifier for the label. Do not edit.
LABEL Label or text in the org’s default language. Replace untranslated values with translated values.
For example, if you build a custom Nickname field on the Account object, the original file contains the following row in the exported Source .stf file.
# KEY LABEL
CustomField.Account.Nickname.FieldLabel Nickname
To translate this label, replace the LABEL text in that row with the translated value.
# KEY LABEL
CustomField.Account.Nickname.FieldLabel Apodo
Important: Don't add columns to or remove columns from the .stf translation file.
SEE ALSO: Considerations for Working with Translation Files Supported Languages
123 Extend Salesforce with Clicks, Not Code Manage Your Translations
Outdated and Untranslated Translation Files
Use the Outdated and untranslated file to translate labels or data that need translation. The file EDITIONS includes labels or data changed since the last translation and labels that haven't been translated. One Outdated and untranslated file is generated for each language. When multiple files are Metadata translation generated, they're exported to a .zip file containing a file for each translation language. available in: Salesforce Note: Salesforce recommends the XML Localization Interchange File Format (.xlf) for Classic (not available in all orgs) and Lightning translation files. See Considerations for Working with Translation Files for tips on editing Experience translation files and how to translate rich text field content. When working with the Outdated and untranslated translation file, each entry needs a new translated Data translation available in: value. Special values are used to delete an existing translation and revert the label to its original Lightning Experience value. Available in: Professional, Enterprise, Performance, XML Localization Interchange File Format (.xlf) Outdated and Untranslated Translation Unlimited, and Developer Editions Files Data translation applies to: Outdated and untranslated .xlf translation file content is organized into translation units. Translation B2B Commerce units for translated labels contain a target tag with the translated value. Untranslated labels have a source tag, but no target tag. Tell your translators: • For untranslated labels, add a target tag containing the translated value after each source tag. • If the label’s translation is out of date, replace the text in the target tag. Outdated labels have a value of outOfDate="true" within the trans-unit tag. Don’t update the outOfDate value. • To delete a translation, replace the value in the label's target tag with <>. When the Bilingual file is imported, the label reverts to its original value. • A translated value for the data in the record’s Name field is required to translate data in other fields for that record. For example, you must provide a German translation for the name of a Product before you can translate its description into German. • Deleting the data translated value for a record’s Name field can delete all of that record’s other translated values for that language. See Considerations for Working with Translation Files for more information.
Tag Description Edit Options trans-unit Translation unit. Contains unique identifiers Do not edit. for the label, including the label’s id, maximum width, and out-of-date indicator.
source Label or text in the org’s default language. Do not edit.
target The current translation that is visible to end Enter the translated value. Add a target tag users selecting the target language as their if needed. personal language.
note Description of the metadata label, if defined, Do not edit. Translatable field descriptions in the source language. each have a separate trans-unit tag.
124 Extend Salesforce with Clicks, Not Code Manage Your Translations
For example, an existing Nickname field on the Account object has a Spanish translated value of “Apodo.” You change the primary label on the Nickname field from “Nickname” to “Preferred Name.” That label is now outdated. You also build a new custom Business Hours field on the Account object. The exported Outdated and untranslated .xlf translation file contains the following trans-unit tags.
To update the outdated label, update the text in the corresponding target tag. To translate the new field’s label, add a target tag containing the translated value to the corresponding trans-unit tag after the source tag. Don’t change the outOfDate tag values. When you import the translated file, labels with updated translations are marked as up to date.
To delete the Preferred Name label’s translation, update the translation value in the target tag with <>. When the file is imported, the label reverts to its original value.
Salesforce Translation Format (.stf) Outdated and Untranslated Translation Files
Note: Salesforce doesn’t recommend the STF format for translation files. If you choose to use this format, we don’t recommend editing the file with Microsoft Excel. For more information and restrictions, see Considerations for Working with Translation Files. Tell your translators to replace the values in the LABEL column with updated translated values. • To delete a translation, replace the desired value in the TRANSLATION column with a left and right angle bracket pair (<>). When the file is imported, the label reverts to its original value. • A translated value for the data in the record’s Name field is required to translate data in other fields for that record. For example, you must provide a German translation for the name of a Product before you can translate its description into German. • Deleting the data translated value for a record’s Name field can delete all of that record’s other translated values for that language. See Considerations for Working with Translation Files for more information.
125 Extend Salesforce with Clicks, Not Code Manage Your Translations
Column Description Edit Options KEY Unique identifier for the label. Do not edit.
LABEL Label or text in the org’s default language. Replace untranslated values with translated values.
For example, an existing custom Nickname field on the Account object has a Spanish translated value of “Apodo.” You change the primary label on the Nickname field from “Nickname” to “Preferred Name.” That label is now outdated. You also build a new custom Business Hours field on the Account object. The exported Outdated and untranslated .stf translation file contains the following rows.
# KEY LABEL
CustomField.Account.Nickname.FieldLabel Preferred Name
CustomField.Account.Business_Hours.FieldLabel Business Hours
To translate the new field’s label and update the existing label, replace the LABEL text in each row.
# KEY LABEL
CustomField.Account.Nickname.FieldLabel Nombre preferido
CustomField.Account.Business_Hours.FieldLabel Horario de oficina
To delete the Nickname field’s outdated translation of “Apodo,” replace the translation value in the LABEL column with <>. When the file is imported, the label reverts to its primary label value of “Preferred Name.”
# KEY LABEL
CustomField.Account.Nickname.FieldLabel <>
SEE ALSO: Considerations for Working with Translation Files
126 Extend Salesforce with Clicks, Not Code Manage Your Translations
Bilingual Translation Files
Use the Bilingual file to review translations, edit existing translations, and add translations for labels EDITIONS or data that haven't been translated. One Bilingual file is generated for each translation language.
Note: Salesforce recommends the XML Localization Interchange File Format (.xlf) for Metadata translation translation files. See Considerations for Working with Translation Files for tips on editing available in: Salesforce translation files and how to translate rich text field content. Classic (not available in all orgs) and Lightning Experience XML Localization Interchange File Format (.xlf) Bilingual Translation Files Data translation available in: Bilingual .xlf translation file content is organized into translation units. Translation units for translated Lightning Experience labels contain a target tag with the translated value. Untranslated labels have a source tag, but no target tag. Available in: Professional, Enterprise, Performance, Tell your translators: Unlimited, and Developer • For untranslated labels, add a target tag containing the translated value after the source Editions tag. Data translation applies to: • If the label’s translation is out of date, replace the text in the target tag. Outdated labels B2B Commerce have a value of outOfDate="true" within the trans-unit tag. • To delete a translation, replace the value in the trans-unit's target tag with <>. When the Bilingual file is imported, the label reverts to its primary label value. • A translated value for the data in the record’s Name field is required to translate data in other fields for that record. For example, you must provide a German translation for the name of a Product before you can translate its description into German. • Deleting the data translated value for a record’s Name field can delete all of that record’s other translated values for that language. See Considerations for Working with Translation Files for more information.
Tag Description Edit Options trans-unit Translation unit. Contains unique identifiers Do not edit. for the label, including the label’s id, maximum width, and out-of-date indicator.
source Label or text in the org’s default language. Do not edit.
target The current translation that is visible to end Enter the translated value. Add a target tag users selecting the target language as their if needed. Replace a value with <> personal language. to delete the translation.
note Description of the metadata label, if defined, Do not edit. Translatable field descriptions in the source language. each have a separate trans-unit tag.
For example, in an org with English as its default language, you build a new custom Business Hours field on the Account object. This label is untranslated. Nickname, an existing custom field on the Account object, has a Spanish translated value of “Apodo.” You change the primary label on the Nickname field from “Nickname” to “Preferred Name.” This label is outdated. Another existing custom Prior Reference Number field on the Account object has an incorrect Spanish translated value of “Número de consulta previa.” Although the translation isn’t out of date, it must be updated to “Número de referencia precedente.”
127 Extend Salesforce with Clicks, Not Code Manage Your Translations
The Name field on a custom Widget object had a primary label of “SLK.” A translator misinterpreted this acronym and entered a Spanish translation of “Flojo.” Although the translation isn’t out of date, you want to revert the translation to the primary label. Finally, a custom Number field on a custom Widget object had a primary label of “Number” and a Spanish translated value of “Número.” You update the primary label to “#” and want to remove the translated value. The exported Bilingual .xlf translation file contains the following row in the OUTDATED AND UNTRANSLATED section.
To make the requested changes: • Add a target tag with the translated value to the new Business Hours field. • Update the translation values in the target tags for the Preferred Name and Prior Reference Number fields. • To delete the translation of the Widget object’s Name and Number fields, update the translation values in those target tags with <>. When this file is imported, those labels revert to the primary label values. • Don’t change the outOfDate tag values. When you import the translated file, labels with updated translations are marked as up to date.
128 Extend Salesforce with Clicks, Not Code Manage Your Translations outOfDate="false">
Salesforce Translation Format (.stf) Bilingual Translation Files
Note: Salesforce doesn’t recommend the STF format for translation files. If you choose to use this format, we don’t recommend editing the file with Microsoft Excel. For more information and restrictions, see Considerations for Working with Translation Files. Bilingual .stf translation file content is separated into translated labels and outdated or untranslated labels. The TRANSLATED section of the .stf file contains text that has been translated and is up to date. When importing, four columns are expected for each label in this section: KEY, LABEL, TRANSLATION, and OUT OF DATE. For this section, tell your translators: • To update a current translation, replace the value in the TRANSLATION column. • To delete a translation, replace the value in the TRANSLATION column with a left and right angle bracket pair (<>). When the file is imported, the label reverts to its primary label’s value.
Column Description Edit Options KEY Unique identifier for the label. Do not edit.
LABEL Label or text in the org’s default language. Do not edit.
TRANSLATION The current translation that is visible to end • To edit a translation, replace the users selecting the target language as their translated value. personal language. • To delete a translation, replace the translated value with <>.
OUT OF DATE Indicates whether the source text has Do not edit. changed since the previous translation. A dash (-) indicates that the translation is current.
The OUTDATED AND UNTRANSLATED section of the file contains labels changed after the label’s translation value was last updated and text that hasn't been translated. When importing, two columns are expected for each label in this section: KEY and LABEL. For this section, tell your translators: • Replace the text in the LABEL column with new or updated translation values.
129 Extend Salesforce with Clicks, Not Code Manage Your Translations
• Delete any values in the TRANSLATED and OUT OF DATE columns. • Delete the corresponding columns in the OUTDATED AND UNTRANSLATED section. • To delete an outdated translation, replace the value in the LABEL column with a left and right angle bracket pair (<>). When the file is imported, the label reverts to its primary label’s value. • A translated value for the data in the record’s Name field is required to translate data in other fields for that record. For example, you must provide a German translation for the name of a Product before you can translate its description into German. • Deleting the data translated value for a record’s Name field can delete all of that record’s other translated values for that language. See Considerations for Working with Translation Files for more information.
Column Description Edit Options KEY Unique identifier for the label. Do not edit.
LABEL Label or text in the org’s default language. Replace label text with new or updated translated values.
TRANSLATION The current translation that is visible to end Delete this column and its contents when users selecting the target language as their updating an out-of-date translation. personal language. Untranslated labels don’t have a value in this column.
OUT OF DATE Indicates whether the source text has Delete this column and its contents when changed since the previous translation. updating an out-of-date translation. An asterisk (*) indicates that the label is out of date. A change was made to the primary label and the translation hasn't been updated. Untranslated labels don’t have a value in this column.
For example, in an org with English as its default language, an existing custom Prior Reference Number field on the Account object has an incorrect Spanish translated value of “Número de consulta previa.” Although the translation isn’t out of date, it must be updated to “Número de referencia precedente.” The Name field on a custom Widget object had a primary label of “SLK.” A translator misinterpreted this acronym and entered a Spanish translation of “Flojo.” Although the translation isn’t out of date, you want to revert the translation to the primary label. You also build a new custom Business Hours field on the Account object. This label is untranslated. Nickname, another existing custom field on the Account object, has a Spanish translated value of “Apodo.” You change the primary label on the Nickname field from “Nickname” to “Preferred Name.” This label is outdated. Finally, a custom Number field on a custom Widget object had a primary label of “Number” and a Spanish translated value of “Número.” You update the primary label to “#” and want to remove the translated value. The exported Bilingual .stf translation file contains the following row in the OUTDATED AND UNTRANSLATED section.
------TRANSLATED------
130 Extend Salesforce with Clicks, Not Code Manage Your Translations
# KEY LABEL TRANSLATION OUT OF DATE
CustomField.Account.Prior_Ref_No.FieldLabel Prior Reference Número de consulta – Number previa
CustomField.Widget__c.Name.FieldLabel SLK Seda –
------OUTDATED AND UNTRANSLATED------
# KEY LABEL TRANSLATION OUT OF DATE
CustomField.Account.Business_Hours.FieldLabel Business Hours
CustomField.Account.Nickname.FieldLabel Preferred Name Apodo *
CustomField.Widget__c.Number.FieldLabel # Número *
To make the requested changes: • In the TRANSLATED section, update translations by replacing the value in the TRANSLATION column. To delete the translation of the Widget object’s Name field, replace the TRANSLATION value with <>. When this file is imported, the label for that Number field reverts to its primary label value of SLK. • In the OUTDATED AND UNTRANSLATED section, replace the value in the LABEL column. Then remove the TRANSLATION and OUT OF DATE columns and their content for the Nickname field. To delete the translation of the Widget object’s Number field, replace the TRANSLATION value with <>. When this file is imported, the label for that Number field reverts to its primary label value of #.
------TRANSLATED------
# KEY LABEL TRANSLATION OUT OF DATE
CustomField.Account.Prior_Ref_No.FieldLabel Prior Reference Número de – Number referencia precedente
CustomField.Widget__c.Name.FieldLabel SLK <> –
------OUTDATED AND UNTRANSLATED------
# KEY LABEL
CustomField.Account.Business_Hours.FieldLabel Horario de oficina
CustomField.Account.Nickname.FieldLabel Nombre preferido
CustomField.Widget__c.Number.FieldLabel <>
131 Extend Salesforce with Clicks, Not Code Manage Your Translations
Important: Delete the TRANSLATION and OUT OF DATE columns only in the OUTDATED AND UNTRANSLATED section. Rows in that section must have exactly two columns of data to be imported. Rows in the TRANSLATED section must have exactly four columns of data to be imported.
SEE ALSO: Considerations for Working with Translation Files
Translation File IDs and Keys
Each translatable item has a unique identifier in the translation file. In .xlf files, it is the id within a EDITIONS trans-unit tag. In .stf files, it is the key. The structure of these identifiers differs for metadata and data translation files. Metadata translation Note: Translation file keys and ids aren’t edited during translation. The text to be translated available in: Salesforce is in the translation file in the source tag for .xlf files or the label column for .stf files. For Classic (not available in all orgs) and Lightning admins, knowing how the id or key work can help them understand how these identifiers Experience are structured. Data translation available in: Lightning Experience Metadata Translation File IDs and Keys All translatable metadata has a setup component. Depending on the setup component, the Available in: Professional, translatable metadata can have an object, aspect, custom report type entity, flow type, flow name, Enterprise, Performance, Unlimited, and Developer and flow component. Editions • Metadata label translation file IDs and keys follow the format: SetupComponentName.ObjectName.AspectName. Data translation applies to: B2B Commerce • Metadata label translation file IDs and keys for custom report types contain the report type entity in place of the object name. The format is: SetupComponentName.CustomReportEntityName.AspectName. • Metadata translation file IDs and keys for flows can also contain the flow component, flow type, flow name, flow version, flow screen, or flow aspect. See Flow Identifiers in Translation Files for detailed examples. This table provides examples of metadata translation IDs and keys.
Translation Label or Text id (in .xlf Files) or Key (in .stf Files) Country “Spain” in address AddressCountry.ES
“Billing” button or link on the Account object ButtonOrLink.Account.Billing
Label of the “Active” field on the Account object CustomField.Account.Active.FieldLabel
Description of the “Active” field on the Account object CustomField.Account.Active.Description.FieldLabel
Help text of the “Active” field on the Account object CustomField.Account.Active.Description.HelpText
“Low” picklist entry in the Customer Priority picklist on the Account PicklistValue.Account.CustomerPriority.Low object
Description of the “East Accounts” Custom Report Type CustomReportType.East_Accounts.Description
“Accounts” Custom Report Type Layout Section on the “Accounts” CrtLayoutSection.Custom_Accounts_Reports_1 Custom Report Type
132 Extend Salesforce with Clicks, Not Code Manage Your Translations
Translation Label or Text id (in .xlf Files) or Key (in .stf Files) Description of the “Goal Layout” Custom Report Type Layout on LayoutSection.Goal.Goal the “Goals” Custom Report Type Layout.Description_1
“Survey Customers” flow name Flow.Flow.Survey_customers.FieldLabel
“Customer Name” screen input field on version 2 of the “Survey Flow.Flow.Survey_customers.2.Survey_ Customer” flow Customer.Field.Customer_Name.FieldLabel
Data Translation File IDs and keys If data translation is enabled in your Salesforce org, the record ID is used to identify the translatable text in an exported data translation file. Data translation IDs and keys follow the format ObjectName.recordUniqueIdentifier.FieldName. This table provides examples of data translation IDs and keys.
Translation Label or Text id (in .xlf Files) or Key (in .stf Files) Name of the product with record ID 01txx0000006yvEAAQ Product2.01txx0000006yvEAAQ.Name
Description of the product with record ID Product2.01txx0000006yvEAAQ.Description 01txx0000006yvEAAQ
Text stored in a custom “Discount Notes” field for the product Product2.01txx0000006yvEAAQ.Discount_Notes__c record ID 01txx0000006yvEAAQ
SEE ALSO: Flow Components for Metadata Translation
Flow Identifiers in Translation Files
In a translation file exported from Translation Workbench, a unique key or trans-unit ID attribute EDITIONS identifies a flow metadata label. Flows follow a convention based on the flow label. Available in: Salesforce Classic (not available in all Flow Key or Trans-Unit ID Example orgs) and Lightning Component Experience Flow Flow.flowType. Flow.Flow.Survey_customers.FieldLabel Available in: Professional, Definition flowUniqueName.FieldLabel Enterprise, Performance, Name Unlimited, and Developer Editions Flow Version Flow.flowType. Flow.Flow.Survey_customers.1.Name Name flowUniqueName. versionNumber.Name
Screen
133 Extend Salesforce with Clicks, Not Code Manage Your Translations
Flow Component Key or Trans-Unit ID Example
Paused Message Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.1.Screen.Greet_Customer. versionNumber.Screen.screenUniqueName. PausedText PausedText
Help Text Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.1.Screen.Greet_Customer. versionNumber.Screen.screenUniqueName. HelpText HelpText
Screen Input Field
Label Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.2.Survey_Customer.Field. versionNumber.screenUniqueName.Field. Customer_Name.FieldLabel fieldUniqueName.FieldLabel
Help Text Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.2.Survey_Customer.Field. versionNumber.screenUniqueName.Field. Customer_Name.HelpText fieldUniqueName.HelpText
Error Message Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.2.Survey_Customer. versionNumber.screenUniqueName.Field. Field.Customer_Name.ErrorMessage fieldUniqueName.ErrorMessage
Screen Output Field
Display Text Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.2.Greet_Customer.Field. versionNumber.screenUniqueName.Field. WelcomeMessage.Description fieldUniqueName.Description
Choice
Label Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.2.Choice.Participate_No. versionNumber.Choice.choiceUniqueName. FieldLabel FieldLabel
Error Message Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.2.Choice.Participate_No. versionNumber.Choice.choiceUniqueName. ErrorMessage ErrorMessage
Input Label Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.2.Choice.Participate_No. versionNumber.Choice.choiceUniqueName. InputLabel InputLabel
Stages
Stage Label Flow.flowType.flowUniqueName. Flow.Flow.Stages_Online_Purchase_Breadcrumbs.1. versionNumber.Stage.stageUniqueName. Stage.Billing_Details.FieldLabel FieldLabel
Text Template
134 Extend Salesforce with Clicks, Not Code Manage Your Translations
Flow Component Key or Trans-Unit ID Example
Label Flow.flowType.flowUniqueName. Flow.Flow.Survey_customers.2.TextTemplate. versionNumber.TextTemplate. ParticipantCity_FieldLabel texttemplateUniqueName.FieldLabel
SEE ALSO: Work with Translation Files Considerations for Translating Flows
Import Translated Files
Import and update the translations for your Salesforce org’s metadata, such as custom fields, report EDITIONS types, and picklist values. Or import and update data translations, such as Product names. Typically, you export translation files from Salesforce, then send them to outside translators or a translation Metadata translation agency for bulk translation activities. You then import the translated files. available in: Salesforce Note: You need the Manage Translation AND Create Documents user permissions to import Classic (not available in all orgs) and Lightning or export translation files. If you attempt either operation without both user permissions, it’s Experience possible to navigate to the import or export page, but the operation itself fails. Data translation available in: Lightning Experience Prepare Your Translated Files 1. Create a separate file for each language. Available in: Professional, Enterprise, Performance, Salesforce recommends the XML Localization Interchange File Format (.xlf) for translation files. Unlimited, and Developer Editions 2. Specify the language for this translation import. When you export a translation file with the Bilingual or Outdated and untranslated export type, Data translation applies to: B2B Commerce the language is already specified. If you’re importing a Source file or importing translations for different language than the original file, update the language code. • For .xlf files, use the target-language attribute on the file tag. For example,
# Language: Spanish Language code: es Type: Source
Translation for the specified language must be supported for your org. For a full list of Salesforce supported languages and their language codes, see Supported Languages in Salesforce Help.
3. If data translation is enabled in your Salesforce org, include a translation type attribute. For .xlf files, include the translation-type attribute on the file tag. For .stf files, include the translation type on its own line after the language code and type.
135 Extend Salesforce with Clicks, Not Code Manage Your Translations
Note: If you export a translation file after data translation is enabled in your org, the resulting file includes this attribute.
File Type Metadata Translation Attribute Data Translation Attribute XML Localization translation-type="metadata" translation-type="data" Interchange File Format (.xlf)
Salesforce Translation Type: Metadata Translation Type: Data Translation Format (.stf)
4. Save import files in UTF-8 encoding. 5. Size your files. When importing metadata translation files, individual uncompressed files are limited to 10 MB each. When importing data translation files, individual uncompressed files are limited to 50 MB each.
6. Bundle multiple files into .zip files. If data translation isn’t enabled in your org, each imported .zip file is limited to 10 MB. If data translation is enabled, each imported .zip file is limited to 1 GB. When zipping data translation files for import, each .zip file can contain up to 100,000 total translation records within up to 2 GB of uncompressed files. Create multiple .zip files as needed.
Important: Each .zip file can only contain metadata or data translation. If data translation is enabled in your org, import metadata and data translations separately. The zipped files don't have to be in the same order or grouping as the exported .zip files. For example, you start with two exported .zip files. The first file includes French, Italian, and Japanese. The second file includes Russian, Simplified Chinese, and Greek. You can create: • One .zip file with French, Greek, and Italian. • One .zip file with Russian and Greek. • One .zip file with Simplified Chinese.
Import Your Prepared Translated Files 1. From Setup, in the Quick Find box, enter Import, and then select Import under Translation Workbench. 2. Click Choose File, and select the file you want to import. 3. Click Import. After the import is complete, a confirmation email is sent to the email address specified in your profile. Wait for each import to finish before submitting another translation file for import. If any portion of the import fails, the email includes details about what went wrong. If the imported zip file exceeds translation import limits, the email lists the files that were imported before the limit was reached. If records within the imported translation files weren’t processed, the email lists those files and includes an error log.
Verify Your Translations There are multiple ways to view the imported translations:
136 Extend Salesforce with Clicks, Not Code Manage Your Translations
• Check metadata labels and data translations in your Salesforce org. • Check metadata labels through Translation Workbench. • Check data translations through the Translation tab within Product. • Export data translations and verify your updated text. Check labels in your Salesforce org.
Note: Labels that are exported and left unchanged in the translation file aren’t saved as translations on import.
SEE ALSO: Supported Languages Work with Translation Files Common Errors with Exporting and Importing Translation Files Documents Home
Common Errors with Exporting and Importing Translation Files
Troubleshoot issues you can encounter while exporting and importing files in Translation Workbench. EDITIONS
Error Message What It Means Troubleshooting Steps Metadata translation Bilingual file section starts with The header rows of the file Export your file again Make sure available in: Salesforce non header row:
Data translation import for key This error message only applies Provide a translated value for Available in: Professional,
Data translation isn’t enabled This error message only applies Enable data translation, and for this org. to data translation files. Data then import the file again. translation isn’t enabled or was disabled after the data translation file was exported.
Duplicate key:
137 Extend Salesforce with Clicks, Not Code Manage Your Translations
Error Message What It Means Troubleshooting Steps File contains translation keys that don't The file contains at least one key with a Create separate import files for metadata match the translation type specified in the translation type that doesn’t match the file and data translation. file header. Create separate import files for type in the header. metadata and data translation.
Invalid Key During translation, Salesforce generates Export your file again, and make sure the unique keys, or identifiers, for each object, keys in it match the keys in the file that picklist value, or page element that you’re you’re trying to import. translating. If these names or keys are changed after you export your file, Salesforce can’t match the correct key with the correct name.
Invalid key:
Invalid key:
Invalid key:
Invalid key:
Invalid key:
Key:
138 Extend Salesforce with Clicks, Not Code Manage Your Translations
Error Message What It Means Troubleshooting Steps Report Type Column key format. Please re-export and use the new key format for those keys.
Maximum character limit
No data to import The file that you’re trying to import is empty Make sure that you’re importing the correct or does not contain any translation changes. file and that it contains translated data.
No language code specified in file header The file that you’re trying to import doesn’t Make sure that your language code is valid have a valid language code, or the language and isn't missing or commented out. code is in the wrong place.
No translated or untranslated section header The file that you’re trying to import is Make sure that your file has section headers, found in the bilingual file missing section headers. and import it again.
No valid file type specified in file header The file that you’re trying to import doesn’t Make sure that your file has a valid have a valid import/export type (Source, import/export type in the file header and Outdated and untranslated, or Bilingual) that the header isn’t translated. specified in the file header. The file type attribute must be in the default language for your org.
No valid translation type specified in file The file that you’re trying to import doesn’t Make sure that your file has a valid header have a valid translation type specified in the translation type in the file header and that file header. The translation type is only the header isn’t translated. required if data translation is enabled. The attributes for metadata translation are: • Translation Type: Metadata for .stf files and • translation-type="metadata" for .xlf files The attributes for data translation are: • Translation Type: Data for .stf files and • translation-type="data" for .xlf files The translation type attribute must be in the default language for your organization.
Not a valid file to import. Please select a .stf, You can import files in .stf or .xlf formats, or Make sure that your file is a .stf, .xlf, or .zip .xlf, or a .zip file for import. .zip files that contain .stf or .xlf files. file, and try importing it again.
139 Extend Salesforce with Clicks, Not Code Manage Your Translations
Error Message What It Means Troubleshooting Steps Some keys are appended with their sort The order of the picklist values in your Export your source file, match the order of order for uniqueness. Re-export your file and source file doesn’t match your setup. the picklist values to your import file, and ensure that the keys in both files match. then import again.
There were issues with import of file: The file that you’re importing has invalid or Export your file again, and identify the fields importFileName.xlf [Your import request missing HTML tags. HTML tags are used in with HTML tags in the exported source text. failed. Please retry or contact support.] translations for rich text area fields. Edit your translation values for these rich text area fields with the correct HTML tags. See Considerations for Working with Translation Files for more information on translating rich text fields.
Wrong number of columns in line:
Your export request failed. Please retry or Salesforce had an unexpected problem Contact Salesforce Customer Support. contact support. while exporting your file.
Your import request failed. Please retry or Salesforce had an unexpected problem Contact Salesforce Customer Support. contact support. while importing your file.
Your organization does not have language The file that you’re trying to import is in a Add the language you want to use to permissions for
SEE ALSO: Export Metadata Translation Files Export Data Translation Files Import Translated Files Considerations for Working with Translation Files
140 Extend Salesforce with Clicks, Not Code Manage Your Translations
Translation Considerations
Review considerations for managing your translations and translating flows. EDITIONS
Considerations for Managing Translations Metadata translation Keep these tips in mind when creating custom labels, working with translators, and maintaining available in: Salesforce translations. Classic (not available in all orgs) and Lightning Considerations for Translating Flows Experience When you use Translation Workbench to translate flows, note these considerations. Data translation available in: Lightning Experience
Available in: Professional, Enterprise, Performance, Unlimited, and Developer Editions
Data translation applies to: B2B Commerce
Considerations for Managing Translations
Keep these tips in mind when creating custom labels, working with translators, and maintaining EDITIONS translations. • Salesforce assumes that all customizations are entered in the Salesforce org’s default language. Metadata translation We recommend that global administrators work together in the org’s default language. available in: Salesforce • Salesforce recommends the XML Localization Interchange File Format (.xlf) for translation files. Classic (not available in all orgs) and Lightning • When creating a custom report type for translation into multiple languages via Translation Experience Workbench, we recommend that you set your personal language to match your org’s default language. This ensures that translated words display in the correct language for translators. Data translation available in: Lightning Experience • Advise users customizing reports or list views to use filter criteria values in their personal language. However, if they use the starts with or containscontains operators, advise Available in: Professional, them to choose the language of the filter criteria values they entered. Enterprise, Performance, • If you installed a managed package that includes translations, those translated values appear Unlimited, and Developer to users regardless of whether the language is active on the Translation Language Settings Editions Setup page. To override metadata translations delivered by a managed package for custom Data translation applies to: objects, see Override Translations in Second-Generation Managed Packages and Unlocked B2B Commerce Packages. • Let translators know which languages they are responsible for translating. • Notify all translators when you add new translated components to your org. For best results, have your translators check their translations frequently, and be sure to notify them when changes occur. • Periodically review outdated translations by exporting your translations. To generate a list of all the translatable customizations and the associated Out of Date states, use the Outdated and Untranslated export type or Bilingual export type.
SEE ALSO: Work with Translation Files Override Translations in Second-Generation Managed Packages and Unlocked Packages
141 Extend Salesforce with Clicks, Not Code Manage Your Translations
Considerations for Translating Flows
When you use Translation Workbench to translate flows, note these considerations. EDITIONS
Translating Flows Available in: Salesforce Classic (not available in all • To check which flow types are translatable, see Flow Types in Salesforce Help. orgs) and Lightning • A translation can only reference a merge field (like {!myVar}) if the field is referenced in the first Experience 1,000 characters of the primary label. Available in: Professional, • Translations for flow definition name and version name each have a maximum limit of 255 Enterprise, Performance, characters. Other translations for flow labels have a maximum of 1,000 characters. Unlimited, and Developer • Text templates and merge field values aren’t supported for translation. Editions • Right-to-left languages aren’t supported. • When a flow label isn’t translated for a language, Salesforce uses the translation for the appropriate fallback language. If the fallback language has no translated label, the primary label is used.
Updating Flow Translations When you change a flow that you translated, Salesforce copies as much information as it can when you create a new version or save changes to the translated version. For example, version 1 of the Survey Customers flow has a translation for the WelcomeMessage field. When you save another version of the flow, Salesforce copies all the latest translations from version 1 to version 2. The same happens if you save it as a new flow. When you remove a label from a flow, translations aren’t copied. Salesforce uses the label’s Unique Name to copy translations to another version. When you change the label’s unique name, Salesforce treats it as a new label. When you delete a flow, its translations are also deleted. When you translate a flow from a managed package, the flow’s Master Definition Name doesn’t appear on the Translate page or the Override page. To update the translation for the Master Definition Name, edit the flow label and then update the translation from the Translate page.
Exporting and Importing Flow Translations • You can export and import translation files to send to translators or to help you translate lengthy text. • When you export translations, the primary labels are truncated after 1,000 characters.
SEE ALSO: Translation Considerations for Flows
142 Extend Salesforce with Clicks, Not Code Set Up Your Data Your Way
Set Up Your Data Your Way
Optimize your Salesforce data to fit the unique needs of your users. You can create your own objects EDITIONS with data that fits together in the ways that make the most sense for you. Available in: both Salesforce Store Information That’s Unique to Your Organization Classic and Lightning Create custom objects to store information that’s unique to your organization. Choose whether Experience your custom objects are searchable, support sharing, or include access to the Bulk API and The available customization Streaming API. options vary according to Store Customers’ Data Privacy Preferences which Salesforce Edition you Store certain data privacy preferences for your customers. have. Classify Sensitive Data to Support Data Management Policies Record data sensitivity and compliance categorization at the field level. Data classification can USER PERMISSIONS be used to guide decisions around access, reporting, and data compliance. To view setup options: Design Your Own Data Model • View Setup and Schema Builder provides a dynamic environment for viewing and modifying all the objects and Configuration relationships in your app. This greatly simplifies the task of designing, implementing, and To customize your org: modifying your data model, or schema. Schema Builder is enabled by default. • Customize Application Create Custom Settings Use custom settings to create custom sets of data, or to create and associate custom data for an org, profile, or user. Customize Fields Customize standard and custom fields to tailor your org to your own unique requirements. Calculate Field Values With Formulas A formula is an algorithm that derives its value from other fields, expressions, or values. Formulas can help you automatically calculate the value of a field based on other fields. Generate Emails From Records A merge field is a field you can put in an email template, mail merge template, custom link, or formula to incorporate values from a record. For example, you can place a merge field in an email template so that the greeting includes the recipient’s name rather than a generic “Hello!”.
Store Information That’s Unique to Your Organization
Create custom objects to store information that’s unique to your organization. Choose whether EDITIONS your custom objects are searchable, support sharing, or include access to the Bulk API and Streaming API. Available in: both Salesforce Every custom object is classified as either an Enterprise Application object or a Light Application object. Classic and Lightning The difference between these two categories is that Light Application objects don’t support sharing, Experience access to the Bulk API, or access to the Streaming API. Available in: Contact If you need to track your organization’s usage of each category, create a custom report type with Manager, Group, a primary object of User Licenses and a child object of Custom Object Usage by User License Metrics. Professional, Enterprise, Performance, Unlimited, and Developer Editions
143 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
By default, all custom objects are Enterprise Application objects. To make your custom object a Light Application object, disable Allow Sharing, Allow Bulk API Access, and Allow Streaming API Access on the object’s detail page.
Manage Custom Objects Create, customize, edit, delete, or truncate custom objects to extend the functionality that standard objects, like accounts and contacts, provide. Track Your Organization’s Custom Object Usage by User License Type To keep track of how many custom objects your users are assigned to, create a custom report type with the User Licenses and Custom Object Usage by User License Metrics objects. Manage Big Objects A big object stores and manages massive amounts of data on the Salesforce platform. You can archive data from other objects or bring datasets from outside systems into a big object to get a full view of your customers. From Setup, you can create a custom big object and define its fields and index. Object Relationships Overview Create relationships to link objects with each other, so that when your users view records, they can also see related data. For example, link a custom object called Bugs to cases to track product defects that are associated with customer cases. Create Record Types for Custom Objects Custom Object Security Learn how security settings work together so you can control access to your custom objects with great flexibility. Notes on Enabling Activities for Custom Objects
SEE ALSO: Track Your Organization’s Custom Object Usage by User License Type
144 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Manage Custom Objects
Create, customize, edit, delete, or truncate custom objects to extend the functionality that standard EDITIONS objects, like accounts and contacts, provide.
Note: Your administrator may have created a tab without any help. If you need help to Available in: both Salesforce understand how a tab for a custom object works, contact your administrator. Classic (not available in all orgs) and Lightning Your object management settings list the custom objects that are defined for your organization. Experience From this list, you can: Available in: Contact • Define a custom object. Manager, Group, • Display detailed information about a custom object. Professional, Enterprise, Optional features you can customize include enabling search and reports, tracking activities, Performance, Unlimited, tracking field history, and making the object available for the Salesforce Customer Portal. Developer, and Database.com Editions • To update the custom object definition, click Edit and update the desired fields. Managed Packages are not Note: The Allow Reports, Allow Activities, and Allow Search fields available in Database.com. are not locked in Managed - Released and can be changed by the developer in future releases of a managed package. USER PERMISSIONS • To delete a custom object, click Del. To create and edit custom • To truncate a custom object, click Truncate. objects: • To view deleted custom objects, click the Deleted Objects link. The total number of deleted • Customize Application custom objects for your organization is listed in parentheses. The detail page of the custom object provides information about various characteristics of the object, including standard fields, custom fields, field history tracking, relationships, custom links, search layouts, page layouts, and object limits. You can: • Click individual items to display additional detail. • To delete a custom field, click Del next to its name in the Custom Fields & Relationships section. • Click More at the bottom of the page or View More below a related list to display more items. • Click New to directly add new items.
Note: The object limit percentages are truncated, not rounded. For example, if your org uses 95.55% of the limit for a particular customization, the object limit displays 95%.
Deployment Status for Custom Objects and External Objects Create a Custom Object Track and store data that’s unique to your organization. Follow different steps, depending on which Salesforce experience you’re using. Modify Custom Objects Custom Object Standard Fields When you create a custom object, these default fields are automatically assigned to the object. Delete Custom Objects Manage Deleted Custom Objects Truncating Custom Objects It’s important to understand what truncating an object does before using it to remove records.
145 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Truncate Custom Objects Truncating custom objects allows you to delete all of the object’s records permanently, but preserve the empty object and its metadata.
SEE ALSO: Make Search Faster Store Information That’s Unique to Your Organization Find Object Management Settings
Deployment Status for Custom Objects and External Objects
While developing a custom object or external object, you might not want users to see and interact EDITIONS with it. Because users can get frustrated with changes in layout or lose data when you delete custom fields, control visibility of the new object until you’re finished. Available in: both Salesforce Use the Deployment Status setting in the object definition to control when users can see and use Classic (not available in all the object and its associated custom tab, related lists, and reports. orgs) and Lightning Experience • Set the deployment status to In Development when first creating your custom object or external object. Doing so hides it from users while you are designing and testing it. Only users with the Available in: Contact Customize Application permission can see the object tab, search results, related lists, and report Manager, Group, data types. Professional, Enterprise, Performance, Unlimited, • Change the deployment status to Deployed when you want to allow all users to use the object Developer, and and the associated custom tab, related lists, and reports. Database.com Editions • If you make more enhancements after deploying a custom object or external object, you can Salesforce Connect external change the deployment status back to In Development. objects are available in: Note: A custom report type’s deployment status changes from Deployed to In Development Developer Edition and for if its primary object is a custom or external object whose deployment status similarly changes. an extra cost in: Enterprise, Performance, and Note: When you create a big object, the status is set to In Development. You can't deploy Unlimited Editions a big object until it includes an index that contains at least one custom field. Only required custom fields are allowed in an index. After you create an index, you see a second status of Deployed. Once you’re ready to grant users access, change the status to Deployed. USER PERMISSIONS
To deploy custom objects SEE ALSO: and external objects: Make Search Faster • Customize Application
Create a Custom Object Track and store data that’s unique to your organization. Follow different steps, depending on which Salesforce experience you’re using.
Create a Custom Object in Lightning Experience Track and store data that’s unique to your organization. If you see the App Launcher icon ( ) on the left side of the navigation bar at the top of your screen, you're in Lightning Experience. If not, you're in Salesforce Classic. Create a Custom Object from a Spreadsheet in Lightning Experience Use custom objects to track and store data that’s unique to your organization. If you prefer not to create a custom object and its fields manually, you can use a spreadsheet to add the object and its fields and populate all its record data.
146 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Create a Custom Object in Salesforce Classic Track and store data that’s unique to your org. Fields for Creating Custom Objects When you create a custom object, several fields are required to define how you can access the object. Considerations for Creating Custom Objects Before you create a custom object, make sure that you’ve reviewed the considerations.
SEE ALSO: Make Search Faster Object Relationships Overview Define Object-Level Help in Salesforce Classic
Create a Custom Object in Lightning Experience
Track and store data that’s unique to your organization. If you see the App Launcher icon ( ) on EDITIONS the left side of the navigation bar at the top of your screen, you're in Lightning Experience. If not, you're in Salesforce Classic. Available in: Lightning 1. From the top-right corner of any page in Setup, click Create > Custom Object. Experience 2. Complete the fields for your custom object and configure its features. Available in: Contact Manager, Group, 3. If you want to create a custom tab for the object immediately after you save it, select Launch Professional, Enterprise, New Custom Tab Wizard after saving this custom object. Performance, Unlimited, You can also create the custom object tab later in Setup by entering Tabs in the Quick Find and Developer Editions box, and clicking Tabs.
4. Save the new object. USER PERMISSIONS
5. In the Object Manager, click Fields & Relationships, and create the custom fields that your To create and edit custom object needs. objects: • Customize Application Tip: If you don’t want your users to see the new custom object right away, set its deployment status to In Development. This setting hides the object from users while you’re designing and testing it.
SEE ALSO: Create a Custom Object from a Spreadsheet in Lightning Experience Fields for Creating Custom Objects Considerations for Creating Custom Objects Create a Custom Object
147 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Create a Custom Object from a Spreadsheet in Lightning Experience
Use custom objects to track and store data that’s unique to your organization. If you prefer not to EDITIONS create a custom object and its fields manually, you can use a spreadsheet to add the object and its fields and populate all its record data. Available in: Lightning Note: Although it’s available in Professional Edition, this feature uses API. To use this feature, Experience Professional Edition orgs must have the API add on enabled. To enable the API add on, contact Available in: Contact your Account Executive. Manager, Group, You can create a custom object from a spreadsheet in two places: in Setup, or from the Navigation Professional, Enterprise, Items tab inside a Lightning app’s settings. Performance, Unlimited, and Developer Editions 1. In Setup, go to Object Manager, then click Create > Custom Object from Spreadsheet.
2. Alternatively, navigate to the Navigation Items tab inside a Lightning app. USER PERMISSIONS a. In Setup, enter App in the Quick Find box, then select App Manager. To create and edit custom b. Next to the app you want to add the custom object to, click , and select Edit. objects: • Customize Application c. Click Navigation Items. d. From the Available Items list, click Create > Custom Object from Spreadsheet.
3. Follow the wizard steps to import your custom object data from an .xlsx file, a .csv file, or a Google sheet. Salesforce detects object field labels from the spreadsheet row that you specify. All fields must be mapped to create the custom object. Skipping the import step creates an empty custom object that uses the fields in the spreadsheet as a template. When you finish creating the object, a custom tab is created for it. The object appears in the list of available items for your app. If you imported field data, your object is ready to go with fully populated records. 4. If you don’t want your users to see the new custom object right away, in the Object Manager in Setup, set its deployment status to In Development. This setting hides the object from users while you’re designing and testing it. 5. When you’re ready for your users to see the new custom object, add it to your app’s Selected Items list.
SEE ALSO: Fields for Creating Custom Objects Create a Custom Object in Lightning Experience Considerations for Creating Custom Objects Create a Custom Object
148 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Create a Custom Object in Salesforce Classic
Track and store data that’s unique to your org. EDITIONS 1. From Setup, enter Objects in the Quick Find box, then select Objects. 2. Click New Custom Object. Available in: Salesforce Classic (not available in all 3. Follow the wizard to complete the fields for your custom object. orgs)
4. Save the new object. Available in: Contact Manager, Group, SEE ALSO: Professional, Enterprise, Performance, Unlimited, Fields for Creating Custom Objects and Developer Editions Considerations for Creating Custom Objects Create a Custom Object USER PERMISSIONS
To create and edit custom objects: • Customize Application
Fields for Creating Custom Objects
When you create a custom object, several fields are required to define how you can access the EDITIONS object.
Note: If an administrator created a tab without including help, contact your administrator Available in: Lightning if you need help with how a custom object works. Experience and Salesforce Classic
Field Description Available in: Contact Manager, Group, Label This name is used to refer to the object in a user Professional, Enterprise, interface page. Performance, Unlimited, Plural Label The plural name of the object. If you create a and Developer Editions tab for this object, this name is used for the tab.
Gender If it is appropriate for your organization’s default language, specify the gender of the label. This field appears if the organization-wide default language expects gender. Your personal language preference setting does not affect whether the field appears. For example, if the organization’s default language is English and your personal language is French, you aren’t prompted for gender when creating a custom object.
Starts with a vowel sound If it’s appropriate for your organization’s default language, indicate whether “an” or “a” precedes the label.
Object Name A unique name used to refer to the object when using the API. In managed packages, this name
149 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Field Description prevents naming conflicts with package installations. Use only alphanumeric characters and underscores. The name must begin with a letter and have no spaces. It cannot end with an underscore nor have two consecutive underscores.
Description An optional description of the object. A meaningful description helps you remember the differences between objects when you are viewing them in a list.
Context-Sensitive Help Setting Defines the URL that displays when a user clicks Help for this Page from the object record’s home (overview), edit, and detail pages, list views, and related lists. This setting doesn’t affect the Help link at the top of a page. That link always opens the Help window. • To display the standard Salesforce Help available for any custom object record, select Open the standard Salesforce Help & Training window. • To display custom object-level help for your custom object, select Open a window using a Visualforce page and then select the Visualforce page to use as the target of the context-sensitive help link from that custom object’s pages.
Record Name The name used in page layouts, list views, related lists, and search results.
Data Type The type of field (text or auto-number) for the record name. Records that have unique IDs instead of names are auto-numbered and always a read-only field.
Display Format For an auto-numbered record name, enter the display format. You can have up to two sets of curly braces. For more information, see Custom Field Attributes on page 234.
Starting Number For an auto-numbered record name, enter the number to use when creating your first record for this custom object.
Allow Reports Makes the data in the custom object records available for reporting purposes. To create reports on custom objects, choose the Other Reports report type category, unless the custom object has a relationship with a standard object. When the custom object has a master-detail relationship with a standard object or is a lookup object on a standard object, select the standard object for the report type category instead. You can still create and run reports without selecting Allow Reports; however, the custom report type is not visible.
Allow Activities Allows users to associate tasks and scheduled calendar events related to the custom object records.
150 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Field Description Allow in Chatter Groups Allows users to add records of this custom object type to Chatter groups. When true, users with permissions can create records of this object type using the group publisher. The created record is associated with the group and appears in the group record list. When false, users with permissions can use the group publisher to create records of this object type, but the record is not associated with the group.
Enable Divisions If your organization has divisions enabled, select this option to enable the custom object for divisions. Divisions group records for simplified search results, list views, reports, and other areas within Salesforce. Salesforce adds a Division field to the custom object. If the custom object is the master in a master-detail relationship, custom objects on the detail side also get the Division field and inherit their division from the master record.
Available for Customer Portal Makes the custom object available to all portal users. This option is available only if your organization has a customer portal. If you enable Digital Experiences in your organization, this option no longer appears, and all custom objects are available in your Experience Cloud sites. If, before enabling , you had a Customer Portal and custom objects without this option selected, those objects become available in your Customer Portal.
Track Field History Enables your organization to track changes to fields on the custom object records. For example, it tracks who changed the field value and when, what the value was before the edit, and what it was changed to. History data is available for reporting, so users can easily create audit trail reports when this feature is enabled.
Allow Sharing When this setting is enabled, the custom object is an Enterprise Application object. When this setting isn’t enabled, the custom object is a Light Application object. When this setting is enabled, you must also enable Allow Bulk API Access and Allow Streaming API Access.
Allow Bulk API Access When this setting is enabled, the custom object is an Enterprise Application object. When this setting isn’t enabled, the custom object is a Light Application object. When this setting is enabled, you must also enable Allow Sharing and Allow Streaming API Access.
151 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Field Description
Allow Streaming API Access When this setting is enabled, the custom object is an Enterprise Application object. When this setting isn’t enabled, the custom object is a Light Application object. When this setting is enabled, you must also enable Allow Bulk API Access and Allow Sharing.
Deployment Status Indicates whether the custom object is visible to other users.
Allow Search To allow your users to find a custom object’s records when they search, create a custom tab set to Default On or Default Off. Creating a custom tab enables the custom object's Allow Search setting. A custom object that's associated with a custom tab is searchable (by default), even if users don't add the tab for display.
Add Notes & Attachments... Allows users to attach notes and attachments to custom object records. You can attach external documents to any object record in much the same way that you can add a PDF file or photo as an attachment to an email. This option is available only when you are creating an object.
Launch the New Custom Tab Wizard Starts the custom tab wizard after you save the custom object.
SEE ALSO: Create a Custom Object
Considerations for Creating Custom Objects
Before you create a custom object, make sure that you’ve reviewed the considerations. EDITIONS Object Creation • Establish object relationships first before adding all custom fields, page layouts, and related Available in: both Salesforce Classic (not available in all lists. orgs) and Lightning • The standard Name field is required on custom object related lists and page layouts. Experience • Provide meaningful names for your custom objects. The plural label of the custom object Available in: Contact is used as the label of the custom tab based on that object. Manager, Group, • When creating an object from a spreadsheet: Professional, Enterprise, – Skipping the import step creates an empty custom object that uses the fields in the Performance, Unlimited, spreadsheet as a template. and Developer Editions – You can click to preview the object data. Only the first 24 rows of data are displayed in preview. – These field types aren’t supported: • Auto Number
152 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
• Formula • Roll-Up Summary • Lookup Relationship • Master-Detail Relationship • External Lookup Relationship • Text Area (Rich) • Text (Encrypted) • Time
Object Permissions In Enterprise, Unlimited, Performance, Professional, and Developer editions, when you create a custom object, the Read, Create, Edit, and Delete permissions for that object are disabled for profiles that have View All Data or Modify All Data disabled. Enable access to custom objects in permission sets or custom profiles, and assign them to the users who need access. In Contact Manager and Group editions, when you create a custom object, the Read, Create, Edit, and Delete permissions for that object are enabled for all profiles. Sharing Model An org-wide default setting controls the data sharing model for custom objects. For more information, see Custom Object Security. Delegating Custom Object Administration After you create a custom object, you can delegate its administration to non-admin users. Queues After you create a custom object, you can define queues to distribute ownership of custom object records to your users.
SEE ALSO: Create a Custom Object
Modify Custom Objects
Customize the user interface for your custom objects by: EDITIONS • Creating a custom tab (see Custom Tabs) • Creating custom fields and relationships (see Custom Object Standard Fields on page 154) Available in: both Salesforce Classic and Lightning • Adding customized buttons and links to perform actions or link to other pages or websites (see Experience Define Custom Buttons and Links on page 775) • Defining which fields display for users on record detail and edit pages (see Build Page Layouts Available in: Contact for Custom Objects on page 33) Manager, Group, Professional, Enterprise, • Specifying which fields display for users in search results, lookup dialogs, and in the key lists on Performance, Unlimited, custom object tabs (see Customize Search Layouts for Custom Objects) and Developer Editions • Creating record types to display different picklist values and page layouts to different users based on their profiles (see Create Record Types for Custom Objects on page 176) USER PERMISSIONS
To customize custom objects: • Customize Application
153 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Custom Object Standard Fields
When you create a custom object, these default fields are automatically assigned to the object. EDITIONS Custom object fields store the data for your custom object records. Custom Fields for Custom Objects Available in: both Salesforce Classic (not available in all You can create custom fields to store information unique to your organization. You can also orgs) and Lightning create custom relationship fields to associate your custom object with another object in Experience Salesforce. Standard Fields for Custom Objects Available in: Contact Manager, Group, Custom objects automatically include the following standard fields. Click Edit to modify any Professional, Enterprise, of the editable fields. Performance, Unlimited, Developer, and Field Name Description Database.com Editions CreatedById ID of the user who created the record. Divisions are not available in Database.com. Currency Currency of the record if multicurrency is enabled.
Division Division to which the custom object record USER PERMISSIONS belongs. Custom objects that are “detail” objects To view and edit standard in a master-detail relationship inherit their fields: division from the master object. Custom objects • Customize Application that are not related to other records are To create custom fields: automatically in the global division. Available • Customize Application only in organizations that use divisions to segment their data.
LastModifiedById ID of the user who most recently changed the record.
Name Identifier for the custom object record. This name appears in page layouts, related lists, lookup dialogs, search results, and key lists on tab home pages. By default, this field is added to the custom object page layout as a required field.
OwnerId ID of the assigned owner of the custom object record. If the custom object becomes the detail side of a master-detail relationship, this field is removed, as ownership of the data is controlled by the master object, or by the primary master object for a custom object with two master-detail relationships.
Note: Custom objects on the detail side of a master-detail relationship can't have sharing rules, manual sharing, or queues, as these require the Owner field.
154 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Delete Custom Objects
When you delete a custom object, Salesforce does not add it to the Recycle Bin. Instead, deleted EDITIONS objects appear in the Deleted Objects list for 15 days. During this time, the object and its data are soft deleted, meaning you can restore or permanently erase (hard delete) the object and its data. Available in: Salesforce After 15 days, the object and its data are automatically hard deleted. Classic (not available in all Soft-deleted custom objects and their data count against your organization’s limits; hard-deleted orgs) items do not. Available in: Contact To delete a custom object: Manager, Group, Professional, Enterprise, 1. From the object management settings for custom objects, click Del next to object that you Performance, Unlimited, want to delete. Developer, and 2. When prompted, select the Yes, I want to delete the custom object Database.com Editions checkbox to confirm and click Delete. USER PERMISSIONS Why Can’t I Delete a Certain Custom Object? To delete custom objects: You can’t delete a custom object if it: • Customize Application • Is on the master side of a master-detail relationship. • Contains custom fields that are used in a roll-up summary field on another object. • Is referenced in Apex, a Visualforce page, or an reporting snapshot. • Is referenced by a duplicate rule or a matching rule. • Contains more than 100,000 records. If the object you want to delete has more than 100,000 records, first delete an appropriate number of records and then delete the object.
Results of Deleting Custom Objects When you delete a custom object, Salesforce: • Displays an Insufficient Privileges message if someone clicks a bookmark to a deleted custom object record’s URL. • Removes the object from Salesforce AppExchange packages. • Changes the master-detail relationship to a lookup relationship, if the deleted object is on the detail side of a master-detail relationship. • Removes or erases: – The object’s custom tab – List views and workflow rules for the object – Mobile configuration settings, including data sets, mobile views, and excluded fields – Standard report types associated with the object, and reports based on standard report types if the deleted object is on the detail side of a master-detail relationship
• Hides, inactivates, or disables: – The custom object definition and related definitions – The object’s records and related records, including any records in the Recycle Bin – Custom report types for which the deleted object is the main object – Custom reports for which the deleted object is the main object – Custom formula fields on the object – Custom validation rules and approval processes on the object
155 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Note: Many removed, hidden, inactive, or disabled items can be restored if you undelete the custom object. See Manage Deleted Custom Objects for information about restoring deleted custom objects.
Results of Hard Deleting Custom Objects When a custom object is hard deleted, either manually, or automatically after 15 days: • The custom object’s definition and data are permanently deleted, and can’t be restored. • The custom object and its data no longer count against your organization’s limits. • If the deleted object is on the detail side of a master-detail relationship, master records currently in the Recycle Bin aren’t restorable if one or more detail records were automatically deleted as a result of the master record being deleted. Attempting to undelete the master record results in an error.
Note: This only happens when the deleted detail records have their custom object definition hard deleted while the master record is in the Recycle Bin.
SEE ALSO: Manage Deleted Custom Objects Find Object Management Settings Delete a Big Object
Manage Deleted Custom Objects
Deleted custom objects appear in the Deleted Objects list for 15 days. During this time, you can EDITIONS choose to permanently delete the object and its data, or you can undelete them. If you undelete a custom object, you might need to do some manual cleanup to restore list views and other Available in: Salesforce customizations that use the object. Classic (not available in all • To view a list of deleted custom objects: orgs) 1. Go to the object management settings for custom objects. Available in: Contact 2. Click Deleted Objects at the bottom of the list. Manager, Group, Professional, Enterprise, The Deleted Objects link appears only when you have at least one deleted custom object in Performance, Unlimited, your organization. The number in parentheses indicates the total number of deleted custom Developer, and objects. Database.com Editions • In the Deleted Objects list, you can do any of the following: – Click the object’s label to view details about it USER PERMISSIONS – Click Erase to permanently remove the object and its data To restore deleted custom – Click Undelete to restore the object and its data objects: • Customize Application To permanently delete Results of Hard Deleting Custom Objects custom objects: When a custom object is hard deleted, either manually, or automatically after 15 days: • Customize Application • The custom object’s definition and data are permanently deleted, and can’t be restored. • The custom object and its data no longer count against your organization’s limits.
156 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
• If the deleted object is on the detail side of a master-detail relationship, master records currently in the Recycle Bin aren’t restorable if one or more detail records were automatically deleted as a result of the master record being deleted. Attempting to undelete the master record results in an error.
Note: This only happens when the deleted detail records have their custom object definition hard deleted while the master record is in the Recycle Bin.
Limitations for Restoring Truncated Custom Objects Copies of truncated custom objects also appear in the list of deleted objects. Truncated custom objects can’t be restored to their original state. Undeleted copies of truncated objects have a new name and new URL, and some fields and data cannot be manually restored.
Restoring a Custom Object to Its Predeleted State When you restore a deleted custom object, its records are also undeleted, including any that were in the Recycle Bin.
Note: It might take several hours before you can search the undeleted object’s records.
To ensure that you return the object to its fully functional, predeleted state, check all affected conditions and customizations, and manually fix them if necessary. AppExchange packages Add the custom object to any appropriate Salesforce AppExchange packages. Custom tabs Re-create a custom tab for the object and add it to any custom apps that use it. List views, reports, and workflow rules Re-create them. Validation rules and approval processes Re-activate them. Formula fields Open and save any custom formula fields on the object to re-enable them. Page layouts Page layouts are restored automatically on the undeleted object. Page layouts are also restored automatically on other objects that use the page layout in a related list—as long as the page layout wasn’t edited while the object was deleted. Otherwise, you have to add the related list back to the other object. Custom report types For custom report types where the deleted object was not the main object, add the reference back to the restored object. Reports based on the custom report type are automatically restored if they weren’t edited while the object was deleted. Re-create any reports that have been edited. Relationships If the deleted custom object was on the detail side of a master-detail relationship, Salesforce converted it to a lookup relationship. Change it back to master-detail. Developer name The developer name for the object was changed to objectname_del. Change it back to the original name, objectname_c, so that customizations using the name will work properly.
157 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Deployment status When the custom object was deleted, its Deployment Status field was set to In Development. When you’ve restored all affected customizations to the undeleted object, change its status back to Deployed.
SEE ALSO: Delete Custom Objects Truncating Custom Objects Find Object Management Settings
Truncating Custom Objects
It’s important to understand what truncating an object does before using it to remove records. EDITIONS Truncating a custom object lets you remove all of the object’s records, while keeping the object and its metadata. Truncating custom objects is similar to the mass delete option available for Available in: both Salesforce standard objects. Classic (not available in all orgs) and Lightning Truncating a custom object permanently removes all of its records. You can’t recover the records Experience from the Recycle Bin. A copy of the truncated object appears in the Deleted Objects list for 15 days—during this period the object and its records continue to count toward your organization’s Available in: Contact limits—and then the copied object and its records are permanently deleted. Manager, Group, Professional, Enterprise, In contrast, if you delete a custom object, the object moves to the Deleted Objects list for 15 days. Performance, Unlimited, After that the object and its records are permanently deleted. Developer, and Important: Truncated custom objects can’t be restored to their original state. Database.com Editions
You can’t truncate standard objects or custom objects that: • Are referenced by another object through a lookup field or that are on the master side of a master-detail relationship • Are referenced in a reporting snapshot • Have a custom index or an external ID • Have activated skinny tables In addition, you can’t truncate custom objects when your org has reached its limit on allowed custom objects. Truncating a custom object erases: • All records currently sitting in the custom object’s Recycle Bin • The custom object’s history • Related events, tasks, notes, and attachments for each deleted record Truncating a custom object breaks: • Bookmarks to the truncated objects and its records. If someone clicks a bookmark to the truncated custom object or to a deleted record’s URL, Salesforce displays an Insufficient Privileges message. • Apex scripts and Visualforce pages with references to a truncated object or record. After truncating a custom object, you can continue to use the custom object and add new records. Salesforce preserves: • The custom object definition and all related definitions • Workflow rules, actions, and triggers • Sharing rules associated with the custom object • Validation rules and approval processes
158 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
• Master-detail relationships and formula fields • Translations • Mobile configuration settings When working with truncated objects, keep in mind: • The truncated object tab has a new URL, so new bookmarks need to be created. • List views and reports need to be refreshed after truncation. • Roll-up summary fields need to be recalculated after truncation. • There is no support for truncation in the API. • To truncate objects that contain master-detail relationships, first truncate the detail (child) objects and then the (master) parent objects, working your way up the relationship tree.
SEE ALSO: Truncate Custom Objects Manage Deleted Custom Objects
Truncate Custom Objects
Truncating custom objects allows you to delete all of the object’s records permanently, but preserve EDITIONS the empty object and its metadata.
Important: Truncating custom objects causes some irreversible changes to the truncated Available in: Salesforce object and its records. Before truncating, see Truncating Custom Objects. Then, enable it for Classic (not available in all your organization by entering User Interface in the Quick Find box, selecting orgs) User Interface, and then selecting the permission. Available in: Contact Truncating custom objects is a way to permanently remove all of the records from a custom object, Manager, Group, while keeping the object and its metadata intact for future use. Truncating is useful, for example, Professional, Enterprise, if you have created a custom object and filled it with test records. When you’re done with the test Performance, Unlimited, Developer, and data, you can truncate the object to purge the test records, but keep the object and put it into Database.com Editions production. This is much faster than batch-deleting records and possibly recreating the object. 1. Go to the object management settings for custom objects. USER PERMISSIONS 2. Click an object name to go to the object’s detail page, and then click Truncate. 3. In the Confirm Custom Object Truncate window, review the warning and then enter the name To truncate custom objects: of the object to truncate in the empty field. • Customize Application 4. Click Truncate.
SEE ALSO: Manage Deleted Custom Objects Find Object Management Settings
159 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Track Your Organization’s Custom Object Usage by User License Type
To keep track of how many custom objects your users are assigned to, create a custom report type EDITIONS with the User Licenses and Custom Object Usage by User License Metrics objects. 1. From Setup, enter Report Types in the Quick Find box, then select Report Types. Available in: both Salesforce Classic (not available in all 2. Click New Custom Report Type. orgs) and Lightning 3. Fill out the fields. Experience
Custom objects are For this field... Enter or select... available in: Contact Primary Object User Licenses Manager, Group, Professional, Enterprise, Report Type Label A label for this report type. The label appears Performance, Unlimited, when users create a report. and Developer Editions For example, Custom Object Usage Custom report types are by User License. available in: Professional, Enterprise, Performance, Report Type Name A unique name for this report type. Unlimited, and Developer Editions Description A description for this report type. This description appears when users create a report. USER PERMISSIONS Store in Category Other Reports To create or update custom report types: • Manage Custom Report 4. (Optional) To make this report type available to other users, select a Deployment Status Types of Deployed. To delete custom report types: 5. Click Next. • Modify All Data 6. Click the box under the primary object. 7. Select Custom Object Usage by User License Metrics. 8. Click Save. 9. Create a report using the new report type.
Manage Big Objects A big object stores and manages massive amounts of data on the Salesforce platform. You can archive data from other objects or bring datasets from outside systems into a big object to get a full view of your customers. From Setup, you can create a custom big object and define its fields and index.
Available in: both Salesforce Classic and Lightning Experience
Available in: Enterprise, Performance, Unlimited, and Developer Editions for up to 1 million records Additional record capacity and Async SOQL query available as an add-on license.
From Setup, enter Big Objects in the Quick Find box, then select Big Objects. From this page you can:
160 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
• Create a big object. • View and update details about a big object. • Delete a big object or view any big objects that were deleted in the last 15 days.
Create or Edit a Big Object Track and store big data that’s unique to your org. For existing big objects, a details page displays information about the big object’s fields and index.
SEE ALSO: Salesforce Developers: Big Objects Implementation Guide
Create or Edit a Big Object Track and store big data that’s unique to your org. For existing big objects, a details page displays information about the big object’s fields and index. 1. From Setup, enter Big Objects in the Quick Find box, then select Big Objects. 2. Click New or click an existing big object. 3. Add or edit details about the big object. 4. Add or edit custom fields. Custom fields store the data for your big object records. 5. Add an index. The index defines the composite primary key for a big object and is used for querying and filtering the big object data. 6. Save the big object. Once you’ve created an index and deployed a big object, you can’t edit or delete the index. To change the index, you must start over with a new big object.
Big Object Definition Details When you create a custom big object, several required fields define how you can access the big object. Custom Big Object Fields Custom fields store the data for your custom big object records. Considerations When Creating an Index Plan carefully when creating an index for your custom big object. The index is used for querying and filtering the big object data and must be designed properly. Add an Index to a Big Object The index defines the composite primary key for a custom big object and is used for querying and filtering the big object data. Each big object requires an index. Delete a Big Object When you delete a custom big object, Salesforce doesn’t add it to the Recycle Bin. Instead, deleted big objects appear in the Deleted Objects list for 15 days. During this time, the big object and its data are soft deleted, meaning you can restore or permanently erase (flag for hard delete) the big object and its data. After 15 days, the big object and its data are automatically flagged for hard delete.
Big Object Definition Details When you create a custom big object, several required fields define how you can access the big object. The big object definition details page displays information about the big object’s fields and index.
161 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Field Name Description Label This name is used to refer to the object in a user interface page.
Plural Label The plural name of the object.
Starts with a vowel sound If it’s appropriate for your organization’s default language, indicate whether “an” or “a” precedes the label.
Object Name A unique name used to refer to the object when using the API. In managed packages, this name prevents naming conflicts with package installations. Use only alphanumeric characters and underscores. The name must begin with a letter and have no spaces. It cannot end with an underscore nor have two consecutive underscores. In the API, the names of custom big objects have a suffix of two underscores immediately followed by a lowercase “b” (__b). For example, a big object named “HistoricalInventoryLevels” is seen as HistoricalInventoryLevels__b in that organization's WSDL.
Description An optional description of the object. A meaningful description helps you remember the differences between objects when you are viewing them in a list.
Context-Sensitive Help Setting Defines the URL that displays when a user clicks Help for this Page from the object record’s home (overview), edit, and detail pages, list views, and related lists. This setting doesn’t affect the Help link at the top of a page. That link always opens the Help window. • To display the standard Salesforce Help available for any custom object record, select Open the standard Salesforce Help & Training window. • To display custom object-level help for your custom object, select Open a window using a Visualforce page and then select the Visualforce page to use as the target of the context-sensitive help link from that custom object’s pages.
Deployment Status When you create a big object, the status is set to In Development. You can't deploy a big object until it includes an index that contains at least one custom field. Only required custom fields are allowed in an index. After you create an index, you see a second status of Deployed. Once you’re ready to grant users access, change the status to Deployed.
Custom Big Object Fields Custom fields store the data for your custom big object records.
Custom Fields for Big Objects Create custom fields to store information unique to your org. You can also create custom relationship fields to associate your big object with another object in Salesforce. Big objects support these field types: • Lookup Relationship • Date/Time • Email • Number • Phone • Text
162 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
• Text Area (Long) • URL To create an index for your big object, at least one custom field must be marked as required.
Standard Fields for Big Objects Currently, big objects don’t include standard fields.
SEE ALSO: Create Custom Fields
Considerations When Creating an Index Plan carefully when creating an index for your custom big object. The index is used for querying and filtering the big object data and must be designed properly. Keep these considerations in mind when creating the index. • An index must include at least one custom field and can have up to five custom fields total. • All custom fields that are part of the index must be marked as required. • You can’t include Long Text Area and URL fields in the index. • The total number of characters across all text fields in an index can’t exceed 100.
Note: Email fields are 80 characters. Phone fields are 40 characters. Keep these lengths in mind when designing your index because they count toward the 100 character limit.
• After you’ve created the index, you can’t edit or delete it. To change the index, you must start over with a new big object. • Design your index so that you assign the most frequently used field in a query filter to Index Position 1. The order in which you define the fields determines the order that they’re listed in the index.
Add an Index to a Big Object The index defines the composite primary key for a custom big object and is used for querying and filtering the big object data. Each big object requires an index. To create an index, you must have at least one required custom field defined on the big object. See Considerations When Creating an Index on page 163 for more details. 1. From the Index section of a big object detail page, click New. This button displays only if the big object has at least one required custom field. 2. Add a Label and Name for the index.
Warning: When querying a big object record via SOQL and passing the results as arguments to the delete API, if any index field name has a leading or trailing white space, you can't delete the big object record.
3. For each custom field listed, set the Index Position and Index Direction. The order in which you define the fields determines the order that they’re listed in the index. Set the Index Position to 1 for the most frequently used filter parameter.
163 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
4. Save the index.
Delete a Big Object When you delete a custom big object, Salesforce doesn’t add it to the Recycle Bin. Instead, deleted big objects appear in the Deleted Objects list for 15 days. During this time, the big object and its data are soft deleted, meaning you can restore or permanently erase (flag for hard delete) the big object and its data. After 15 days, the big object and its data are automatically flagged for hard delete. Salesforce runs a background job to completely remove big objects that have been flagged for hard-delete from your org. The job doesn’t run immediately, but you can’t access these large objects because they no longer appear in the Deleted Objects list. Soft-deleted big objects and their data always count against your org’s limits. Big objects that are flagged for hard delete, but the background job hasn’t yet removed, also count. After the background job removes these big objects, they no longer count against your org’s limit. 1. From Setup, enter Big Objects in the Quick Find box, then select Big Objects. 2. Click Del next to the object that you want to delete. 3. When prompted, select the Yes, I want to delete the Big Object checkbox to confirm and click Delete. The big object is soft deleted and remains in the Deleted Objects list for 15 days. 4. To permanently erase (flag for hard-delete) the big object, click Deleted Big Object. 5. Click Erase next to the big object you want to permanently erase. 6. When prompted, select the Yes, I want to permanently delete the Big Object checkbox to confirm and click Delete. The big object is flagged for hard-delete and can no longer be restored.
164 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Object Relationships Overview
Create relationships to link objects with each other, so that when your users view records, they can EDITIONS also see related data. For example, link a custom object called Bugs to cases to track product defects that are associated with customer cases. Available in: Salesforce You can define different types of relationships by creating custom relationship fields on an object. Classic (not available in all Before you begin creating relationships, determine the type of relationship that suits your needs. orgs) and Lightning Experience Different types of relationships between objects in Salesforce determine how they handle data deletion, sharing, and required fields in page layouts. Let’s review the types of relationships. Available in: Contact Manager, Group, Master-detail Professional, Enterprise, Closely links objects together such that the master record controls certain behaviors of the Performance, Unlimited, detail and subdetail record. For example, you can define a two-object master-detail relationship, Developer, and such as Account—Expense Report, that extends the relationship to subdetail records, such as Database.com Editions Account—Expense Report—Expense Line Item. You can then perform operations across the master—detail—subdetail relationship.
Tip: Create a master-detail relationship before a custom object contains data.
Behaviors of master-detail relationships: • Deleting a detail record moves it to the Recycle Bin and leaves the master record intact; deleting a master record also deletes related detail and subdetail records. Undeleting a detail record restores it, and undeleting a master record also undeletes related detail and subdetail records. However, if you delete a detail record and later separately delete its master record, you can’t undelete the detail record, as it no longer has a master record to relate to. • By default, records can’t be reparented in master-detail relationships. Administrators can, however, allow child records in master-detail relationships on custom objects to be reparented to different parent records by selecting the Allow reparenting option in the master-detail relationship definition. • The Owner field on the detail and subdetail records isn’t available and is automatically set to the owner of the master record. Custom objects on the detail side of a master-detail relationship can't have sharing rules, manual sharing, or queues, as these require the Owner field. • Detail and subdetail records inherit security settings and permissions from the master record. You can’t set permissions on the detail record independently. • The master-detail relationship field (which is the field linking the objects) is required on the page layout of the detail and subdetail records. • The master object can be a standard object, such as Account or Opportunity, or a custom object. • As a best practice, don't exceed 10,000 child records for a master-detail relationship. • Each custom object can have up to two master-detail relationships and up to 25 total relationships. • The Related To entry can’t be changed after you save the relationship. • A profile or a permission set can have an entity, such as Account, with a master-detail relationship. A broken permission dependency exists if the child entity has permissions that the parent should have. Salesforce updates the parent entity for a broken permission dependency on the first save action for the profile or permission set.
If the child entity has these permissions These permissions are enabled on the parent entity Modify All OR View All View All
View All OR Read Read
165 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Many-to-many You can use master-detail relationships to model many-to-many relationships between any two objects. A many-to-many relationship allows each record of one object to be linked to multiple records from another object and vice versa. For example, you create a custom object called Bug that relates to the standard case object such that a bug could be related to multiple cases and a case could also be related to multiple bugs. Lookup Links two objects together. Lookup relationships are similar to master-detail relationships, except they don’t support sharing or roll-up summary fields. With a lookup relationship, you can: • Link two different objects. • Link an object with itself (except for the user object; see Hierarchical on page 167). For example, you might want to link a custom object called Bug with itself to show how two different bugs are related to the same problem.
Note: Lookup relationships from objects related to the campaign member object aren’t supported; however, you can create lookup relationships from the campaign member object related to other objects. When you create a lookup relationship, you can set these options: • Make the lookup field required for saving a record, requiring it on the corresponding page layout as well. • If the lookup field is optional, you can specify one of three behaviors to occur if the lookup record is deleted: – Clear the value of this field This is the default. Clearing the field is a good choice when the field doesn’t have to contain a value from the associated lookup record. – Don’t allow deletion of the lookup record that’s part of a lookup relationship If you have dependencies built on the lookup relationship, such as a workflow rule, this option doesn’t allow the lookup record to be deleted.
Note: Deleting a record that has child records isn’t allowed, except when the child records are soft-deleted (sent to the Recycle Bin). If all the child records of a parent record are soft-deleted, then the parent record is deleted. Furthermore, any soft-deleted children are then removed from the recycle bin and permanently deleted.
– Delete this record also Available only if a custom object contains the lookup relationship, not if it’s contained by a standard object. However, the lookup object can be either standard or custom. Choose when the lookup field and its associated record are tightly coupled and you want to completely delete related data. For example, say that you have an expense report record with a lookup relationship to individual expense records. When you delete the report, you probably want to delete all the expense records, too.
Warning: Choosing Delete this record also can result in a cascade-delete. A cascade-delete bypasses security and sharing settings, which means users can delete records when the target lookup record is deleted even if they don’t have access to the records. To prevent records from being accidentally deleted, cascade-delete is disabled by default. Contact Salesforce to get the cascade-delete option enabled for your organization. Cascade-delete and its related options aren’t available for lookup relationships to business hours, network, lead, price book, product, or user objects.
When you define a lookup relationship, you can include a lookup field on the page layouts for that object and create a related list on the associated object's page layouts. For example, if you have a custom object called PTO Requests and you want your users to link a PTO request with the employee submitting the request, create a lookup relationship from the PTO Request custom object with the user object. If the parent record in a lookup relationship is deleted, the field history tracking for the child record doesn't record the deletion. For example, if a parent account is deleted, the Account History related list for the child account doesn’t show the deletion.
166 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
You can't delete an object or record in a lookup relationship if the combined number of records between the two linked objects is more than 100,000. To delete an object or record in a lookup relationship, first delete an appropriate number of its child records. When you delete an object used by a lookup field, delete the field, too. To delete both the object and the field, use the Metadata API with a delete manifest that uses purgeOnDelete. Or, use Setup in the UI to delete the field first. Otherwise, the object can’t be deleted. External lookup An external lookup relationship links a child standard, custom, or external object to a parent external object. When you create an external lookup relationship field, the standard External ID field on the parent external object is matched against the values of the child’s external lookup relationship field. External object field values come from an external data source. Indirect lookup An indirect lookup relationship links a child external object to a parent standard or custom object. When you create an indirect lookup relationship field on an external object, you specify the parent object field and the child object field to match and associate records in the relationship. Specifically, you select a custom unique, external ID field on the parent object to match against the child’s indirect lookup relationship field, whose values come from an external data source. Hierarchical A special lookup relationship available for only the user object. It lets users use a lookup field to associate one user with another that does not directly or indirectly refer to itself. For example, you can create a custom hierarchical relationship field to store each user's direct manager.
Tip: When creating a hierarchical field in Personal, Contact Manager, Group, and Professional Editions, you can select the Restricted Field checkbox so that only users with the Manage Internal Users permission can edit it. In Professional, Enterprise, Unlimited, Performance, and Developer Edition, use field-level security instead.
Create a Many-to-Many Relationship Considerations for Relationships
SEE ALSO: Considerations for Relationships External Object Relationships Create a Many-to-Many Relationship Create a Custom Object
167 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Create a Many-to-Many Relationship
You can use master-detail relationships to model many-to-many relationships between any two EDITIONS objects. A many-to-many relationship allows each record of one object to be linked to multiple records from another object and vice versa. For example, you create a custom object called Bug Available in: both Salesforce that relates to the standard case object such that a bug could be related to multiple cases and a Classic (not available in all case could also be related to multiple bugs. When modeling a many-to-many relationship, you use orgs) and Lightning a junction object to connect the two objects you want to relate to each other. Experience
Junction Object Available in: Contact A custom object with two master-detail relationships. Using a custom junction object, you can Manager, Group, model a “many-to-many” relationship between two objects. For example, you create a custom Professional, Enterprise, object called “Bug” that relates to the standard case object such that a bug could be related to Performance, Unlimited, multiple cases and a case could also be related to multiple bugs. Developer, and Creating the many-to-many relationship consists of: Database.com Editions 1. Creating the junction object. Reports are not available in Database.com. 2. Creating the two master-detail relationships. 3. Customizing the related lists on the page layouts of the two master objects. USER PERMISSIONS 4. Customizing reports to maximize the effectiveness of the many-to-many relationship. To create a many-to-many Creating the Junction Object relationship: • Customize Application 1. Create a custom object to be your junction object. 2. In the custom object wizard, consider these tips specifically for junction objects: • Name the object with a label that indicates its purpose, such as BugCaseAssociation. • For the Record Name field, it is recommended that you use the auto-number data type. • Do not launch the custom tab wizard before clicking Save. Junction objects do not need a tab.
Creating the Two Master-Detail Relationships To create the two master-detail relationships: 1. Verify that the two objects you want to relate to each other already exist. For example, you may want to relate the standard case object to a custom bug object. 2. On the junction object, create the first master-detail relationship field. In the custom field wizard: a. Choose Master-Detail Relationship as the field type. b. Select one of the objects to relate to your junction object. For example, select Case. The first master-detail relationship you create on your junction object becomes the primary relationship. This affects the following for the junction object records: • Look and feel: The junction object's detail and edit pages use the color and any associated icon of the primary master object. • Record ownership: The junction object records inherit the value of the Owner field from their associated primary master record. Because objects on the detail side of a relationship do not have a visible Owner field, this is only relevant if you later delete both master-detail relationships on your junction object. • Division: If your organization uses divisions to segment data, the junction object records inherit their division from their associated primary master record. Similar to the record ownership, this is only relevant if you later delete both master-detail relationships.
168 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
c. Select a Sharing Setting option. For master-detail relationship fields, the Sharing Setting attribute determines the sharing access that users must have to a master record to create, edit, or delete its associated detail records. d. For the Related List Label that will display on the page layout of the master object, do not accept the default. Change this to use the name of the other master object in your many-to-many relationship. For example, change this to Bugs so users will see a Bugs related list on the case detail page.
3. On the junction object, create the second master-detail relationship. In the custom field wizard: a. Choose Master-Detail Relationship as the field type. b. Select the other desired master object to relate to your junction object. For example, select Bug. The second master-detail relationship you create on your junction object becomes the secondary relationship. If you delete the primary master-detail relationship or convert it to a lookup relationship, the secondary master object becomes primary.
c. Select a Sharing Setting option. For master-detail relationship fields, the Sharing Setting attribute determines the sharing access that users must have to a master record to create, edit, or delete its associated detail records. d. For the Related List Label that will display on the page layout of the master object, do not accept the default. Change this to use the name of the other master object in your many-to-many relationship. For example, change this to Cases so users will see a Cases related list on the bug detail page.
Customizing Many-to-Many Relationship Related Lists For a many-to-many relationship in Salesforce, each master object record displays a related list of the associated junction object records. To create a seamless user experience, you can change the name of the junction object related list on each of the master object page layouts to have the name of the other master object. For example, you might change the BugCaseAssociations related list to Cases on the bugs page layout and to Bugs on the cases page layout. You can further customize these related lists to display fields from the other master object. To customize the fields that display in the junction object related list on each master object page layout: 1. Edit the page layout of each master object that is related to the junction object. For example, modify the BugCaseAssociations related list for case records by editing the page layout for cases. 2. Edit the properties of the related list you want to modify. For example, on cases the BugCaseAssociations related list was renamed to Bugs, so select the Bugs related list. 3. Add the fields to display in the related list. You can add fields from the junction object itself, but more importantly, you can add fields from the other master object. Each field is prefixed with its object name in the popup window. In the related list itself, only fields from the junction object are prefixed with the object name; fields from the other master object are not.
Note: The junction object related list does not include an icon on the master record's detail pages because the junction object does not have a custom tab. If you make a tab for the junction object, the icon is included.
Customizing Reports for Many-to-Many Relationships Many-to-many relationships provide two standard report types that join the master objects and the junction object. The report types are: • “Primary master with junction object and secondary master” in the primary master object's report category. • “Secondary master with junction object and primary master” in the secondary master object's report category. The order of the master objects in the report type is important. The master object listed first determines the scope of records that can be displayed in the report.
169 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
You can create custom reports based on these standard report types. In addition, you can create custom report types to customize which related objects are joined in the report.
SEE ALSO: Find Object Management Settings Object Relationships Overview Considerations for Relationships Create a Custom Object Find Object Management Settings
Considerations for Relationships
Review the following considerations before creating relationships between objects: EDITIONS Relationship Limits Each custom object can have up to two master-detail relationships and many lookup Available in: both Salesforce relationships. Each relationship is included in the maximum number of custom fields allowed. Classic (not available in all orgs) and Lightning Converting Relationships Experience You can convert a master-detail relationship to a lookup relationship as long as no roll-up summary fields exist on the master object. Available in: Contact Manager, Group, Converting a master-detail relationship to a lookup for a custom object on the “detail” side, Professional, Enterprise, changes the organization-wide default for the object to public read/write. Performance, Unlimited, You can convert a lookup relationship to a master-detail relationship if the lookup field in all Developer, and the records contains a value. Database.com Editions A lookup relationship can’t be changed to a master-detail relationship if the organization-wide Salesforce Connect external default of the child object access level in the relationship is Controlled by Parent. objects are available in: Developer Edition and for Converting a lookup to a master-detail-relationship changes the organization-wide default to an extra cost in: Enterprise, Controlled by Parent and the sharing model is updated to public read/write. Performance, and Self-Relationships Unlimited Editions You can create a relationship from an object to itself, but it must be a lookup relationship, and a single record can't be linked to itself. However, a record can indirectly relate to itself. For example, the Holiday Promotion campaign can select the Direct Mail campaign in the lookup relationship, and the Direct Mail campaign can select the Holiday Promotion campaign in the lookup relationship. You can't create a many-to-many self-relationship, that is, the two master-detail relationships on the junction object can't have the same master object. Icons for Custom Related Lists The icon you select for the associated custom tab also displays in any custom-related list you create based on a relationship. Custom related lists don’t include an icon if they’re based on a relationship with a custom object that doesn't have a custom tab. Master-Detail Relationships To create multilevel master-detail relationships, you need the Customize Application user permission. When you define a master-detail relationship, the custom object on which you're working is the detail side. Its data appears as a custom related list on page layouts for the other object.
170 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
By default, records can’t be reparented in master-detail relationships. Administrators can, however, allow child records in master-detail relationships on custom objects to be reparented to different parent records by selecting the Allow reparenting option in the master-detail relationship definition. You can have up to three custom detail levels. Standard objects can't be on the detail side of a custom object in a master-detail relationship. An object can appear one time in multilevel master-detail relationships. For example, a subdetail object in one multilevel master-detail relationship can't also be the owner of the master object in another multilevel master-detail relationship. A subdetail object can't also be the master object of the subdetail object’s detail object. Multilevel master-detail relationships don’t support division transfers. You can't create a master-detail relationship if the custom object already contains data. You can, however, create the relationship as a lookup and then convert it to master-detail if the lookup field in all records contains a value. Converting relationships from lookup to master-detail, or from master-detail to lookup behaves the same as for two-object master-detail relationships. That is, the two linked objects in the detail-subdetail1, or subdetail1-subdetail2 relationship have the same conversion limits as the master-detail relationship. Roll-up summary fields work as in two-object master-detail relationships. A master can roll up fields on detail records; however, it can't directly roll up fields on subdetail records. The detail record must have a roll-up summary field for the field on the subdetail record, allowing the master to roll up from the detail's roll-up summary field. You can use multilevel master-detail relationships in custom report types. The Allow Reports checkbox must be checked when you create the custom object. Custom report types created for multilevel master-detail relationships count toward the organization’s custom report type limit, and no reports generate if this limit is exceeded. Custom junction objects can’t have detail objects. That is, a custom junction object can’t become the master object in a multilevel master-detail relationship. You can't delete a custom object if it is on the master side of a master-detail relationship. If you delete a custom object that is on the detail side of a master-detail relationship, the relationship is converted to a lookup relationship. Deleting a detail record moves it to the Recycle Bin and leaves the master record intact; deleting a master record also deletes related detail and subdetail records. Undeleting a detail record restores it, and undeleting a master record also undeletes related detail and subdetail records. However, if you delete a detail record and later separately delete its master record, you can’t undelete the detail record, as it no longer has a master record to relate to. A Metadata API deployment that includes Master-Detail relationships deletes all detail records in the Recycle Bin in the following cases. 1. For a deployment with a new Master-Detail field, soft delete (send to the Recycle Bin) all detail records before proceeding to deploy the Master-Detail field, or the deployment fails. During the deployment, detail records are permanently deleted from the Recycle Bin and can’t be recovered. 2. For a deployment that converts a Lookup field relationship to a Master-Detail relationship, detail records must reference a master record or be soft-deleted (sent to the Recycle Bin) for the deployment to succeed. However, a successful deployment permanently deletes any detail records in the Recycle Bin. As a best practice, don't exceed 10,000 child records for a master-detail relationship. A profile or a permission set can have an entity, such as Account, with a master-detail relationship. A broken permission dependency exists if the child entity has permissions that the parent should have. Salesforce updates the parent entity for a broken permission dependency on the first save action for the profile or permission set.
If the child entity has these permissions These permissions are enabled on the parent entity
Modify All OR View All View All
171 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
If the child entity has these permissions These permissions are enabled on the parent entity
View All OR Read Read
Many-to-Many Relationships Junction object records are deleted when either associated master record is deleted and placed in the Recycle Bin. If both associated master records are deleted, the junction object record is deleted permanently and can't be restored. Sharing access to a junction object record is determined by a user's sharing access to both associated master records and the Sharing Setting option on the relationship field. See Custom Object Security on page 177. For example, if the sharing setting on both parents is Read/Write, then the user must have Read/Write access to both parents in order to have Read/Write access to the junction object. If the sharing setting on both masters is Read-Only, a user with Read-Only rights on the master records would have Read access to the junction object. In a many-to-many relationship, a user can't delete a parent record if there are more than 200 junction object records associated with it and if the junction object has a roll-up summary field that rolls up to the other parent. To delete this object, manually delete junction object records until the count is fewer than 200. The first master-detail relationship you create on your junction object becomes the primary relationship. This affects the following for the junction object records: • Look and feel: The junction object's detail and edit pages use the color and any associated icon of the primary master object. • Record ownership: The junction object records inherit the value of the Owner field from their associated primary master record. Because objects on the detail side of a relationship do not have a visible Owner field, this is only relevant if you later delete both master-detail relationships on your junction object. • Division: If your organization uses divisions to segment data, the junction object records inherit their division from their associated primary master record. Similar to the record ownership, this is only relevant if you later delete both master-detail relationships. The second master-detail relationship you create on your junction object becomes the secondary relationship. If you delete the primary master-detail relationship or convert it to a lookup relationship, the secondary master object becomes primary. Roll-up summary fields that summarize data from the junction object can be created on both master objects. Formula fields and validation rules on the junction object can reference fields on both master objects. You can define Apex triggers on both master objects and the junction object. A junction object can't be on the master side of another master-detail relationship. You can't create a many-to-many self-relationship, that is, the two master-detail relationships on the junction object can't have the same master object. Lookup Relationships If the lookup field is optional, you can specify one of three behaviors to occur if the lookup record is deleted: • Clear the value of this field This is the default. Clearing the field is a good choice when the field doesn’t have to contain a value from the associated lookup record. • Don’t allow deletion of the lookup record that’s part of a lookup relationship If you have dependencies built on the lookup relationship, such as a workflow rule, this option doesn’t allow the lookup record to be deleted.
Note: Deleting a record that has child records isn’t allowed, except when the child records are soft-deleted (sent to the Recycle Bin). If all the child records of a parent record are soft-deleted, then the parent record is deleted. Furthermore, any soft-deleted children are then removed from the recycle bin and permanently deleted.
172 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
• Delete this record also Available only if a custom object contains the lookup relationship, not if it’s contained by a standard object. However, the lookup object can be either standard or custom. Choose when the lookup field and its associated record are tightly coupled and you want to completely delete related data.
Warning: Choosing Delete this record also can result in a cascade-delete. A cascade-delete bypasses security and sharing settings, which means users can delete records when the target lookup record is deleted even if they don’t have access to the records. To prevent records from being accidentally deleted, cascade-delete is disabled by default. Contact Salesforce to get the cascade-delete option enabled for your organization. Cascade-delete and its related options aren’t available for lookup relationships to business hours, network, lead, price book, product, or user objects.
In a chain of lookup relationships, these behaviors work independently on each target field at each level. Say, for example, field A is the target lookup of field B, which in turn is the target lookup of field C. You can have a delete restriction on A and none on B, which means that A can't be deleted but B can. After B is deleted, the relationship between A and B no longer exists and C holds an empty value for the lookup. In a multilevel lookup relationship, these options can conflict. For example, if field A is the target lookup of field B, which in turn is the target lookup of field C, you can specify that A deletes B, but B can’t be deleted because it’s in a relationship with C. If you try to delete A, you get an error that B can’t be deleted because it’s linked to C. If the parent record in a lookup relationship is deleted, the field history tracking for the child record doesn't record the deletion. For example, if a parent account is deleted, the Account History related list for the child account doesn’t show the deletion. You can’t select indirect lookup fields in the parent field when you add the Related List - Single component to a Lightning Page. Instead, select the related list that’s associated with the indirect lookup field. It doesn’t show data in the related list, but shows the lookup field with no issue. Relationships on External Objects Lookup, external lookup, and indirect lookup relationships have some special behaviors and limitations. • Only lookup, external lookup, and indirect lookup relationships are available for external objects. No other relationship types are supported. • Depending on the availability of the external system, related lists of child external objects can load slowly when users view the parent record detail pages. • Relationships that involve external objects allow users to create child records from the record detail pages of parent records. However, the relationship field on each new child record isn’t automatically populated to identify the parent record. • Syncing doesn’t create relationship fields on the external objects in your Salesforce org. However, you can change the field type of a sync-created custom field to Lookup Relationship, External Lookup Relationship, or Indirect Lookup Relationship. Changing the field type of an existing custom field is simpler and more efficient than manually creating a relationship field on the external object. For example, suppose that the external system has a foreign key relationship. Syncing the related tables creates a text field in your org for the external column that identifies the foreign keys. To reflect the foreign key relationship within your org, change the field type of that text field to External Lookup Relationship.
• A relationship field is a type of custom field. Therefore, like all custom fields on an external object, relationship fields can be overwritten when you sync the external object. See the sync considerations for each Salesforce Connect adapter that you use. • Cascade-delete isn’t available for external object relationships. • In Salesforce Classic, indirect lookup relationship fields don’t display the expected names of parent records. Instead, each indirect lookup relationship field displays the value of the target field on the parent object. To find related records, target field values are matched against the values of the indirect lookup relationship field on the child object. The target field, which has the External ID and Unique attributes, is selected when an indirect lookup relationship field is created.
173 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
• In Salesforce Classic, external lookup relationship fields don’t always display the expected names of parent records. – In a list view, an external lookup relationship field displays the parent object ID or the value of the parent object’s External ID standard field. The latter appears by default, but if a custom field on the parent object has the Is Name Field attribute, the parent object ID is displayed. – In a record detail page, an external lookup relationship field displays the name as expected if the org has previously retrieved the parent record. If you see an ID in an external lookup relationship field, reload the page to replace the ID with the name.
• Lookup search isn’t available for external lookup relationship fields. To edit an external lookup relationship field, manually enter the value of the External ID standard field for the parent record. This limitation doesn’t apply when the parent external object is associated with the cross-org adapter for Salesforce Connect. • Lookup search isn’t available for indirect lookup relationship fields. To edit an indirect lookup relationship field, manually enter the value of the target field of the parent record. The target field is the custom field with External ID and Unique attributes that was selected when the indirect lookup relationship was created. To determine related records, Salesforce matches target field values against the values of the indirect lookup relationship field on the child object. • With external lookup and indirect lookup relationships, the parent record appears as a clickable link in the relationship field on the child record. If the child record is viewed by a user who doesn’t have access to the parent record, the parent record appears in the relationship field as plain text instead of a link. • Lookup filters aren’t available for external lookup relationship fields. • Indirect lookup relationship fields can be created on external objects only. • Only objects that have a custom field with the External ID and Unique attributes are available as parent objects in indirect lookup relationships. If you don't see the desired object when you create an indirect lookup relationship field, add a custom unique, external ID field to that object. • If the external system uses case-sensitive values in the specified External Column Name, make sure that the parent object field is also case-sensitive. When you define the parent object’s custom field, select External ID, Unique, and Treat "ABC" and "abc" as different values (case sensitive). Impact of Relationships on Reports The type of relationship you create affects which standard report types are available and how they're categorized. These report types determine which related objects can be included in the report: • Lookup relationships allow data from the two related objects to be joined in one report. • Master-detail relationships allow data from three objects to be joined in one report: the master object, the detail object, plus one other lookup object. If the detail object has multiple lookup relationships, a separate report type is available based on each lookup. • Many-to-many relationships provide two standard report types that join the master objects and the junction object. The report types are: – “Primary master with junction object and secondary master” in the primary master object's report category. – “Secondary master with junction object and primary master” in the secondary master object's report category. The order of the master objects in the report type is important. The master object listed first determines the scope of records that can be displayed in the report.
The reporting impact of each relationship type is summarized in the following table:
Relationship Type Standard Report Types Report Type Category Lookup Object by itself Based on the object Object with first lookup
174 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Relationship Type Standard Report Types Report Type Category Object with second lookup Object with third lookup
Master-Detail Master object by itself Master object Master object with detail object Master object with detail object and first lookup Master object with detail object and second lookup Master object with detail object and third lookup
Many-to-Many Primary master object by itself Primary master object Secondary master object by itself and Primary master object with junction object Secondary master object and secondary master object Secondary master object with junction object and primary master object
Custom report types give you more flexibility to join data from multiple objects, including lookups and master-detail relationships.
Important: Converting a relationship from lookup to master-detail or vice versa can cause existing custom reports to become unusable due to the different standard report types available for each type of relationship. We recommend that you test your custom reports immediately after converting the relationship type. If you revert your relationship back to the original type, the reports are restored and become usable again.
SEE ALSO: Object Relationships Overview Create a Many-to-Many Relationship External Object Relationships
175 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Create Record Types for Custom Objects
Create record types for a custom object to display different picklist values and page layouts to EDITIONS different users based on their profiles. 1. From the object management settings for a custom object, go to Record Types. Available in: Salesforce Classic (not available in all 2. Click New in the Record Types related list. orgs) 3. Select Master from the Existing Record Type dropdown list to copy all available picklist values, or choose an existing record type to clone its picklist values. Available in: Professional, Enterprise, Performance, Note: When you create a record type without cloning an existing one, the new record Unlimited, and Developer type automatically includes the master picklist values for both standard and custom Editions picklists. You can then customize the picklist values for the record type.
4. Enter a Record Type Label that's unique within the object. USER PERMISSIONS
Important: Don’t name your record type Master because it’s reserved for record types. To create record types for custom objects: 5. Enter a description. • Customize Application 6. Select Active to activate the record type. 7. Select Make Available next to a profile to make the record type available to users with that profile. Select the checkbox in the header row to make it available for all profiles.
Tip: If each profile is associated with a single record type, users will never be prompted to select a record type when creating records. Users assigned to a record type can still view and edit records associated with record types not enabled for their profiles.
8. For selected profiles, select Make Default next to a profile to make it the default record type for users of that profile. Select the checkbox in the header row to make it the default for all profiles. 9. Click Next. 10. Choose a page layout option to determine what page layout displays for records with this record type: • To apply a single page layout for all profiles, select Apply one layout to all profiles and choose the page layout from the dropdown list. • To apply different page layouts based on user profiles, select Apply a different layout for each profile and choose a page layout for each profile.
11. Click Save to edit the values of the standard and custom picklists available for the record type, or click Save and New to create another record type.
SEE ALSO: Find Object Management Settings
176 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Custom Object Security
Learn how security settings work together so you can control access to your custom objects with EDITIONS great flexibility. Set custom object security at the following levels Available in: both Salesforce Classic (not available in all • Tab—display the custom tab for the appropriate users based on their user profiles. orgs) and Lightning • Object—set the access users have to create, read, edit, and delete records for each object. Experience • Records—set the default sharing model for all your users. This determines the access users Available in: Contact have to custom object records that they do not own. Manager, Group, • Relationship—for objects on the detail side of a master-detail relationship, specify the sharing Professional, Enterprise, access that users must have to the master record in order to create, edit, or delete the associated Performance, Unlimited, detail records. This is specified in the Sharing Setting attribute of the master-detail Developer, and relationship field on the detail object. Database.com Editions • Fields—set the level of access users have to fields on your custom object page layout. Tabs are not available in These requirements apply to custom objects with no master-detail relationship. Database.com.
Action Required Privileges Create a record “Create” permission. The user must have the tab displayed to create a new record from the Create New drop-down list in the sidebar.
View a record “Read” permission and Public Read Only or Public Read/Write sharing model if not the record owner.
Edit a record “Edit” permission and Public Read/Write sharing model if not the record owner.
Delete a record “Delete” permission and must be the record owner or above the record owner in the role hierarchy.
These requirements apply to custom objects that have a master-detail relationship with a standard or custom object.
Action Required Privileges Create a record “Create” permission and either read or read/write access to the related master record, depending on the value of the Sharing Setting attribute of the master-detail relationship field on the detail object.
View a record “Read” permission and read access to the related master record. If the record has two master records in a many-to-many relationship, the user must have read access to both master records.
Edit a record “Edit” permission and either read or read/write access to the related master record, depending on the value of the Sharing
177 Extend Salesforce with Clicks, Not Code Store Information That’s Unique to Your Organization
Action Required Privileges Setting attribute of the master-detail relationship field on the detail object.
Delete a record “Delete” permission and either read or read/write access to the related master record, depending on the value of the Sharing Setting attribute of the master-detail relationship field on the detail object. When a user deletes a record that has related custom object records, all related custom object records are deleted regardless of whether the user has delete permission to the custom object.
Delegated administrators can manage nearly every aspect of specified custom objects, but they cannot create or modify relationships on the object or set organization-wide sharing defaults.
Notes on Enabling Activities for Custom Objects
• If you enable activities when creating a custom object, the activity related lists are added to the EDITIONS default page layout automatically. If you enable activities later, after the custom object already exists, you must add the related lists to the page layout manually. Available in: both Salesforce • Disabling activities for a custom object does not delete existing activity records. However, Classic and Lightning activity related lists are removed from custom object pages, and reports containing activities Experience and the custom object are deleted. Available in: Contact • If a custom object has a master-detail relationship with accounts, the custom object’s activities Manager, Group, roll up to the account and cause the account’s Last Activity date to be updated. For Professional, Enterprise, custom objects related to other types of records, the activities do not roll up. Performance, Unlimited, • The ability to send emails or create mail merge documents is available for activities on custom and Developer Editions objects. The email must be sent to a contact or lead. • When you change the ownership of a custom object record, any open activities related to that custom object are also transferred to the new record owner. • You cannot disable activity tracking for a custom object if any workflow tasks are associated with that custom object. • Custom object records can only be associated with a call log in Salesforce CRM Call Center if activities are enabled for the object.
SEE ALSO: Create a Custom Object
178 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Store Customers’ Data Privacy Preferences
Store certain data privacy preferences for your customers. EDITIONS Regardless of whether you’re working toward complying with data protection and privacy regulations, data privacy records can help you track and store your customers’ consent. We’ve listed Available in: both Salesforce some of the regulations that are important to many companies collecting and processing their Classic (not available in all customers’ data. orgs) and Lightning Experience • General Data Protection Regulation (GDPR), European Union • Gramm-Leach-Bliley Act (GLB Act), United States Available in: all editions, including partner and • Canada’s Anti-Spam Law (CASL) customer community users.
Set Up Tracking and Storage of Certain Data Privacy Preferences Let your users store and track certain data privacy preferences for your customers. Consent Management Objects Get familiar with the objects you can use for managing your customers’ privacy and consent. Tracking Customer Requests for Data Privacy Updates If you store certain data privacy preferences in data privacy records based on the Individual object, track customers’ requests so that you can honor their wishes. Best Practices for Tracking Data Privacy Keep these best practices in mind when storing certain data privacy preferences in data privacy records based on the Individual object. Track Certain Data Privacy Preferences for Leads and Contacts Already in Salesforce Create data privacy records based on the Individual object for leads and contacts already in Salesforce using scripts. Manage Duplicate Data Privacy Records Keep your records clean and free of duplicates so that you can reach more customers and maintain better relationships with them.
Set Up Tracking and Storage of Certain Data Privacy Preferences
Let your users store and track certain data privacy preferences for your customers. EDITIONS Data protection details are available in all your org's records by default. You can easily verify that they're available or disable them from the Setup page. Available in: both Salesforce Classic (not available in all 1. From Setup, enter Data Protection and Privacy in the Quick Find box, and then orgs) and Lightning select Data Protection and Privacy. Experience 2. Click Edit, select or unselect Make data protection details available in records, and then click Save. Available in: all editions, including partner and You can make data protection information visible to users by adding the Individual field to customer community users. Lead, Contact, and Person Accounts page layouts. Consider renaming this field to something meaningful to your users. (Example: Manage data privacy or Track customer consent)
Note: If you don’t see tabs for the consent management objects, set the objects’ tab settings to Default On for the profiles where you want to enable tabs. Other Settings Consider enabling or updating these settings. • Create custom fields for data privacy records
179 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
• Create sharing rules for data privacy records • Encrypt personal data in certain data privacy fields (Shield customers) • Set the organization-wide sharing default • Track field history for individuals
SEE ALSO: Track Certain Data Privacy Preferences for Leads and Contacts Already in Salesforce Best Practices for Tracking Data Privacy
Consent Management Objects
Get familiar with the objects you can use for managing your customers’ privacy and consent. EDITIONS After you learn about these objects and fields, you can track and store certain data privacy preferences. But keep in mind that you must decide how to honor your customers’ privacy, and Available in: both Salesforce then implement a process to accomplish that. Classic (not available in all orgs) and Lightning Note: Consent management object records aren’t counted toward your storage usage. Experience
Table 1: Consent Management Objects Available in: all editions. The Individual object is available Object What It Tracks for partner and customer Authorization Form The version number and effective dates of the community users. authorization form.
Authorization Form Consent Information related to the customer’s consent to the authorization form.
Authorization Form Data Use The data use purpose associated with the authorization form.
Authorization Form Text The text and language of the authorization form.
Communication Subscription The customer's preferences for a communication subscription.
Communication Subscription Channel Type The engagement channel through which to contact a customer for a communication subscription.
Communication Subscription Consent Information related to the customer’s consent to the communication subscription.
Communication Subscription Timing The customer's timing preferences for receiving a communication subscription.
Contact Point Consent Information related to the customer’s consent to be contacted via a specific contact point.
Contact Point Email The customer’s preference for the time they prefer to be contacted via email.
180 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Object What It Tracks
Contact Point Phone The customer’s preference for the time they prefer to be contacted via phone.
Contact Point Type Consent Customer allows contact via a specific contact point type like email, but not through phone calls and mail.
Data Use Purpose The reason for collecting customer data.
Data Use Legal Basis The legal basis for contacting an individual or party, such as legitimate interest.
Engagement Channel Type The channel to use to reach a customer, such as email or web.
Individual The customers’ preferences for: • Collecting, storing, and sharing their personal data • Packaging their personal data so they can take ownership of it • Deleting records and personal data related to them • Solicitation of products and services • Tracking their geolocation and web activity
Party Consent Information related to an individual's consent.
Authorization Form Objects Keep track of data related to authorization forms, such as terms of service, privacy policy, and other consent forms. Each authorization form object stores different data. You can use them together to create a full picture of your customer’s consent to the authorization form. Communication Subscription Objects You can store and manage the data related to your customer’s communication subscriptions, such as newsletters or appointment reminders. Different communication subscription objects store different data, such as how the customer consented to the communication subscription and preferred contact timing. Fields in Data Privacy Records Get the skinny on the fields that appear in data privacy records based on the Individual object. Data privacy records store certain privacy settings for your customers. Fields in Contact Point Consent Records Represents a customer's consent to be contacted via a specific contact point, such as an email address or phone number. Fields in Contact Point Email and Contact Point Phone Records Contact point email and contact point phone records let you enter in details about the time a customer prefers to be contacted. Fields in Contact Point Type Consent Records Contact point type consent records let you enter details about how a customer has agreed to be contacted by your company. For example, you can indicate that a customer consented to a specific contact point like email, but not phone calls and mail. Fields in Data Use Purpose Records Represents a category that defines the reason for contacting an individual. For example, billing, marketing, or surveys.
181 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Fields in Data Use Legal Basis Records Represents the legal basis for contacting an individual. For example, billing or contract. Fields in Party Consent Records Represents consent preferences for an individual.
Authorization Form Objects
Keep track of data related to authorization forms, such as terms of service, privacy policy, and other EDITIONS consent forms. Each authorization form object stores different data. You can use them together to create a full picture of your customer’s consent to the authorization form. Available in: both Salesforce Classic (not available in all Authorization Form orgs) and Lightning Experience Stores the name, version, and effective dates of the authorization form. You can use the revision number to determine if you’re using the current version. You can also link to a default authorization Available in: all editions form text record to use if text isn’t available for a specific language.
Authorization Form Text Manages the text associated with the authorization form. You can create multiple text versions for the same authorization form to support different languages, regions, and situations. You can also include a summary to describe the form’s purpose and display to customers when asking for their consent.
Authorization Form Consent Tracks information related to each customer’s consent to the authorization form. Indicates the individual that consented and when, how, and to which version of the authorization form.
Authorization Form Data Use Optionally, you can connect an authorization form to one or more data use purpose records. Indicate the data use purpose associated with the form, such as billing or marketing, and its corresponding legal basis.
Communication Subscription Objects
You can store and manage the data related to your customer’s communication subscriptions, such EDITIONS as newsletters or appointment reminders. Different communication subscription objects store different data, such as how the customer consented to the communication subscription and Available in: both Salesforce preferred contact timing. Classic (not available in all orgs) and Lightning Communication Subscription Experience Store a customer’s subscription preferences for a specific communication. Available in: all editions.
Communication Subscription Channel Type Specify the engagement channel that you can use to contact the customer for a communication subscription.
182 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Communication Subscription Consent Track information related to each customer’s consent to the communication subscription. Indicate the individual or person account that consented, when consent was captured, and through what method. You can also specify if another person consented on behalf of the customer listed in the record.
Communication Subscription Timing Manage the customer’s time preferences for receiving a communication subscription. For example, track whether to send a reminder to a patient two weeks before an appointment or a newsletter to a customer every Tuesday. You can also ensure that you reach customers when they prefer and in the correct time zone.
Engagement Channel Type Store the channels by which you can communicate with a customer, such as email, phone, or web.
Fields in Data Privacy Records
Get the skinny on the fields that appear in data privacy records based on the Individual object. Data EDITIONS privacy records store certain privacy settings for your customers. Available in: both Salesforce Field Description Classic (not available in all Block Geolocation Tracking Preference to not track geolocation on mobile orgs) and Lightning devices. Experience Available in: all editions, Don’t Process Preference to not process personal data, which including partner and can include collecting, storing, and sharing customer community users. personal data.
Don’t Profile Preference to not process data for predicting personal attributes, such as interests, behavior, and location.
Don’t Solicit Preference to not solicit products and services.
Don’t Track Preference to not track customer web activity and whether the customer opens email sent through Salesforce.
Export Individual’s Data Preference to export personal data for delivery to the individual.
Forget This Individual Preference to delete records and personal data related to this individual.
Individual’s Age Indication for whether the individual is considered to be a minor.
OK to Store PII Data Elsewhere Indication that you can store personally identifiable information outside of their legislation area. For example, you could store an EU citizen’s personal data in the US.
183 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Fields in Contact Point Consent Records
Represents a customer's consent to be contacted via a specific contact point, such as an email EDITIONS address or phone number. Available in: both Salesforce Field Description Classic (not available in all Capture Contact Point Type orgs) and Lightning The contact point used to capture consent. Experience • Email Available in: all editions. • Mailing Address • Phone • Social • Web
Capture Source The way you captured consent. For example, a website or online form.
Contact Point The contact point record, such as for phone or email, that you want to associate this consent with.
Data Use Purpose The data use purpose record that you want to associate this consent with.
Effective From The date when consent starts.
Effective To The date when consent ends.
Party The record based on the individual object you want to associate consent with.
Privacy Consent Status Whether the customer associated with this record agrees to this form of contact. • Not Seen • Seen • Opt In • Opt Out
Fields in Contact Point Email and Contact Point Phone Records
Contact point email and contact point phone records let you enter in details about the time a EDITIONS customer prefers to be contacted. Available in: both Salesforce Field Description Classic (not available in all Best Time to Contact End Time The end time for when the customer prefers to orgs) and Lightning be contacted. Experience Available in: all editions Best Time to Contact Start Time The start time for when the customer prefers to be contacted.
184 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Field Description Best Time to Contact Timezone The timezone for when it’s best to reach out to the customer.
Fields in Contact Point Type Consent Records
Contact point type consent records let you enter details about how a customer has agreed to be EDITIONS contacted by your company. For example, you can indicate that a customer consented to a specific contact point like email, but not phone calls and mail. Available in: both Salesforce Classic (not available in all Field Description orgs) and Lightning Experience Capture Contact Point Type The contact point used to capture consent. Available in: all editions • Email • Mailing Address • Phone • Social • Web
Capture Source The way you captured consent. For example, a website or online form.
Contact Point Type The contact method you want to apply consent to. • Email • Mailing Address • Phone • Social • Web
Double Consent Capture Date Date when double opt-in was captured.
Data Use Purpose The data use purpose record that you want to associate this consent with.
Name The name of the contact point type consent record.
Party The record based on the Individual object you want to associate consent with.
Privacy Consent Status Whether the individual associated with this record agrees to this form of contact. • Not Seen • Seen • Opt In • Opt Out
185 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Fields in Data Use Purpose Records
Represents a category that defines the reason for contacting an individual. For example, billing, EDITIONS marketing, or surveys. Available in: both Salesforce Field Description Classic (not available in all Can Data Subject Opt Out Indication of whether an individual can decline orgs) and Lightning contact for the described purpose. Experience Available in: all editions Legal Basis The legal basis record associated with this purpose.
Name The reason for contacting an individual. For example, “billing” or “marketing.”
Fields in Data Use Legal Basis Records
Represents the legal basis for contacting an individual. For example, billing or contract. EDITIONS
Field Description Available in: both Salesforce Name The name for the legal basis. For example, Classic (not available in all “billing” or “contract.” orgs) and Lightning Experience Source The source of the legal basis. For example, the Available in: all editions URL of a contract.
Fields in Party Consent Records
Represents consent preferences for an individual. EDITIONS
Field Description Available in: both Salesforce Action The action that the individual is consenting to, Classic (not available in all such as collecting data. orgs) and Lightning Experience Capture Contact Point Type The contact point used to capture consent. Available in: all editions. • Email • Mailing Address • Phone • Social • Web
Capture Source The way you captured consent. For example, a website or online form.
Party The record based on the individual object you want to associate consent with.
186 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Field Description Privacy Consent Status Whether the individual associated with this record agrees to this form of contact. • Not Seen • Seen • Opt In • Opt Out
Tracking Customer Requests for Data Privacy Updates
If you store certain data privacy preferences in data privacy records based on the Individual object, EDITIONS track customers’ requests so that you can honor their wishes. To track customers’ requests for updates to their data privacy preferences, run an Apex trigger or Available in: both Salesforce query records in the SOAP API. Classic (not available in all orgs) and Lightning Apex Triggers Experience From Setup, enter Individual in the Quick Find box, and then select Triggers. To create a new trigger, select New. Available in: all editions, including partner and To monitor changes to a specific field, customize the trigger. customer community users. Example:
trigger IndividualUpdated on Individual (after update) { for(String individualId : Trigger.newMap.keySet()) { if( Trigger.oldMap.get(individualId).ShouldForget != Trigger.newMap.get(individualId).ShouldForget ) { // Do something when ShouldForget ("Forget this Individual") changes } } }
To track customers’ requests, either query for triggers in the API, or create reports on flagged items using custom report types. Reports Use data privacy reports to understand the information stored in data privacy records. Standard Report: Field History - If your organization tracks field history on data privacy records based on the Individual object, you can report on that information using the individual history report. SOAP API Query records for changes to data privacy flags using the SOAP API. For more details, see SOAP API: Individual
SEE ALSO: Best Practices for Tracking Data Privacy Define Apex Triggers
187 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Best Practices for Tracking Data Privacy
Keep these best practices in mind when storing certain data privacy preferences in data privacy EDITIONS records based on the Individual object. Encrypting Personal Data Available in: both Salesforce The Name field in data privacy records is personal data. Salesforce Shield customers can use Classic (not available in all Shield to encrypt this field. If you’ve added custom fields that contain personal data, consider orgs) and Lightning encrypting them. Experience Helping Your Users Decode Individual Available in: all editions, After you add the Individual field to your page layouts, consider renaming the field to something including partner and meaningful for your users. (Example: Manage data privacy or Track customer consent) customer community users. Keeping Renamed Contacts, Leads, and Person Accounts Consistent with Data Privacy Record Names Renaming a contact, lead, or person account doesn’t update any corresponding privacy data. To keep the name of data privacy records up to date, write an Apex trigger. Converting Leads to Existing Contacts When you convert a lead, you can decide which data privacy record you maintain between the converted lead and the contact.
To Maintain the Data You Need To Privacy Record From the Contact Sit back and do nothing.
Lead Edit the contact’s IndividualId to replace the ID with the one from the converted lead. If your contact doesn’t include the ID before the conversion, the conversion process populates the field from the converted lead.
Creating Community Users from Contacts with Associated Data Privacy Records To create a new community member from a contact record, first disable Don’t Process and Forget this Individual in the associated data privacy record.
SEE ALSO: Lead Conversion Field Mapping
Track Certain Data Privacy Preferences for Leads and Contacts Already in Salesforce
Create data privacy records based on the Individual object for leads and contacts already in Salesforce EDITIONS using scripts. These scripts create unique data privacy records for each lead and contact. Keep in mind, if you Available in: both Salesforce already have any data privacy records for your leads and contacts, this script creates duplicate Classic (not available in all records. orgs) and Lightning Experience
Available in: all editions, including partner and customer community users.
188 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
Create Data Privacy Records for Contacts Create data privacy records and link them to contacts already in Salesforce when you run this script.
global class CreateIndividualFromContact implements Database.Batchable
global void execute(Database.BatchableContext BC, List
global void finish(Database.BatchableContext BC) {}
}
Create Data Privacy Records for Leads Create data privacy records and link them to leads already in Salesforce when you run this script.
global class CreateIndividualFromLead implements Database.Batchable
global Database.Querylocator start(Database.BatchableContext BC) { //Query to fetch non-converted Leads that don't have Individual created. You may modify the query to add custom fields return Database.getQueryLocator('Select FirstName, LastName, Salutation from Lead where IsConverted = false and IndividualId = NULL'); }
global void execute(Database.BatchableContext BC, List
189 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
}
global void finish(Database.BatchableContext BC) {} }
Manage Duplicate Data Privacy Records
Keep your records clean and free of duplicates so that you can reach more customers and maintain EDITIONS better relationships with them. You can work with duplicate data privacy records individually or in bulk. You can’t merge duplicate Available in: both Salesforce data privacy records automatically. Classic (not available in all orgs) and Lightning You can create a custom matching rule for the Individual object to identify duplicate data privacy Experience records and a custom duplicate rule to handle the duplicates. The Individual object doesn’t include standard matching and duplicate rules, so you must create Available in: all editions, including partner and your own custom matching and duplicate rules to manage your data privacy duplicates. customer community users.
Merge Duplicate Data Privacy Records in Lightning Experience Merge duplicate data privacy records based on the Individual object in Lightning Experience.
SEE ALSO: Manage Duplicates One at a Time Manage Duplicates Globally Duplicate Detection and Handling Process Customize Duplicate Management
Merge Duplicate Data Privacy Records in Lightning Experience
Merge duplicate data privacy records based on the Individual object in Lightning Experience. EDITIONS 1. Choose a data privacy record based on the Individual object. A message tells you if duplicates exist for that record. To see them, click View Duplicates. Available in: Lightning Experience
Available in: all editions, including partner and customer community users.
USER PERMISSIONS
To merge data privacy records based on the Individual object: • Delete on individuals
190 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
2. Choose up to three data privacy records to merge. Click Next.
3. Choose one data privacy record as the master, and choose the field values that you want to keep. Click Next.
191 Extend Salesforce with Clicks, Not Code Store Customers’ Data Privacy Preferences
4. Confirm your choices and merge.
192 Extend Salesforce with Clicks, Not Code Classify Sensitive Data to Support Data Management Policies
Classify Sensitive Data to Support Data Management Policies
Record data sensitivity and compliance categorization at the field level. Data classification can be EDITIONS used to guide decisions around access, reporting, and data compliance. Available in: Salesforce Set Up Data Classification Metadata Classic and Lightning Customize your data classification settings to meet your organization’s needs. You can also Experience upload or download data classification values. Available in: All editions Data Classification Metadata Fields Record the data owner, field usage, data sensitivity, and compliance categorization for any USER PERMISSIONS standard or custom object field. You can also access data classification metadata in the Salesforce API and Apex. To edit or view data classification fields: Create Reports from Data Classification Metadata • Customize Application Run reports to help meet your data management policies. or Modify Data Classification
Set Up Data Classification Metadata
Customize your data classification settings to meet your organization’s needs. You can also upload EDITIONS or download data classification values.
Note: Data classification is automatically enabled in all orgs. Available in: Salesforce Classic and Lightning 1. Select whether to use default data sensitivity levels. Experience a. From Setup, enter Data Classification Settings in the Quick Find box and Available in: All editions select Data Classification Settings. b. Select or deselect Use default data sensitivity level. This setting applies a default value USER PERMISSIONS for the Data Sensitivity field for all contacts, leads, person accounts, and users. To edit or view data 2. Edit data classification values. classification fields: a. From Setup, select Object Manager, then select the object you want to edit. • Customize Application or Modify Data b. Select Fields & Relationships from the sidebar. Select the field where you want to set up Classification data classification and click Edit. c. Select the value for each metadata field from the dropdown lists. d. Click Save.
Note: To edit data classification values for fields that aren’t available in the Object Manager, use the CustomField Metadata API or Data Classification Upload tool.
3. (Optional) Edit Data Sensitivity picklist values. a. From Setup, enter Data Classification Settings in the Quick Find box and select Data Classification Settings. b. Select Edit Data Sensitivity Picklist Values c. Add, delete, rename, or reorder an existing picklist value. You can also add a Description or indicate that fields with this picklist value contain data highly sensitive to your company by selecting High-risk level.
193 Extend Salesforce with Clicks, Not Code Classify Sensitive Data to Support Data Management Policies
4. (Optional) Edit Compliance Categorization picklist values. a. From Setup, enter Data Classification Settings in the Quick Find box and select Data Classification Settings. b. Select Edit Compliance Categorization Picklist Values c. Add, delete, rename, or reorder an existing picklist value.
5. (Optional) Upload data classification information in a CSV file. a. From Setup, enter Data Classification Upload in the Quick Find box and select Data Classification Upload. b. Click Choose File. A CSV file can contain a maximum of 10,000 rows. Each row must include the object name, field name, and data sensitivity level.
6. (Optional) Download data classification information in a CSV file. a. From Setup, enter Data Classification Download in the Quick Find box and select Data Classification Download. b. Click Download. The maximum size of the CSV file is 5 MB. Only fields that have an associated data sensitivity value are included in the file. The file includes the first 2,000 records for each data sensitivity value.
You can update multiple fields at once using the CustomField Metadata API.
Data Classification Metadata Fields
Record the data owner, field usage, data sensitivity, and compliance categorization for any standard EDITIONS or custom object field. You can also access data classification metadata in the Salesforce API and Apex. Available in: Salesforce You can use the data classification metadata fields on all standard and custom objects. Classic and Lightning Experience
Field Description Available in: All editions Compliance Categorization The compliance acts, definitions, or regulations that are related to the field’s data. Default values: USER PERMISSIONS • CCPA—California Consumer Privacy Act To edit or view data • COPPA—Children's Online Privacy classification fields: Protection Act • Customize Application • GDPR—General Data Protection Regulation or Modify Data Classification • HIPAA—Health Insurance Portability and Accountability Act • PCI—Payment Card Industry • PersonalInfo—Personal information. For use with the Enhanced Personal Information Management feature. Only available if Enhanced Personal Information Management and Digital Experiences are enabled. • PII—Personally Identifiable Information
194 Extend Salesforce with Clicks, Not Code Classify Sensitive Data to Support Data Management Policies
Field Description
The field corresponds to the ComplianceGroup field on the FieldDefinition Tooling API.
Data Owner The person or group associated with this field. The data owner understands the importance of the field’s data to your company and might be responsible for determining the minimum data sensitivity level. The field corresponds to the BusinessOwnerId field on the FieldDefinition Tooling API.
Data Sensitivity Level The sensitivity of the data contained in this field. Default values: • Public—Available to the public to view but not alter. • Internal—Available to company employees and contractors. This data must not be shared publicly, but it can be shared with customers, partners, and others under a non-disclosure agreement (NDA). • Confidential—Available to an approved group of employees and contractors. This data isn’t restricted by law, regulation, or a company master service agreement (MSA). It can be shared with customers, partners, and others under an NDA. • Restricted—Available only to an approved group of employees and contractors. This data is likely restricted by law, regulation, an NDA, or a company MSA. • MissionCritical—Available only to a small group of approved employees and contractors. Third parties who are given access could be subject to heightened contractual requirements. This data is almost always restricted by law, regulation, an NDA, or a company MSA. The field corresponds to the SecurityClassification field on the FieldDefinition Tooling API and the FieldSecurityClassification SOAP API.
Field Usage Tracks whether the field is in use. Default values: • Active—In use and visible. • DeprecateCandidate—Planned for deprecation and no longer in use. • Hidden—Not visible and possibly planned for deprecation. Use with caution.
Note: Changing the value of Field Usage doesn’t hide or expose the field. The field corresponds to the BusinessStatus field on the FieldDefinition Tooling API.
195 Extend Salesforce with Clicks, Not Code Design Your Own Data Model
You can customize the values for the Compliance Categorization, Data Sensitivity Level, and Field Usage fields. • To edit the Compliance Categorization values, select Edit Compliance Categorization Picklist Values on the Data Classification Settings Setup page or update the ComplianceGroup picklist using the StandardValueSet Metadata API type. • To edit the Data Sensitivity Level values, select Edit Data Sensitivity Picklist Values on the Data Classification Settings Setup page or update the SecurityClassification picklist using the StandardValueSet Metadata API type. • To edit the Field Usage values, update the FieldBusinessStatus picklist using the StandardValueSet Metadata API type.
Note: You can also access data classification metadata by querying your Salesforce data. For example, this sample query retrieves values for all data classification metadata fields in account and lead records.
SELECT Id, DeveloperName, Description, BusinessOwnerId, BusinessStatus, SecurityClassification FROM FieldDefinition WHERE EntityDefinitionId in ('Account','Lead')
Create Reports from Data Classification Metadata
Run reports to help meet your data management policies. EDITIONS 1. To expose the metadata fields, create a custom report type. From Setup, enter Report Types in the Quick Find box, then select Report Types. Available in: Salesforce Classic and Lightning 2. Click New Custom Report Type. Experience 3. For Primary Object, select Entity Definition. Available in: All editions 4. Fill in the remaining fields and click Next. 5. Add a child object. Click the box under the primary object and select Field Definitions. USER PERMISSIONS 6. Click Save. To edit or view data 7. Exit Setup and click the Reports tab. Build a report in Lightning Experience or Classic using the classification fields: report type you made. • Customize Application or Modify Data Classification
Design Your Own Data Model
Schema Builder provides a dynamic environment for viewing and modifying all the objects and EDITIONS relationships in your app. This greatly simplifies the task of designing, implementing, and modifying your data model, or schema. Schema Builder is enabled by default. Available in: both Salesforce You can view your existing schema and interactively add new custom objects, custom fields, and Classic and Lightning relationships, simply by dragging and dropping. Schema Builder automatically implements the Experience changes and saves the layout of your schema any time you move an object. This eliminates the Available in: All Editions need to click from page to page to find the details of a relationship or to add a new custom field to an object in your schema. Schema Builder provides details like the field values, required fields, and how objects are related by displaying lookup and master-detail relationships. You can view the fields and relationships for both standard and custom objects.
Schema Builder lets you add the following to your schema:
196 Extend Salesforce with Clicks, Not Code Design Your Own Data Model
• Custom objects • Lookup relationships • Master-detail relationships • All custom fields except: Geolocation
Note: You can’t export your schema from Schema Builder (for example, to use the schema in another org).
How Do I Access Schema Builder? Schema Builder Custom Object Definition
SEE ALSO: How Do I Access Schema Builder? Custom Field Types Change Sets
How Do I Access Schema Builder?
From Setup, enter Schema Builder in the Quick Find box, then select Schema Builder. EDITIONS When working with Schema Builder: • Click an object and move it to any space on the canvas. Schema Builder saves the layout of your Available in: both Salesforce Classic (not available in all schema any time you move an object. orgs) and Lightning • Click Auto-Layout to sort the layout of the objects in your schema. Experience
Important: When you click Auto-Layout, you can’t undo it. Available in: All Editions
• Click View Options to: USER PERMISSIONS – Display Element Names if you prefer system names, or Display Element Labels if you prefer text values. To view objects in Schema – Show/Hide Relationships Builder: • Customize Application – Show/Hide Legend
• The Elements tab lets you drag and drop new custom objects and fields onto the canvas. – To create a custom object, see Creating Objects with Schema Builder. – To create a custom field, see Creating Fields with Schema Builder.
• The Objects tab lets you select objects to display on the canvas. – Click the drop-down list in the sidebar to filter your list of objects: • All Objects • Selected Objects • Standard Objects • Custom Objects • System Objects
197 Extend Salesforce with Clicks, Not Code Design Your Own Data Model
Note: Objects created outside of Schema Builder, such as through an app or the API, don’t automatically display on the canvas. Select the checkbox for the object created outside Schema Builder to display it on the canvas.
– To search for an object, type its name in the Quick Find box. – Hover over an object in your list of objects and click to find it on the canvas.
• Hover over relationship lines to show relationship details such as lookup and master-detail relationships. Click the name of the object to find it on the canvas. You can hide relationships if your schema is taking too long to load. • To view the details of a field in a new window, right-click the element name or label and select View Field in New Window. • To edit properties of a custom field, right-click the element name or label and select Edit Field Properties. • To manage permissions of a custom field, click the element name or label and select Manage Field Permissions. Use the dialog box that appears to manage the field’s visibility and writeability for all standard and custom profiles. By default, the field-level security for custom fields is set to visible and editable for internal profiles—those not cloned from Partner User or Customer Portal Manager. Fields that are not normally editable, such as formulas and roll-up summary fields, are visible and read only. • Click to: – Hide Object on Canvas – View Object detail in a new window – View Page Layouts detail in a new window
• For objects with many fields (Lead or Campaign, for example), click Show More Fields to display all the fields. • To zoom in, click . To zoom out, click .
Note: You can’t save the level of zoom when closing Schema Builder.
• To collapse the sidebar, click . To expand it, click . • The map in the lower right corner shows the overall layout of your objects on the canvas. Click the map to navigate the layout of your objects. To pan across the schema layout while zoomed in, click and hold the canvas while moving the mouse. • To close the Schema Builder and save the layout of your objects, click Close.
Important: If your schema contains many objects and fields, loading can take a long time. Click Hide Relationships to improve Schema Builder performance.
Create Objects with Schema Builder Create Fields with Schema Builder Delete Custom Objects with Schema Builder You can delete the custom objects that you no longer need by using Schema Builder.
198 Extend Salesforce with Clicks, Not Code Design Your Own Data Model
Delete Custom Fields with Schema Builder Conveniently avoid “custom field clutter” by using Schema Builder to delete custom fields that you no longer need.
SEE ALSO: Create Objects with Schema Builder Delete Custom Objects with Schema Builder Create Fields with Schema Builder Delete Custom Fields with Schema Builder Find Object Management Settings
Create Objects with Schema Builder
To create a custom object with Schema Builder: EDITIONS 1. Click the Elements tab. 2. Click Object and drag it onto the canvas. Available in: both Salesforce Classic (not available in all 3. Enter information to define your object. For a list of object definitions, see Schema Builder orgs) and Lightning Custom Object Definition on page 201. Experience
4. Click Save. Available in: All Editions
SEE ALSO: USER PERMISSIONS Schema Builder Custom Object Definition To create new custom objects in Schema Builder: • Customize Application
Create Fields with Schema Builder
To create a custom field with Schema Builder: EDITIONS 1. Click the Elements tab. 2. Click a field and drag it onto an object on the canvas. Available in: both Salesforce Classic (not available in all 3. Enter a Field Label. orgs) and Lightning Salesforce populates Field Name using the field label. This name can contain only Experience underscores and alphanumeric characters, and must be unique in your org. It must begin with Available in: All Editions a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. USER PERMISSIONS Ensure that the custom field name and label are unique for that object. • If a standard and custom field have identical names or labels, the merge field displays the To create new fields in custom field value. Schema Builder: • Customize Application • If two custom fields have identical names or labels, the merge fieldcan display an unexpected value. If you create a field label called Email and a standard field labeled Email exists, the merge field is unable to distinguish between the fields. Adding a character to the custom field name makes it unique. For example, Email2.
199 Extend Salesforce with Clicks, Not Code Design Your Own Data Model
4. Enter a Description of the custom field. 5. Enter Help Text to detail the purpose and function of a custom field. 6. Enter a Default Value to automatically insert a value of a custom field when a new record is created. 7. Depending on the custom field type you choose, enter any remaining field attributes. 8. Click Save. Any field you add through Schema Builder isn’t automatically added to the page layout. You will need to edit the page layout to specify where the field should be displayed.
Delete Custom Objects with Schema Builder
You can delete the custom objects that you no longer need by using Schema Builder. EDITIONS Schema Builder displays a list of side effects when you try to delete a custom object. Be sure you’re ready to accept these side effects before finalizing the deletion. See Delete Custom Objects on page Available in: both Salesforce 155 and Manage Deleted Custom Objects on page 156. Classic (not available in all orgs) and Lightning 1. Click on the custom object’s icon. Experience 2. Select Delete Object.... A dialog box displays that explains the side effects of deleting an object. Available in: All Editions Read this information carefully. 3. If you accept the conditions, check Yes, I want to delete the custom object. USER PERMISSIONS 4. Click Delete. To delete custom objects in Schema Builder: • Customize Application
Delete Custom Fields with Schema Builder
Conveniently avoid “custom field clutter” by using Schema Builder to delete custom fields that you EDITIONS no longer need. Schema Builder displays a list of side effects when you try to delete a custom field. Be sure you’re Available in: both Salesforce ready to accept these side effects before finalizing the deletion. Classic (not available in all orgs) and Lightning 1. Right-click on the custom field. Experience 2. Select Delete Field.... A dialog box displays that explains the side effects of deleting a custom field. Read this information carefully. Available in: All Editions 3. If you accept the conditions, check Yes, I want to delete the custom field. USER PERMISSIONS 4. Click Delete. To delete custom fields in Schema Builder: • Customize Application
200 Extend Salesforce with Clicks, Not Code Design Your Own Data Model
Schema Builder Custom Object Definition
Field Description EDITIONS
Label A name used to refer to the object in any user Available in: both Salesforce interface pages. Classic (not available in all orgs) and Lightning Plural Label The plural name of the object. If you create a Experience tab for this object, this name is used for the tab. Available in: All Editions Starts with a vowel sound If it’s appropriate for your organization’s default language, check if your label should be preceded by "an" instead of "a".
Object Name A unique name used to refer to the object when using the API. In managed packages, this unique name prevents naming conflicts on package installations. The Object Name field can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
Description An optional description of the object. A meaningful description helps you remember the differences between your custom objects when you’re viewing them in a list.
Record Name The name used in page layouts, list views, related lists, and search results.
Data Type The type of field (text or auto-number) for the record name. Records that have unique IDs instead of names use auto-numbers. An auto-number is a unique number assigned automatically. It is always a read-only field.
Allow Reports Makes the data in the custom object records available for reporting purposes. To create reports on custom objects, choose the Other Reports report type category, unless the custom object has a relationship with a standard object. When the custom object has a master-detail relationship with a standard object or is a lookup object on a standard object, select the standard object for the report type category instead.
Allow Activities Allows users to associate tasks and scheduled calendar events related to the custom object records.
201 Extend Salesforce with Clicks, Not Code Design Your Own Data Model
Field Description Track Field History Enables your organization to track changes to fields on the custom object records, such as who changed the value of a field, when it was changed, and what the value of the field was before and after the edit. History data is available for reporting, so users can easily create audit trail reports when this feature is enabled.
Enable Divisions If your organization has divisions enabled, select this option to enable the custom object for divisions. Divisions group records for simplified search results, list views, reports, and other areas within Salesforce. Salesforce adds a Division field to the custom object. If the custom object is the master in a master-detail relationship, custom objects on the detail side also get the Division field and inherit their division from the master record.
Available for Customer Portal This option makes the custom object available through the Salesforce Customer Portal.
Namespace Prefix In a packaging context, a namespace prefix is a one to 15-character alphanumeric identifier that distinguishes your package and its contents from packages of other developers on AppExchange. Namespace prefixes are case-insensitive. For example, ABC and abc are not recognized as unique. Your namespace prefix must be globally unique across all Salesforce organizations. It keeps your managed package under your control exclusively.
Deployment Status Indicates whether the custom object is visible to other users.
Add Notes & Attachments... Allows users to attach notes and attachments to custom object records. This allows you to attach external documents to any object record, in much the same way that you can add a PDF or photo as an attachment to an email. This option is only available when you are creating a new object.
202 Extend Salesforce with Clicks, Not Code Create Custom Settings
Create Custom Settings
Use custom settings to create custom sets of data, or to create and associate custom data for an EDITIONS org, profile, or user. Custom settings are similar to custom objects in that they let you customize org data. Unlike custom Available in: Salesforce objects, which have records based on them, custom settings let you utilize custom data sets across Classic and Lightning your org. Custom settings also let you distinguish particular users or profiles based on custom Experience. criteria. Available in: Group, Custom settings data is exposed in the application cache, which enables efficient access without Professional, Developer, the cost of repeated queries to the database. This data can then be used by formula fields, validation Enterprise, Performance, rules, flows, Apex, and SOAP API Unlimited, and Database.com Editions. Note: If you're thinking of using List Custom Settings, consider using Custom Metadata Packages are not available Types instead. Unlike List Custom Settings, you can migrate the records of Custom Metadata in Database.com. Types using Packages or Metadata API tools. The following examples illustrate how you can use custom settings: • A shipping application requires users to fill in the country codes for international deliveries. By USER PERMISSIONS creating a list setting of all country codes, users have quick access to this data without needing to query the database. • An application calculates and tracks compensation for its sales reps, but seniority determines commission percentages. By creating a hierarchy setting, the administrator can associate a different commission percentage for each profile in the sales organization. Within the application, one formula field can then be used to calculate compensation for all users. The personalized setting at the profile level inserts the correct commission percentage. • An application displays a map of account locations, the best route to take, and traffic conditions. This information is useful for sales reps, but account executives only want to see account locations. By creating a hierarchy setting with custom checkbox fields for route and traffic, you can enable this data for just the “Sales Rep” profile. To create and use custom settings: 1. Review the protection and privacy options. 2. Create the custom setting. 3. Add fields and data. 4. Reference the custom setting data in your application using formula fields, validation rules, Apex, or SOAP API.
Protection and Privacy Options for Custom Settings Manage the visibility and permissions of custom settings. Define Custom Settings Create custom sets of data. View and Edit Custom Settings After you create a custom setting, you can view the details of the custom setting, manage the custom setting, and add fields. View Custom Settings Usage and Data View the percentage of custom settings data your org has used. Grant Permissions on Custom Settings By default, access to custom settings is limited through the Restrict access to custom settings org-wide preference. Admins can grant API Read access through profiles and permission sets to users without the Customize Application permission.
203 Extend Salesforce with Clicks, Not Code Create Custom Settings
Grant Read Access to All Custom Settings Admins with the Customize Application permission can grant API read access to all custom settings. Access Custom Settings with Code You can access custom settings from Apex, SOAP API, and formulas. Custom Settings Limits and Considerations When working with custom settings, be aware of the following considerations and limits on the amount of cached data.
Protection and Privacy Options for Custom Settings
Manage the visibility and permissions of custom settings. EDITIONS
Packages Available in: Salesforce Classic and Lightning Only custom settings definitions are included in packages, not data. To include data, populate the Experience. custom settings using a standard Apex or API script run by the subscribing organization after they install the package. Available in: Group, Professional, Developer, When a custom setting is contained in a managed package, and the visibility is set to Protected, Enterprise, Performance, access is allowed only through the Apex code that is part of that managed package. Subscriber Unlimited, and organizations can’t directly access, read, or modify the protected custom settings. Database.com Editions. Note: Protected custom settings in an unmanaged package behave like public custom Packages are not available settings. Make sure that secrets, personally identifying information, or any private data are in Database.com. stored in protected custom metadata types that are installed as part of a managed package. Outside of a managed package, use named credentials or encrypted custom fields to store secrets like OAuth tokens, passwords, and other confidential material.
Visibility You can create protected custom settings in developer and scratch orgs. The options for custom settings are. • Protected—Custom settings in a managed package are visible through Apex and formulas within the same package and namespace. However, they are not visible to subscribing organizations through Apex and API. Custom settings contained in an unmanaged package behave like public custom settings and don’t provide protection. • Public—Regardless of the type of package (managed or unmanaged), the following have access: – Apex – Formulas – Flows – API for users with Customize Application permission or permissions granted through profiles or permission sets.
Schema Settings The schema setting options for custom settings are. • Restrict access to custom settings—This org-wide preference is enabled by default and limits access to custom setting values. Admins with Customize Application permission can grant Read access to users through profiles and permission sets using the Custom Setting Definitions or View All Custom Settings permissions. • Enable SOSL on custom settings—Custom settings values are not returned in Salesforce Object Search language (SOSL) queries. If your Apex operations require this functionality, enable this option.
204 Extend Salesforce with Clicks, Not Code Create Custom Settings
Grant Permissions on Profiles or Permission Sets The Restrict access to custom settings org-wide preference is enabled by default and Read access to custom settings must be explicitly granted. Admins with Customize Application permission can grant Read permission through profiles and permission sets to users without the Customize Application permission. • To grant permission to specific custom settings, use the Custom Setting Definitions permission. • To grant permission to all custom settings, use the View All Custom Settings permission.
Behavior of Apex, Visualforce, and Aura There are different execution code modes within Salesforce that affect the accessibility of custom settings. Apex code that is run in system mode ignores user permissions and your Apex code is given access to all objects and fields. Object permissions, field-level security, and sharing rules aren't applied for the current user. Running in system mode ensures that the code doesn’t fail because of hidden fields or objects for a user. In user mode, functionality such as Visualforce Components, Visualforce Email templates, and Aura, is run with respect to the user's permissions and sharing of records.
Note: Functionality that runs in system mode, such as Apex, is not affected by the Restrict access to custom settings org preference. Also, the with sharing modifier in the Apex class, doesn’t affect query behavior such as, isAccessible() and isCreatable(). If a field value is retrieved in Apex and assigned to a non-sObject variable, the behavior is the same whether the preference is enabled or not. When functionality is run in user mode, such as Visualforce Components, Visualforce Email templates, and Aura, you must have permission to access the custom settings. For example, without permission, the fields on Visualforce pages that you don't have access to aren’t displayed. The $Setup global variable (available in Visualforce and formulas) continues to load values by direct reference (meaning, data that is assigned to an sObject type) regardless of the running user. Consider the following scenario: 1. Apex loads a record that is a row included in a variable such as MySetting__c. 2. What Visualforce displays is MySetting__c.MyPath__c. 3. Access checks are run when the page is loaded. 4. However, the checks are not run in system mode, which is the standard Visualforce behavior. Users without permission to the custom settings can’t display the Visualforce page because Visualforce is reinitiating the access check. In this scenario, if a user isn’t allowed permission to the custom setting, there are two workarounds. You can create a string for each object, which can be passed through, or create a wrapper class. Use these options instead of assigning a variable such as MySetting__c, then rendering mySetting.Path__c mySetting.Name. For example,
class DataHolder{ public string path {get;set;} public boolean active {get;set;} }
When you load the rows into a collection, the Visualforce checks are bypassed because the type is a data type instead of an sObject. Here’s an example that includes the @AuraEnabled annotation for an Aura or Lightning components controller.
class with sharing MyController { @AuraEnabled public static List
205 Extend Salesforce with Clicks, Not Code Create Custom Settings
return [select developername from my__mdt]; } @AuraEnabled public static List
SEE ALSO: Grant Permissions on Custom Settings Access Custom Settings with Code Grant Permissions on Custom Settings Grant Read Access to All Custom Settings
Define Custom Settings
Create custom sets of data. EDITIONS Note: We strongly suggest using custom metadata types instead of custom settings. Unlike list custom settings, you can migrate the records of custom metadata types using Available in: Salesforce second-generation packages or Metadata API tools. Classic and Lightning Experience. To create a custom setting: Available in: Group, 1. From Setup, enter Custom Settings in the Quick Find box, then select Custom Professional, Developer, Settings. Enterprise, Performance, 2. Click New. Unlimited, and Database.com Editions. Note: A icon indicates that the custom setting is in an installed managed package. Packages are not available You can’t edit or delete a protected custom setting installed from a managed package. in Database.com. 3. Define the following: • Label—Enter the label displayed in the application. USER PERMISSIONS • Object Name—Enter the name to be used when the custom setting is referenced by formula fields, validation rules, Apex, or SOAP API. To manage, create, edit, and delete custom settings: Note: Salesforce recommends using ASCII for the Object Name. The name can't • Customize Application exceed 38 ASCII characters. If you use double byte, there are additional limits on the number of characters allowed.
• Setting Type—Select a type of List or Hierarchy. After you save a custom setting, you can’t change this value. – List—Defines application-level data, such as country codes or state abbreviations, and provides a reusable set of static data that can be accessed across your organization. If you use a particular set of data frequently within your application, putting that data in a list custom setting streamlines access to it. Data in list settings does not vary by profile or user, but it is available organization-wide. Examples of list data include two-letter state abbreviations, international dialing prefixes, and
206 Extend Salesforce with Clicks, Not Code Create Custom Settings
catalog numbers for products. Because the data is cached, access is low-cost and efficient—you don't have to use SOQL queries that count against your governor limits. – Hierarchy—Uses a built-in hierarchical logic that lets you personalize settings for specific profiles or users. The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or lowest, value. In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.
• Visibility—(Available in developer and scratch orgs) Select the visibility. After you save a custom setting, you cannot change this value. – Protected—If the custom setting is contained in a managed package, subscribing organizations can't see the custom setting—it doesn't display as part of the package list. In addition, subscribing organizations can't access the custom setting using Apex or the API. Custom settings can only be accessed by the Apex code that is part of the managed package. If the custom setting is contained in an unmanaged package, they behave like public custom settings. – Public—Regardless of the type of package (managed or unmanaged), the following have access: • Apex • Formulas • Flows • API for users with Customize Application permission or permissions granted through profiles or permission sets.
4. Enter an optional description of the custom setting. A meaningful description helps you remember the differences between your custom settings when you view them in a list. 5. Click Save. After you create a custom setting, add fields to the custom setting.
Add Custom Settings Fields After you define custom settings, add fields to them. The custom fields contain the data used by the custom setting. Create Custom Settings Records After you define your custom settings and add fields, you can populate the fields with data. Manage Custom Settings Data After creating custom setting and adding fields, you can add records, then use the values in these records in your Apex code and validation rules.
207 Extend Salesforce with Clicks, Not Code Create Custom Settings
Add Custom Settings Fields
After you define custom settings, add fields to them. The custom fields contain the data used by EDITIONS the custom setting. 1. From Setup, enter Custom Settings in the Quick Find box, then select Custom Available in: Salesforce Settings. Classic and Lightning Experience. 2. Click the custom setting that you want to add fields to. (If you just created the custom setting, the Custom Setting Detail page appears.) Available in: Group, 3. Click New. Professional, Developer, Enterprise, Performance, 4. Select a field type and click Next. Unlimited, and Database.com Editions. Note: Record size is based on the maximum field size of each field type, not the actual storage that’s used in each field. When adding fields to a custom setting definition, use Packages are not available the appropriate type and specify a length that doesn’t exceed what’s needed for your in Database.com. data. This action helps you avoid reaching the cached data limit. For example, if you create a US social security number (SSN) field, select the Text data type and specify a length of 9. If you select a Text Area data type, the field would add 255 characters to the USER PERMISSIONS usage count for each record, regardless of the number of characters entered. To manage, create, edit, and delete custom settings: 5. Enter the details for the field. • Customize Application 6. Confirm the information, and then click Save or Save & New. After you add fields, add data, and for hierarchy custom settings, specify the access level.
SEE ALSO: Create Custom Settings Records
Create Custom Settings Records
After you define your custom settings and add fields, you can populate the fields with data. EDITIONS You can define one or more data sets. For list custom settings, each data set is named and can be accessed by that name using Apex, formula fields, and so on. Available in: Salesforce Classic and Lightning For custom settings that are hierarchies, the access level—user, profile, or organization—determines Experience. how you access the data. The user level is the lowest level, so it is used first, unless otherwise specified in your application. For example, you can specify different contact numbers for your application: Available in: Group, one for the general user, and one that is only displayed for system administrators. Professional, Developer, Enterprise, Performance, To add data to custom setting fields: Unlimited, and 1. From Setup, enter Custom Settings in the Quick Find box, select Custom Settings, Database.com Editions. then click Manage next to a custom setting. Or from the detail page for a custom setting, click Packages are not available Manage. in Database.com. 2. Click New or Edit next to an existing data set. 3. Add or change data. USER PERMISSIONS For custom settings that are lists: a. Specify or change the name for the data set. This name is used by Apex, formula fields, and so on. b. Enter or change data for all fields.
208 Extend Salesforce with Clicks, Not Code Create Custom Settings
c. Click Save. For custom settings that are hierarchies: a. For the default organization level values, enter or change the data for the fields. The default organization location is automatically populated. b. For profile or user level values, select either Profile or User from the Location picklist. Enter the name of the profile or user, or use the lookup dialog search. Then enter or change the data for the fields. c. Click Save.
Note: For a hierarchy custom setting, you can add only one record for a profile or user. Adding two records for the same profile or user results in an error.
SEE ALSO: Manage Custom Settings Data Add Custom Settings Fields
Manage Custom Settings Data
After creating custom setting and adding fields, you can add records, then use the values in these EDITIONS records in your Apex code and validation rules. 1. From Setup, enter Custom Settings in the Quick Find box, then select Custom Available in: Salesforce Settings. Classic and Lightning Experience. 2. Click Manage next to a custom setting, or from the detail page for a custom setting. 3. Provide or change values for the custom setting. Available in: Group, Professional, Developer, • If you are managing a list setting: Enterprise, Performance, – To add data to the fields, click New. Unlimited, and Database.com Editions. – To change the name of the data set or to change the data, click Edit next to the name of an existing set of data. Packages are not available in Database.com. – To delete the data set, click Delete next to the name of an existing set of data.
• If you are managing a hierarchy setting, decide where in the permission hierarchy you want to add default data (organization, profile, or user). USER PERMISSIONS To add default data at the organization level, click New in the Default Organization Level Value section. If data has already been defined for the organization, you can only edit or delete it. To add default data at the profile or user level, click New in the lower section of the page, near the Setup Owner.
After you define data: • To change the default data set at the organization level, click Edit in the Default Organization Level Value section. • To delete the data set (only for hierarchical custom settings), click Delete in the Default Organization Level Value section. • To view the data (only for hierarchical custom settings), click View next to the name of an existing set of data.
SEE ALSO: Custom Settings Limits and Considerations
209 Extend Salesforce with Clicks, Not Code Create Custom Settings
View and Edit Custom Settings
After you create a custom setting, you can view the details of the custom setting, manage the EDITIONS custom setting, and add fields. From Setup, enter Custom Settings in the Quick Find box, then select Custom Settings, Available in: Salesforce then click the name of the custom setting you'd like to view. While viewing a custom setting, you Classic and Lightning can: Experience. • To change a custom setting, click Edit. Available in: Group, • To delete a custom setting, click Delete. Professional, Developer, Enterprise, Performance, Note: A icon indicates that the custom setting is in an installed managed package. Unlimited, and You can’t edit or delete a protected custom setting installed from a managed package. Database.com Editions.
• To add data to a custom setting, click Manage. Packages are not available in Database.com. • To add fields and data to the custom setting, click New.
SEE ALSO: USER PERMISSIONS
Create Custom Settings Records To manage, create, edit, Add Custom Settings Fields and delete custom settings: • Customize Application
View Custom Settings Usage and Data View the percentage of custom settings data your org has used.
View the System Usage Data View the number of custom objects and custom settings in your org, including installed objects from AppExchange. View the Percentage of Custom Settings Data View the percentage of custom settings data used in your organization, out of an allowed limit.
View the System Usage Data
View the number of custom objects and custom settings in your org, including installed objects EDITIONS from AppExchange. 1. From Setup, enter System Overview in the Quick Find box, then select System Available in: Salesforce Overview. Classic and Lightning Experience. 2. In the Schema section, you see the number of custom object and custom settings: • Your Custom Objects and Custom Settings—The number of custom object and custom Available in: Group, settings you created. The edition of Salesforce used determines the limit. Professional, Developer, Enterprise, Performance, • Total Custom Objects and Total Custom Settings—Total number of custom objects and Unlimited, and custom settings in your org, and it includes objects installed from AppExchange managed Database.com Editions. packages. Packages are not available in Database.com.
210 Extend Salesforce with Clicks, Not Code Create Custom Settings
View the Percentage of Custom Settings Data
View the percentage of custom settings data used in your organization, out of an allowed limit. EDITIONS 1. From Setup, enter Custom Settings in the Quick Find box, then select Custom Settings. Available in: Salesforce Classic and Lightning 2. To view the percentage of custom settings data your org has used, click Get Usage. Once the Experience. usage information is returned, the button no longer appears on the page. 3. To manage a custom setting, click Manage next to a previously defined custom setting, and Available in: Group, click View next to the data set you want to view. (only for hierarchical custom settings.) Professional, Developer, Enterprise, Performance, Unlimited, and Database.com Editions. Packages are not available in Database.com.
Grant Permissions on Custom Settings
By default, access to custom settings is limited through the Restrict access to custom EDITIONS settings org-wide preference. Admins can grant API Read access through profiles and permission sets to users without the Customize Application permission. Available in: Salesforce 1. From Setup, enter Schema Settings in the Quick Find box, and make sure that the Classic and Lightning Restrict access to custom settings org permission is enabled. Experience. 2. Enter User Management Settings in the Quick Find box, and enable Enhanced Available in: Group, Profile User Interface. Professional, Developer, This setting provides a uniform and streamlined interface, but isn’t a requirement for granting Enterprise, Performance, Unlimited, and permissions. Database.com Editions. 3. Enter Profiles or Permission Sets in the Quick Find box. Packages are not available 4. Click the name of the profile or permission set that you want to edit. in Database.com. 5. Click Custom Setting Definitions. 6. Click Edit. 7. Add the custom setting to the Enabled Custom Setting Definitions list. 8. Click Save.
211 Extend Salesforce with Clicks, Not Code Create Custom Settings
Grant Read Access to All Custom Settings
Admins with the Customize Application permission can grant API read access to all custom settings. EDITIONS 1. From Setup, enter Schema Settings in the Quick Find box, and make sure that the Restrict access to custom settings org permission is enabled. Available in: Salesforce Classic and Lightning 2. Enter User Management Settings in the Quick Find box, and enable Enhanced Experience. Profile User Interface. This setting provides a uniform and streamlined interface, but isn’t a requirement for granting Available in: Group, permissions. Professional, Developer, Enterprise, Performance, 3. Enter Profiles or Permission Sets in the Quick Find box. Unlimited, and 4. Click the name of the profile or permission set that you want to edit. Database.com Editions. Packages are not available 5. Click System permissions. in Database.com. 6. Check the View All Custom Settings permission. 7. Click Save. USER PERMISSIONS
To grant access to custom settings: • Customize Application
Access Custom Settings with Code
You can access custom settings from Apex, SOAP API, and formulas. EDITIONS Note: Formulas include: flows, workflow rules, approval processes, validation rules, formula fields, and Process Builder processes. Available in: Salesforce Classic and Lightning Here are some sample code segments: Experience. Formula Fields Available in: Group, Formula fields only work for hierarchy custom settings; they can’t be used for list custom settings. Professional, Developer, Enterprise, Performance, Unlimited, and Database.com Editions. Packages are not available in Database.com.
{!$Setup.CustomSettingName__c.CustomFieldName__c}
Apex Apex can access both custom setting types. Samples for List Custom Settings When you add data to a custom setting, name each data set so that you can distinguish them. The following returns a map of custom settings data. The getAll method returns values for all custom fields associated with the list setting.
Map
212 Extend Salesforce with Clicks, Not Code Create Custom Settings
The following example uses the getValues method to return all the field values associated with the specified data set. This method can be used with list and hierarchy custom settings, using different parameters.
CustomSettingName__c mc = CustomSettingName__c.getValues(data_set_name);
Samples for Hierarchy Custom Settings The following example uses the getOrgDefaults method to return the data set values for the organization level:
CustomSettingName__c mc = CustomSettingName__c.getOrgDefaults();
The following example uses the getInstance method to return the data set values for the specified profile. The getInstance method can also be used with a user ID.
CustomSettingName__c mc = CustomSettingName__c.getInstance(Profile_ID);
SOAP API Custom settings that have Privacy defined as Public have the same type of exposure to the API as custom objects. When a custom setting is contained in a managed package, and Privacy for a custom setting is Protected, the settings can only be accessed by the Apex code or formulas that are part of the managed package.
Note: You can also access custom settings data through a Standard Object Query Language (SOQL) query, but this method doesn't use the application cache. It’s similar to querying a custom object.
SEE ALSO: Grant Permissions on Custom Settings
Custom Settings Limits and Considerations When working with custom settings, be aware of the following considerations and limits on the amount of cached data. • Custom settings are a type of custom object. Each custom setting counts against the total number of custom objects available for your organization. • The total amount of cached data allowed for your org is the lesser of these two values: – 10 MB – 1 MB multiplied by the number of full-featured user licenses in your org For example, if your org has three full licenses, you have 3 MB of custom setting storage. If your org has 20 full licenses, you have 10 MB of storage. Each certified managed package gets a separate limit in addition to your org limit. For example, let’s say your org has two certified managed packages installed and your organization has three full licenses. Each certified managed package can have 3 MB of custom setting storage in addition to your org’s 3-MB custom setting storage limit.
• You can add up to 300 fields per custom setting, unless your field limit for custom objects is lower than 300. If your custom objects field limit is lower than 300, your field limit for custom settings is equal to your custom objects field limit. • You can’t share a custom setting object or record. • No owner is assigned when a custom setting is created, so the owner can’t be changed. • Accessing an undeleted custom setting in a formula field results in an error if the user doesn’t have the “Customize Application” permission. To prevent this error, redeploy this custom setting to the organization. Alternatively, delete this custom setting, re-create it with the same name and data, and then delete and re-create all formula fields that use this setting.
213 Extend Salesforce with Clicks, Not Code Customize Fields
• If a cross-object formula references a currency field from a custom setting, this field value isn’t converted to the currency of the record containing the formula. An inaccurate formula result is possible if the custom setting field's currency and the record's currency are different. • You can’t disable specific permissions with a muting permission set. To see how much custom settings data your organization is using, from Setup, enter Custom Settings in the Quick Find box, then select Custom Settings. For each custom setting, this page lists the size of one record, the number of records created, and the total size used for each custom setting. Record size is based on the maximum field size of each field type, not the actual storage that’s used in each field. When adding fields to a custom setting definition, use the appropriate type and specify a length that doesn’t exceed what’s needed for your data. This action helps you avoid reaching the cached data limit. For example, if you create a US social security number (SSN) field, select the Text data type and specify a length of 9. If you select a Text Area data type, the field would add 255 characters to the usage count for each record, regardless of the number of characters entered.
Note: A icon indicates that the custom setting is in an installed managed package. You can’t edit or delete a protected custom setting installed from a managed package.
Customize Fields
Customize standard and custom fields to tailor your org to your own unique requirements. EDITIONS You can: • Modify some aspects of standard fields Available in: both Salesforce Classic and Lightning • Change or add values to standard and custom picklist fields Experience • Define dependency rules between fields Available in: All Editions • Create custom fields to capture additional information Standard Fields and Page • Create formula fields that automatically calculate values based on the contents of other fields Layouts are not available in • Define default values for custom fields Database.com • Define validation rules for your fields • Make a field required USER PERMISSIONS • Set fields to track changes, including the date, time, nature of the change, and who made the change To create or change custom fields: • Create page layouts to control the display of fields • Customize Application • Set field-level security to control access to fields • Create or modify field sets
Customize Standard Fields You can customize several aspects of standard fields, such as the values in picklists, the format for auto-number fields, tracking field history, lookup filters on relationship fields, and field-level help. Modify Standard Auto-Number Fields Custom Fields Create Custom Fields Capture your unique business data by storing it in custom fields. When you create a custom field, you configure where you want it to appear and optionally control security at the field level.
214 Extend Salesforce with Clicks, Not Code Customize Fields
Define Default Field Values Define a default value for a field. Use a formula to generate dynamic values or constants for static values. Validation Rules Examples of Validation Rules Review examples of validation rules for various types of apps that you can use and modify for your own purposes. Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. Require Field Input to Ensure Data Quality Improve the quality of data that users enter in Salesforce by creating universally required fields. About Field Sets Roll-Up Summary Field A roll-up summary field calculates values from related records, such as those in a related list. You can create a roll-up summary field to display a value in a master record based on the values of fields in a detail record. The detail record must be related to the master through a master-detail relationship. For example, you want to display the sum of invoice amounts for all related invoice custom object records in an account’s Invoices related list. You can display this total in a custom account field called Total Invoice Amount. Lookup Filters Improve user productivity and data quality with lookup filters. Lookup filters are administrator settings that restrict the valid values and lookup dialog results for lookup, master-detail, and hierarchical relationship fields. Fields: What’s Different or Not Available in the Salesforce Mobile App Not every Lightning Experience feature is in the Salesforce mobile app. Find out what’s different.
Customize Standard Fields
You can customize several aspects of standard fields, such as the values in picklists, the format for EDITIONS auto-number fields, tracking field history, lookup filters on relationship fields, and field-level help.
Tip: You can’t delete standard fields, but you can remove them from your page layouts. Available in: both Salesforce Classic and Lightning 1. Navigate to the fields page for your object. Experience 2. Click the field label. Available in: All Editions 3. To add custom help text, click Edit. except for Database.com. 4. On the field’s information page, you can—depending on your Edition—set field-level security, view accessibility settings, and configure validation rules. USER PERMISSIONS
You can also do more, depending on the field’s type. For example, if the field is a picklist, you To change standard fields: can add, delete, and reorder its values, and set dependencies. You can’t increase the field length • Customize Application of a standard field. If you need a longer text area, consider creating a custom field.
Beyond the Basics What does that Indexed checkbox mean on a field, and how did it get there?
215 Extend Salesforce with Clicks, Not Code Customize Fields
If a field is indexed, you can use sidebar search or advanced search to find values in the field. Having a field indexed can also speed up other operations on the field, such as reporting. Check out this blog post to find out more: Know Thy Salesforce Field Indexes for Fast Reports, List Views, and SOQL.
SEE ALSO: Custom Fields Add or Edit Picklist Values Rename Object, Tab, and Field Labels Field-Level Help Lookup Filters
Modify Standard Auto-Number Fields
The unique identifiers for solutions, cases, and contracts are standard auto-number fields. Each EDITIONS record is assigned a unique number with a specified format upon creation. You can modify the format and numbering for these auto-number fields. Available in: both Salesforce 1. From the management settings for the object whose field you want to modify, go to the fields Classic (not available in all area. orgs) and Lightning Experience 2. Click Edit next to the name of the field. 3. Enter a Display Format to control such formatting details as the minimum number of Available in: Contact Manager, Group, leading zeros as well as any prefix or suffix for the number. See Custom Field Attributes on page Professional, Enterprise, 233. Performance, Unlimited, Format changes do not affect existing records; they are applied only to new records. and Developer Editions
4. Enter the number to be assigned to the next record that is created after you save your changes. USER PERMISSIONS 5. Click Save.
Warning: Salesforce warns you if the next number you enter is not higher than existing To modify standard auto-number fields: numbers. However, it may be possible to create duplicate numbers if you change the • Customize Application auto-number format multiple times using similar formats each time.
SEE ALSO: Custom Field Types
216 Extend Salesforce with Clicks, Not Code Customize Fields
Custom Fields
You can add custom fields for each of the objects that your Salesforce org uses. EDITIONS The number of custom fields allowed per object varies according to your Salesforce Edition. For the total custom fields that you can create, see Custom Fields Allowed Per Object on page 232. Available in: both Salesforce Classic (not available in all When your org is close to the limit of 800 custom fields and you delete or create fields, field creation orgs) and Lightning can fail. The physical delete process reclaims and cleans fields, making them count temporarily Experience toward the limit. The delete process runs only when the queue is full, so it can take days or weeks to start. In the meantime, the deleted fields are still counted as part of the limit. To request immediate Available in: All Editions deletion of fields, contact Salesforce Support. Don’t add a field dependency between managed custom fields in your org, as it can cause errors. USER PERMISSIONS
To create or change custom SEE ALSO: fields: Create Custom Fields • Customize Application Edit Custom Fields Additional Custom Field Options Custom Field Attributes
217 Extend Salesforce with Clicks, Not Code Customize Fields
Create Custom Fields
Capture your unique business data by storing it in custom fields. When you create a custom field, EDITIONS you configure where you want it to appear and optionally control security at the field level. Watch a Demo: How to Create a Custom Field in Salesforce Available in: both Salesforce Classic (not available in all Want to customize Salesforce so it captures all your business data? This short video walks you orgs) and Lightning through how to create a custom picklist field, from choosing the correct field type to applying field Experience level security. Available in: Contact Watch a Demo: How to Add a Custom Field in Salesforce (Lightning Experience) Manager,Essentials, Group, Want to add and arrange a new field while viewing an individual record for an object? This short Professional, Enterprise, video walks you through creating a picklist field while viewing a contact, and then changing the Performance, Unlimited, page layout for the field. Developer, and Database.com Editions Before you begin, determine the type of field you want to create. Salesforce Connect external Note: When your org is close to the limit of 800 custom fields and you delete or create fields, objects are available in: field creation can fail. The physical delete process reclaims and cleans fields, making them Developer Edition and for count temporarily toward the limit. The delete process runs only when the queue is full, so an extra cost in: Enterprise, it can take days or weeks to start. In the meantime, the deleted fields are still counted as part Performance, and of the limit. To request immediate deletion of fields, contact Salesforce Support. Unlimited Editions 1. From the management settings for the object you want to add a field to, go to Fields. Custom Custom fields aren’t task and event fields are accessible from the object management settings for Activities. available on Activities in Group Edition 2. Click New. Custom settings aren’t Tip: On custom objects, you can also set field dependencies and field history tracking in available in Professional this section. Edition 3. Choose the type of field and click Next. Consider the following. Layouts aren’t available in Database.com • Some data types are available for certain configurations only. For example, the Master-Detail Relationship option is available for custom objects only when the custom object doesn’t already have a master-detail relationship. USER PERMISSIONS • Custom settings and external objects allow only a subset of the available data types. To create or change custom • You can’t add a multi-select picklist, rich text area, or dependent picklist custom field to fields: opportunity splits. • Customize Application • Relationship fields count towards custom field limits. • Additional field types may appear if an AppExchange package using those field types is installed. • The Roll-Up Summary option is available on certain objects only. • Field types correspond to API data types. • If your organization uses Shield Platform Encryption, ensure you understand how to encrypt custom fields using the Shield Platform Encryption offering.
4. For relationship fields, associate an object with the field and click Next. 5. For indirect lookup relationship fields, select a unique, external ID field on the parent object, and then click Next. The parent field values are matched against the values of the child indirect lookup relationship field to determine which records are related to each other. 6. To base a picklist field on a global picklist value set, select the value set to use.
218 Extend Salesforce with Clicks, Not Code Customize Fields
7. Enter a field label. Salesforce populates Field Name using the field label. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. Use the field name for merge fields in custom links, custom s-controls, and when referencing the field from the API.
Tip: Ensure that the custom field name and label are unique for that object. • If a standard and custom field have identical names or labels, the merge field displays the custom field value. • If two custom fields have identical names or labels, the merge fieldcan display an unexpected value. If you create a field label called Email and a standard field labeled Email exists, the merge field is unable to distinguish between the fields. Adding a character to the custom field name makes it unique. For example, Email2.
8. Enter field attributes and select the appropriate checkboxes to specify whether the field must be populated and what happens if the record is deleted. 9. For master-detail relationships on custom objects, optionally select Allow reparenting to allow a child record in the master-detail relationship to be reparented to a different parent record. 10. For relationship fields, optionally create a lookup filter to limit search results for the field. Not available for external objects. 11. Click Next. 12. In Enterprise, Unlimited, Performance, and Developer Editions, specify the field’s access settings for each profile, and click Next.
Access Level Enabled Settings Users can read and edit the field. Visible
Users can read but not edit the field. Visible and Read-Only
Users can’t read or edit the field. None
Note: • When you create a custom field, by default the field isn’t visible or editable for portal profiles, unless the field is universally required.
13. Choose the page layouts that will display the editable field and click Next.
Field Location on Page Layout Normal Last field in the first two-column section.
Long text area End of the first one-column section.
User Bottom of the user detail page.
Universally required Can’t remove it from page layouts or make read only.
14. For relationship fields, optionally create an associated records related list and add it to page layouts for that object. • To edit the related list name on page layouts, click Related List Label and enter the new name.
219 Extend Salesforce with Clicks, Not Code Customize Fields
• To add the related list to customized page layouts, select Append related list to users’ existing personal customizations.
15. Click Save to finish or Save & New to create more custom fields.
Note: Creating fields can require changing a large number of records at once. If your request is queued to process these changes efficiently, you receive an email notification when the process has completed.
Create a Custom Picklist Field Create custom picklist fields to let your users select values from lists that you define. Create a Global Picklist Value Set Use global picklist value sets to share values across objects and custom picklist fields, and to restrict the picklists to only the values that you specify. Make Your Custom Picklist Field Values Global When you create a custom picklist, it’s only available to the current object. To share the values with other objects, promote the picklist to a global value set. The original custom picklist references the global value set for its values, and the global value set is also available to other custom picklists. Custom Field Types Salesforce supports many different field types. Pick the right type, or convert an existing one. What’s the Difference between Standard Fields and Custom Fields? You can add custom fields to standard and custom objects in Salesforce, allowing you to infinitely customize your organization. Although custom fields are similar to the standard fields that come built-in to Salesforce, there are some differences between standard fields and custom fields. Custom Fields Allowed Per Object The number of custom fields allowed per object varies according to your Salesforce Edition. Custom Field Attributes A custom field entry consists of several attributes. Geolocation Custom Field The geolocation custom field allows you to identify locations by their latitude and longitude and to calculate distances between locations. Manage Fields for a Specific Object Edit Custom Fields Delete Fields Manage Deleted Custom Fields Deleted custom fields and their data are stored until your org permanently deletes them or 15 days has elapsed, whichever happens first. Until that time, you can restore the field and its data. Purge Deleted Custom Fields Deleted fields are available for 15 days until they’re hard deleted. During that time, the field continues to count toward your custom field allocation. You can use the Purge button to initiate the hard-delete process and free up custom field allocation for your org. Additional Custom Field Options Editing Rich Text Area Fields in Records Use rich text area fields to improve the appearance of text, including adding images and hyperlinks.
220 Extend Salesforce with Clicks, Not Code Customize Fields
Rich Text Area Field Limitations Keep these limitations in mind when working with rich text area fields. Valid Range for Date Fields Classic Encryption for Custom Fields Restrict other Salesforce users from seeing custom text fields that you want to keep private. Only users with the View Encrypted Data permission can see data in encrypted custom text fields. Time Custom Field Track time, unbound to a date, with this custom field type. The time type is useful for time management, event planning, and project management. Add or Edit Picklist Values Add or edit values in a custom picklist from the fields area of an object. If the picklist uses a global picklist value set, you can change its values only by editing the global value set. Your changes affect all picklists that inherit their values from that global value set. Define Dependent Picklists Rich Text Editor Use the rich text editor to format text in custom fields with the rich text area type. You can also use the rich text editor in many other features, such as Chatter publisher and groups. Change the Custom Field Type
SEE ALSO: External Object Relationships Which Standard Fields Can I Encrypt? Which Custom Fields Can I Encrypt? What’s the Difference Between Classic Encryption and Shield Platform Encryption? Encrypt New Files and Attachments Find Object Management Settings Map Custom Lead Fields for Lead Conversion Specify Lookup Search Filter Fields
Create a Custom Picklist Field
Create custom picklist fields to let your users select values from lists that you define. EDITIONS Watch a Demo: Custom Fields: Picklists Available in: Salesforce You can create these types of picklist fields: Classic and Lightning • Local picklist—Lets users select a single value from a list that you define. This picklist is unique Experience and had its own set of values. Available in: All Editions • Shared picklist—Lets users select a single value from a global picklist value set that you define in Setup. All custom picklist fields that use a global value set inherit its values and can’t have additional values. USER PERMISSIONS
• Multi-select picklist—Allows users to select more than one picklist value from a list that you To create or change custom define. These fields display each value separated by a semicolon. fields: Note: You can’t add a multi-select picklist, rich text area, or dependent picklist custom field • Customize Application to opportunity splits.
221 Extend Salesforce with Clicks, Not Code Customize Fields
1. Go to the fields area of the object you want to create a picklist field for. 2. In the custom fields related list, click New. 3. Select Picklist or Picklist (Multi-Select), and then click Next. 4. Enter a label for the picklist field. 5. To use the values from an existing global picklist, select Use global picklist value set. To use values that you create specifically for this picklist, select Enter values for the picklist, with each value separated by a new line.
Tip: Provide feedback and suggestions for global picklists in the Global, Restricted Custom Picklists group in the Salesforce Trailblazer Community.
6. If you didn’t use a global picklist value set, enter picklist values. Put each value on a separate line. Values can be up to 255 characters long.
7. Optionally, sort the values alphabetically or use the first value in the list as the default value, or both. If you select both options, Salesforce alphabetizes the entries and then sets the first alphabetized value as the default.
Note: Don’t assign default values to fields that are both required and unique, because uniqueness errors can result. See Default Field Values on page 284. You can use a formula to assign a default value dynamically. For example, you can assign a value based on the current user. The following formula sets an Opportunity priority to High for all users in the Fast Response Sales profile. Other users see the default listed in the Values set. IF($Profile.Name = "Fast Response Sales", "High", "") For picklists, a valid formula result is either a constant or the API name of an entry in the Values list. The formula result has higher precedence than the default assigned in the Values list. If the formula doesn’t generate a valid result, the default assigned in the Values list is entered in the field. If a default is not assigned to the Values list, no value is entered in the picklist field.
8. Choose whether to restrict this picklist’s values to an admin-approved list. Selecting Restrict picklist to the values defined in the value set prevents users from loading unapproved values through the API. 9. If you’re creating a multi-select picklist, enter how many values you want displayed at a time on edit pages. The number of values determines the box height. 10. Enter description or help text if desired, and then click Next. 11. Set field-level security for the picklist field, and then click Next. 12. Choose the page layouts on which to include the picklist field. 13. Click Save.
SEE ALSO: Create Custom Fields Add or Edit Picklist Values Create a Global Picklist Value Set Make Your Custom Picklist Field Values Global
222 Extend Salesforce with Clicks, Not Code Customize Fields
Create a Global Picklist Value Set
Use global picklist value sets to share values across objects and custom picklist fields, and to restrict EDITIONS the picklists to only the values that you specify.
Note: Give your feedback and suggestions for global picklists in the Global, Restricted Custom Available in: Salesforce Picklists group in the Salesforce Trailblazer Community. Classic and Lightning Experience A custom picklist is tied to a particular object as a field on the object. Unlike a custom picklist field, a global picklist exists independently as a global picklist value set. Its values are shared with any Available in: All Editions picklist that’s based on it. A global picklist is a restricted picklist by nature. Only a Salesforce admin can add to or modify its USER PERMISSIONS values. Users can’t add unapproved values, even through the API. To create or change custom Note: Global picklist value sets limits: fields: • Customize Application • Global picklist value sets have a combined active and inactive limit of 1,000. • You can have up to 500 picklist global value sets in an org. • There’s no limit on the number of custom picklists that use global picklist value sets. • If you apply a global picklist value set to more than 13 different objects, you can deactivate values from the picklist value set, but you can’t replace any picklist values or delete values from the set.
1. From Setup, enter Picklist in the Quick Find box, then select Picklist Value Sets. 2. Next to Global Value Sets, click New. 3. Enter a label for the global value set. This name appears in Setup, and when users create a picklist based on this global value set. 4. To tell users what these values are for, enter a specific description of the global value set. This text appears on the Picklist Value Sets list page in Setup. 5. Enter the values, one per line. 6. Optionally choose to sort the values alphabetically or to use the first value in the list as the default value, or both. If you select both options, Salesforce alphabetizes the entries and then sets the first alphabetized value as the default.
7. Click Save. Your global value set is ready to be used in custom picklist fields. To arrange values or re-alphabetize them, use Reorder. To create a picklist that uses a global picklist value set, see Create a Custom Picklist Field. To see all the fields where this value set is used, look under Fields Where Used on the global picklist’s detail page. You can’t undo a custom picklist field’s association with a global value set. If you need a picklist field to use a different global value set or different individual values, delete the custom picklist field, and create a new one in its place. As you add new values to an existing global picklist, you can add the new values to all record types that use the picklist. Select Add the new picklist values to all Record Types that use this Global Value Set; otherwise, you have to add the new values to existing records types manually.
SEE ALSO: Manage Inactive Picklist Values Create a Custom Picklist Field Make Your Custom Picklist Field Values Global
223 Extend Salesforce with Clicks, Not Code Customize Fields
Make Your Custom Picklist Field Values Global
When you create a custom picklist, it’s only available to the current object. To share the values with EDITIONS other objects, promote the picklist to a global value set. The original custom picklist references the global value set for its values, and the global value set is also available to other custom picklists. Available in: Salesforce Note: After a picklist is promoted to a global value set, you can’t demote it. You manage the Classic and Lightning values in the global value set or edit the custom picklist field to use different values. Experience 1. Go to the fields area of the object you want to create a picklist field for. Available in: All Editions 2. In the Custom Fields related list, click Edit. USER PERMISSIONS 3. Click Promote to Global Value Set. To create or change custom fields: • Customize Application
4. Enter a label for the global value set. 5. Accept the Field Name or edit it. 6. Optionally, enter a description to identify it when using the values for other custom picklists. 7. Click Promote to Global Value Set, again. You can use the new global value set for other fields and manage the values in Picklist Value Sets. When promoting a custom picklist, be aware of the following. • You can promote fields that have up to 1,000 values (both active and inactive). • You can promote only restricted picklists. To promote an unrestricted picklist, convert it to a restricted picklist. • You cannot promote a field to an existing global value set. • Picklist values translated using Translation workbench have a limit of 40 characters. • For an app to help manage picklist values, see Picklist Field Merge Salesforce Lab App. • You can’t undo a custom picklist field’s association with a global value set. If you need a picklist field to use a different global value set or different individual values, delete the custom picklist field, and create a new one in its place.
SEE ALSO: Create a Custom Picklist Field Create a Global Picklist Value Set
224 Extend Salesforce with Clicks, Not Code Customize Fields
Custom Field Types Salesforce supports many different field types. Pick the right type, or convert an existing one. When you have data that doesn’t match any of the standard fields, your administrator can create a custom field for that data. For example, use a Middle Name field for contacts. The first step in creating a custom field is choosing the type of the field. This table includes a description of each custom field type. Additional field types may appear if an AppExchange package using those field types is installed.
Type Description Auto Number Automatically assigns a unique number to each record. The maximum length of any auto-number field is 30 characters, 20 of which are reserved for prefix or suffix text. Not available for external objects.
Checkbox Allows users to check a box, indicating a true or false attribute of a record. When using a checkbox field for a report or list view filter, use “True” for checked values and “False” for unchecked values. The Data Import Wizard and the weekly export tool use “1” for checked values and “0” for unchecked values.
Currency Allows users to enter a currency amount. The system automatically formats the field as a currency amount. This formatting is useful if you export data to a spreadsheet application. Not available for external objects.
Note: Salesforce uses the round-half-to-even tie-breaking rule for currency fields. For example, 23.5 becomes 24, 22.5 becomes 22, −22.5 becomes −22, and −23.5 becomes −24. Values lose precision after 15 decimal places.
Date Allows users to enter a date or pick a date from a popup calendar. In reports, you can limit the data by specific dates using any custom date field.
Date/Time Allows users to enter a date or pick a date from a popup calendar and enter a time of day. There are visual and behavioral differences for Date/Time fields in Lightning Experience and Salesforce Classic. In Lightning Experience, the date and time fields are separate, and the initial time is set to 12:00 PM when you select a date in the calendar. In Salesforce Classic, the date/time field is a single field. You can set the field to the current date and time by clicking the date and time link next to the field. The time of day includes AM or PM notation. In reports, you can limit the data by specific dates and times using any custom date field.
Email Allows users to enter an email address of up to 80 characters, which is validated to ensure proper format. If this field is specified for contacts or leads, users can choose the address when clicking Send an Email. You can't use custom email addresses for mass emails or list emails.
225 Extend Salesforce with Clicks, Not Code Customize Fields
Type Description Emails sent to a record's custom email address fields aren't logged against that record.
Note: This field can be encrypted using Shield Platform Encryption.
External Lookup Relationship When you create an external lookup relationship field, the standard External ID field on the parent external object is matched against the values of the child’s external lookup relationship field. External object field values come from an external data source.
Formula Allows users to automatically calculate values based on other values or fields such as merge fields. Not available for external objects.
Note: Salesforce uses the round half up tie-breaking rule for numbers in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35.
Geolocation Allows users to specify a location by its latitude and longitude. Geolocation is a compound field that counts toward your org’s limits as three custom fields: one for latitude, one for longitude, and one for internal use. Not available for external objects.
Hierarchical Relationship Creates a hierarchical lookup relationship between users. Allows users to use a lookup field to associate one user with another that neither directly nor indirectly refers to itself. For example, you can create a custom hierarchical relationship field to store each user's direct manager.
Indirect Lookup Relationship An indirect lookup relationship links a child external object to a parent standard or custom object. When you create an indirect lookup relationship field on an external object, you specify the parent object field and the child object field to match and associate records in the relationship. Specifically, you select a custom unique, external ID field on the parent object to match against the child’s indirect lookup relationship field. The child lookup field’s value comes from an external data source.
Lookup Relationship Creates a relationship between two records so you can associate them with each other. For example, opportunities have a lookup relationship with cases that lets you associate a particular case with an opportunity. • On a standard or custom object, a lookup relationship creates a field that allows users to click a lookup icon and select another record from a popup window. • On an external object, the lookup relationship field references 18-character Salesforce IDs that are stored in an external data source. Those IDs are matched against the parent object to determine which records are related to each other.
226 Extend Salesforce with Clicks, Not Code Customize Fields
Type Description On the parent record, you can display a related list to show all the records that are linked to it. You can create lookup relationship fields that link to users, standard objects, or custom objects. If a lookup field references a record that has been deleted, Salesforce clears the value of the lookup field by default. Alternatively, you can choose to prevent records from being deleted if they’re in a lookup relationship. Lookup relationship fields are not available in Personal Edition. Lookup relationship fields to campaign members are not available; however, lookup relationship fields from campaign members to standard or custom objects are available.
Master-Detail Relationship Creates a relationship between records where the master record controls certain behaviors of the detail record such as record deletion and security. Not available for standard objects or external objects, although you can create a master-detail relationship field on a custom object that links to a standard object. Master-detail relationships cannot be used with campaign members.
Number Allows users to enter any number. This number is treated as a real number and any leading zeros are removed.
Note: Salesforce uses the round half up tie-breaking rule for number fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.34. Salesforce rounds numbers referenced in merge fields according to the user’s locale, not the number of decimal spaces specified in the number field configuration. When you use Einstein Prediction Builder to build a prediction, a custom field is created for storing and displaying the prediction scores on records. Or, you can create a predictive custom field manually, enable it as an AI prediction field, and enter its name and label when building a prediction in Einstein Prediction Builder. For example, display how likely a customer is to pay an invoice on time. In Lightning Experience, custom objects can store more decimal places than you define. If you enter 90.678 on a field that accepts 2 decimal places, the number is displayed as 90.68 on the record form. When you inline edit, the field shows the original input, 90.678. Similarly, the value is stored as 90.678 in the database. In Salesforce Classic, the input 90.678 is saved as 90.68.
227 Extend Salesforce with Clicks, Not Code Customize Fields
Type Description Percent Allows users to enter a percentage number as a decimal—for example, 0.10. The system automatically converts the decimal to a percentage—for example, 10%.
Note: Values lose precision after 15 decimal places. Also, if you enter a value with more than 15 decimal places and add a percent sign to the number, a runtime error occurs.
Phone Allows users to enter any phone number. Character limit is 40. Salesforce automatically formats it as a phone number. If you are using Salesforce CRM Call Center, custom phone fields are displayed with the button, allowing click-to-dial functionality. Therefore, Salesforce recommends that you do not use a custom phone field for fax numbers.
Note: This field can be encrypted using Shield Platform Encryption.
Picklist Lets users select a single value from a list that you define. Available for external objects only with the cross-org adapter for Salesforce Connect.
Picklist (Multi-select) Allows users to select more than one picklist value from a list that you define. These fields display each value separated by a semicolon. Available for external objects only with the cross-org adapter for Salesforce Connect.
Roll-Up Summary Automatically displays the record count of related records or calculates the sum, minimum, or maximum value of related records. The records must be directly related to the selected record and on the detail side of a custom master-detail relationship with the object that contains the roll-up summary field. For example, a custom field called “Total Number of Guests” displays the number of guest custom object records in the Guests related list. Not available for external objects.
Text Allows users to enter any combination of letters, numbers, or symbols. You can set a maximum length, up to 255 characters.
Note: This field can be encrypted using Shield Platform Encryption.
Text (Encrypted) Allows users to enter any combination of letters, numbers, or symbols that are stored in encrypted form. You can set a maximum length of up to 175 characters. Encrypted fields are encrypted with 128-bit master keys and use the Advanced Encryption Standard (AES) algorithm. You can archive, delete, and import your master encryption key. To enable master encryption key management, contact Salesforce. Not available for external objects.
228 Extend Salesforce with Clicks, Not Code Customize Fields
Type Description
Note: This field can be encrypted using Classic Encryption. If your org uses Shield Platform Encryption, use Text to create an encrypted text field.
Text Area Allows users to enter up to 255 characters that display on separate lines similar to a Description field.
Text Area (Long) Allows users to enter up to 131,072 characters that display on separate lines similar to a Description field. You can set the length of this field type to a lower limit, if desired. Any length from 256 to 131,072 characters is allowed. The default is 32,768 characters. Every time you press Enter within a long text area field, a line break, and a return character are added to the text. These two characters count toward the 131,072 character limit. This data type is not available for activities or products on opportunities. The first 999 characters in a standard rich text area or a long text area are displayed in a report. For custom fields, only the first 255 characters are displayed. If you download the report as Details Only, the entire field is available.
Note: This field can be encrypted using Shield Platform Encryption.
Text Area (Rich) With the use of a toolbar, users can format the field content and add images and hyperlinks. The toolbar allows the user to undo, redo, bold, italicize, underline, strike-out, add a hyperlink, upload or link to an image, modify alignment, add a numbered or non-numbered list, indent, and outdent. The maximum field size is 131,072 characters, inclusive of all the formatting and HTML tags. The first 999 characters in a standard rich text area or a long text area are displayed in a report. For custom fields, only the first 255 characters are displayed. If you download the report as Details Only, the entire field is available. The maximum size for uploaded images is 1 MB. Only gif, jpeg, and png file types are supported. Not available for external objects. There are visual and formatting differences for rich text areas in Lightning Experience and the Salesforce mobile app, compared to Salesforce Classic.
Time Allows users to enter a time of day, including hours, minutes, second, and milliseconds. Append a “Z” at the end to denote Greenwich Mean Time (GMT).17:30:45.125, 17:30:45, 17:30, and 17:30:45Z are all examples of valid entries. The time displays in a 12-hour notation with AM or PM. The displayed time depends on the Locale setting on the Company Information page in Setup.
URL Allows users to enter up to 255 characters of any valid website address. Only the first 50 characters are displayed on the record detail pages. When a user clicks the field in Salesforce Classic, the URL opens in a separate browser window. In Lightning Experience,
229 Extend Salesforce with Clicks, Not Code Customize Fields
Type Description internal URLs open in the same window and external URLs open in a separate browser window. In Salesforce console apps, the URL opens in a new workspace tab. In Lightning console apps, internal URLs open in a new workspace tab and external URLs open in a separate browser window.
Warning: When opening an external URL, a message asks for the user’s permission. To prevent the modal from displaying every time you open an external URL, disable your browser’s popup blocker.
Note: This field can be encrypted using Shield Platform Encryption.
Set an AI Prediction Field When you use Einstein Prediction Builder to build a prediction, a custom field is created for storing and displaying the prediction scores on records. Or, you can create a predictive custom field manually, and enter its name and label when building a prediction in Einstein Prediction Builder.
SEE ALSO: Custom Field Attributes Set an AI Prediction Field Einstein Prediction Builder
Set an AI Prediction Field When you use Einstein Prediction Builder to build a prediction, a custom field is created for storing and displaying the prediction scores on records. Or, you can create a predictive custom field manually, and enter its name and label when building a prediction in Einstein Prediction Builder. The recommended way to create a custom field for storing prediction scores is through the setup flow in Einstein Prediction Builder, which creates the field for you. If you choose to create the custom field manually instead, choose the Number type. As you name the field, select the AI Prediction checkbox. After the field is enabled, use Einstein Prediction Builder to build a prediction, entering the custom field's exact name and label when setting up the location for storing your prediction scores. Custom formula fields can also reference AI prediction fields. For example, create a number field to predict the payment for a service named LikelyCost__c. Select the AI Prediction checkbox. Then, create a formula field called InitialOffer__c with a formula of LikelyCost__c * 1.5. In this case, LikelyCost__c is a numeric AI Prediction field and InitialOffer__c is just a custom formula field. Once the field is used in a prediction, the resulting value is powered by Einstein Prediction Builder. Whether Einstein Prediction Builder creates the field for you, or you do it on your own, these fields have some limitations. These limitations apply to both AI prediction fields and custom formula fields that reference AI prediction fields: • An AI prediction field can be used for only one prediction. Once it’s being used for a prediction, whether created automatically or manually, you can’t use it for another prediction. • The field value changes only when new predictions are made about the corresponding object. Value changes in this field do not trigger Process Builder, Apex triggers, or workflows. • The Roll-Up Summary field type does not support AI prediction fields.
230 Extend Salesforce with Clicks, Not Code Customize Fields
• Fields enabled as AI prediction fields included in packages are not uploaded, so they can’t be distributed in packages. • We don’t recommend using a custom number field that Einstein Prediction Builder manages in a validation rule. If the prediction changes the field value in a way that violates the validation rule, you can’t save changes to a record that uses the field. These limitations are specific to AI prediction number fields: • The number of decimal places and the character length of the number field must match the settings in Einstein Prediction Builder. Einstein Prediction Builder handles these settings for you when it creates the field. If you create the field, ensure that the number and length match the prediction in Einstein Prediction Builder.
Note: If the field being predicted is a Boolean field type, the number of decimal places defaults to 0 and the character length defaults to 3.
• To create and grant permissions to the field, the Manage Profiles and Permission Sets permission is required. Typically, this permission is set as part of the Customize App permission, but large orgs sometimes keep Manage Profiles and Permission Sets separate. • You can’t disable the field setting. If you have to replace it, delete it and create another field. • You can’t delete a prediction field if Einstein Prediction Builder is still referencing it. • You can’t convert number fields enabled as AI prediction fields to other field types. • The custom field setting, as well as the prediction results (scores) from Einstein Prediction Builder, are available in Salesforce Classic. The Einstein Prediction Builder setup flow is available only in Lightning Experience.
Note: When you let Einstein Prediction Builder create the field for you while building a prediction, it ensures proper scale and precision. If you create the field manually and try to use it when building a prediction, you may get an error message if the custom field is invalid.
Note: When creating the custom predictive field manually, be sure to give field-level security permissions to the Admin role. Otherwise, prediction scores won't be able to be stored in this field.
SEE ALSO: Einstein Prediction Builder Build a Prediction
What’s the Difference between Standard Fields and Custom Fields?
You can add custom fields to standard and custom objects in Salesforce, allowing you to infinitely EDITIONS customize your organization. Although custom fields are similar to the standard fields that come built-in to Salesforce, there are some differences between standard fields and custom fields. Available in: both Salesforce Custom objects and fields let you tailor which data is stored to fit your organization’s needs. Though Classic and Lightning the Lightning Platform database provides several standard objects and accompanying standard Experience fields, you can easily customize how you track and report on your data. Available in: All Editions Custom objects give you the flexibility to store any type of enterprise data that’s relevant to your app, by creating objects. For example, if you’re building a recruiting app, you can create custom objects called Position and Candidate to track information on job openings and candidates, respectively. Categorize and track your data even more granularly by using custom fields. Like standard objects, custom objects have fields that define the data for those object records. You can, for example, add a custom number field Years of Experience to the custom candidate object or a custom text field Description to the custom position object. You can add custom fields to both custom and standard objects. See the following for more information: • Create Custom Fields
231 Extend Salesforce with Clicks, Not Code Customize Fields
• Edit Custom Fields • Manage Fields for a Specific Object • Build a Formula Field • Define Default Field Values • Additional Custom Field Options • Custom Field Attributes • Change the Custom Field Type
Custom Fields Allowed Per Object The number of custom fields allowed per object varies according to your Salesforce Edition.
Personal Contact Group Essentials Professional Enterprise Unlimited Developer Edition Manager Edition Editions Edition Edition and Edition Performance Edition 5 25 100 100 100 500 800 500
There is a 900 maximum hard limit on the total custom fields per object allowed. In addition to the limits listed above, you can install fields from the AppExchange for a total of 900 custom fields. For example, for the Unlimited Edition, you can create 800 custom fields on an object plus install 100 fields from a managed package and 100 of the fields are limited to specific objects. For the Enterprise Edition, you can create 500 custom fields on an object plus install 400 fields from a managed package and 100 of those fields are limited to specific objects. Beyond 800 fields, you are limited to the following objects. • Account • AccountContactRelation • Asset • Campaign • CampaignMember • Case • Contact • ContentVersion • Contract • Custom Object • Individual • KnowledgeArticleVersion • Lead • Opportunity • OpportunityLineItem • Order • OrderItems (Order Product) • Product2 (Products)
232 Extend Salesforce with Clicks, Not Code Customize Fields
• Solution • Users • UserRole (Role)
Custom Field Type Allocations The maximum number of activities, long text area fields, rich text area fields, relationship fields, and roll-up summary fields varies.
Field Type Essentials Personal Contact Group Professional Enterprise Developer Unlimited Edition Edition Manager Edition Edition Edition Edition and Performance Edition Activities No additional allocation 20 100
Long text An object can contain unlimited rich text area and long text area fields, although your edition’s allocation for total area custom fields allowed on an object, regardless of field type, applies. Each object can contain 1,638,400 characters across Rich text area long text area and rich text area fields. When you create a long text area or rich text area field, you set a character limit for the field—the maximum length of the text that can be entered. The default character limit for long text area and rich text area fields is 32,768 (32 KB). The maximum character limit for long text area and rich text area fields is 131,072 (128 KB). The minimum character limit is 256. The maximum size of an image that can be uploaded in a rich text area field is 1 MB.
Relationship No 40 Roll-up additional 25 summary allocation
Note: Geolocation is a compound field that counts toward your org’s limits as three custom fields: one for latitude, one for longitude, and one for internal use.
SEE ALSO: Salesforce Features and Edition Allocations
Custom Field Attributes A custom field entry consists of several attributes.
Field Description # Visible Lines For long text area fields, set the number of lines to be displayed on edit pages. You can display between 2 and 50 lines (the default is 6 lines). If the text does not fit in the specified number of visible lines, scroll bars appear. Long text area fields are fully displayed on detail pages and printable views.
Calculation Options Determines how a roll-up summary field is recalculated after its properties change. Choose Automatic calculation to recalculate a field the next time it’s displayed. Choose Force a mass recalculation of this field as a safety net option to force recalculation of the roll-up summary field values.
233 Extend Salesforce with Clicks, Not Code Customize Fields
Field Description Child Relationship Name The name used in API SOQL relationship queries.
Data Type The data type of a field determines what type of information is in the field. For example, a field with the Number data type contains a positive or negative integer. For more information on data types, see Custom Field Types on page 225.
Decimal Places For currency, geolocation, number, and percent fields, this field represents the number of digits you can enter to the right of a decimal point. The system rounds the decimal numbers you enter, if necessary. For example, if you enter 4.986 in a field with Decimal Places set to 2, the number rounds to 4.99.
Default Value The value to apply when a user creates a record. For checkbox custom fields, choose Checked or Unchecked as the default value to indicate the default when creating records. Don’t assign default values to fields that are both required and unique, because uniqueness errors can result. See Default Field Values on page 284.
Description Text that describes the custom field. This description is for administration purposes only and doesn’t display to users on record detail and edit pages that include the field.
Display Format For auto-number fields, enter a Display Format to control formatting details such as the minimum number of leading zeros and any prefix or suffix for the number. Begin by entering the required minimum {0} as a placeholder for the auto-number without any leading zeros. Add any prefix to your number before this placeholder and insert any suffix text after the placeholder. Insert any date prefixes or suffixes in the form of {YY}, {YYYY}, {MM}, or {DD}, which represent the record creation date in Greenwich Mean Time (GMT). For information on using auto-number formats when entering your Display Format, see Auto-Number Formatting Examples on page 239.
Encrypted If checked, this custom field is encrypted using Shield Platform Encryption.
Note: This page is about Shield Platform Encryption, not Classic Encryption. What's the difference?
External Column Name Available on external objects only. Maps the custom field to an external data source’s table column. For a lookup relationship field, specify the external table column that contains 18-character Salesforce IDs.
External ID For each object that can have custom fields, you can set up to 25 custom auto-number, email, number, or text fields as external IDs. An external ID field contains record identifiers from a system outside of Salesforce. You can use an external ID field to update or upsert records using the API. When using the API or the Data Import Wizard for custom objects and solutions, you can use this field to prevent duplicates by also marking the field as Unique.
234 Extend Salesforce with Clicks, Not Code Customize Fields
Field Description
Note: Custom fields marked as Unique count against an object's limit of 25 External ID fields. Custom indexing that occurs automatically in the background by Salesforce does not count against External ID limits. Not available for external objects. Each external object has an External ID standard field. Its values uniquely identify each external object record in your org.
Filter Criteria The criteria used to select a group of records to calculate the value of a roll-up summary field.
Filtering Disabled For custom fields on external objects, determines whether the field is available in filters.
Formulas Enter the formula for the custom formula field or custom summary formula for reports.
Help Text The text that displays in the field-level help hover text for this field.
Is Name Field For external object fields of type text, specifies this custom field as the name field for the external object. Not available for text area fields. By default, the External ID standard field is the name field for the external object. If you select this checkbox, make sure that the External Column Name specifies a table column that contains name values. Each external object can have only one name field. For internal use only, Salesforce stores the value of the name field from each row that’s retrieved from the external system. This behavior doesn’t apply to external objects that are associated with high-data-volume external data sources.
Label The name of the custom field as you want it to appear.
Latitude and Longitude Display Notation For geolocation fields, determines how the latitude and longitude notation appears in the Salesforce interface. Degrees, Minutes, Seconds A notation for angular measurement that is based on the number 60: there are 360 degrees to a circle, 60 minutes to a degree, and 60 seconds to a minute. Decimal Expresses the value as degrees, and converts the minutes and seconds to a decimal fraction of the degree. Decimal notation doesn’t use cardinal points. North and East are positive values; South and West are negative values. For example, the coordinates for San Francisco can be expressed as follows:
Latitude Longitude Degrees, 37° 46' 30" N 122° 25' 5" W Minutes, Seconds
Decimals 37.794016° –122.395016°
235 Extend Salesforce with Clicks, Not Code Customize Fields
Field Description Regardless of the notation you choose to display in the interface, latitude and longitude are stored in Salesforce as decimals.
Length (for text fields) For text fields, the maximum number of characters that a user can enter in a field (up to 255 characters).
Length (for number, currency, percent fields) For number, currency, and percent fields, the number of digits you can enter to the left of the decimal point, for example, 123.98 for an entry of 3.
Note: Changing the number of digits (either manually or through workflow rules) can result in truncated values in Salesforce Classic and no value changes in Lightning Experience. The following example shows this behavior. 1. Create a percentage field with a length of 16 and 2 decimal places. 2. Create a record that includes the field with set the value to 1235689.22. 3. Change the percent field digits to a length of 3. In Lightning Experience, the record shows the percentage as 1,235,689.22% and in Salesforce Classic, the percentage is shown as 689.22%.
Mask Character For encrypted text fields, determines the character to use for hidden characters. Available options are * and X.
Mask Type For text fields encrypted with Classic Encryption, determines which characters are hidden and the use of dashes in the field. Masked characters are hidden using the character selected in Mask Character. Available options are: Mask All Characters All characters in the field are hidden. Last Four Characters Clear All characters are hidden but the last four display. Credit Card Number The first 12 characters are hidden and the last four display. Salesforce automatically inserts a dash after every fourth character. National Insurance Number All characters are hidden. Salesforce automatically inserts spaces after each pair of characters if the field contains nine characters. Use this option for UK NINO fields. Social Security Number The first five characters are hidden and the last four display. Salesforce automatically inserts a dash after the third and fifth characters. Social Insurance Number All characters are hidden but the last three display. Salesforce automatically inserts a dash after the third and sixth characters.
Master Object The object on the master side of a master-detail relationship used to display the value of a roll-up summary field.
236 Extend Salesforce with Clicks, Not Code Customize Fields
Field Description Related List Label For relationship fields, the title for the related list that displays associated records on the parent record.
Related To For relationship fields, the name of the associated object.
Required Makes the field required everywhere in Salesforce. Not available for external objects. You must specify a default value for required campaign member custom fields. Don’t assign default values to fields that are both required and unique, because uniqueness errors can result. See Require Field Input to Ensure Data Quality on page 328.
Roll-Up Type For roll-up summary fields, choose the type of calculation to make:
Type Description COUNT Totals the number of related records.
SUM Totals the values in the field you select in the Field to Aggregate option. Only number, currency, and percent fields are available.
MIN Displays the lowest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
MAX Displays the highest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
Starting Number For auto-number fields, enter a Starting Number that’s less than 1 billion. Select Generate Auto Number for existing records to automatically number all current records that begin with the starting number that you enter. If deselected, the next record that you enter is assigned the starting number and your older records are blank in this field. For leads, only unconverted leads are assigned a number. When you create records, Starting Number’s value increments to store the number that will be assigned to the next auto-number field created. You can’t edit Starting Number after creating an auto-number field. To edit a Starting Number value, change your auto-number field to a text field and then back to an auto-number field. To restart Starting Number values for fields on objects from a managed package, uninstall and then reinstall the package.
Warning: Be sure that you don’t create records with duplicate auto-number values. An auto-number field can contain up to 10 digits and up to 20 extra characters for your prefix or suffix.
237 Extend Salesforce with Clicks, Not Code Customize Fields
Field Description
Note: • You can’t retrieve the starting number of an auto-number field through Metadata API. To specify a Starting Number while deploying, add a startingNumber tag for your field to your package.xml file. For example:
Sharing Setting For master-detail relationship fields, the Sharing Setting attribute determines the sharing access that users must have to a master record to create, edit, or delete its associated detail records.
Sorting Disabled For custom fields on external objects, determines whether the field is sortable.
Summarized Object The object on the detail side of a master-detail relationship used to provide the values calculated in a roll-up summary field.
Unique If checked, prevents duplicate field values. For text fields, you can control whether values that are identical except for their case are considered unique. Select Treat "ABC" and "abc" as duplicate values to enforce case-insensitive uniqueness, or select Treat "ABC" and "abc" as different values to enforce case-sensitive uniqueness.
Note: Some characters have both single-byte and double-byte versions. For example, all the following characters have single-byte and double-byte versions: “!@#$%^&*(){}[]\|:";',.<>?/~`”. For the purpose of unique field value comparison, the single-byte and double-byte versions of these characters are considered identical. Superscript characters are not treated as unique characters. Text such as ABC² and ABC2 are considered identical.
Note: Custom fields marked as Unique count against an object's limit of 25 External ID fields. Custom indexing that occurs automatically in the background by Salesforce does not count against External ID limits.
Values For picklist fields, a list of available values (up to 255 characters for each value). For picklists, optionally choose to alphabetize the picklist entries. You can also set the first value as the default selection. If you select both options, Salesforce alphabetizes the entries and then sets the first alphabetized value as the default. For multi-select picklists, enter a list of values, select the sorting options that apply, and then enter how many values you want displayed at a time on edit pages. The number of values determines the box height.
238 Extend Salesforce with Clicks, Not Code Customize Fields
Auto-Number Formatting Examples Use these examples when setting the display format for auto-number fields.
Format Displayed Values {0} 3 66 103
{000} 003 066 103
Sample- {00000} Sample- 00003 Sample- 00666 Sample- 10023
Value- {00} {MM} {DD} {YY} Value- 03 12 02 04 Value- 76 03 03 04 Value- 123 11 09 04
PO #{0} {MM}-{DD}-{YY} PO #12233 12-20-04 PO #25 06-07-04 PO #3 07-07-04
SEE ALSO: Create Custom Fields Create a Many-to-Many Relationship Object Reference for Salesforce and Lightning Platform
Geolocation Custom Field
The geolocation custom field allows you to identify locations by their latitude and longitude and EDITIONS to calculate distances between locations. You can calculate the distance between two geolocation fields, such as between a warehouse and Available in: both Salesforce a store. Or you can calculate the distance between a geolocation field and a pair of latitude and Classic and Lightning longitude coordinates, such as between a warehouse and 37.794016°, -122.395016°—the location Experience also known as San Francisco. Latitude values must be within -90 and 90. Longitude values must Available in: All Editions be within -180 and 180. Geolocation is a compound field that counts toward your org’s limits as three custom fields: one for latitude, one for longitude, and one for internal use. Support for the compound field (geolocation) versus the field’s components (latitude and longitude) varies depending on the functionality you’re using in Salesforce. For example, you can create list views that show the field and its components, but you can’t select the compound geolocation field in Apex. You can run SOQL queries only on a geolocation field’s components. Compound fields, including geolocation fields, have the following limitations. • Compound fields are read-only. To update field values, modify the individual field components. • Compound fields are accessible only through the SOAP API, REST API, and Apex. The compound versions of fields aren’t accessible anywhere in the Salesforce user interface. • Although compound fields can be queried with the Location and Address Apex classes, they’re editable only as components of the actual field. Read and set geolocation field components by appending “__latitude__s” or “__longitude__s” to the field name, instead of the usual “__c.” For example:
Double theLatitude = myObject__c.aLocation__latitude__s; myObject__c.aLocation__longitude__s = theLongitude;
You can’t access or set the compound value. • You can’t use compound fields in Visualforce—for example, in an
239 Extend Salesforce with Clicks, Not Code Customize Fields
• If you select compound fields for export in the Data Loader, they cause error messages. To export values, use individual field components. • Custom geolocation and location fields on standard addresses aren’t supported with email templates. • You can’t use compound fields in lookup filters, except to filter distances that are within or not within given ranges. You can use distance lookup filters only in the Metadata API. • The only formula functions that you can use with compound fields are ISBLANK, ISCHANGED, and ISNULL. You can’t use BLANKVALUE, CASE, NULLVALUE, PRIORVALUE, or the equality and comparison operators with compound fields. The equality and comparison operators include = and == (equal), <> and != (not equal), < (less than), > (greater than), <= (less than or equal), >= (greater than or equal), && (AND), and || (OR). Other limitations of geolocation fields include: • Geolocation fields aren’t supported in custom settings. • Geolocation fields aren’t available in dashboards or Schema Builder. • Geolocation fields are available in Visual Workflow and in formula-based workflow and approvals, but they can’t be used in filter-based workflow updates and approvals. • DISTANCE formulas are supported in: – Entry criteria for workflow rules and approval processes – Field update actions in workflow rules and approval processes – Custom validation rules – Lookup filters (in the Metadata API only)
• Geolocation fields and latitude and longitude on standard addresses aren’t supported in Salesforce to Salesforce. • In Developer, Professional, Enterprise, Unlimited, and Performance editions, Salesforce can automatically add or update geolocation fields for Account, Contact, Lead, and WorkOrder records. To use this feature, your administrator must enable the geo data integration rule for each object. For all other objects and editions, set values for latitude and longitude by using SOQL, Workbench, SOAP or REST API, or a geocoding service. You can then use address fields as locatable values. To find geocoding services, search AppExchange. • Geolocation fields are supported in SOQL with the following limitations. – DISTANCE and GEOLOCATION are supported in WHERE and ORDER BY clauses in SOQL, but not in GROUP BY. DISTANCE is supported in SELECT clauses. – DISTANCE supports only the logical operators > and <, returning values within (<) or beyond (>) a specified radius. – When using the GEOLOCATION function in SOQL queries, the geolocation field must precede the latitude and longitude coordinates. For example, DISTANCE(warehouse_location__c, GEOLOCATION(37.775,-122.418), 'km') works but DISTANCE(GEOLOCATION(37.775,-122.418), warehouse_location__c, 'km') doesn’t work. – Apex bind variables aren’t supported for the units parameter in the DISTANCE function. This query doesn’t work.
String units = 'mi'; List
240 Extend Salesforce with Clicks, Not Code Customize Fields
For more information and examples, see the SOQL and SOSL Reference.
SEE ALSO: Custom Field Types Custom Field Attributes
Manage Fields for a Specific Object
1. From the object management settings for the object whose fields you want to view, go to EDITIONS Fields. 2. Click the field label. Available in: both Salesforce Classic and Lightning 3. To modify a custom field, add custom help text, or change the data type, click Edit. Experience 4. If a custom field exists in a Managed - Released package, click Delete to delete the custom field component from future installations. Available in: Contact Manager, Group, 5. To set users’ access to the field, click Set Field-Level Security. This option is available depending Professional, Enterprise, on the edition that you have. Performance, Unlimited, 6. To view who can access the field based on permissions and record type, click View Field Developer, and Accessibility. This option is available depending on the edition that you have. Database.com Editions 7. If the custom field is a dependent picklist, click Change next to the controlling field to edit the Standard fields are not dependency rules. available in Database.com Salesforce Connect external 8. To change External ID, Required, or other attributes under the General Options objects are available in: section, see Custom Field Attributes. Developer Edition and for 9. To restore the field and its data, click Undelete. This option is available only if the field has been an extra cost in: Enterprise, deleted but not permanently erased. The field’s behavior may be different after restoring it. To Performance, and restore the field completely, see Manage Deleted Custom Fields. Unlimited Editions
Note: If your organization uses person accounts, the Account Fields page lists both person account and business account fields. Person accounts use a combination of account and contact fields. The following contact fields are available for person accounts, but not for business accounts. • Fields in the Account Standard Fields list that display with a person account icon. • Fields in the Contact Custom Fields & Relationships list.
Find Where a Field Is Used Find out where a custom field is referenced, such as in a formula or Apex class, with a click of the Where is this used? button. You can see where a field is used and where changes to the field appear before you edit it.
SEE ALSO: Create Custom Settings
241 Extend Salesforce with Clicks, Not Code Customize Fields
Find Where a Field Is Used
Find out where a custom field is referenced, such as in a formula or Apex class, with a click of the EDITIONS Where is this used? button. You can see where a field is used and where changes to the field appear before you edit it. Available in: Salesforce On a custom field’s detail page, click Where is this used? to see the field reference details. To view Classic and Lightning the settings for the layout, formula, or other reference, click a reference label. Experience The list can include these references. Available in: Professional, • Active validation rule Enterprise, Performance, and Unlimited Editions • Layout • Formula field USER PERMISSIONS • Visualforce page • Apex class To view references: • View Setup • Apex trigger • Email template (Salesforce Classic, text based) • Field set • Flow (query) • Lightning component markup (attr) • Process Builder (criteria) • URL button (formula) • Lightning page (related list single) • Lookup filter (lookup and master detail) • Report (column, filter)
Note: References to reports on objects where there’s a foreign key relationship don’t appear. For example, if a custom object has a lookup relationship to Account or any standard object, and the custom fields of Account are added to a report of type CustomObject with Account, then the report isn’t listed for the custom fields on Account.
Considerations • Reference labels link to more information only if there‘s a known settings page for the reference. For example, a report name links to the report settings. But a criteria formula created within a flow doesn’t link to the flow settings. • Within a subscriber org, references in a managed package aren’t included in the list of results. For example, a number field is referenced in a formula. If you add the field to a package and then install the package in a subscriber org, the subscriber org’s field reference detail page doesn’t show that this number field is referenced in a formula field. But new references that are created after installing the managed package in the subscriber org do appear. For example, after you install the managed package and you add the number field to another formula in the subscriber org, the new reference appears. • Only the IDs of reports that are accessible to the user initiating the query are returned. For example, if an admin creates a report and saves the report in a private folder, then the report isn’t listed in the reference detail page for a standard user. • Joined reports aren’t supported and aren’t displayed in the reference detail page. • The list of field references is limited to the first 2,000 entries and sorted alphabetically by reference type.
SEE ALSO: Manage Fields for a Specific Object
242 Extend Salesforce with Clicks, Not Code Customize Fields
Edit Custom Fields
1. From the management settings for the field’s object, go to Fields. EDITIONS 2. Click Edit next to the field’s name. 3. Modify the field attributes. The attributes differ depending on the field type. Available in: both Salesforce Classic and Lightning If you’re editing a picklist, you can change its definition and its values. For picklist settings, see Experience Add or Edit Picklist Values on page 260. Available in: All Editions To change the type of this custom field, see Change the Custom Field Type on page 280. Standard Objects are not 4. Optionally, define custom help text for the field. available in Database.com 5. For lookup and master-detail relationship fields, optionally define a lookup filter. 6. For formula fields, click Next to modify the formula. USER PERMISSIONS 7. In Enterprise, Unlimited, Performance, and Developer Editions, click Next to set the field-level To create or change fields: security for the field. • Customize Application Note: • Editing fields can require changing a large number of records at once. To process these changes efficiently, your request can be queued and you receive an email notification when the process has completed. • To customize the way a custom object’s related list appears on a parent record’s detail page, edit the parent record’s page layout. For example, if you want to edit which fields appear on a custom object’s related list on accounts, you would edit the account page layout. • You cannot change the Field Name if a custom field is referenced in Apex. • When editing fields for accounts, opportunities, cases, contacts, or custom objects, check for any criteria-based sharing rules that use the field in the rules. A field change may affect which records are shared.
SEE ALSO: Define Default Field Values Find Object Management Settings
Delete Fields
1. From the management settings for the field’s object, go to Fields. EDITIONS 2. Click Del next to the name of the field. 3. When prompted, select the Yes, I want to delete the custom field Available in: both Salesforce Classic and Lightning checkbox to confirm, and click Delete. Experience Deleted custom fields and their data are stored until your org permanently deletes them or 15 days has elapsed, whichever happens first. Until that time, you can restore the field and its data. Available in: All Editions For information on restoring deleted custom fields and relationships, see Manage Deleted Custom Fields on page 244. USER PERMISSIONS
To delete custom fields: • Customize Application
243 Extend Salesforce with Clicks, Not Code Customize Fields
Note: • Before deleting a custom field, consider where it’s referenced. You can’t delete a custom field that’s referenced elsewhere. For example, you can’t delete a custom field that’s referenced by a field update or Apex. • You can’t delete a field if that field is being updated by a background job, such as an update to a roll-up summary field. Wait until the background job finishes, and try again. • When you delete a custom field, all of the field history data is deleted and changes are no longer tracked. • A background process periodically runs that cleans up metadata associated with deleted custom fields. This process will affect the Last Modified Date and Last Modified By fields on page layouts, record types, and custom objects.
SEE ALSO: Find Object Management Settings
Manage Deleted Custom Fields
Deleted custom fields and their data are stored until your org permanently deletes them or 15 days EDITIONS has elapsed, whichever happens first. Until that time, you can restore the field and its data. The field counts against the maximum number of custom fields allowed in your org until it’s Available in: both Salesforce permanently deleted by the hard-delete process (see Notes on Hard Deleting Custom Fields). A Classic and Lightning deleted field also counts against the applicable limit for its field type. For example, a deleted custom Experience roll-up summary field counts against the maximum number of roll-up summary fields for your Available in: Contact Salesforce edition. If you receive the error message “Unable to access page” or “No clean data Manager, Group, columns available for custom fields” when trying to create or edit custom fields, you must erase Professional, Enterprise, some fields. Performance, Unlimited, Developer, and Notes on Restored Custom Fields Database.com Editions Page Layouts and Lead • When deleted, the following characters are appended to the end of a custom field's developer Fields are not available in name unless a deleted field already has that developer name: “_del”. These characters remain Database.com when you restore the custom field. • Formula fields are restored in a disabled state, which means they do not contain updated data until you edit and save them. While a formula field is disabled, “#Error!” displays in place of the USER PERMISSIONS formula value. To restore deleted custom • Restored fields do not display in search results immediately after you restore them. It can take fields and relationships: a short time before the restored custom field and its data are available in search results. • Customize Application • Lead fields that are mapped to account, contact, or opportunity fields for lead conversion are To permanently delete still mapped accordingly when restored. custom fields or • Auto number fields continue to increment after they are deleted and contain the correct values relationships: when restored. • Customize Application • Field history data for the deleted custom field is restored.
Notes on Hard Deleting Custom Fields • The estimated time for a hard-delete process varies, and depends on the system demand to maintain overall performance. However, you can monitor and view the details of a hard delete of a custom field by going to the Background Jobs page. From Setup, enter Background Jobs in the Quick Find box, then select Background Jobs. A row with the name “Cleanup of custom field
244 Extend Salesforce with Clicks, Not Code Customize Fields
data when a custom field definition is hard deleted” indicates that a hard delete job is in progress. The Background Jobs page also shows the details of background jobs, including a percentage estimate of the progress. • When an org is at or above 75% of its custom field allocation limit for the current object, Salesforce displays a value for the custom fields that are ready for the hard-delete process value. This value increments when you click Erase or when a field is beyond the 15-day grace period, until the field is moved into the hard-delete process by Salesforce. The value changes only while Salesforce is actively hard deleting the field. • Performance and Unlimited Edition orgs can use a Purge button to initiate the hard-delete process immediately.
Manage Deleted Fields in Lightning Experience Restore or permanently delete a custom field in Lightning Experience. Manage Deleted Fields in Salesforce Classic Restore or permanently delete a custom field in Salesforce Classic. Manually Restore Attributes of Deleted Fields Custom fields consist of several attributes that provide additional information about the field. Some of these attributes are not restored automatically after a field is undeleted and must be restored manually.
SEE ALSO: Purge Deleted Custom Fields Find Object Management Settings
Manage Deleted Fields in Lightning Experience
Restore or permanently delete a custom field in Lightning Experience. EDITIONS 1. From the Object Manager page, click the name of the custom object. 2. Click Fields & Relationships. Available in: Lightning Experience 3. To see a list of soft deleted fields, click Deleted Fields at the top of the Custom Fields & Relationships page. Available in: Contact Manager, Group, 4. From the list of deleted fields, perform the following actions: Professional, Enterprise, a. To permanently remove the custom field and its data, click Erase. Performance, Unlimited, Developer, and b. To restore the field and its data, click Undelete. Database.com Editions Note: If you undelete a custom field, manually restore attributes of the deleted field Page Layouts and Lead that were not automatically restored. Fields are not available in Database.com
SEE ALSO: USER PERMISSIONS Manually Restore Attributes of Deleted Fields To restore deleted custom fields and relationships: • Customize Application To permanently delete custom fields or relationships: • Customize Application
245 Extend Salesforce with Clicks, Not Code Customize Fields
Manage Deleted Fields in Salesforce Classic
Restore or permanently delete a custom field in Salesforce Classic. EDITIONS 1. From the management settings for the field’s object, go to Fields. 2. Click Deleted Fields at the bottom of the list of custom fields and relationships. The number Available in: Salesforce Classic in parentheses indicates the total number of deleted custom fields for this object. For Performance and Unlimited Editions, the Deleted Fields link always displays. For other editions, Available in: Contact this link displays only after you’ve deleted a custom field. Manager, Group, 3. Use the list of deleted fields to perform the following actions: Professional, Enterprise, Performance, Unlimited, a. To view details about a field, click the field label. Developer, and b. To permanently remove the custom field and its data, click Erase. Database.com Editions c. To restore the field and its data, click Undelete. Page Layouts and Lead Fields are not available in Note: If you undelete a custom field, manually restore attributes of the deleted field Database.com that were not automatically restored.
USER PERMISSIONS SEE ALSO: To restore deleted custom Manually Restore Attributes of Deleted Fields fields and relationships: • Customize Application To permanently delete custom fields or relationships: • Customize Application
246 Extend Salesforce with Clicks, Not Code Customize Fields
Manually Restore Attributes of Deleted Fields
Custom fields consist of several attributes that provide additional information about the field. Some EDITIONS of these attributes are not restored automatically after a field is undeleted and must be restored manually. Available in: both Salesforce 1. Add the field to any page layouts that changed during the time the custom field was deleted. Classic and Lightning If reports and page layouts were not edited, the restored field remains on them. Experience 2. Make the field unique if necessary. Salesforce automatically removes the unique attribute from Available in: Contact any deleted custom field. Manager, Group, Professional, Enterprise, 3. Make the field required if necessary. Salesforce automatically removes the required attribute Performance, Unlimited, for any deleted custom field. Developer, and 4. Add the custom field to any appropriate Salesforce AppExchange packages. Salesforce Database.com Editions automatically removes deleted custom fields from packages that contain them. Page Layouts and Lead 5. Convert lookup relationships to a master-detail relationship if necessary. Salesforce converts all Fields are not available in relationships to lookup relationships when they are deleted. To convert a lookup relationship Database.com to a master-detail relationship, populate all the applicable records with the appropriate data.
6. Redefine any field dependencies that Salesforce removed when the field was deleted. USER PERMISSIONS 7. Edit and save any formula fields. Saving prompts a syntax check; if necessary, resolve errors. To restore deleted custom 8. Set up field history tracking if necessary. If the list of fields enabled for history tracking was fields and relationships: modified during the deletion process, the restored field is no longer setup to track field history. • Customize Application To permanently delete custom fields or relationships: • Customize Application
Purge Deleted Custom Fields
Deleted fields are available for 15 days until they’re hard deleted. During that time, the field continues EDITIONS to count toward your custom field allocation. You can use the Purge button to initiate the hard-delete process and free up custom field allocation for your org. Available in: Salesforce An object’s Deleted Fields detail page lists the recently deleted fields. These fields are removed Classic from the object but remain in the system until they’re hard deleted. When you’re at or above 75% Available in: Enterprise, of your custom field allocation limit and have fields that are ready to hard delete, Salesforce displays Performance, and the Purge button. Click the button to free up custom fields faster than the automated process. Unlimited Editions After you click Purge, Salesforce asks you to confirm the action. The custom fields that are in the ready for the hard-delete state move to the hard-delete process state. The hard-delete process completely removes the field and the associated system data. If changing the status of the fields takes longer than 30 seconds, Salesforce sends an email with more information to the user who clicked the button.
SEE ALSO: Manage Deleted Custom Fields
Additional Custom Field Options Changing Page Layouts To change the location of a new custom field, edit the page layout for the appropriate tab.
247 Extend Salesforce with Clicks, Not Code Customize Fields
Using Record Types If your organization uses record types, edit the record type to modify which picklist values are visible for the record type. Tracking Custom Field History You can select which custom fields to track on the History related list of custom objects and most standard objects. All entries include the date, time, nature of the change, and who made the change. History data does not count against your organization’s storage limit. Using the Translation Workbench If your organization uses the Translation Workbench, notify your translators that new fields need translations. Activity Custom Fields Activity custom fields can apply only to tasks or only to events, or to both tasks and events. For example, you can create one Time Spent field and then add it to both the event page layout and the task page layout. Mapping Custom Lead Fields For lead custom fields, you can click Map Lead Fields to specify which custom lead fields to map to custom account, contact, and opportunity fields during a lead conversion.
SEE ALSO: Which Standard Fields Can I Encrypt? Which Custom Fields Can I Encrypt?
Editing Rich Text Area Fields in Records
Use rich text area fields to improve the appearance of text, including adding images and hyperlinks. EDITIONS Rich text area fields use the rich text editor to format content. The rich text editors for custom fields in Lightning Experience and the Salesforce mobile app have a few differences compared to rich Available in: the Salesforce text editors in Salesforce Classic. mobile app, Salesforce Classic, and Lightning In Lightning Experience and the Salesforce mobile app, rich text editors for custom fields use the Experience open-source Quill library. In Salesforce Classic, rich text editors for custom fields use CKEditor. In Lightning Experience, Salesforce Knowledge and emails also use the CKEditor. The rich text editors Available in: Essentials, have the following toolbar buttons. Contact Manager, Group, Professional, Enterprise, Rich Text Editor Toolbar In Lightning Experience In Salesforce Classic Performance, Unlimited, Button for Custom Fields and the Salesforce mobile and Developer Editions app Color USER PERMISSIONS
Format Font (Bold, Italic, To create or change custom Underline, Strikethrough) fields: • Customize Application Format Body (Bulleted List, Numbered List, Indent, and Outdent)
Align Text (Left Align, Center Align, and Right Align)
Insert Link
Insert Image
248 Extend Salesforce with Clicks, Not Code Customize Fields
Rich Text Editor Toolbar Button for In Lightning Experience and the In Salesforce Classic Custom Fields Salesforce mobile app Remove Formatting
Undo and Redo Last Action
Note: We recommend using the toolbar to format your content. The rich text editor provides only a WYSIWYG interface. You can’t edit HTML tags. When you copy content from a web page or another source and paste it into the editor, unsupported tags are removed. Text enclosed in unsupported tags is preserved as plain text. HTML markup counts against the character limit of the field. For more information, see Rich Text Area Field Limitations. Note these differences across rich text editors in Lightning Experience and the Salesforce mobile app compared to Salesforce Classic. In Lightning Experience and the Salesforce mobile app: • Spaces are considered non-empty values. • The default font family is Salesforce Sans, Arial, sans-serif. • The Insert Link button enables you to enter a URL with the _blank target value by default. This button appears disabled when the record edit page is loaded, and is enabled after you activate the editor with your keyboard or mouse. • The Insert Image button enables you to insert an image by uploading it or by selecting one that has been previously uploaded to your org. • Use keyboard shortcuts to undo and redo content formatting. In Windows, undo your last action by pressing Ctrl+Z, and reverse your last undo by pressing Ctrl+Y. On Mac OS, use Cmd+Z and Cmd+Y. Alternatively, use the Edit menu in your browser to undo or redo your changes. In Salesforce Classic: • Spaces are considered empty values. • The default font family is Arial, Verdana, Trebuchet MS, sans-serif. • Color formatting is preserved when you switch to Salesforce Classic to edit a custom field that’s been formatted in Lightning Experience or the Salesforce mobile app. This occurs even though the Color button isn’t available in Salesforce Classic. • The Insert Link button lets you enter a URL with a selection of protocols and target values. When you switch to Lightning Experience or the Salesforce mobile app and edit the custom field, unsupported protocols or target values aren’t preserved. • The Insert Image button lets you insert an image by uploading it or reference one that’s hosted on another server.
Implementation Tips • Specify the size of the editor box for a rich text field by configuring the Number of lines displayed property in the field’s setup. • When you view or print content, Salesforce preserves the formatted version of the rich text. • Searches of content that contains rich text area fields ignore images and tags. • Deleting a rich text area field moves it to the Deleted Fields section on the custom object or Salesforce Knowledge article types. • You can convert rich text area fields into long text area fields only. Any images get deleted the next time you save the long text area field. After converting, markup is hidden in the long text area field but it isn’t removed from the record, so if you change your mind, you can restore the markup before you save the record. • The text part of a rich text area field counts toward data storage for the object that contains the field.
249 Extend Salesforce with Clicks, Not Code Customize Fields
Pasting Content from External Sources • You can copy and paste text from external sources, such as Microsoft® Word, but sometimes doing so requires reapplying the formatting. • Text from external sources can include HTML tags and special formatting that you can’t see and don’t need. The tags are counted against the character limit of a field. We recommend pasting text into a plain text editor such as Notepad on Windows or TextEdit on macOS first. Copy the text from the plain text editor, paste it into a rich text field, and apply formatting using the rich text field’s buttons. • JavaScript and CSS are treated as text. For example, if you’re creating an Idea through the API, the JavaScript or CSS code is removed without warning. Salesforce supports a limited number of approved HTML tags. • When a rich text area field is used in a formula, the HTML tags are stripped out before the formula is run. • Rich text area fields can be filtered and summarized in reports, but HTML tags and special formatting aren’t included in report results. For example, some text becomes “some text” instead of some text or some text. • You can use a rich text area field in a mail merge, but the HTML tags are included as text in the resulting document. Images aren’t merged.
Images in Rich Text Area Fields • The maximum size of an image that can be uploaded in a rich text area field is 1 MB. You can upload only .gif, .jpg, and .png file types. • To upload many images, use API version 20 or later.
Note: When you upload images via the API, the alt attribute isn’t populated unless you specified it separately.
• Images uploaded into a rich text area field are extracted in your org’s weekly export and included in the exported data. • Images in rich text area fields count toward file storage for the object that contains the field. • You can’t add a hyperlink to an image. • You can’t upload an image to a rich text area using the file:// protocol in the URL field. Instead, use http:, https:, data:, //, /, or a relative URL. • You can’t resize images in Lightning Experience and the Salesforce mobile app. An exception to this is in Lightning Knowledge when using the Chrome browser.
Formatting Support The power of the rich text editor is in its WYSIWYG interface. Type in the editor and use the toolbar to format your content as much as you can. When you paste formatted content from another source, you can expect some formatting differences in Lightning Experience and the Salesforce mobile app. Here are formatting considerations to look out for.
Warning: If you add a custom rich text area field in Salesforce Classic and edit it in Lightning Experience, you can also expect the formatting differences. Saving your changes in Lightning Experience overwrites the original formatting you had in Salesforce Classic and conversely. Alternatively, you can fix some of the formatting using the toolbar or switch to Salesforce Classic to perform your edits. Colors The Color button is available in Lightning Experience only. Color formatting is preserved when you edit the rich text field in Salesforce Classic. The rich text field in Lightning Experience handles color formatting in RGB format, which adds the tag around your text. The rich text field in Salesforce Classic handles color formatting in hexadecimal format, which adds the tag around your text. The RGB and hexadecimal value depends on the color you choose.
250 Extend Salesforce with Clicks, Not Code Customize Fields
Definition lists Formatting for definition lists is preserved, but the styling appears different in Lightning Experience and the Salesforce mobile app. Definition terms are not bold. Fonts Pasting text with a predefined font face, color, or size converts the font tag into a span tag with the style attribute. Headings Heading styles are different in Lightning Experience and Salesforce Classic. Headings in Salesforce Classic are bold and become smaller in size as the header level increases in number. Headings in Lightning Experience have the following font size and weight. • h1: 24 px (not bold) • h2: 18 px (bold) • h3: 18 px (not bold) • h4: 14 px (bold) • h5: 14 px (not bold) • h6: 12 px (bold) Inline styles on h1, h2, h3, h4, h5, and h6 tags are not supported and are ignored. Hyperlinks Hyperlinks always open in a new window or tab in Lightning Experience and the Salesforce mobile app using target=”_blank”. In Salesforce Classic, you can use different target values in hyperlinks in the rich text field. If you edit a rich text field with such a link in Lightning Experience or the app, the target value is converted to _blank. Inline styles In Salesforce Classic, inline styles are supported on div, span, p, br, and hr tags. In Lightning Experience and the Salesforce mobile app, inline styles are supported only on span tags. Lists Nested ordered lists in rich text fields are numbered differently in Salesforce Classic than they are in Lightning Experience and the Salesforce mobile app. In Salesforce Classic, nested ordered lists are numbered with this pattern: 1, 1, 1. In Lightning Experience and the Salesforce mobile app, nested ordered lists are numbered with this pattern: 1, a, i. In Lightning Experience and the Salesforce mobile app, you can’t nest a bulleted list within a numbered list. The nested bulleted list is converted to a numbered list when you paste it into the editor. You also can’t nest a numbered list within a bulleted list. The nested numbered list is converted to a bulleted list when you paste it into the editor.
Warning: Nesting lists of different types is supported in Salesforce Classic only. Don’t edit an existing rich text area field containing a nested list of a different type in Lightning Experience and the Salesforce mobile app. If you do, the nested list is converted to the same type as its parent list, even if you don’t edit the list itself. Nested lists of the same type are supported. However, pasting a nested list into the editor flattens the list into one list in Lightning Experience and the Salesforce mobile app. For example, a nested bulleted list within a bulleted list becomes a single bulleted list when pasted. For nested lists of the same type, use the toolbar to adjust your list formatting. You can also press the Tab key or Shift+Tab to create a nested list item or remove a nested list item.
Note: In Lightning Experience and the Salesforce mobile app, pasting lists that are copied from Microsoft® Word is not supported and results in list items getting converted into paragraphs. Although they look visually like lists, they are pasted as p tags.
251 Extend Salesforce with Clicks, Not Code Customize Fields
Paragraphs and line breaks Pressing the Enter key creates a paragraph in Lightning Experience and the Salesforce mobile app. However, pressing the Enter key in Salesforce Classic adds a
element inside the current paragraph. The visual difference is minor. Markup for blank lines is
in Salesforce Classic. If you create text in a rich text field in Lightning Experience or the Salesforce mobile app and later edit it in Salesforce Classic, markup for the blank lines is converted to
. Subsequent edits in Lightning Experience or the Salesforce mobile app don’t change blank lines back to their original markup. Paragraphs in rich text editors add extra characters to the text when saved in Lightning Experience and the Salesforce mobile app. Each paragraph contributes seven characters to the character count. For example, if your admin specifies a 5000 character limit, you can enter only 4993 characters in the rich text editor of a custom field in Lightning Experience. Breaking the text into multiple paragraphs further reduces the number of characters you can enter. Blank lines contribute no visible characters, but contribute several characters with their markup. Special Characters Rich text field values are returned in HTML format. Some characters are escaped when the custom field value is retrieved through the API. • Ampersand character & is returned as & • Greater than character > is returned as > • Less than character < is returned as < • Quote character " is returned as " • Single quote character ' is returned as ' Tables In Salesforce Classic, Lightning Experience, and the Salesforce mobile app, pasting tables is supported, but you can edit only the content within the tables. Text-level markup • Addresses with address tags cause enclosing list formatting to be removed. • Nested quotes using q tags are not supported. • Strikethrough text uses strike tags. • Teletype text within tt tags is converted to use code tags. This table lists supported HTML tags and formatting considerations in Lightning Experience and the Salesforce mobile app. When you edit a rich text field or paste text with unsupported tags in Lightning Experience and the Salesforce mobile app, those tags are removed. Text that was enclosed in unsupported tags is preserved as plain text.
HTML Tags Supported in Custom Fields in Comments for Lightning Experience and the Salesforce Supported in Lightning Experience and the Mobile App Salesforce Classic Salesforce Mobile App? a The target attribute is always set to _blank. This tag is removed if href has no value.
abbr
acronym This tag is converted into an abbr tag.
address When text with this tag is nested in a list and pasted in the editor, the list tags,ol, li, and ul, are removed. Some tags before the address tag get nested in address.
252 Extend Salesforce with Clicks, Not Code Customize Fields
HTML Tags Supported in Custom Fields in Comments for Lightning Experience and the Salesforce Supported in Lightning Experience and the Mobile App Salesforce Classic Salesforce Mobile App?
b
bdo
big
blockquote Consecutive block quotes are merged.
br Line breaks are nested in p tags.
caption
cite
code
col
colgroup
dd
del
dfn
div
dl
dt Definition terms are not bold.
font Pasting text with a predefined font face, color, or size converts the font tag into a span tag with the style attribute.
h1 Inline styles on headings are not supported.
h2 Inline styles on headings are not supported.
h3 Inline styles on headings are not supported.
h4 Inline styles on headings are not supported.
h5 Inline styles on headings are not supported.
h6 Inline styles on headings are not supported.
hr
i
img
ins
253 Extend Salesforce with Clicks, Not Code Customize Fields
HTML Tags Supported in Custom Fields in Comments for Lightning Experience and the Salesforce Supported in Lightning Experience and the Mobile App Salesforce Classic Salesforce Mobile App?
kbd
li Pasting a nested list of the same type flattens the list into one list, for example, a nested bulleted list within a bulleted list. Use the toolbar to adjust your list formatting.
ol Nesting an ordered list (numbered) in an unordered list (bulleted) converts the ordered list into an unordered list.
p Pressing Enter creates a new p.
pre
q Nested quotes are not supported.
s This tag is converted into a strike tag.
samp
small
span This tag is nested in a p tag, which adds extra padding around the text.
strike
strong
sub Nested sub tags are merged.
sup Nested sup tags are merged.
table
tbody
td
tfoot
th
thead
tr
tt This tag is converted into a code tag.
u
ul Nesting an unordered list (bulleted) in an ordered list (numbered) converts the unordered list into an ordered list.
254 Extend Salesforce with Clicks, Not Code Customize Fields
HTML Tags Supported in Custom Fields in Comments for Lightning Experience and the Salesforce Supported in Lightning Experience and the Mobile App Salesforce Classic Salesforce Mobile App?
var
SEE ALSO: Create Custom Fields Rich Text Fields in Knowledge Articles
Rich Text Area Field Limitations
Keep these limitations in mind when working with rich text area fields. EDITIONS Rich text area fields aren’t available in self-service portals and they aren’t supported for external objects. Also, consider the following limitations. Available in: the Salesforce mobile app, Salesforce Character Limits Classic, and Lightning • Salesforce supports up to 131,072 characters for each rich text area field, including the Experience HTML tags. If desired, you can set a lower limit. Available in: Essentials, • An object can contain unlimited rich text area and long text area fields, although your Contact Manager, Group, edition’s allocation for total custom fields allowed on an object, regardless of field type, Professional, Enterprise, applies. Each object can contain 1,638,400 characters across long text area and rich text Performance, Unlimited, area fields. When you create a long text area or rich text area field, you set a character limit and Developer Editions for the field—the maximum length of the text that can be entered. The default character limit for long text area and rich text area fields is 32,768 (32 KB). The maximum character limit for long text area and rich text area fields is 131,072 (128 KB). The minimum character limit is 256. • You can’t paste special characters, such as bullets or curly quotes, into a rich text field from another application. It’s best to type or paste in plain text and use the rich text editor to format it. • HTML code isn’t supported in the Salesforce HTML editor. HTML code is treated as text. • The character count includes HTML markup that is not visible in the editor. The HTML markup is returned through the API. Depending on how much formatting you apply, the number of characters you can type into the rich text field is fewer than the specified limit. This is because the HTML markup counts against the character limit of a field. For example, bold formatting includes the tag around your text and adds up to 7 more characters. Special characters like & are encoded as & which adds up to 5 more characters. Also, the rich text field in Lightning Experience and Salesforce Classic can vary in HTML markup, such as with using RGB or hexadecimal values when color formatting is applied. Paragraph and line breaks also insert the and
tags, counting against the character limit. See Editing Rich Text Area Fields in Records for information on formatting support. Formatting and Toolbar Differences Between Lightning Experience and Salesforce Classic The rich text editors for custom fields in Lightning Experience and the Salesforce mobile app come with a few differences, as compared to rich text editors in Salesforce Classic. See Editing Rich Text Area Fields in Records. Images and Hyperlinks • You can’t disable specific rich text area features. For example, you can't disable support for hyperlinks or images on certain fields. • You can’t upload an image to a rich text area using the file:// protocol in the URL field. Instead, use http:, https:, data:, //, /, or a relative URL. • When uploading an image to a rich text area, you must enter a URL that is valid and well-formed.
255 Extend Salesforce with Clicks, Not Code Customize Fields
Reports • Only the first 254 characters in a rich text area or a long text area are supported with the “contains” operator in a report filter. • The first 999 characters in a standard rich text area or a long text area are displayed in a report. For custom fields, only the first 255 characters are displayed. If you download the report as Details Only, the entire field is available.
Valid Range for Date Fields Only dates within a certain range are valid. The earliest valid date is 1700-01-01T00:00:00Z GMT, or just after midnight on January 1, 1700. The latest valid date is 4000-12-31T00:00:00Z GMT, or just after midnight on December 31, 4000. These values are offset by your time zone. For example, in the Pacific time zone, the earliest valid date is 1699-12-31T16:00:00, or 4:00 PM on December 31, 1699.
Classic Encryption for Custom Fields
Restrict other Salesforce users from seeing custom text fields that you want to keep private. Only EDITIONS users with the View Encrypted Data permission can see data in encrypted custom text fields. Before you begin working with encrypted custom fields, review these implementation notes, Available in: both Salesforce restrictions, and best practices. Classic and Lightning Experience Implementation Notes Available in: Developer, Enterprise, Performance, • Encrypted fields are encrypted with 128-bit master keys and use the Advanced Encryption Unlimited, and Standard (AES) algorithm. You can archive, delete, and import your master encryption key. To Database.com Editions enable master encryption key management, contact Salesforce. • You can use encrypted fields in email templates but the value is always masked regardless of whether you have the View Encrypted Data permission. • If you have the View Encrypted Data permission and you grant login access to another user, the user can see encrypted fields in plain text. • Only users with the View Encrypted Data permission can clone the value of an encrypted field when cloning that record. • Only the
Restrictions Encrypted text fields: • Can’t be unique, have an external ID, or have default values. • Aren’t available for mapping leads to other objects. • Are limited to 175 characters because of the encryption algorithm. • Aren’t available for use in filters such as list views, reports, roll-up summary fields, and rule filters. • Can’t be used to define report criteria, but they can be included in report results. • Aren’t searchable, but they can be included in search results. • Aren’t available for Connect Offline, Salesforce for Outlook, lead conversion, workflow rule criteria or formulas, formula fields, outbound messages, default values, and Web-to-Lead and Web-to-Case forms.
Best Practices • Encrypted fields are editable regardless of whether the user has the View Encrypted Data permission. Use validation rules, field-level security settings, or page layout settings to prevent users from editing encrypted fields.
256 Extend Salesforce with Clicks, Not Code Customize Fields
• You can still validate the values of encrypted fields using validation rules or Apex. Both work regardless of whether the user has the View Encrypted Data permission. • To view encrypted data unmasked in the debug log, the user must also have the View Encrypted Data in the service that Apex requests originate from. These requests can include Apex Web services, triggers, workflows, inline Visualforce pages (a page embedded in a page layout), and Visualforce email templates. • Existing custom fields can’t be converted into encrypted fields nor can encrypted fields be converted into another data type. To encrypt the values of an existing (unencrypted) field, export the data, create an encrypted custom field to store that data, and import that data into the new encrypted field. • Mask Type isn’t an input mask that ensures the data matches the Mask Type. Use validation rules to ensure that the data entered matches the mask type selected. • Use encrypted custom fields only when government regulations require it because they involve more processing and have search-related limitations.
Note: This page is about Classic Encryption, not Shield Platform Encryption. What's the difference?
SEE ALSO: Create Custom Fields
Time Custom Field Track time, unbound to a date, with this custom field type. The time type is useful for time management, event planning, and project management. You can select the time field type when you create a custom field. The time type is a timestamp without the date included. However, a time field value’s precision is in milliseconds. A date/time field value’s precision is in seconds. Use the time field type when you require a time of day that isn’t specific to a single date. For example, use it to display business hours, or if you want to compare times of the day to calculate a duration.
Time Field Behavior The display and management of time field values observes the following behaviors. • In formulas, get a time value from the TIMEVALUE function. Use TIMENOW, HOUR, MINUTE, SECOND, and MILLISECOND functions with time in formulas. • The time field type is represented in the Metadata API as a FieldType enumeration value. • A time field displays a value based on your Personal Locale setting on the Language & Time Zone page in My Settings. See Supported Date and Time Formats (ICU) in Salesforce Help for each locale’s display Time Format. • The unit for adding or subtracting time values is milliseconds. For example, Timefield1__c has the value “5:00pm”: Timefield1__c + 600000 is “5:10pm” Timefield1__c - 600000 is “4:50pm” Time fields don’t include a date. So, adding 25 hours to a time value is the same as adding one hour. The clock restarts after 24 hours.
• You can subtract one time field from another in a formula. The result is in milliseconds. For example, TimeField1__c has the value “10:00pm” and TimeField2__c has the value “9:00pm”: TimeField1__c - TimeField2__c is 3600000 The result is never a negative number. Subtraction is the difference between two time values, using a 24-hour clock.
257 Extend Salesforce with Clicks, Not Code Customize Fields
For example, when calculating the number of hours a business is open, you use the following formula: (ClosedTime - OpenTime) / 3600000. ClosedTime = 5 PM, OpenTime = 8 AM, ClosedTime - OpenTime = 9 hours ClosedTime = 5 AM, OpenTime = 7 AM, ClosedTime - OpenTime = 22 hours
Time Field Limitations Be aware of the following limitations when using a time field type. The time field: • Isn’t supported in Flow Builder, Process Builder, and Schema Builder. • Doesn't support the creation of custom index for SOQL queries. • Isn’t available for standard lookup relationships in external objects.
Note: In formula expressions, use the international date format (ISO) for text arguments. For example, use TIMEVALUE("11:30:00.000") instead of TIMEVALUE("11:30 AM").
Time Fields in Salesforce Classic In Salesforce Classic, you have several formatting options when setting time values. For example, you can set time values to include seconds, milliseconds, time zone, and use 24-hour notation. Time Fields in Lightning Experience In Salesforce Lightning Experience, you can choose a time from a dropdown list of selectable options.
SEE ALSO: Create Custom Fields Locales Overview Formula Operators and Functions Using Date, Date/Time, and Time Values in Formulas Custom Field Attributes Define Default Field Values
Time Fields in Salesforce Classic In Salesforce Classic, you have several formatting options when setting time values. For example, you can set time values to include seconds, milliseconds, time zone, and use 24-hour notation.
Time Field Format • The time custom field type can use 24-hour notation. You can save a time value in HH:MM, for example, 14:40. • Time fields support the following input formats.
Format Example hh:mm:ss aa 10:30:25 AM
hh:mm:ss.SSS a 10:30:25.125 AM
HH:mm:ss.SSS 14:30:25.125
258 Extend Salesforce with Clicks, Not Code Customize Fields
Format Example
HH:mm:ss.SSSZ 14:30:25.125Z displays as GMT
hh:mm a 10:30 AM
hh:mma 10:30AM
h a 4 PM
ha 4PM
H:mm 1:23 is 1:23 AM
H 14 is 2:00 PM
Hmm 123 is 1:23 AM
HHmm 1434 is 2:34 PM
h= Hour of day (1-12), H = Hour of day (0-23), m= minute, s= seconds, S= milliseconds, a= AM or PM, Z= GMT time zone. • Use the HH:MM:SS.MS format when loading values with Data Loader.
• Use the HH:MM:SS.MS format to set a default value for a field, such as TIMEVALUE("10:30:00.000") for 10:30 AM.
Time Fields in Lightning Experience In Salesforce Lightning Experience, you can choose a time from a dropdown list of selectable options. The following example shows the check-in and check-out times for a hotel in Lightning Experience.
259 Extend Salesforce with Clicks, Not Code Customize Fields
Add or Edit Picklist Values
Add or edit values in a custom picklist from the fields area of an object. If the picklist uses a global EDITIONS picklist value set, you can change its values only by editing the global value set. Your changes affect all picklists that inherit their values from that global value set. Available in: both Salesforce Note: Changes to picklist values are logged in Setup Audit Trail. To view the audit history: Classic and Lightning From Setup, enter View Setup Audit Trail in the Quick Find box, then select Experience View Setup Audit Trail. Available in: All Editions 1. Navigate to the fields area for your object. 2. In the Custom Fields & Relationships related list, click the name of the picklist field to update. USER PERMISSIONS
3. In the Values section, click Edit next to a value. To change picklists: 4. Change the value’s name, and optionally make the value the default for the master picklist. • Customize Application 5. Assign a color to use in charts by clicking the button and selecting how to assign colors to values. • Assign fixed colors to all values assigns a fixed color to each value from the standard set of chart colors. The Chart Colors column shows the assigned colors. For example, if you want Closed Lost values always to be red in charts grouped by Opportunity Stage, assign red to that picklist value. • Assign colors to values dynamically assigns colors when a chart is generated. For example, if you need only certain picklist values to have fixed colors in charts, manually assign colors to those values and leave the rest to be assigned dynamically.
Note: Chart colors aren’t available for multi-select picklists, currency picklists, or Task Subject, Event Subject, Knowledge Validation Status, and Opportunity Competitor picklists.
Tip: • If you use record types, changing the default value of the master picklist doesn’t affect the default value of the picklist for a record type. • For Ideas, setting the default value of the Categories or Status picklists doesn’t affect the default value on the Ideas pages. • If you change the label for a picklist value that’s used as a filter criterion, the picklist value is automatically removed from the filter criteria. For example, if your report contains a filter where Lead Source equals Email or Web and you change the picklist value Web to Referral, your report filter changes to Lead Source equals Email. If the changed picklist value was the only value specified for a particular filter, it continues to show up in your filters, but an error appears.
6. Click Save. 7. To make the picklist required (if it’s not already), click Edit at the top of the detail page, and check Always require a value in this field in order to save a record. 8. To change the picklist from unrestricted to restricted or vice-versa, adjust the Restrict picklist to the values defined in the value set setting. 9. To open an easy-to-print list of your picklist values, click Printable View.
Note: If your org uses the Translation Workbench, notify your translators that the translations can be outdated when you change picklist values.
Picklists with Additional Information Picklist Limitations
260 Extend Salesforce with Clicks, Not Code Customize Fields
Replace Picklist Values As your business needs change, replace picklist values with more relevant alternatives. Replacing a value globally replaces that field value on all existing records. Remove a Picklist Value Remove or replace custom picklist values to update the records that have the picklist field. Protect Picklist API Names for Formulas and Integrations When you create a picklist value, an API Name that matches the Label is assigned. By default, the API Name can be changed at any time, but you can choose to protect the API Name. Sort Picklists Manage Inactive Picklist Values Establish upper bound limits, deactivate, reactivate, or remove a value from a restricted or unrestricted picklist.
SEE ALSO: Manage Inactive Picklist Values Replace Picklist Values Protect Picklist API Names for Formulas and Integrations Picklist Limitations
Picklists with Additional Information These standard picklist fields have additional information that you can edit.
Picklist Description Partner Role (for accounts) Roles of account partners, for example, Consultant, Supplier. These options are available when you add an account to the Partners related list of an account or opportunity. To edit, from Setup, enter Partner Roles in the Quick Find box, then select Partner Roles. Enter the name of the partner role in the “Role” column. In the “Reverse Role” column, enter the corresponding reverse partner role. Assigning a partner role to an account creates a reverse partner relationship so that both accounts list the other as a partner. Each role and reverse role value can have up to 40 characters.
Priority (for cases) Urgency of case, for example, Low, High. If you delete a value, you have the option to map the deleted value to another existing value in all your org’s cases. Each picklist value can have up to 40 characters.
Status (for campaign members) State of a campaign member, for example, Sent or Responded. If you delete a Status value, you have the option to map the deleted value to another existing value. The new replacement value is automatically added to the member status for campaigns that contained the deleted value.
261 Extend Salesforce with Clicks, Not Code Customize Fields
Picklist Description If the deleted value is the default member status for a campaign, the new replacement value becomes the default status for that campaign.
Status (for cases) State of case, for example, New, On Hold. If you delete a value, you have the option to map the deleted value to another existing value in all your org’s cases. Each picklist value can have up to 40 characters.
Status (for contracts) State of the contract in the contract business process. You can add values to this picklist and organize each value into one of several categories, for example, “Draft”, “In Approval Process”, or “Activated”. Then sort your contracts using these categories in reports and views.
Contact Role (for contracts) Role of a contact on a contract, for example, Business User, Decision Maker. These options are available when you add a contact to the Contact Roles related list of a contract. To edit, from Setup, enter Contact Roles in the Quick Find box, then select Contact Roles on Contracts. Each picklist value can have up to 40 characters.
Lead Status (for leads) State of the lead, for example, Open, Qualified. Select one value as the “Default Status” assigned to all new leads created manually, via imports, or via your website. Select one or more values as the “Converted Status” assigned to converted leads. When you convert qualified leads into an account, contact, and opportunity, you can select one of the “Converted” statuses to assign to the lead. Leads with a “Converted” status type are no longer available in the Leads tab, although you can include them in reports. If you delete a value, you have the option to map the deleted value to another existing value in all your org’s leads. Each value can have up to 20 characters.
Contact Role (for opportunities) Role of a contact for an opportunity, for example, Business User, Decision Maker. These options are available when you add a contact to the Contact Roles related list of an opportunity. To edit, from Setup, enter Contact Roles in the Quick Find box, then select Contact Roles on Opportunities. Each picklist value can have up to 40 characters.
Stage (for opportunities) Sales process stages, for example, Prospect, Proposal. This picklist also affects the Type and Forecast Category values of an opportunity. Specifically, changing the Type or Forecast
262 Extend Salesforce with Clicks, Not Code Customize Fields
Picklist Description Category for a Stage picklist value updates all opportunities that have that stage value. To edit, from the management settings for opportunities, go to Fields, and then click Edit next to Stage. To deactivate an active stage, click Del next to the stage. On the mapping page, don't replace the stage with another existing value; just click Save. The stage now appears in the Inactive Stage Picklist Values related list. The stage is no longer in use but can exist in older opportunity records.
Status (for solutions) Status of a solution, for example, Draft, Reviewed. Mark one or more values as “Reviewed”. When users solve cases using solutions, they can view which solutions have been reviewed and which have not. Each picklist value can have up to 40 characters.
Priority (for tasks) Importance of the task, for example, High, Normal, Low. Set one value as the default priority of all new tasks, and one value as the highest priority. If you delete a value, you have the option to map the deleted value to another existing value in all your org’s tasks. Each picklist value can have up to 20 characters.
Status (for tasks) State of a task, for example, Not Started, Completed. Choose at least one value as the “Closed” status and one value as the “Default” status for all new tasks. If you delete a value, you have the option to map the deleted value to another existing value in all your org’s tasks. Each picklist value can have up to 40 characters.
Task Type (for tasks) Send Email Default specifies the default task type assigned when the task is sending email or mass email, and when tasks are created via inbound email, such as Email to Salesforce. Default specifies the default picklist value when creating tasks. To edit, from the management settings for tasks, go to Fields, and then click Edit next to the picklist value that you want to specify as the default.
SEE ALSO: Picklist Limitations
263 Extend Salesforce with Clicks, Not Code Customize Fields
Picklist Limitations
The maximum number of characters you can have in a picklist depends on the type of picklist. Each EDITIONS value in a picklist includes a line break and a return character that aren’t visible. These two additional characters per value are counted as part of the character limit for each value. Available in: both Salesforce When selecting picklist values for a list view filter, the combined size of the selected picklist values Classic and Lightning must be fewer than 240 characters. Experience Other limits apply to standard and custom picklists. Available in: All Editions Standard Picklists aren’t Other Limits for Standard Picklists available in Database.com For standard picklists, each value can have up to 255 characters, not including line breaks and returns. This applies to single-select and multi-select picklists. USER PERMISSIONS
Picklist Field Maximum Number of Values To change picklists: • Customize Application Lead Status 100
Task Status 100
Task Priority 50
Case Status 100
Case Priority 50
Opportunity Stage 100
Limits for Custom Picklists Inactive and active picklists limits: • Restricted picklists have a combined active and inactive limit of 1,000. • Bound unrestricted picklists have a limit of 1,000 on active picklists and a limit of 4,000 on inactive picklists. • Existing unbound picklists have no limit. By default, all newly created picklists are bound to the 4,000 inactive limit. Custom single-select picklists limits: • Up to 1,000 values. • Up to 255 characters per value. Custom multi-select picklists limits: • Up to 500 values. • Up to 255 characters per value. • Users can select up to 100 values at a time on a record. Global picklist value sets limits: • Global picklist value sets have a combined active and inactive limit of 1,000. • You can have up to 500 picklist global value sets in an org. • There’s no limit on the number of custom picklists that use global picklist value sets. • If you apply a global picklist value set to more than 13 different objects, you can deactivate values from the picklist value set, but you can’t replace any picklist values or delete values from the set.
264 Extend Salesforce with Clicks, Not Code Customize Fields
Functional Limitations for Custom Picklists • You can make a custom single-select picklist field into a restricted picklist only if the picklist has fewer than 1,000 values (or entries). You can make a custom multi-select picklist field into a restricted picklist only if the picklist has fewer than 500 values (or entries). A restricted picklist’s values are limited to only those values defined by a Salesforce admin, which prevents users from loading redundant or erroneous values through the API. • Global picklist value sets are always restricted picklists, which is a good thing because it preserves data integrity. (Global value sets are shared across objects. Reuse the value set for any custom picklist field.) • For custom picklist fields that use a global picklist value set, you can change from a single-select to multi-select picklist and vice versa. However, you can’t change the picklist to a different field type, such as checkbox, currency, or text. • You can’t undo a custom picklist field’s association with a global value set. If you need a picklist field to use a different global value set or different individual values, delete the custom picklist field, and create a new one in its place.
Replace Picklist Values
As your business needs change, replace picklist values with more relevant alternatives. Replacing EDITIONS a value globally replaces that field value on all existing records. For example, let’s say you have a status picklist with three different closed values, Closed-red, Available in: both Salesforce Closed-yellow, and Closed-green, and you want to simplify those to just one value. Replace them Classic and Lightning with the new value Closed. Experience
Important: If you replace a parent value in a controlling picklist, the picklist dependency on Available in: All Editions that value is lost. After replacing the parent value, re-create the dependency using the new parent value. USER PERMISSIONS 1. If necessary, create the replacement value in the picklist edit page. See Add or Edit Picklist Values. To replace picklist values: • Customize Application 2. Navigate to the picklist. • For a global picklist value set: From Setup, enter picklist in the Quick Find box, then select Picklist Value Sets. • For a picklist on an object, go to the fields area of the object. For example, for an Account picklist: From Setup, enter Account in the Quick Find box, then select Fields under Accounts.
3. Start the picklist value replace process. • For a global picklist value set: Go to the Global Value Set Detail page by clicking the picklist name. In the Values section, click Replace. • For all other picklists: Click Replace next to the picklist name.
4. Enter the value to change, and select a new replacement value.
Note: Replacing an existing picklist value also changes the Modified By date and time for the record.
5. To use the new value in records where this field is currently empty, select Replace all blank values. 6. To update all occurrences of the value in your org’s records with the new value, click Replace. Occurrences in the Recycle Bin are also updated. Your replace job is queued. To check the job’s status, from Setup, enter Background Jobs in the Quick Find box, then select Background Jobs. You receive an email when the job is complete.
265 Extend Salesforce with Clicks, Not Code Customize Fields
Note: If you replace the Stage picklist for opportunities, the Probability, Forecast Category, and Expected Revenue fields are also updated with the corresponding values.
SEE ALSO: Create a Global Picklist Value Set Protect Picklist API Names for Formulas and Integrations Manage Inactive Picklist Values
Remove a Picklist Value Remove or replace custom picklist values to update the records that have the picklist field. You have several ways to remove existing picklist field values. And, the steps are a little different when your picklist values are part of a global picklist value set. While you remove them, you can also to replace them with another value. For more information on replacing an existing value, see Replace Picklist Values. The following steps remove existing values. 1. Navigate to the picklist. • For a global picklist value set: From Setup, enter picklist in the Quick Find box, then select Picklist Value Sets. • For a picklist on an object, go to the fields area of the object. For example, for an Account picklist: From Setup, enter Account in the Quick Find box, then select Fields under Accounts.
2. Click the picklist name. 3. To remove a value from the picklist, click Del next to the value’s name. Decide whether to replace the value or leave it blank. If you replace it with a blank value, existing records will not display the value anymore. To keep the value on existing records, use Deactivate, instead of Del.
Note: Some special picklists,such as opportunity Stage, Task Priority, Task Status, Lead Status, and Case Status,prompt you to map the deleted value to another existing value in all your org’s records. You can map the values or leave your existing data unchanged. Using the option to replace a picklist value while deleting the current value does not trigger workflow rules.
For orgs using record types, include some or all the values from the master picklist in different record types to offer a subset of values to users based on their profile.
Protect Picklist API Names for Formulas and Integrations
When you create a picklist value, an API Name that matches the Label is assigned. By default, the EDITIONS API Name can be changed at any time, but you can choose to protect the API Name. A picklist value is identified by either the displayed value or the API Name. Formulas reference the Available in: both Salesforce API Name so that the formula continues to work even if the displayed value changes. An admin Classic and Lightning can prevent changes to the API Name to protect the references to the fields in formulas or during Experience integrations, such as data import. Available in: All Editions 1. From Setup, enter picklist in the Quick Find box, then select Picklist Settings. 2. To prevent changes to the API names for any of the values, select Disable editing picklist USER PERMISSIONS values' API names. To customize picklist settings: • Customize Application
266 Extend Salesforce with Clicks, Not Code Customize Fields
If you need to change an API Name later, you can deselect this option.
SEE ALSO: Create a Custom Picklist Field Replace Picklist Values Add or Edit Picklist Values
Sort Picklists
1. From the management settings for the picklist field’s object, go to Fields. EDITIONS • For custom task or event fields, go to the object management settings for Activities. • For standard task fields, go to the object management settings for Tasks. For standard event Available in: both Salesforce fields, go to the object management settings for Events. Classic and Lightning Experience • For Knowledge validation status picklists, from Setup, enter Validation Statuses in the Quick Find box, then select Validation Statuses. Available in: All Editions
2. Click the name of the picklist to update. USER PERMISSIONS 3. Click Reorder. 4. Use the arrows to arrange the field in the proper sequence. To sort picklists: • Customize Application 5. Select a default value if desired. 6. To alphabetize the entries for users on edit pages, check Sort values alphabetically.... 7. Save your changes. On record edit and detail pages and in reports, picklist and multi-select picklist fields can include inactive values. These inactive values are sorted last, unless you’ve chosen alphabetical sorting. In that case, all values are sorted alphabetically.
SEE ALSO: Find Object Management Settings
Manage Inactive Picklist Values
Establish upper bound limits, deactivate, reactivate, or remove a value from a restricted or unrestricted EDITIONS picklist. Having inactive picklist values can be a result of an import or intentionally removing the value from Available in: both Salesforce the list of available values for future use. In certain cases, importing text fields can create numerous Classic and Lightning unwanted picklist fields. Managing your inactive picklist values and enforcing limits on inactive Experience values for unrestricted picklists can improve performance and improve your Salesforce org’s overall Available in: All Editions health.
Disable Upper Bound Limit on Inactive Values Upper bound limits, which are set by default on inactive values for unrestricted picklists, can improve performance and your Salesforce org’s overall health. If your org's inactive unrestricted picklist values go unchecked, performance degrades. The point when degradation occurs depends on your implementation.
267 Extend Salesforce with Clicks, Not Code Customize Fields
Establish an Upper Bound Limit You can enforce an upper bound limit on existing standard picklists. The limit is enforced on the inactive values of picklists whose numbers don’t exceed the allowable limit. By default, all new picklists have an enforced limit of 4,000 on inactive values for unrestricted picklist fields. View Active and Inactive Picklist Values You can view the number of active and inactive picklist values and the maximum number allowed from the picklist field detail page. Converting a Text Field Type to a Picklist By default, an upper bound limit of 4,000 is applied to inactive unrestricted picklists for each field. If you exceed this limit when converting a text field to a picklist field, you get an error message. Deactivate and Reactivate Values Deactivate, reactivate, or remove a value from a restricted or unrestricted custom picklist. If it’s a global picklist value set, these actions simultaneously update all custom picklists that inherit its value set.
Disable Upper Bound Limit on Inactive Values
Upper bound limits, which are set by default on inactive values for unrestricted picklists, can improve EDITIONS performance and your Salesforce org’s overall health. If your org's inactive unrestricted picklist values go unchecked, performance degrades. The point when degradation occurs depends on your Available in: Salesforce implementation. Classic and Lightning Important: We recommend disabling the limit only for troubleshooting, such as when errors Experience occur during data creation or metadata deployment. Available in: All Editions These rules apply when limits are enforced. • The limit for inactive values on unrestricted picklists is 4,000. USER PERMISSIONS • The enforced limit applies to all new picklist fields. To create or change custom • The limit applies to inactive values on newly created unrestricted picklists. fields: • Current unrestricted picklists in your org aren’t affected by the new limit. • Customize Application • Admins can choose to exclude their Salesforce org from inactive value limits. • The limit doesn’t apply to restricted picklist and global picklist value sets. Global picklist value sets have a combined active and inactive limit of 1,000. To remove the limit on inactive values for unrestricted picklists (not recommended). 1. From Setup, in the Quick Find box, enter Picklist Settings. 2. In the Picklist Settings window, click Remove upper bound on inactive picklist values.
SEE ALSO: Establish an Upper Bound Limit
268 Extend Salesforce with Clicks, Not Code Customize Fields
Establish an Upper Bound Limit
You can enforce an upper bound limit on existing standard picklists. The limit is enforced on the EDITIONS inactive values of picklists whose numbers don’t exceed the allowable limit. By default, all new picklists have an enforced limit of 4,000 on inactive values for unrestricted picklist fields. Available in: Salesforce 1. To enforce the upper bound limit on inactive values for unrestricted picklists, the setting, Classic and Lightning “Remove upper bound on inactive picklist values” must not be disabled. Experience 2. From Setup, in the Quick Find box, enter Picklist Settings. Available in: All Editions 3. In the Picklist Settings window, click Establish upper bound on existing picklists. A query is run on picklists to find inactive values that satisfy the 4,000 limit. The limit is enforced USER PERMISSIONS only on those picklists. A message appears to show the number of picklists that were bound to the To create or change custom limit, or that there are no unbound picklists that meet the limit. fields: You can run the upper bound on existing picklists setting multiple times. For example, if you delete • Customize Application picklist values, you can potentially reduce the total number of values to be under the limit. Another scenario is if you remove the limit with the remove upper bound on inactive picklist values setting to perform a conversion or import. You can reinforce the limit after conversion and then run the establish upper bound on existing picklists setting on values that meet the criteria. Removing the limit with the remove upper bound on inactive picklist values setting clears the upper bound limit for all unrestricted picklists.
Note: Admins or Salesforce can’t configure the limit of 4,000 for inactive values.
SEE ALSO: Converting a Text Field Type to a Picklist
View Active and Inactive Picklist Values
You can view the number of active and inactive picklist values and the maximum number allowed EDITIONS from the picklist field detail page. Limits are applied as follows: Available in: Salesforce Classic and Lightning • Restricted picklists have a combined active and inactive limit of 1,000. Experience • Bound unrestricted picklists have a limit of 1,000 on active picklists and a limit of 4,000 on inactive picklists. Available in: All Editions • Global picklist value sets have a combined active and inactive limit of 1,000. • Existing unbound picklists have no limit. By default, all newly created picklists are bound to the USER PERMISSIONS 4,000 inactive limit. To create or change custom 1. To view active and inactive picklist values, the setting, “Remove upper bound on inactive picklist fields: values” must not be disabled. • Customize Application 2. Navigate to the picklist. • For a picklist on an object, go to the fields section of the object. • For a global picklist, from Setup, in the Quick Find box, enter picklist, then select Picklist Value Sets.
3. Go to the picklist’s detail page by clicking the picklist’s name. In the Picklist Values Used section, you see the active and inactive number of picklist values and the maximum number allowed.
269 Extend Salesforce with Clicks, Not Code Customize Fields
Converting a Text Field Type to a Picklist
By default, an upper bound limit of 4,000 is applied to inactive unrestricted picklists for each field. EDITIONS If you exceed this limit when converting a text field to a picklist field, you get an error message. These rules apply to conversion: Available in: both Salesforce Classic and Lightning • The limit isn’t case-sensitive. Experience • If there are more than 4,000 unique values, the conversion fails. This conversion limit includes active picklists. Available in: All Editions • Soft-deleted values count toward the 4,000 unique value limit. To avoid values that count toward the limit, permanently delete any soft deleted records and field values by emptying the recycle bin. • Keep this setting: Remove upper bound on inactive picklist values. • You can’t convert a defined unique text field to a picklist or a multi-select picklist. 1. From the management settings for the field’s object, go to Fields. 2. Click Edit next to the custom field that you want to change. 3. Click Change Field Type. 4. Select a Picklist and click Next. 5. Enter a field label, name, and any other attributes, and then save your changes.
SEE ALSO: Change the Custom Field Type Disable Upper Bound Limit on Inactive Values Establish an Upper Bound Limit
Deactivate and Reactivate Values
Deactivate, reactivate, or remove a value from a restricted or unrestricted custom picklist. If it’s a EDITIONS global picklist value set, these actions simultaneously update all custom picklists that inherit its value set. Available in: Salesforce Note: Only a Salesforce admin can modify the values of a restricted picklist. Users can’t add Classic and Lightning unapproved values, even through the API. Experience The unrestricted picklist values for the Task.Subject and Event.Subject fields Available in: All Editions can’t be deactivated. The picklist values are deleted instead of deactivated. USER PERMISSIONS 1. Navigate to the picklist you want to modify. • For a picklist on an object, go to the fields section of the object. To create or change custom fields: • For a global picklist, from Setup, in the Quick Find box, enter picklist, then select • Customize Application Picklist Value Sets.
2. Go to the picklist’s detail page by clicking the picklist’s name. 3. In the Values section, modify the picklist value. These actions simultaneously update all custom picklists that inherit its value set. • To deactivate a value, which removes it from the picklist but keeps it on existing records, click Deactivate next to the value’s name. The value moves to the Inactive Values section. If you need the value again later, click Activate next to its name.
270 Extend Salesforce with Clicks, Not Code Customize Fields
• To remove a value from the picklist and all records that use it, click Del next to the value’s name, and select Replace value on records with blank value. Then save the changes. • To remove a value from a global picklist and any custom picklists that share its value set, click Del next to the value’s name, and then click OK. If any custom picklists use this global picklist value set, you’re prompted to replace the value with a blank value or an existing, active value. If no custom picklists use the value set, the value is deleted from the global picklist. If a global picklist value is used in historical trending, it’s deactivated but not deleted. Deleting a value in a global picklist value set or on non-global, restricted picklists goes to the background jobs queue. When the job completes, your picklist is updated and you’re notified by email. Changes to picklist values are logged in Setup Audit Trail. To view the audit history, from Setup, in the Quick Find box, enter View Setup Audit Trail, then select View Setup Audit Trail. Using the option to replace a picklist value while deleting the current value doesn’t trigger workflow rules.
Define Dependent Picklists
Tip: If your org uses record types, make sure that your controlling and dependent picklist EDITIONS values are available in the appropriate record types before defining a dependent picklist. 1. From the management settings for the object you want to add a field to, go to Fields. Custom Available in: both Salesforce task and event fields are accessible from the object management settings for Activities. Classic and Lightning Experience 2. Click Field Dependencies. Available in: All Editions 3. Click New. Standard Objects are not 4. Choose a controlling field and dependent field. available in Database.com Note: Some picklist and checkbox fields may not be available as controlling fields. USER PERMISSIONS 5. Click Continue. 6. Use the field dependency matrix to specify the dependent picklist values that are available To define dependent when a user selects each controlling field value. picklists: • Customize Application 7. Optionally, click Preview to test your selections. If your organization uses record types, choose a record type to test how it affects your controlling and dependent picklist values. The record type controls what values are available in the controlling field. The record type and the controlling field together determine what values are available in the dependent picklist. For example, a dependent value is only available if it is available in the selected record type and the selected controlling value.
Note: The Filter by Record Type option doesn’t appear in the Preview window for activity custom fields.
8. Click Save.
Dependent Picklists Using the Field Dependency Matrix Edit Dependent Picklists Delete Picklist Dependencies Dependent Picklist Considerations
271 Extend Salesforce with Clicks, Not Code Customize Fields
Dependent Picklists
Use dependent picklists to help your users enter accurate and consistent data. A dependent picklist EDITIONS is a custom or multi-select picklist for which the valid values depend on the value of another field, called the controlling field. Controlling fields can be any picklist (with at least one and fewer than Available in: both Salesforce 300 values) or checkbox field on the same record. Classic and Lightning For example, you can define a Reason custom picklist on opportunities and make its valid values Experience Stage depend on the value of the picklist as follows: Available in: All Editions • If Stage is Closed Won, the valid values for Reason are Superior features or Lower price. • If Stage is Closed Lost, the valid values for Reason are Inferior features, Higher price, or Company viability.
SEE ALSO: Define Dependent Picklists Dependent Picklist Considerations
Using the Field Dependency Matrix
The field dependency matrix lets you specify the dependent picklist values that are available when EDITIONS a user selects each controlling field value. The top row of the matrix contains the controlling field values, while the columns list the dependent field values. Available in: both Salesforce Use this matrix to include or exclude values. Included values are available in the dependent picklist Classic and Lightning when a value in the controlling field is selected. Excluded fields are not available in the dependent Experience picklist for the selected controlling field value. Available in: All Editions To include or exclude values: • Double-click values to include them. Included values are indicated with highlighting. Double-click USER PERMISSIONS any highlighted values to exclude them. • Click a value and use SHIFT+click on another value to select a range of adjacent values. Then To define picklist dependencies: click Include Values to make the values available, or Exclude Values to remove them from • Customize Application the list of available values. • Click a value and use CTRL+click to select multiple values. Then click Include Values to make the values available, or Exclude Values to remove them from the list of available values. • Click a column header to select all the values in that column. Then click Include Values to make the values available, or Exclude Values to remove them from the list of available values. To change the values in your view: • Click View All to view all available values at once. • Click Go To and choose a controlling value to view all the dependent values in that column. • Click Previous or Next to view the values in columns that are on the previous or next page. • Click View sets of 5 to view 5 columns at a time.
272 Extend Salesforce with Clicks, Not Code Customize Fields
Edit Dependent Picklists
1. From the management settings for the picklist’s object, go to Fields. EDITIONS 2. Click Field Dependencies. 3. Click Edit next to the field dependency relationship you want to change. Available in: both Salesforce Classic and Lightning 4. Use the field dependency matrix to specify the dependent picklist values that are available Experience when a user selects each controlling field value. Available in: All Editions 5. Optionally, click Preview to test your selections. 6. Save your changes. USER PERMISSIONS
SEE ALSO: To edit field dependencies: • Customize Application Find Object Management Settings
Delete Picklist Dependencies
If you no longer want the values of a dependent picklist to depend on a controlling field, delete its EDITIONS dependency. Deleting the dependency removes the logic that defines how the values of the picklist depend on the controlling field, but doesn't delete the fields or affect their data. Available in: both Salesforce 1. From the management settings for the picklist’s object, go to Fields. Classic and Lightning Experience 2. Click Field Dependencies. 3. Click Del next to the field dependency relationship you want to delete. Available in: All Editions 4. Click OK to confirm. USER PERMISSIONS
SEE ALSO: To delete picklist Find Object Management Settings dependencies: • Customize Application
Dependent Picklist Considerations
Consider the following when defining dependent picklists: EDITIONS Checkboxes Checkbox fields can be controlling fields but not dependent fields. Available in: both Salesforce Classic and Lightning Converting fields Experience When you convert existing fields to dependent picklists or controlling fields, it doesn’t affect the existing values in your records. After conversion, the dependency rules apply to new records Available in: All Editions and to any changes to existing records. Page Layouts and Leads are Default values not available in You can set default values for controlling fields but not for dependent picklists. Database.com Field-level security Field-level security settings for a controlling field and dependent picklist are independent. USER PERMISSIONS Remember to hide a controlling field whenever its correlating dependent picklist is hidden. Import To define and edit dependent picklists: The Data Import Wizard doesn’t consider field dependencies. You can import any value into a • Customize Application dependent picklist regardless of the value imported for a controlling field.
273 Extend Salesforce with Clicks, Not Code Customize Fields
Lead conversion If you create a dependency for lead fields that map to account, contact, and opportunity fields for lead conversion, create the same dependency on the account, contact, or opportunity. Dependent picklists and controlling lead fields can be mapped to account, contact, or opportunity fields with different dependency rules. Multi-select picklists Multi-select picklists can be dependent picklists but not controlling fields. Standard versus custom picklists Custom picklist fields can be either controlling or dependent fields. Standard picklist fields can be controlling fields but not dependent fields. Picklist limitations A controlling field can have up to 300 values. If a field is both a controlling field and dependent picklist, it can’t contain more than 300 values. The following fields are not available as controlling fields. Activity Fields Call Type Create recurring series of events Show Time As Subject Task Type Contact Fields Salutation Contact Currency Custom Object Fields Currency Lead Fields Converted Unread By Owner Dependency limitations Before defining a dependency, make sure that your picklist has at least one value. Standard fields like Product Family do not contain values until you add them. If a standard controlling field relies on functionality that your organization decides to disable, the dependency rules for the picklist go away. For example, if your organization disables the Self-Service portal and the Closed by Self-Service User is a controlling field, its dependent picklist displays all available values. If you replace a parent value in a controlling picklist, the picklist dependency is lost. After replacing the parent value, re-create the dependency using the new parent value. Connect Offline While controlling fields and dependent picklists are available in Connect Offline, the logic between them is not.
274 Extend Salesforce with Clicks, Not Code Customize Fields
Page layouts Page layouts that contain dependent picklists must also contain their controlling picklist fields, or the dependent picklist values don't display. For visually impaired users, make sure that the dependent picklist is lower on the page layout than its controlling field. If a dependent picklist is required and no values are available for it based on the controlling field value, users can save the record without entering a value. The record is saved with no value for that field. Record types You can define or change the record type for your dependent picklist only within the Preview dialog when creating or editing the field dependency values. The record type controls what values are available in the controlling field. The record type and the controlling field together determine what values are available in the dependent picklist. For example, a dependent value is only available if it is available in the selected record type and the selected controlling value.
Rich Text Editor Use the rich text editor to format text in custom fields with the rich text area type. You can also use the rich text editor in many other features, such as Chatter publisher and groups.
Available in: the Salesforce mobile app, Salesforce Classic, and Lightning Experience
Available in: All Editions
You can perform the following operations with the rich text editor’s WYSIWYG interface. • Format text as bold, italicized, underlined, or strikethrough • Create bullet and numbered lists • Change paragraph indentation • Insert a hyperlink • Insert an image (copying inline images from external sources and pasting them into the editor is not supported) • Remove formatting The availability of toolbar buttons varies across features. For example, the code snippet button is available in Chatter publisher but not in custom fields. Extra functions are supported for features such as Salesforce Knowledge and Ideas, like the ability to embed multimedia content.
Note: Beginning in Summer ’17, custom fields provide a rich text editor that no longer uses CKEditor in Lightning Experience and the Salesforce mobile app. Rich text editors provide a WYSIWYG interface only; you can’t edit HTML tags. When you copy content from a web page or another source and paste it into the editor, unsupported tags are removed. Text that was enclosed in unsupported tags is preserved as plain text. You aren’t notified when unsupported or potentially malicious HTML tags are removed. You can expect minor formatting or styling differences when editing a rich text field across the interfaces. We recommend using the toolbar to fix formatting or styling differences. Lightning Knowledge continues to use the CKEditor for custom rich text fields. Knowledge article rich text fields provide additional functions, such as the ability to view and edit the source HTML, support for more HTML styles, and smart links between articles.
Some features have rich text editors across Salesforce Classic, Lightning Experience, and the Salesforce mobile app. For example, the Information field in groups provides a rich text editor in all three user interfaces. The Chatter Publisher has a rich text editor only in Salesforce Classic and Lightning Experience.
275 Extend Salesforce with Clicks, Not Code Customize Fields
Salesforce Classic Lightning Experience The Salesforce Mobile App
Groups
Lightning Components (ui:inputRichText and lightning:inputRichText)
Custom Fields
Chatter Publisher
Knowledge Article
Lightning App Builder (Rich Text Component)
Experience Builder (Rich Content Editor)
Flow Builder
Idea Themes
Send Email Action
Sales Path
Notes
Rich Text Editor Considerations When you use the editor, note the following. • The maximum number of characters you can enter in the rich text editor is equal to the field length specified when creating or editing the field. The default is 32,768 characters, which includes characters used by HTML tags that apply formatting. • Clicked hyperlinks open in a new browser window. The rich text editor supports HTTP, HTTPS, and mailto hyperlinks. • The rich text editor doesn’t validate hyperlinks to web pages. Confirm that you are specifying a valid URL. • To insert an image, click and either select: – Web Address and enter the URL of the image. This option isn’t available in Lightning Experience. – Upload Image and select an image from your local host. You can upload only JPEG, PNG, or GIF files. The file cannot exceed 1 MB. You can’t add a hyperlink to an image. Copying inline images from external sources to the text editor is not supported. Optionally, enter a description that appears when you hover over the image. The image must have a URL that Salesforce can access. • The rich text editor supports all languages that Salesforce Knowledge supports. • The rich text editor does not support JavaScript or Cascading Style Sheets (CSS). • The rich text editor is disabled for users who have accessibility mode enabled. It’s replaced with a text field.
276 Extend Salesforce with Clicks, Not Code Customize Fields
Supported Formatting We recommend that you use the toolbar to format your content. When you copy content from a web page or another source and paste it into the editor, unsupported tags are removed. Text that was enclosed in unsupported tags is preserved as plain text. The rich text editor supports the tags listed in the table.
Note: Rich text editors in custom rich text area fields have minor formatting differences in Lightning Experience and the Salesforce mobile app, as compared to Salesforce Classic. For more information, see Editing Rich Text Area Fields in Records. The tags can include the following attributes.
alt face size
background height src
border href style
class name target
colspan rowspan width
277 Extend Salesforce with Clicks, Not Code Customize Fields
The following URL protocols are supported. • http: • https: • file: • ftp: • mailto: • # • / for relative links
Rich Text Editors Using CKEditor Rich text editors in Salesforce Classic continue to use CKEditor. Beginning in Spring ’21, Salesforce uses CKEditor version 4.14.0. In Salesforce Classic, CKEditor is used by: • Chatter Publisher • Custom Fields • Email • Flow Builder • Groups • Idea Themes • Knowledge Article In Lightning Experience and the Salesforce mobile app, the following features have rich text editors that use CKEditor. • Email Composer, using the Send Email action • Lightning Knowledge These features load the rich text editor in an iframe. To load the editor correctly in an iframe, your browser must use appropriate security settings. Refer to your browser’s instructions to configure the settings. For example: Internet Explorer Make sure that the Launching programs and files in an IFRAME security setting is set to Enable or Prompt. Safari We recommend changing your Privacy settings for cookies to Allow from websites I visit. Chrome Make sure that Block third-party cookies and site data is not selected in the Content settings. To enter content in Internet Explorer 11 on touch-enabled devices running Windows, first click the rich text area field, then tab into the editor.
Add Videos Using the HTML Editor Adding Code Samples to Posts You can paste code samples into your posts in Chatter Answers and Ideas.
SEE ALSO: Editing Rich Text Area Fields in Records Rich Text Fields in Knowledge Articles
278 Extend Salesforce with Clicks, Not Code Customize Fields
Add Videos Using the HTML Editor
Available in: Salesforce Classic and Lightning Experience USER PERMISSIONS
Available in: Enterprise, Performance, Unlimited, and Developer Editions To create or change custom fields: • Customize Application Approved Video Sites • app.ustudio.com • dailymotion.com • documentforce.com • fast.wistia.net • force.com • ooyala.com • play.vidyard.com • player.youku.com • players.brightcove.net • salesforce.com • salesforce-sites.com • sites.com • ustream.tv • visualforce.com • videos.sproutvideo.com • vimeo.com • youtube.com (including youtube.co.uk, youtube.ca, youtube.com.br, youtube.es, youtube.fr, youtube.ie, youtube.jp, youtube.nl, youtube-nocookie.com, and youtube.pl) 1. Copy the
Button Description Lets you paste the
Lets you paste the
3. Click Save.
279 Extend Salesforce with Clicks, Not Code Customize Fields
Note: If you run into problems embedding videos, check your browser security settings. Some browsers block iframe elements. Also, embedded videos are removed from emails when you insert Knowledge articles into case emails. Also, you can't send embedded videos via email.
SEE ALSO: Rich Text Editor
Adding Code Samples to Posts You can paste code samples into your posts in Chatter Answers and Ideas. When you enable Chatter Answers and Ideas, users can add code samples to their posts. Code can be copied from any text editor and pasted into the body of a post with the formatting preserved. 1. Copy the code sample from a text editor to your clipboard. 2. In the editor, enter the text for your posts and click the button to add the code sample. 3. Paste the code sample into the Add a code sample text box and click OK. The code sample appears in the body of the post with its formatting intact.
Change the Custom Field Type
1. From the management settings for the field’s object, go to Fields. EDITIONS Note: For fields on Salesforce Knowledge article types, from Setup, enter Knowledge Article Types in the Quick Find box, select Knowledge Article Types, and Available in: both Salesforce then select an article type. Classic and Lightning Experience 2. Click Edit next to the custom field you want to change. Available in: All Editions 3. Click Change Field Type. Standard Objects are not 4. Select a new data type and click Next. available in Database.com 5. Enter a field label, name, and any other attributes, and then save your changes. Salesforce Connect external objects are available in: Developer Edition and for Notes on Changing Custom Field Types an extra cost in: Enterprise, Performance, and SEE ALSO: Unlimited Editions Custom Field Types Which Standard Fields Can I Encrypt? USER PERMISSIONS Which Custom Fields Can I Encrypt? To change custom fields: Find Object Management Settings • Customize Application
Notes on Changing Custom Field Types Note these considerations before you convert fields from one type to another: • Only convert custom fields that there’s no data for or you risk losing your data. Changing the data type of an existing custom field can cause data loss in these situations:
280 Extend Salesforce with Clicks, Not Code Customize Fields
– Changing to or from type Date or Date/Time – Changing to Number from any other type – Changing to Percent from any other type – Changing to Currency from any other type – Changing from Checkbox to any other type – Changing from Picklist (Multi-Select) to any other type – Changing to Picklist (Multi-Select) from any other type Currently defined picklist values are retained when you change a picklist to a multi-select picklist. If records contain values that aren’t in the picklist definition, those values are deleted from those records when the data type changes.
– Changing from Auto Number to any other type – Changing to Auto Number from any type except Text – Changing from Text to Picklist – Changing from Text Area (Long) to any type except Email, Phone, Text, Text Area, or URL
• If data is lost, any list view based on the custom field is deleted, and assignment and escalation rules can be affected. • You can’t change the data type of any custom field that is mapped for lead conversion. • If you change the data type of a custom field that‘s set as an external ID, choosing a data type other than text, number, or email causes the field to no longer act as an external ID. • The option to change the data type of a custom field isn’t available for all data types. For example, an existing custom field can’t be converted into an encrypted field nor can an encrypted field be converted into another data type. • In Salesforce Knowledge article types, the file field type can't be converted into other data types. • You can’t change the data type of a custom field referenced by other items in Setup such as Visualforce pages, Apex code, processes, or flows. • Changing a custom field type can require changing many records at once. If your request is queued to process these changes efficiently, you receive an email notification when the process has completed. • Before changing a custom field’s type, make sure it isn’t the target of a workflow field update or referenced in a field update formula that would be invalidated by the new type. • If you encrypt a custom field using Shield Platform Encryption, you can’t change the field type. These data types have other restrictions when you convert them:
Data Type Description Auto Number If you convert an auto-number field into a text field, the data in that field remains unchanged. Also, you can safely convert a text custom field into an auto-number field without losing your data. Converting an auto-number field into any other data type results in data loss. Auto-number fields can contain a maximum of 30 characters. Before converting a text custom field into an auto-number field, change any records that contain more than 30 characters in that field.
Formula Formula fields are special read-only fields that can’t be converted to any other data type. Likewise, you can’t convert any other field type into a formula field.
281 Extend Salesforce with Clicks, Not Code Customize Fields
Data Type Description Picklist Changing your custom picklists into custom checkboxes is simple. If you select Checkbox as the new data type, you can choose which picklist values to map to checked boxes and unchecked boxes. You can change custom picklists into multi-select picklists without losing any data. Since your records contain only a single value of that picklist, that value is still selected but users can select more values.
Relationships • You can convert relationship fields to nonrelationship fields and vice versa, but only on external objects. • If your org has a large number of records, Salesforce displays a waiting page after you request to change a master-detail into a lookup relationship or a lookup into a master-detail relationship. • After you have created a roll-up summary field on an object, you cannot convert the object's master-detail relationship into a lookup relationship. • If any records on an object have a null value set for the lookup field, you can’t convert the lookup relationship to a master detail relationship. • If you convert a master-detail relationship to a lookup for a custom object on the “detail” side, the org-wide default for the object is automatically updated to Public Read/Write. Similarly, converting a lookup to a master-detail-relationship changes the org-wide default to Controlled by Parent.
Text By default, an upper bound limit of 4,000 is applied to inactive unrestricted picklists for each field. If you exceed this limit when converting a text field to a picklist field, you receive an error message. You can’t convert a defined unique text field to a picklist or a multi-select picklist.
Text Area (Long) When you convert a long text area field to an Email, Phone, Text, Text Area, or URL type field, the record data is truncated to the first 255 characters of the field.
Text Area (Rich) You can convert rich text area fields into long text area fields only. Any images get deleted the next time you save the long text area field. After converting, markup is hidden in the long text area field but it isn’t removed from the record, so if you change your mind, you can restore the markup before you save the record.
SEE ALSO: Change the Custom Field Type Custom Metadata Type Fields
282 Extend Salesforce with Clicks, Not Code Customize Fields
Define Default Field Values
Define a default value for a field. Use a formula to generate dynamic values or constants for static EDITIONS values. 1. Create a custom field. See Create Custom Fields. You can also define a default value for an Available in: both Salesforce existing custom field. See Edit Custom Fields. Classic and Lightning Experience 2. Choose the type of field and click Next. For a list of the types available for default values, see Default Field Values. Available in: Contact 3. Enter the attributes for the field. Manager, Group, Professional, Enterprise, 4. Enter a default value or define a formula to calculate the default value. Performance, Unlimited, and Developer Editions Note: You can define a formula for default values only where appropriate. For example, the default value options for a checkbox field are limited to the options available for those types of fields, such as Checked or Unchecked. USER PERMISSIONS For picklists, a valid formula result is either a constant or the API name of an entry in the To view default field values: Values list. The formula result has higher precedence than the default assigned in the • View Setup and Values list. If the formula doesn’t generate a valid result, the default assigned in the Values Configuration list is entered in the field. If a default isn’t assigned to the Values list, no value is entered To define or change default in the picklist field. field values: • Customize Application 5. Click Next. 6. Set the field-level security to determine whether the field is visible for specific profiles, and click Next. 7. Choose the page layouts that display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is added to the bottom of the user detail page. 8. Click Save to finish or Save & New to create more custom fields. You must specify a default value for required campaign member custom fields. To avoid uniqueness errors, don’t assign default values to fields that are both required and unique.
Default Field Values Prepopulate field values with defaults to save your users time and improve consistency. Default field values make your users more productive by reducing the number of fields they need to fill in manually. Useful Default Field Value Formulas Default Field Value Considerations Be aware of the behavior and rules when you assign default values to custom fields.
283 Extend Salesforce with Clicks, Not Code Customize Fields
Default Field Values
Prepopulate field values with defaults to save your users time and improve consistency. Default EDITIONS field values make your users more productive by reducing the number of fields they need to fill in manually. Available in: both Salesforce Default field values automatically insert the value of a custom field when a new record is created. Classic (not available in all You can use a default value on a formula for some types of fields or exact values, such as Checked orgs) and Lightning or Unchecked for checkbox fields. Experience After you have defined default values: Available in: Contact Manager, Group, 1. The user chooses to create a new record. Professional, Enterprise, 2. Default field value is executed. Performance, Unlimited, 3. Salesforce displays the edit page with the default field value prepopulated. and Developer Editions 4. The user enters the fields for the new record. 5. The user saves the new record. The user can change the field’s value but the initial default field value is only executed once, during record creation. For example, you can set the default field value on a custom lead field to seven days after the creation date to signify when to contact the lead again. You can change this value later, but you cannot automatically restore the value that was seven days after the creation date. Set up default field values for the following types of custom fields: • Checkbox • Currency • Date • Date/Time • Email • Number • Percent • Phone • Picklist • Text • Text Area • Time • URL For a description of these types, see Custom Field Types on page 225.
SEE ALSO: Define Default Field Values Default Field Value Considerations Useful Default Field Value Formulas Reference Custom Metadata Type Records in Default Values
284 Extend Salesforce with Clicks, Not Code Customize Fields
Useful Default Field Value Formulas
EDITIONS Maximum Discount Rate Your organization may apply different discount rates to opportunities based on the department of Available in: both Salesforce the person creating the opportunity. Use the following example to set a default value for a custom Classic (not available in all field called Discount Rate on opportunities. orgs) and Lightning Experience
Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To view default field values: • View Setup and Configuration To define or change default field values: • Customize Application
CASE(User.Department, "IT", 0.25, "Field", 0.15, 0)
In this example, the formula inserts a discount rate of 25% on any opportunity created by a user in the IT department or 15% on any opportunity created by someone in the Field department. A zero is applied if the creator doesn't belong to either of these departments. This is a custom percent field on opportunities that uses the standard user field Department.
Product Language You might want to associate a product with its language so that your users know the type of documentation or adapter to include. Use the following default value formula to automatically set the language of a product based on the country of the user creating the product. In this example, the default value is Japanese if the user's country is Japan and English if the user's country is US. If neither is true, the default value unknown is inserted into the Product Language field.
CASE($User.Country , "Japan", "Japanese", "US", "English","unknown")
Tax Rate Use this default value formula to set the tax rate of an asset based on the user's city. Create a custom percent field with the following default value:
IF($User.City = "Napa", 0.0750, IF($User.City = "Paso Robles", 0.0725, IF($User.City = "Sutter Creek", 0.0725, IF($User.City = "Los Olivos", 0.0750, IF($User.City = "Livermore", 0.0875, null ) )
285 Extend Salesforce with Clicks, Not Code Customize Fields
) ) )
In this example, a tax rate of 8.75% is applied to an asset when the user's address is in the city of Livermore. When none of the cities listed applies, the Tax Rate field is empty. You can also use the Tax Rate field in formulas to automatically calculate taxable amounts and final sales prices.
Default Field Value Considerations
Be aware of the behavior and rules when you assign default values to custom fields. EDITIONS Default field values automatically insert the value of a custom field when a new record is created. You can use a default value on a formula for some types of fields or exact values, such as Checked Available in: both Salesforce or Unchecked for checkbox fields. Review the following considerations before incorporating default Classic (not available in all field values in your organization. orgs) and Lightning Experience • If a default value is based on the value of a merge field, Salesforce uses the value of the merge field at the time the default value is executed. If the value of the merge field changes later, the Available in: Contact default value is not updated. Manager, Group, • Users can change or remove the default field value on a record. Professional, Enterprise, Performance, Unlimited, • Don’t assign default values to fields that are both required and unique, because uniqueness and Developer Editions errors can result. • If you make an activity custom field universally required, you must also provide a default value. • If an activity custom field is unique, you cannot provide a default value. • Default field values are different from formula fields in the following ways: they are only executed once, at record creation; they are not read only; and the user can change the value but cannot restore the default field value. • Since the default value is inserted before users enter any values in the new record, you cannot use the fields on the current record to create a default field value. For example, you cannot create a default field value on a contact that uses the first initial and last name because those values are not available when you click New to create a contact record. However, you can use the record type because it is selected before the record edit page displays. • Record type default field values have precedence over an object’s default field values. • To apply a different default value for different record types, use the record type as a merge field in a CASE function within the default field value setup. • Fields that are not visible to the user due to field-level security are still available in the formula for a default field value. • Connect Offline and Salesforce for Outlook do not display default values. However, Salesforce inserts the default values when a user syncs unless the user entered a value. • Default field values are not available in the Self-Service portal. • Lead conversion, Web-to-Lead, and Web-to-Case do not execute default field values. • Visualforce pages don’t support default field values.
Note: You can define a formula for default values only where appropriate. For example, the default value options for a checkbox field are limited to the options available for those types of fields, such as Checked or Unchecked. For picklists, a valid formula result is either a constant or the API name of an entry in the Values list. The formula result has higher precedence than the default assigned in the Values list. If the formula doesn’t generate a valid result, the default assigned in the Values list is entered in the field. If a default isn’t assigned to the Values list, no value is entered in the picklist field.
286 Extend Salesforce with Clicks, Not Code Customize Fields
Validation Rules
Improve the quality of your data using validation rules. Validation rules verify that the data a user EDITIONS enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns Available in: both Salesforce a value of “True” or “False”. Validation rules also include an error message to display to the user Classic and Lightning when the rule returns a value of “True” due to an invalid value. Experience
Important: We don’t recommend using a custom number field that Einstein Prediction Available in: Essentials, Builder manages in a validation rule. If the prediction changes the field value in a way that Contact Manager, Group, violates the validation rule, you can’t update the record that uses the field. If you get a Professional, Enterprise, validation rule error when saving a record that contains an Einstein Prediction Builder field, Performance, Unlimited, edit, deactivate, or delete the validation rule. Developer, and Database.com Editions After you have defined validation rules: 1. The user chooses to create a record or edit an existing record. 2. The user clicks Save. 3. All validation rules are verified. • If all data is valid, the record is saved. • If any data is invalid, the associated error message displays without saving the record.
4. The user makes the necessary changes and clicks Save again. You can specify the error message to display when a record fails validation and where to display it. For example, your error message can be “The close date must occur after today's date.” You can choose to display it near a field or at the top of the page. Like all other error messages, validation rule errors display in red text and begin with the word “Error”.
Note: In Salesforce Classic, users with custom profiles must have Read permission on a standard object to view validation rules for that object.
Important: Validation rules apply to new and updated records for an object, even if the fields referenced in the validation rule aren’t included in a page layout or an API call. Validation rules don't apply if you create records for an object with Quick Create. If your organization has multiple page layouts for the object on which you create a validation rule, verify that the validation rule works on each layout. If your organization has any integrations that use this object, verify that the validation rule works for each integration.
Managing Validation Rules Define Validation Rules Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value. Clone Validation Rules Activate Validation Rules Validation Rules Fields Tips for Writing Validation Rules
287 Extend Salesforce with Clicks, Not Code Customize Fields
Validation Rule Considerations Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value. Review these considerations before implementing validation rules in your organization.
SEE ALSO: Examples of Validation Rules Custom Metadata Type Fields and Validation Rules Custom Metadata Types and Validation Rule Formulas Set an AI Prediction Field Einstein Prediction Builder Edit Object Permissions in Profiles
Managing Validation Rules
Validation rules verify that the data a user enters in a record meets the standards you specify before EDITIONS the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include Available in: both Salesforce an error message to display to the user when the rule returns a value of “True” due to an invalid Classic and Lightning value. Experience From the validation rules page you can: Available in: Essentials, • Define a validation rule. Contact Manager, Group, • Click Edit next to a rule name to update the rule fields. Professional, Enterprise, Performance, Unlimited, • Delete a validation rule. Developer, and • Click a validation rule name to view more details or to clone the rule. Database.com Editions • Activate a validation rule.
SEE ALSO: Examples of Validation Rules
288 Extend Salesforce with Clicks, Not Code Customize Fields
Define Validation Rules
Validation rules verify that the data a user enters in a record meets the standards you specify before EDITIONS the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include Available in: both Salesforce an error message to display to the user when the rule returns a value of “True” due to an invalid Classic and Lightning value. Experience Before creating validation rules, review the Validation Rule Considerations. Available in: Essentials, 1. From the management settings for the relevant object, go to Validation Rules. Contact Manager, Group, Professional, Enterprise, 2. In the Validation Rules related list, click New. Performance, Unlimited, Note: The detail page of a custom activity field does not list associated validation rules. Developer, and To edit the validation rule for a custom activity field, select the validation rule from Setup Database.com Editions by entering Activities in the Quick Find box, then selecting Activities and choose Task Validation Rules or Event Validation Rules. USER PERMISSIONS
3. Enter the properties of your validation rule. To view field validation rules: 4. To check your formula for errors, click Check Syntax. • View Setup and Configuration
SEE ALSO: To define or change field validation rules: Validation Rules • Customize Application Clone Validation Rules Tips for Writing Validation Rules Examples of Validation Rules
Clone Validation Rules
1. From the management settings for the relevant object, go to Validation Rules. EDITIONS 2. In the Validation Rules related list, click the name of the validation rule. 3. Click Clone. Available in: both Salesforce Classic and Lightning 4. Define the new rule based on the original rule. Experience
5. Click Save to finish or Save & New to create additional validation rules. Available in: Essentials, Note: The detail page of a custom activity field does not list associated validation rules. To Contact Manager, Group, edit the validation rule for a custom activity field, select the validation rule from Setup by Professional, Enterprise, Performance, Unlimited, entering Activities in the Quick Find box, then selecting Activities and choose Developer, and Task Validation Rules or Event Validation Rules. Database.com Editions
SEE ALSO: USER PERMISSIONS Define Validation Rules Validation Rules Fields To view field validation rules: • View Setup and Activate Validation Rules Configuration To define or change field validation rules: • Customize Application
289 Extend Salesforce with Clicks, Not Code Customize Fields
Activate Validation Rules
1. From the management settings for the relevant object, go to Validation Rules. EDITIONS 2. Click Edit next to the rule you want to activate. 3. To activate the rule, select Active, and save your changes. Available in: both Salesforce Classic and Lightning 4. To deactivate the rule, deselect Active, and save your changes. Experience
Note: The detail page of a custom activity field does not list associated validation rules. Available in: Essentials, Contact Manager, Group, Professional, Enterprise, SEE ALSO: Performance, Unlimited, Define Validation Rules Developer, and Validation Rules Fields Database.com Editions Find Object Management Settings USER PERMISSIONS
To view field validation rules: • View Setup and Configuration To define or change field validation rules: • Customize Application
Validation Rules Fields
Field Description EDITIONS
Rule Name Unique identifier of up to 40 characters with no spaces or special Available in: both Salesforce characters such as extended characters. Classic and Lightning Experience Active Checkbox that indicates if the rule is enabled. Available in: Essentials, Description A 255-character or less description that distinguishes the validation Contact Manager, Group, rule from others. For internal purposes only. Professional, Enterprise, Error Condition The expression used to validate the field. See Build a Formula Field Performance, Unlimited, Formula and Formula Operators and Functions. Developer, and Database.com Editions Error Message The message that displays to the user when a field fails the validation rule. If your organization uses the Translation Workbench, you can translate the error message into the languages Salesforce supports. See Enable or Disable Translation Workbench.
Error Location Determines where on the page to display the error. To display the error next to a field, choose Field and select the field. If the error location is a field, the validation rule is also listed on the detail page of that field. If the error location is set to a field that is later deleted, to a field that is read only, or to a field that isn’t visible on
290 Extend Salesforce with Clicks, Not Code Customize Fields
Field Description the page layout, Salesforce automatically changes the location to Top of Page.
Note: Error messages can only be displayed at the top of the page in validation rules for case milestones and Ideas.
SEE ALSO: Define Validation Rules
Tips for Writing Validation Rules
• Consider all the settings in your organization that can make a record fail validation, including EDITIONS assignment rules, field updates, field-level security, or fields hidden on a page layout. • Be careful not to create contradicting validation rules for the same field; otherwise, users won’t Available in: both Salesforce be able to save the record. Classic and Lightning Experience Tip: A poorly designed validation rule can prevent users from saving valid data. Make sure you thoroughly test a validation rule before activating it. You can also use the debug Available in: Essentials, log to monitor the details of your rule implementation. Contact Manager, Group, Professional, Enterprise, • When referencing related fields in a validation formula, make sure those objects are deployed. Performance, Unlimited, • Use the RecordType.Id merge field in your formula to apply different validations for Developer, and different record types. Database.com Editions • You don’t have to begin a validation rule formula with the IF function. Any Boolean error condition expression works. For example: – Correct: CloseDate < TODAY() – Incorrect: IF(CloseDate < TODAY(), TRUE, FALSE)
• Keep in mind that when a validation rule contains the BEGINS or CONTAINS function, it processes blank fields as valid. For example, if you have a validation rule that tests whether the serial number of an asset begins with “3”, all assets with a blank serial number are considered valid. • When using a validation rule to ensure that a number field contains a specific value, use the ISBLANK function to include fields that don’t contain any value. For example, to validate that a custom field contains a value of ‘1’, use the following validation rule to display an error if the field is blank or any other number:
OR (ISBLANK (field__c), field__c<>1)
• Avoid using the IsClosed or IsWon opportunity merge fields in validation formulas. Instead, use the ISPICKVAL function to determine if the Stage contains the appropriate value. For example, the following validation formula makes a custom Project Start Date field required whenever the Stage is “Closed Won”:
AND(ISPICKVAL(StageName, "Closed Won"), ISBLANK(Project_Start_Date__c))
• Simplify your validation formulas by using checkbox fields, which don't require any operator because they return true or false. For example, the following validation formula checks to be sure an opportunity has opportunity products using the HasOpportunityLineItem merge field before users can save a change to it:
NOT(OR(ISNEW(),HasOpportunityLineItem))
291 Extend Salesforce with Clicks, Not Code Customize Fields
Tips for Writing Validation Rule Error Messages • Give instructions. An error message like “invalid entry” doesn’t tell the user what type of entry is valid. Write something more specific, such as “Close Date must be after today.” • Always include the field label. Users might not know what field is failing validation, especially if the error message appears at the top of the page.
Note: When defining validation rules, you can set the error location to Top of Page or Field. If the error location is set to a field that is later deleted, to a field that is read only, or to a field that isn’t visible on the page layout, Salesforce automatically changes the location to Top of Page.
• If you have a multilingual organization, translate your error messages. You can translate error messages using the Translation Workbench. • Assign corresponding numbers to validation rules and their error messages. This allows you to identify the source of the error.
SEE ALSO: Define Validation Rules Validation Rule Considerations
Validation Rule Considerations
Validation rules verify that the data a user enters in a record meets the standards you specify before EDITIONS the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include Available in: both Salesforce an error message to display to the user when the rule returns a value of “True” due to an invalid Classic (not available in all value. Review these considerations before implementing validation rules in your organization. orgs) and Lightning Experience
How Salesforce Processes Validation Rules Available in: Essentials, Salesforce processes rules in the following order: Contact Manager, Group, Professional, Enterprise, 1. Validation rules Performance, Unlimited, 2. Assignment rules Developer, and Database.com Editions 3. Auto-response rules 4. Workflow rules (with immediate actions) 5. Escalation rules In addition, • When one validation rule fails, Salesforce continues to check other validation rules on that field or other fields n the page and displays all error messages at once. • If validation rules exist for activities and you create an activity during lead conversion, the lead converts but a task isn’t created. • Validation rules are only enforced during lead conversion if validation and triggers for lead conversion are enabled in your organization. • Campaign hierarchies ignore validation rules. • Salesforce runs validation rules before it creates records submitted via Web-to-Lead and Web-to-Case and then creates records that have valid values. • To give a default value to a division field before the validation rule evaluation, the division field must be on the page layout. • Validation rules continue to run on individual records if the owner is changed. If the Mass Transfer tool is used to change the ownership of multiple records, however, validation rules don’t run on those records.
292 Extend Salesforce with Clicks, Not Code Customize Fields
Validation Rule Field Restrictions Validation rule formulas don’t or can’t refer to: • Compound fields, including addresses, first and last names, and dependent picklists and lookups
Note: However, you can use compound fields in ISNULL, ISBLANK, and ISCHANGED functions.
• Campaign statistic fields, including statistics for individual campaigns and campaign hierarchies • Merge fields for auto-number or compound address fields, such as Mailing Address
Note: You can use merge fields for individual address fields, such as Billing City, in validation rule formulas.
In relation to other fields and functions in Salesforce, validation rules behave as follows: • The detail page of a custom activity field doesn't list associated validation rules. • Workflow rules and some processes can invalidate previously valid fields. Invalidation occurs because updates to records based on workflow rules and also on process scheduled actions don’t trigger validation rules. • Process record updates on immediate actions do fire validation rules. • You can’t create validation rules for relationship group members. • You can use roll-up summary fields in validation rules because the fields don’t display on edit pages. Don’t use roll-up summary fields as the error location.
Lookup Filters vs. Validation Rules Validation rules and lookup filters achieve similar ends, but offer different advantages. Use a lookup filter: • To improve user efficiency by limiting the number of available options in a lookup search dialog. • To improve user efficiency by automating filters on lookup search dialogs that your users manually set. Use a validation rule: • If you're close to the maximum number of lookup filters allowed. • To implement a complex business rule that requires you to use a formula. Formulas can reference fields that basic filter criteria can't reference, such as fields on the parent of the source object. Formulas can also use functions. For example, use ISNEW to apply the rule only on record creation, or ISCHANGED to apply the rule only when a field changes.
SEE ALSO: Define Validation Rules Activate Validation Rules Examples of Validation Rules
293 Extend Salesforce with Clicks, Not Code Customize Fields
Examples of Validation Rules
Review examples of validation rules for various types of apps that you can use and modify for your EDITIONS own purposes. Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. Available in: both Salesforce Use the following samples for validation rules in Salesforce and Salesforce AppExchange apps, Classic and Lightning including: Experience Available in: Contact Sample Account Address Validation Rules Manager, Group, Professional, Enterprise, Sample Account Validation Rules Performance, Unlimited, Sample Call Center Validation Rules Developer, and Sample Experience Cloud Site Validation Rules Database.com Editions Sample Contact Validation Rules USER PERMISSIONS Sample Cross Object Validation Rules Sample Date Validation Rules To view field validation rules: • View Setup and Sample Number Validation Rules Configuration Sample Opportunity Management Validation Rules To define or change field Sample Quote Validation Rules validation rules: • Customize Application Sample User, Role, and Profile Validation Rules Miscellaneous Sample Validation Rules
SEE ALSO: Validation Rules Define Validation Rules
Sample Account Address Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
294 Extend Salesforce with Clicks, Not Code Customize Fields
Canadian Billing Postal Code
Field Value Description: Validates that the account Billing Zip/Postal Code is in the correct format if Billing Country is Canada.
Formula: AND( OR(BillingCountry = "CAN", BillingCountry = "CA", BillingCountry = "Canada"), NOT(REGEX(BillingPostalCode, "((?i)[ABCEGHJKLMNPRSTVXY]\\d[A-Z]?\\s?\\d[A-Z]\\d)?")) )
Error Message: Canadian postal code must be in A9A 9A9 format.
Error Location: Billing Zip/Postal Code
Billing Zip Code Is in Billing State
Field Value Description: Validates that the account Billing Zip/Postal Code is valid by looking up the first five characters of the value in a custom object called Zip_Code__c that contains a record for every valid zip code in the US. If the zip code is not found in the Zip_Code__c object, or the Billing State does not match the corresponding State_Code__c in the Zip_Code__c object, an error is displayed.
Formula: VLOOKUP( $ObjectType.Zip_Code__c.Fields.City__c , $ObjectType.Zip_Code__c.Fields.Name , LEFT(BillingPostalCode,5)) <> BillingCity
Error Message: Billing Zip Code does not exist in specified Billing State.
Error Location: Billing Zip/Postal Code
295 Extend Salesforce with Clicks, Not Code Customize Fields
US Billing Zip Code
Field Value Description: Validates that the account Billing Zip/Postal Code is in 99999 or 99999-9999 format if Billing Country is USA or US.
Formula: AND( OR(BillingCountry = "USA", BillingCountry = "US"), NOT(REGEX(BillingPostalCode, "\\d{5}(-\\d{4})?")) )
Note: This example uses the REGEX function; see Shipping Zip Code if you are not familiar with regular expressions.
Error Message: Zip code must be in 99999 or 99999-9999 format.
Error Location: Billing Zip/Postal Code
296 Extend Salesforce with Clicks, Not Code Customize Fields
Shipping Zip Code
Field Value Description: Validates that the account Shipping Zip/Postal Code is in 99999 or 99999-9999 format if Shipping Country is USA or blank.
Formula: AND( OR(ShippingCountry = "USA", ISBLANK(ShippingCountry)), OR( AND(LEN(ShippingPostalCode) <>5, LEN(ShippingPostalCode) <> 10), NOT(CONTAINS("0123456789", LEFT( ShippingPostalCode, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 2, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 3, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 4, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 5, 1))), AND( LEN(ShippingPostalCode) = 10, OR( MID( ShippingPostalCode , 6, 1) <> "-", NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 7, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 8, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 9, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 10, 1))) ) ) ) )
Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
Tip: You can also validate zip codes using a regular expression; for an example of a formula using a regular expression, see REGEX on page 401.
Error Message: Zip code must be in 99999 or 99999-9999 format.
Error Location: Shipping Zip/Postal Code
297 Extend Salesforce with Clicks, Not Code Customize Fields
Valid Billing State (US)
Field Value Description: Validates that the account Billing State/Province is a valid two-character abbreviation if Billing Country is US, USA, or blank.
Formula: AND ( OR(BillingCountry = "US", BillingCountry="USA", ISBLANK(BillingCountry)), OR( LEN(BillingState) < 2, NOT( CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & "IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & "NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & "WA:WV:WI:WY", BillingState) )))
Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
Error Message: A valid two-letter state code is required.
Error Location: Billing State/Province
Valid Billing Province (Canada)
Field Value Description: Validates that the account Billing State/Province is a valid two-character abbreviation if Billing Country is CA or CAN.
Formula: AND ( OR(BillingCountry = "CA", BillingCountry="CAN"), OR( LEN(BillingState) < 2, NOT( CONTAINS("AB:BC:MB:NB:NL:NT:NS:NU:ON:PC:QC:SK:YT", BillingState) )))
Error Message: A valid two-letter province code is required.
Error Location: Billing State/Province
298 Extend Salesforce with Clicks, Not Code Customize Fields
Valid Shipping State
Field Value Description: Validates that the account Shipping State/Province is a valid two-character abbreviation if Shipping Country is US, USA, or blank.
Formula: AND ( OR(ShippingCountry = "US", ShippingCountry="USA", ISBLANK(ShippingCountry)), OR( LEN(ShippingState) < 2, NOT( CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & "IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & "NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & "WA:WV:WI:WY", ShippingState) )))
Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
Error Message: A valid two-letter state abbreviation is required.
Error Location: Shipping State/Province
Valid Shipping Province (Canada)
Field Value Description: Validates that the account Shipping State/Province is a valid two-character abbreviation, if Billing Country is CA or CAN.
Formula: AND ( OR(ShippingCountry = "CA", ShippingCountry="CAN"), OR( LEN(ShippingState) < 2, NOT( CONTAINS("AB:BC:MB:NB:NL:NT:NS:NU:ON:PC:QC:SK:YT", ShippingState) )))
Error Message: A valid two-letter province abbreviation is required.
Error Location: Shipping State/Province
299 Extend Salesforce with Clicks, Not Code Customize Fields
Valid Billing Country
Field Value Description: Validates that the account Billing Country is a valid ISO 3166 two-letter code.
Formula: OR( LEN(BillingCountry) = 1, NOT( CONTAINS( "AF:AX:AL:DZ:AS:AD:AO:AI:AQ:AG:AR:AM:" & "AW:AU:AZ:BS:BH:BD:BB:BY:BE:BZ:BJ:BM:BT:BO:" & "BA:BW:BV:BR:IO:BN:BG:BF:BI:KH:CM:CA:CV:KY:" & "CF:TD:CL:CN:CX:CC:CO:KM:CG:CD:CK:CR:CI:HR:" & "CU:CY:CZ:DK:DJ:DM:DO:EC:EG:SV:GQ:ER:EE:ET:FK:" & "FO:FJ:FI:FR:GF:PF:TF:GA:GM:GE:DE:GH:GI:GR:GL:" & "GD:GP:GU:GT:GG:GN:GW:GY:HT:HM:VA:HN:HK:HU:" & "IS:IN:ID:IR:IQ:IE:IM:IL:IT:JM:JP:JE:JO:KZ:KE:KI:" & "KP:KR:KW:KG:LA:LV:LB:LS:LR:LY:LI:LT:LU:MO:MK:" & "MG:MW:MY:MV:ML:MT:MH:MQ:MR:MU:YT:MX:FM:MD:MC:" & "MC:MN:ME:MS:MA:MZ:MM:MA:NR:NP:NL:AN:NC:NZ:NI:" & "NE:NG:NU:NF:MP:NO:OM:PK:PW:PS:PA:PG:PY:PE:PH:" & "PN:PL:PT:PR:QA:RE:RO:RU:RW:SH:KN:LC:PM:VC:WS:" & "SM:ST:SA:SN:RS:SC:SL:SG:SK:SI:SB:SO:ZA:GS:ES:" & "LK:SD:SR:SJ:SZ:SE:CH:SY:TW:TJ:TZ:TH:TL:TG:TK:" & "TO:TT:TN:TR:TM:TC:TV:UG:UA:AE:GB:US:UM:UY:UZ:" & "VU:VE:VN:VG:VI:WF:EH:YE:ZM:ZW", BillingCountry)))
Error Message: A valid two-letter country code is required.
Error Location: Billing Country
Sample Account Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Account Number Is Numeric Classic and Lightning Experience
Field Value Available in: Contact Description: Validates that the Account Number is numeric if not blank. Manager, Group, Professional, Enterprise, Formula: Performance, Unlimited, AND( Developer, and ISBLANK(AccountNumber), Database.com Editions NOT(ISNUMBER(AccountNumber)) )
Error Message: Account Number is not numeric.
Error Location: Account Number
300 Extend Salesforce with Clicks, Not Code Customize Fields
Account Number Length
Field Value Description: Validates that the Account Number is exactly seven digits (if it is not blank). The number seven is simply illustrative. You can change this to any number you like.
Formula: AND( ISBLANK(AccountNumber), LEN(AccountNumber) <> 7 )
Error Message: Account Number must be seven digits.
Error Location: Account Number
Annual Revenue Range
Field Value Description: Validates that the account Annual Revenue is not negative and does not exceed $100 billion. This limit is designed to catch typos.
Formula: OR( AnnualRevenue < 0, AnnualRevenue > 100000000000 )
Error Message: Annual Revenue cannot exceed 100 billion.
Error Location: Annual Revenue
Sample Call Center Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: Essentials, Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
301 Extend Salesforce with Clicks, Not Code Customize Fields
Conditionally Require Description When Case Reason is “Other”
Field Value Description: Validates that a custom field called Other Reason contains a value if a case has a Case Reason of “Other.”
Formula: AND( ISPICKVAL( Reason, "Other" ), ISBLANK(Other_Reason__c) )
Error Message: Description of Other Reason is required.
Error Location: Other Reason
Prevent Open Cases from Being Reset to New
Field Value Description: If a case is already open, prevents the Status from being changed back to “New.”
Formula: AND( ISCHANGED( Status ), NOT(ISPICKVAL(PRIORVALUE( Status ), "New")), ISPICKVAL( Status, "New") )
Error Message: Open case Status cannot be reset to New.
Error Location: Status
Restrict Status of Re-Opened Cases
Field Value Description: Validates that the case Status is “Re-opened” when a closed case is opened again.
Formula: AND( ISCHANGED( Status ), OR( ISPICKVAL(PRIORVALUE( Status ), "Closed"), ISPICKVAL(PRIORVALUE( Status ), "Closed in SSP")), NOT( ISPICKVAL( Status, "Re-Opened")) )
Error Message: Closed case can only be changed to “Re-opened.”
Error Location: Status
302 Extend Salesforce with Clicks, Not Code Customize Fields
Prevent Case Milestone Completion After Cases Are Closed
Field Value Description: Validates that a milestone's Completion Date can't occur after the case's Status is Closed.
Formula: Case.IsClosed = true
Error Message: You can't complete a milestone after a case is closed.
Error Location: Top of Page
Prevent Case Milestone Completion Before Case Creation Dates
Field Value Description: Validates that the milestone's Completion Date has occurred after the case's Date/Time Opened.
Formula: CompletionDate >= Case.CreatedDate && CompletionDate <= Case.ClosedDate
Error Message: The milestone Completion Date must occur after the date the case was created and before the case was closed.
Error Location: Top of Page
Sample Experience Cloud Site Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Preventing Offensive Language in Questions Classic and Lightning Experience
Field Value Available in: Contact Description: Prevents users from entering offensive language in the Title and Manager, Group, Professional, Enterprise, Description fields when asking a question. Performance, Unlimited, Formula: Developer, and OR(CONTAINS(Title, 'darn'), CONTAINS(Body, Database.com Editions 'darn'))
Error Message: Question title or description contains offensive language.
303 Extend Salesforce with Clicks, Not Code Customize Fields
Preventing Offensive Language in Replies
Field Value Description: Prevents users from entering offensive language when replying to a question.
Formula: OR(CONTAINS(Body, 'darn'), CONTAINS(Body, 'dang'))
Error Message: Reply contains offensive language.
Preventing Offensive Language in Ideas
Field Value Description: Prevents users from entering offensive language in the Title and Description fields when posting an idea.
Formula: OR(CONTAINS(Title, 'darn'), CONTAINS(Body, 'darn'))
Error Message: Idea title or description contains offensive language.
Preventing Offensive Language in Idea Comments
Field Value Description: Prevents users from entering offensive language when posting a comment.
Formula: OR(CONTAINS(CommentBody , 'darn'), CONTAINS(CommentBody, 'dang'))
Error Message: Comment contains offensive language.
Sample Contact Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
304 Extend Salesforce with Clicks, Not Code Customize Fields
Mailing Address Fields Are Required
Field Value Description: Validates that the contact Mailing Street, Mailing City, and Mailing Country are provided.
Formula: OR( ISBLANK( MailingStreet ), ISBLANK( MailingCity ), ISBLANK( MailingCountry ) )
Error Message: Mailing Street, City, and Country are required.
Error Location: Top of Page
Mailing Street Is Required
Field Value Description: Validates that the contact Mailing Street is provided.
Formula: ISBLANK( MailingStreet )
Error Message: Mailing Street is required.
Error Location: Mailing Street
305 Extend Salesforce with Clicks, Not Code Customize Fields
Mailing Zip Code
Field Value Description: Validates that the contact Mailing Zip/Postal Code is in 99999 or 99999-9999 format if Mailing Country is USA or blank.
Formula: AND( OR(MailingCountry = "USA", ISBLANK(MailingCountry)), OR( AND(LEN(MailingPostalCode) <>5, LEN(MailingPostalCode) <> 10), NOT(CONTAINS("0123456789", LEFT( MailingPostalCode, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 2, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 3, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 4, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 5, 1))), AND( LEN(MailingPostalCode) = 10, OR( MID( MailingPostalCode , 6, 1) <> "-", NOT(CONTAINS("0123456789", MID( MailingPostalCode , 7, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 8, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 9, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 10, 1))) ) ) ) )
Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
Tip: You can also validate zip codes using a regular expression; for an example of a formula using a regular expression, see REGEX on page 401.
Error Message: Zip code must be in 99999 or 99999-9999 format.
Error Location: Mailing Zip/Postal Code
306 Extend Salesforce with Clicks, Not Code Customize Fields
Phone Number Has International Format
Field Value Description: Validates that the Phone number begins with a plus sign (+) for country code. Note that this validation rule conflicts with the ten-digit rule.
Formula: LEFT(Phone, 1) <> "+"
Error Message: Phone number must begin with + (country code).
Error Location: Phone
US Phone Number Has Ten Digits
Field Value Description: Validates that the Phone number is in (999) 999-9999 format. This works by using the REGEX function to check that the number has ten digits in the (999) 999-9999 format.
Formula: NOT(REGEX(Phone, "\\D*?(\\d\\D*?){10}"))
Error Message: US phone numbers should be in this format: (999) 999-9999.
Error Location: Phone
Sample Cross Object Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Discounts Must Be Within Range Classic and Lightning Experience This example consists of three validation rules on opportunity products. The examples below work together to help you manage discount amounts for products and require a custom percent field Available in: Contact on opportunity products called Line Discount. The examples below also require you to use Manager, Group, price books and customize the Product Family field to include the following values: Professional, Enterprise, Software, Consulting, and Training. Performance, Unlimited, Developer, and Software Discounts Database.com Editions
Field Value Description: Prevents users from saving software products with a discount over 10 percent.
Formula: AND(Line_Discount__c > 0.10, ISPICKVAL(Product2.Family, "Software"))
307 Extend Salesforce with Clicks, Not Code Customize Fields
Field Value Error Message: The discount must be 10% or less for software products.
Error Location: Line Discount
Consulting Discounts
Field Value Description: Prevents users from saving consulting products with a discount over 15 percent.
Formula: AND(Line_Discount__c > 0.15, ISPICKVAL(Product2.Family, "Consulting"))
Error Message: The discount must be 15% or less for consulting products.
Error Location: Line Discount
Training Discounts
Field Value Description: Prevents users from saving training products with a discount over 20 percent.
Formula: AND(Line_Discount__c > 0.20, ISPICKVAL(Product2.Family, "Training"))
Error Message: The discount must be 20% or less for training products.
Error Location: Line Discount
Prevent Changing Opportunity Products on Closed Opportunities This example consists of two validation rules: one on opportunity products and another on opportunities.
Field Value Description: Prevents users from editing opportunity products after an opportunity is closed. Create the following validation rule example on opportunity products.
Formula: OR(ISPICKVAL(Opportunity.StageName, "Closed Won"), ISPICKVAL(Opportunity.StageName, "Closed Lost"))
Error Message: Cannot change opportunity products for closed opportunities.
308 Extend Salesforce with Clicks, Not Code Customize Fields
Field Value Error Location: Top of Page
The following validation rule is on opportunities.
Field Value Description: Prevents users from deleting opportunity products after an opportunity is closed. Create the following validation rule example on opportunities. It uses a custom roll-up summary field on opportunities that counts the number of opportunity products on an opportunity.
Formula: AND(OR(ISPICKVAL(StageName, "Closed Won"), ISPICKVAL(StageName, "Closed Lost")), Number_of_Line_Items__c < PRIORVALUE(Number_of_Line_Items__c) )
Error Message: Cannot delete opportunity products for closed opportunities.
Error Location: Top of Page
Prevent Saving a Case When Account Does Not Have Support
Field Value Description: Prevents users from saving a case for an account that does not have support. This example assumes you have a custom checkbox field on accounts called Allowed Support that tracks if the account has support.
Formula: Account.Allowed_Support__c = FALSE
Error Message: Unable to create cases for this account because it is not signed up for support.
Error Location: Top of Page
Prevent Saving a Case When Contact is No Longer with the Company
Field Value Description: Prevents users from saving an open case associated with a contact that is no longer with the company. This example uses a custom checkbox field on contacts called No Longer With Company.
309 Extend Salesforce with Clicks, Not Code Customize Fields
Field Value Formula: AND(Contact.Not_Longer_With_Company__c, NOT(IsClosed))
Error Message: Unable to save this case because the related contact is no longer with the company. To continue, choose another contact.
Error Location: Contact Name
Sample Date Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Date Must Be a Weekday Classic and Lightning Experience
Field Value Available in: Contact Description: Validates that the value of a custom date field is a weekday (not Manager, Group, Professional, Enterprise, Saturday or Sunday). Performance, Unlimited, Formula: Developer, and CASE(MOD( My_Date__c - DATE(1900, 1, 7), 7), Database.com Editions 0, 0, 6, 0, 1) = 0
Error Message: Date must be a weekday.
Error Location: My Date
Date Must Be a Weekend Day
Field Value Description: Validates that the value of a custom date field is a Saturday or Sunday.
Formula: CASE( MOD( My_Date__c - DATE(1900, 1, 7), 7), 0, 1, 6, 1, 0) = 0
Error Message: Date must be a weekend day.
Error Location: My Date
310 Extend Salesforce with Clicks, Not Code Customize Fields
Date Must Be in the Current Month
Field Value Description: Validates that a custom date field contains a date within the current month and year.
Formula: OR ( YEAR( My_Date__c ) <> YEAR ( TODAY() ), MONTH( My_Date__c ) <> MONTH ( TODAY() ) )
Error Message: Date must be in the current month.
Error Location: My Date
Date Must Be in the Current Year
Field Value Description: Validates that a custom date field contains a date within the current year.
Formula: YEAR( My_Date__c ) <> YEAR ( TODAY() )
Error Message: Date must be in the current year.
Error Location: My Date
Date Must Be the Last Day of the Month
Field Value Description: Validates whether a custom field called My Date is the last day of the month. To do this, it determines the date of the first day of the next month and then subtracts 1 day. It includes special case logic for December.
Formula: DAY(My_Date__c) <> IF(Month(My_Date__c)=12, 31, DAY(DATE(YEAR(My_Date__c),MONTH(My_Date__c)+1,1) - 1))
Error Message: Date must be the last day of the month.
Error Location: My Date
311 Extend Salesforce with Clicks, Not Code Customize Fields
Date Must Be Within One Year of Today
Field Value Description: Validates whether a custom field called Follow-Up Date is within one year of today’s date. This example assumes a 365 day year. (It does not handle leap years.)
Formula: Followup_Date__c - TODAY() > 365
Error Message: Follow-Up Date must be within one year of today.
Error Location: Follow-Up Date
Day of Month Cannot Be Greater Than 15
Field Value Description: Validates that a custom field called Begin Date contains a date in the first 15 days of the specified month.
Formula: DAY( Begin_Date__c ) > 15
Error Message: Begin Date cannot be after the 15th day of month.
Error Location: Begin Date
End Date Cannot Be Before Begin Date
Field Value Description: Validates that a custom field called End Date does not come before another custom field called Begin Date.
Formula: Begin_Date__c > End_Date__c
Error Message: End Date cannot be before Begin Date.
Error Location: Begin Date
312 Extend Salesforce with Clicks, Not Code Customize Fields
Expiration Date Cannot Be Before Close Date
Field Value Description: Validates that a custom field called Expiration Date does not come before Close Date.
Formula: Expiration_Date__c < CloseDate
Error Message: Expiration Date cannot be before Close Date.
Error Location: Expiration Date
Sample Number Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Time Cards Must Total 40 Hours Classic and Lightning Experience
Field Value Available in: Contact Description: Ensures that users cannot save a time card record with more than Manager, Group, Professional, Enterprise, 40 hours in a work week. This example requires five custom fields on Performance, Unlimited, your custom object, one for each day of work. Developer, and Formula: Database.com Editions Monday_Hours__c + Tuesday_Hours__c + Wednesday_Hours__c + Thursday_Hours__c + Friday_Hours__c > 40
Error Message: Your total hours cannot exceed 40.
Error Location: Top of Page
Number Cannot Be Negative
Field Value Description: Validates that a custom field called Hours Worked is not a negative number.
Formula: Hours_Worked__c < 0
Error Message: Hours Worked cannot be less than zero.
Error Location: Hours Worked
313 Extend Salesforce with Clicks, Not Code Customize Fields
Number Must Be Even
Field Value Description: Validates that a custom field called Ark Passengers is a non-negative even number.
Formula: OR( Ark_Passengers__c < 0, MOD( Ark_Passengers__c, 2) <> 0 )
Error Message: Ark Passengers must be a positive even number.
Error Location: Ark Passengers
Number Must Be Odd
Field Value Description: Validates that a custom field called Socks Found is a non-negative odd number.
Formula: OR( Socks_Found__c < 0, MOD( Socks_Found__c, 2) = 0 )
Error Message: Socks Found must be an odd number.
Error Location: Socks Found
Number Must Be a Multiple of Five
Field Value Description: Validates that a custom field called Multiple of 5 is a multiple of five.
Formula: MOD( Multiple_of_5__c, 5) <> 0
Error Message: Number must be a multiple of five.
Error Location: Multiple of 5
314 Extend Salesforce with Clicks, Not Code Customize Fields
Number Must Be an Integer
Field Value Description: Validates that a custom field called My Integer is an integer.
Formula: FLOOR( My_Integer__c) <> My_Integer__c
Error Message: This field must be an integer.
Error Location: My Integer
Number Must Be Between -50 and 50
Field Value Description: Validates that a custom field called Volume is between -50 and 50.
Formula: ABS( Volume__c) > 50
Error Message: Volume must be between -50 and 50.
Error Location: Volume
Number Range Validation
Field Value Description: Validates that the range between two custom fields, Salary Min and Salary Max, is no greater than $20,000.
Formula: (Salary_Max__c - Salary_Min__c) > 20000
Error Message: Salary range must be within $20,000. Adjust the Salary Max or Salary Min values.
Error Location: Salary Max
315 Extend Salesforce with Clicks, Not Code Customize Fields
Percentage Must Be Between Zero and 100
Field Value Description: Validates that a custom field called Mix Pct is between 0 and 100%. Note that percent fields are expressed divided by 100 in formulas (100% is expressed as 1; 50% is expressed as 0.5).
Formula: OR( Mix_Pct__c > 1.0, Mix_Pct__c < 0.0 )
Error Message: Mix Pct must be between 0 and 100%.
Error Location: Mix Pct
Sample Opportunity Management Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Conditionally-Required Field Based on Opportunity Stage Classic and Lightning Experience
Field Value Available in: Contact Description: Validates that a custom field called Delivery Date is provided Manager, Group, Professional, Enterprise, if an opportunity has advanced to the Closed Won or Performance, Unlimited, Negotiation/Review stage. Developer, and Formula: Database.com Editions AND ( OR ( ISPICKVAL(StageName, "Closed Won"), ISPICKVAL(StageName, "Negotiation/Review")), ISBLANK(Delivery_Date__c) )
Error Message: Delivery Date is required for this stage.
Error Location: Delivery Date
316 Extend Salesforce with Clicks, Not Code Customize Fields
Close Date Cannot Be Prior to Current Month
Field Value Description: Validates that the Close Date of an opportunity is not within a month prior to the current month. Note the use of ISNEW and ISCHANGED in this formula to ensure the condition is only checked when the opportunity is being created or the Close Date field is modified subsequently.
Formula: AND( OR ( ISNEW(), ISCHANGED( CloseDate )), CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1) )
Error Message: Close Date cannot be prior to current month.
Error Location: Close Date
Close Date Must Be a Future Date
Field Value Description: Ensures that users do not change the Close Date of an opportunity to a day in the past.
Formula: SampleDate < TODAY()
Error Message: Close Date cannot be a day in the past.
Error Location: Close Date
Discounts on Opportunities
Field Value Description: Validates that a custom discount percent field is between 0 and 40%.
Formula: OR(Discount_Rate__c < 0, Discount_Rate__c > 0.40)
Error Message: The Discount Rate must not exceed 40%.
Error Location: Discount Rate
317 Extend Salesforce with Clicks, Not Code Customize Fields
High-Value Opportunity Must Be Approved Before Closed
Field Value Description: Opportunities with amounts greater than $50,000 require that a custom checkbox field called Approved is checked in order to change the stage to Closed Won or Closed Lost. To automate this, set field-level security on the Approved checkbox so that it can only be checked via a custom approval process (Enterprise Edition, Unlimited Edition, or Performance Edition).
Formula: AND( OR( ISPICKVAL(StageName,"Closed Won"), ISPICKVAL(StageName,"Closed Lost")), (Amount > 50000), NOT(ISPICKVAL(Approval_Status__c ,"Approved")))
Error Message: All high-value opportunities must be approved for closure. Click the Request Close button.
Error Location: Top of Page
Opportunity Amount Cannot Exceed $10 Million
Field Value Description: Validates that opportunity Amount is positive and no more than $10 million. This limit is designed to catch typos.
Formula: OR( Amount < 0, Amount > 10000000 )
Error Message: Amount cannot exceed $10 million.
Error Location: Amount
Opportunity Check for Products
Field Value Description: Validates that an opportunity has at least one opportunity product before users can save a change to an opportunity.
Formula: NOT(OR(ISNEW(),HasOpportunityLineItem))
Error Message: You must add products to this opportunity before saving.
Error Location: Top of Page
318 Extend Salesforce with Clicks, Not Code Customize Fields
Opportunity Must Have Products if Beyond “Needs Analysis” Stage
Field Value Description: Validates that an opportunity has opportunity products before the Stage can move beyond Needs Analysis.
Formula: AND ( CASE( StageName, "Value Proposition", 1, "Id. Decision Makers", 1, "Perception Analysis", 1, "Proposal/Price Quote", 1, "Negotiation/Review", 1, "Closed Won", 1, 0) = 1, NOT(HasOpportunityLineItem) )
Error Message: Opportunity products are required to advance beyond the Needs Analysis stage.
Error Location: Top of Page
Opportunity Name Format
Field Value Description: Validates that an opportunity contains a hyphen as a way of enforcing an “[Account] - [Amount]” opportunity naming convention.
Formula: FIND( " - ", Name ) = 0
Error Message: Opportunity Name should use “[Account] - [Amount]” format.
Error Location: Opportunity Name
319 Extend Salesforce with Clicks, Not Code Customize Fields
Prevent Sales Reps from Moving Opportunity Stage Backwards
Field Value Description: Prevent sales reps from changing opportunity Stage “backwards” to specific values, once they have accepted the opportunity via a custom approval process. The approval process sets the custom Accepted Flag checkbox to True.
Formula: AND( Accepted_Flag__c, OR ( ISPICKVAL( StageName, "Stage 1"), ISPICKVAL( StageName, "Stage 2")) )
Error Message: Invalid stage for accepted opportunity.
Error Location: Stage
Probability Must Be 100% for Won Opportunities
Field Value Description: Validates that the probability of a won opportunity is properly set to 100%. This is useful for data cleanliness and reporting purposes.
Formula: AND ( ISPICKVAL( StageName, "Closed Won"), Probability <> 1)
Error Message: Probability must be 100% for won opportunities.
Error Location: Probability
Probability Must Be Zero for Lost Opportunities
Field Value Description: Validates that the probability of a lost opportunity is properly set to zero. This is useful for data cleanliness and reporting purposes.
Formula: AND ( ISPICKVAL( StageName, "Closed Lost"), Probability <> 0)
Error Message: Probability must be 0% for lost opportunities.
Error Location: Probability
320 Extend Salesforce with Clicks, Not Code Customize Fields
Project Start Date
Field Value Description: Validates that a field is conditionally required based on the values of other fields. Use this validation formula to ensure that users include a Project Start Date for an opportunity that is closed/won.
Formula: AND(ISPICKVAL(StageName, "Closed Won"), ISNULL(Project_Start_Date__c))
Error Message: Project start date is required for won opportunities.
Error Location: Project Start Date
Sample Quote Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Display Error if Quote Line Item Discount Exceeds 40% Classic and Lightning Experience
Field Value Available in: Contact Description: Shows an error if a quote line item's discount exceeds 40%. Manager, Group, Professional, Enterprise, Formula: Performance, Unlimited, Discount > .40 Developer, and Database.com Editions Error Message: The discount on this quote line item cannot exceed 40%.
Error Location: Discount on quote
Sample User, Role, and Profile Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
321 Extend Salesforce with Clicks, Not Code Customize Fields
Discount Percent Does Not Exceed Role-Based Limit
Field Value Description: Validates that a custom field on opportunities called Discount Percent does not exceed a maximum value that varies depending on the user’s role. The default maximum is 15%.
Formula: Discount_Percent__c > VLOOKUP($ObjectType.Role_Limits__c.Fields.Limit__c, $ObjectType.Role_Limits__c.Fields.Name, $UserRole.Name)
Error Message: Discount (%) exceeds limit allowed for your role.
Error Location: Discount Percent
Expense Amount Does Not Exceed User's Max Allowed Expense
Field Value Description: Validates a custom field called Expense Amount against a custom user field called Max Allowed Expense.
Formula: Expense_Amount__c > $User.Max_Allowed_Expense__c
Error Message: Amount cannot exceed your maximum allowed expense.
Error Location: Expense Amount
Only Record Owner Can Change Field
Field Value Description: Ensures that only the record owner can make changes to a custom field called Personal Goal.
Formula: AND( ISCHANGED( Personal_Goal__c ), Owner <> $User.Id )
Error Message: Only record owner can change Personal Goal.
Error Location: Personal Goal
322 Extend Salesforce with Clicks, Not Code Customize Fields
Only Record Owner or Administrator Can Change Field
Field Value Description: Ensures that a user can make changes to a custom field called Personal Goal only if the user is the record owner or has a custom profile of “Custom: System Admin.”
Formula: AND( ISCHANGED( Personal_Goal__c ), Owner <> $User.Id, $Profile.Name <> "Custom: System Admin" )
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
Error Message: Only record owner or administrator can change Personal Goal.
Error Location: Personal Goal
Opportunity Close Date Can Only Be Back-Dated by Administrator
Field Value Description: Validates that the Close Date of an opportunity does not fall prior to the current month, except for users who have a custom profile called “Custom: System Admin.”
Formula: AND( OR ( ISNEW(), ISCHANGED( CloseDate )), CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1), $Profile.Name <> "Custom: System Admin" )
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
Error Message: Close Date cannot be prior to current month.
Error Location: Close Date
323 Extend Salesforce with Clicks, Not Code Customize Fields
Miscellaneous Sample Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Allow Number to Be Increased but Not Decreased Classic and Lightning Experience
Field Value Available in: Contact Description: Allows a custom field called Commit Amount to be increased Manager, Group, Professional, Enterprise, but not decreased after initial creation. This rule uses the Performance, Unlimited, PRIORVALUE() function to compare the updated value of the field to Developer, and its value prior to update. Database.com Editions Formula: PRIORVALUE(Commit_Amount__c) > Commit_Amount__c
Error Message: Commit Amount cannot be decreased.
Error Location: Commit Amount
California Driver's License
Field Value Description: Ensures that a custom field called Drivers License is in the correct A9999999 format when the Mailing State is “CA”.
Formula: AND( MailingState = "CA", NOT(REGEX(Drivers_License__c, "([A-Z]\\d{7})?")) )
Error Message: Invalid California driver's license format.
Error Location: Drivers License
324 Extend Salesforce with Clicks, Not Code Customize Fields
Force Users to Check “I Accept Terms” to Enter Certain Values
Field Value Description: Uses a checkbox labeled “I accept terms” to force the user to select a checkbox in order to enter a value called Number of Days that exceeds their Paid Time Off (PTO) balance available.
Formula: AND( NOT( I_accept_terms__c ), Number_of_Days__c > $User.PTO_Balance__c )
Error Message: Request will cause a negative PTO balance. You must accept Negative PTO Balance terms.
Error Location: I accept terms
Prohibit Changes to a Field After It Has Been Saved
Field Value Description: Prevents users from changing a custom field called Guaranteed Rate after it has been saved initially.
Formula: AND( NOT( ISNEW() ), ISCHANGED( Guaranteed_Rate__c ) )
Error Message: Guaranteed Rate cannot be changed.
Error Location: Guaranteed Rate
325 Extend Salesforce with Clicks, Not Code Customize Fields
Social Security Number Format
Field Value Description: Validates that a custom text field called SSN is formatted in 999-99-9999 number format (if it is not blank). The pattern specifies: • Three single digits (0-9):\\d{3} • A dash • Two single digits (0-9):\\d{2} • A dash • Four single digits (0-9):\\d{4}
Formula: NOT( OR( ISBLANK(Social_Security_Number__c), REGEX( Social_Security_Number__c , "[0-9]{3}-[0-9]{2}-[0-9]{4}") ) )
Error Message: SSN must be in this format: 999-99-9999.
Error Location: SSN
Valid Currency
Field Value Description: Validates selected currency against an explicit subset of active currencies in your organization using the Currency picklist. Use this example if you only allow some of the active currencies in your organization to be applied to certain types of records.
Formula: CASE(CurrencyIsoCode, "USD", 1, "EUR", 1, "GBP", 1, "JPY", 1, 0) = 0
Error Message: Currency must be USD, EUR, GBP, or JPY.
Error Location: Currency
326 Extend Salesforce with Clicks, Not Code Customize Fields
Valid Credit Card Number
Field Value Description: Validates that a custom text field called Credit_Card_Number is formatted in 9999-9999-9999-9999 or 9999999999999999 number format when it is not blank. The pattern specifies: • Four digits (0-9) followed by a dash: \\d{4}- • The aforementioned pattern is repeated three times by wrapping it in () {3} • Four digits (0-9) • The OR character (|) allows an alternative pattern of 16 digits of zero through nine with no dashes: \\d{16}
Formula: NOT( REGEX( Credit_Card_Number__c , "(((\\d{4}-){3}\\d{4})|\\d{16})?"))
Error Message: Credit Card Number must be in this format: 9999-9999-9999-9999 or 9999999999999999.
Error Location: Credit Card Number
Valid IP Address
Field Value Description: Ensures that a custom field called IP Address is in the correct format, four 3-digit numbers (0-255) separated by periods.
Formula: NOT( REGEX( IP_Address__c, "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.) {3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ))
Error Message: Error: IP Address must be in form 999.999.999.999 where each part is between 0 and 255.
Error Location: IP Address
327 Extend Salesforce with Clicks, Not Code Customize Fields
Website Extension
Field Value Description: Validates a custom field called Web Site to ensure its last four characters are in an explicit set of valid website extensions.
Formula: AND( RIGHT( Web_Site__c, 4) <> ".COM", RIGHT( Web_Site__c, 4) <> ".com", RIGHT( Web_Site__c, 4) <> ".ORG", RIGHT( Web_Site__c, 4) <> ".org", RIGHT( Web_Site__c, 4) <> ".NET", RIGHT( Web_Site__c, 4) <> ".net", RIGHT( Web_Site__c, 6) <> ".CO.UK", RIGHT( Web_Site__c, 6) <> ".co.uk" )
Error Message: Web Site must have an extension of .com, .org, .net, or .co.uk.
Error Location: Web Site
Require Field Input to Ensure Data Quality
Improve the quality of data that users enter in Salesforce by creating universally required fields. EDITIONS A universally required field is a custom field. It must have a value whenever a record is saved within Salesforce, the Lightning Platform API, Connect Offline, Salesforce for Outlook, the Self-Service Available in: both Salesforce portal, or automated processes such as Web-to-Lead and Web-to-Case. Making a field required on Classic (not available in all a page layout or through field-level security ensures that users must enter a value. Making a field orgs) and Lightning required universally gives you a higher level of data quality beyond the presentation level of page Experience layouts. Available in: Contact You can make the following types of custom fields universally required: Manager, Group, Professional, Enterprise, • Currency Performance, Unlimited, • Date Developer, and • Date/Time Database.com Editions • Email Connect Offline, Salesforce • Master-Detail Relationship (always required) for Outlook, the Self-Service portal, Web-to-Lead, and • Number Web-to-Case are not • Percent available in Database.com • Phone . • Picklist • Text • Text Area • URL To make a custom field universally required, select the Required checkbox when defining the custom field.
328 Extend Salesforce with Clicks, Not Code Customize Fields
Note: You must specify a default value for required campaign member custom fields. If you make a user field universally required, you must specify a default value for that field.
Relationship group members do not support universally required fields.
Considerations for Universally Required Fields
Considerations for Universally Required Fields
A universally required field is a custom field. It must have a value whenever a record is saved within EDITIONS Salesforce, the Lightning Platform API, Connect Offline, Salesforce for Outlook, the Self-Service portal, or automated processes such as Web-to-Lead and Web-to-Case. Review the following Available in: both Salesforce considerations before making your custom fields universally required. Classic (not available in all • Standard fields cannot be universally required. orgs) and Lightning Experience • Universally required fields are required across all record types. • Edit pages always display universally required fields, regardless of field-level security. Available in: Contact Manager, Group, • When designing your page layouts, universally required fields: Professional, Enterprise, – Cannot be removed from a page layout Performance, Unlimited, – Are automatically added to the end of the first section of a page layout if not already on it Developer, and Database.com Editions – Cannot be read only or optional – Display in bold, indicating they are always visible Standard Objects, Page Layouts, Connect Offline, – Are disabled on the field properties page because you cannot remove the required setting Salesforce for Outlook, the • Universally required fields are only enforced during lead conversion if validation and triggers Self-Service portal, Web-to-Lead, and for lead conversion are enabled in your organization. Web-to-Cases are not • Quick Create does not enforce universally required fields. available in Database.com • If you make an activity custom field universally required, you must also provide a default value. • You must include universally required fields in your import files or the import will fail. • Don’t assign default values to fields that are both required and unique, because uniqueness errors can result. • You cannot make a field universally required if it is used by a field update that sets the field to a blank value. • Required fields may be blank on records that existed before making the field required. When a user updates a record with a blank required field, the user must enter a value in the required field before saving the record. • Web-to-Lead and Web-to-Case request data is not validated by Salesforce. Invalid data isn’t saved when requests are submitted. For example, if your custom field is a currency field and a user enters alphabetic characters such as “Abc” instead of numbers, the request is still submitted but with no value saved in the custom currency field.
SEE ALSO: Require Field Input to Ensure Data Quality
329 Extend Salesforce with Clicks, Not Code Customize Fields
About Field Sets
A field set is a grouping of fields. For example, you could have a field set that contains fields describing EDITIONS a user's first name, middle name, last name, and business title. When a field set is added to a Visualforce page, developers can loop over its fields and render them. If the page is added to a Available in: Salesforce managed package, administrators can add, remove, or reorder fields in a field set to modify the Classic fields presented on the Visualforce page without modifying any code. The same Visualforce page can present different sets of information, depending on which fields a subscriber prefers to keep. Available in: Group, Professional, Enterprise, As an administrator, you can create or edit field sets for your organization, or edit any installed field Performance, Unlimited, set. Field sets are available on all standard objects that support custom fields, and any organization and Developer Editions that supports creating Visualforce pages.
Note: Only fields available in the API can be added to field sets.
Fields added to a field set can be in one of two categories: • If a field is marked as Available for the Field Set, it exists in the field set, but the developer hasn’t presented it on the packaged Visualforce page. Administrators can display the field after the field set is deployed by moving it from the Available column to the In the Field Set column. • If a field is marked as In the Field Set, the developer has rendered the field on the packaged Visualforce page by default. Administrators can remove the field from the page after the field set is deployed by removing it from the In the Field Set column.
Creating and Editing Field Sets Field Sets Required Bit
SEE ALSO: Create Custom Fields Developer's Guide: Visualforce Developer's Guide ISVforce Guide
Creating and Editing Field Sets
Salesforce has a drag-and-drop WYSIWYG tool for creating and editing field sets The enhanced EDITIONS field sets editor is enabled by default, and provides all of the functionality of the original editor, as well as additional functionality and an easier-to-use WYSIWYG interface. Available in: Salesforce 1. From the management settings for the appropriate object, go to Field Sets, and then click New. Classic 2. Enter a Field Set Label. This is the name presented to subscribers who install the field through Available in: Contact a managed package. Manager, Group, 3. Optionally, enter a name for your field set. This is used by your Visualforce page to reference Professional, Enterprise, Performance, Unlimited, the field set. and Developer Editions 4. In the Where is this used? area, provide a brief description of which Visualforce pages use the field set, and for what purpose. This information helps a subscriber understand where and how an installed field set is being used, so that they can populate it with their own fields. 5. Save your changes.
330 Extend Salesforce with Clicks, Not Code Customize Fields
6. To add fields to the field set, drag the fields from the object palette and drop them into the Available for the Field Set or the In the Field Set container. The fields in the Available for the Field Set container are not initially visible on the Visualforce page. The fields in the In the Field Set container are visible by default.
Note: In the field set, you can span to fields that reference multiple objects. When you span a field into a field set that references multiple objects, the only field you can span to is the Name object. You can drag and drop a field from one container to the other. The vertical order of the In the Field Set list indicates the order of how the fields render on Visualforce pages.
7. To remove a field from the field set, drag the element back to the object palette, or click next to the element. 8. To make a field required, double click the element or click ( ) next to it and select the Required checkbox.
Note: Indicates the field is required and must have a value to save the record.
9. Save your changes.
Important: The total number of cross object spans within the In the Field Set container can't exceed 25.
After a field set is deployed in your organization, you can always mark fields that are in the Available for the Field Set list as In the Field Set, or vice versa. To do so: 1. Find the field set that you want to edit. From Setup enter Installed Packages in the Quick Find box, select Installed Packages, click an installed package, and then click the field set you want to edit. Alternatively, if you know which object contains the field set you want to edit, go to the object detail page and click Edit in the field set related list. 2. If you didn't create the field set initially, you'll only be able to edit the fields within the field set. To move fields between containers, drag and drop a field from one container to the other. To change the order of a rendered field, drag a field up or down the list and drop the field in the order you want it to appear. 3. Save your changes.
SEE ALSO: About Field Sets
Field Sets Required Bit
You can define a field as required when you create or edit field sets. You may want to define a field EDITIONS as required to ensure a user enters the necessary information on a field. The required field is only available in the In the Field Set container. If you define a field as required in the In Available in: Salesforce the Field Set container, and remove the field from the In the Field Set, the Classic required attribute is removed. Available in: Group, Note: If you remove fields that were made required by an installed managed package from Professional, Enterprise, the In the Field Set container, the required attribute isn’t removed from those Performance, Unlimited, fields. and Developer Editions To define a field as required in a field set, see Creating and Editing Field Sets on page 330
SEE ALSO: About Field Sets
331 Extend Salesforce with Clicks, Not Code Customize Fields
Roll-Up Summary Field
A roll-up summary field calculates values from related records, such as those in a related list. You EDITIONS can create a roll-up summary field to display a value in a master record based on the values of fields in a detail record. The detail record must be related to the master through a master-detail relationship. Available in: both Salesforce For example, you want to display the sum of invoice amounts for all related invoice custom object Classic (not available in all records in an account’s Invoices related list. You can display this total in a custom account field orgs) and Lightning called Total Invoice Amount. Experience
You can perform different types of calculations with a roll-up summary field. You can count the Available in: Contact number of detail records related to a master record. Or, you can calculate the sum, minimum value, Manager, Group, or maximum value of a field in the detail records. Professional, Enterprise, Before you begin creating roll-up summary fields for your organization, review the implementation Performance, Unlimited, tips and best practices. Developer, and Database.com Editions Implementation Tips Administration • Create roll-up summary fields on: – Any custom object that is on the master side of a master-detail relationship – Any standard object that is on the master side of a master-detail relationship with a custom object – Opportunities using the values of opportunity products related to the opportunity – Accounts using the values of related opportunities – Campaigns using campaign member status or the values of campaign member custom fields
Note: Campaign member custom formula fields that reference fields derived from leads or contacts are not supported.
• The types of fields you can calculate in a roll-up summary field depend on the type of calculation. For example, – Number, currency, and percent fields are available when you select SUM as the roll-up type. – Number, currency, percent, date, and date/time fields are available when you select MIN or MAX as the roll-up type.
• Sometimes you can’t change the field type of a field that you reference in a roll-up summary field. • Make sure that the filter for your roll-up summary doesn't encounter a formula field that results in “#Error!”. If one of your filter criteria uses a formula field that results in an error, no matches are returned for that filter criterion. For example, your roll-up summary filter is “Formula Field equals 10”. Two records contain errors, and one contains the value “10” in that field. In this case, your summary includes only the record with the value “10.” • Salesforce does not recalculate the value of campaign roll-up summary fields when leads or contacts are deleted. Select the Force a mass recalculation of this field option on the edit page of the roll-up summary field to manually recalculate the value. • You can’t use long text area, multi-select picklist, Description fields, system fields like Last Activity, cross-object formula fields, and lookup fields in the field column of roll-up summary filters. • Auto number fields are not available as the field to aggregate in a roll-up summary field. • After you have created a roll-up summary field on an object, you cannot convert the object's master-detail relationship into a lookup relationship. • Roll-up summary fields are not available for mapping lead fields of converted leads. Management
332 Extend Salesforce with Clicks, Not Code Customize Fields
• If a roll-up summary field doesn’t contain cross-object field references or functions that derive values on the fly, such as NOW or TODAY, it can calculate the values of formula fields.
Note: The value of a formula field can result in “#Error!”, which affects the summarized total. If your roll-up summary type is COUNT, records are included regardless of whether they contain a formula field with an error. However, when the Field to Aggregate is a formula field that results in “#Error!”, calculations of type MIN, MAX, and SUM exclude those formula values.
• Changes to the value of a roll-up summary field can trigger assignment rules to run. If a roll-up summary field is part of the criteria in an assignment rule, the field’s new value is used to evaluate whether to reassign the record. • A roll-up summary field can trigger workflow rules and field validations. However, workflow rules and field validations do not fire when the following changes cause a mass recalculation of roll-up summary values: – Changing the roll-up summary definition (such as the object, function, or field being aggregated) – Changing the expression of a formula field referenced in a roll-up summary field – Replacing picklist values for picklist fields referenced in the roll-up summary filter – Changing picklist record type definitions – Changing currency conversion rates – Changing price book entries
• Calculating roll-up summary field values can take up to 30 minutes, depending on the number of records affected and other factors. • You aren’t prevented from creating roll-up summary fields that can result in invalid values, such as February 29 in a non-leap year. If a roll-up summary field results in an invalid value, the value is not recalculated. The field continues to display with an invalid roll-up summary icon ( ) until you change the values being summarized. • If your organization uses multiple currencies, the currency of the master record determines the currency of the roll-up summary field. For example, if the master and detail records are in different currencies, the detail record value is converted into the currency of the master record. • Changing a conversion rate triggers roll-up summary fields to recalculate. If you’re using multiple currencies, we recommend changing the conversion rate from Manage Currencies in Setup, and not from the API. If you change the rate from the API, related jobs that are less than 24 hours old can interfere with your change. For details, see Edit Conversion Rates. • If your organization has advanced currency management enabled, currency roll-up summary fields are invalid if they are on accounts and summarizing opportunity values, or on opportunities and summarizing custom object values. • Salesforce prevents users from saving a record if it invalidates a related record. For example, a master record has a validation rule that requires the roll-up summary field value to be greater than 100. If the user’s change to a related child record would put the value over 100, the user can’t save the record. • If a lookup field references a record that has been deleted, Salesforce clears the value of the lookup field by default. Alternatively, you can choose to prevent records from being deleted if they’re in a lookup relationship. To be used in a roll-up summary field with a Roll-Up Type of COUNT or SUM, the lookup field must have the What to do if the lookup record is deleted? option set to Don’t allow deletion of the lookup record that’s part of a lookup relationship. If the option Clear the value of this field. You can’t choose this option if you make the field required is selected, you can’t create a COUNT or SUM roll-up summary field that pulls data from your lookup field.
• When multiple currencies are enabled in an org and corporate currency is different from the currency set on the record, the UI and the database for roll-up summary field values can display different decimal values. Values in the UI are displayed as two decimal places, whereas the database displays the exact value, which can be several decimal places. This behavior is due to the way values are stored in the database. The UI precision doesn’t affect the precision of the database, which is a floating-point value.
333 Extend Salesforce with Clicks, Not Code Customize Fields
In some cases, there can be small numerical remainders after deletion or filtering of records when you use SUM as the roll-up type. To correct the value, select the Force a mass recalculation of this field option on the edit page of the roll-up summary field to manually recalculate the value.
• When you delete a roll-up summary field using Metadata API, the field isn't saved in the Recycle Bin. The field is purged even if you don’t set the purgeOnDelete deployment option to true.
Best Practices • Apply field-level security to your roll-up summary fields if they calculate values that you do not want visible to users. Fields that your users cannot see due to field-level security settings on the detail record are still calculated in a roll-up summary field. • If you have validation rules, consider how they affect roll-up summary fields. The value in a roll-up summary field changes when the values in the detail records change. So, validation errors can display when saving either the detail or master record. • Because roll-up summary fields are not displayed on edit pages, you can use them in validation rules but not as the error location for your validation. • Avoid referencing a roll-up summary field from a child record. The roll-up summary fields referenced from child records can have outdated values, because their parent records have not been updated. Instead, reference roll-up summary fields from parent records. Your roll-up summary fields will always have updated values, because that rule runs after the parent value has been updated. If you’re trying to enforce a record limit of 25 on the parent roll-up summary field, create validation rules on your child objects. When you add a child record, your validation rule on the child object can check if the count is already 25 or greater.
AND(ISNEW(), Sample.Line_Count__c >= 25)
• Plan your implementation of roll-up summary fields carefully before creating them. Once created, you cannot change the detail object selected or delete any field referenced in your roll-up summary definition. • Advanced currency management affects roll-up summary fields. If your organization enables advanced currency management, delete the currency roll-up summary fields on accounts that summarize opportunity values and on opportunities that summarize custom object values. Otherwise, the fields continue to display with an invalid roll-up summary icon because their values are no longer calculated. • Automatically derived fields, such as current date or current user, aren’t allowed in a roll-up summary field. Forbidden fields include formula fields containing functions that derive values on the fly, such as DATEVALUE, NOW, and TODAY. Formula fields that include related object merge fields are also not allowed in roll-up summary fields. • When you refer to a roll-up summary field in a list view or report, you can’t use certain qualifiers, including: – Starts with – Contains – Does not contain – Includes – Excludes – Within
334 Extend Salesforce with Clicks, Not Code Customize Fields
Defining Roll-Up Summaries Define roll-up summary fields on the object that is on the master side of a master-detail relationship.
SEE ALSO: Create Custom Fields Custom Fields Allowed Per Object
Defining Roll-Up Summaries
Define roll-up summary fields on the object that is on the master side of a master-detail relationship. EDITIONS If a relationship does not already exist, first create a master-detail relationship between the master object that displays the value and the detail object containing the records you are summarizing. Available in: both Salesforce Classic and Lightning To define a roll-up summary field: Experience 1. Create a custom field on the object where you want the field displayed. Summary fields summarize the values from records on a related object, so the object on which you create the Available in: Contact field should be on the master side of a master-detail relationship. For instructions on creating Manager, Group, Professional, Enterprise, a custom field, see Create Custom Fields on page 218. Performance, Unlimited, 2. Choose the Roll-Up Summary field type, and click Next. Developer, and 3. Enter a field label and any other attributes. Click Next. Database.com Editions 4. Select the object on the detail side of a master-detail relationship. This object contains the records you want to summarize. USER PERMISSIONS
5. Select the type of summary: To view roll-up summary field definitions: Type Description • View Setup and Configuration COUNT Totals the number of related records. To edit roll-up summary field SUM Totals the values in the field you select in the Field to Aggregate definitions: option. Only number, currency, and percent fields are available. • Customize Application
MIN Displays the lowest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
MAX Displays the highest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
6. Enter your filter criteria if you want a selected group of records in your summary calculation. If your organization uses multiple languages, enter filter values in your organization's default language. When you use picklists to specify filter criteria, the selected values are stored in the organization's default language. If you edit or clone existing filter criteria, first set the Default Language on the Company Information page to the same language that was used to set the original filter criteria. Otherwise, the filter criteria may not be evaluated as expected.
7. Click Next. 8. Set the field-level security to determine whether the field should be visible for specific profiles, and click Next.
335 Extend Salesforce with Clicks, Not Code Customize Fields
9. Choose the page layouts that should display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is automatically added to the bottom of the user detail page. 10. Click Save to finish or Save & New to create more custom fields.
SEE ALSO: Roll-Up Summary Field
Lookup Filters
Improve user productivity and data quality with lookup filters. Lookup filters are administrator EDITIONS settings that restrict the valid values and lookup dialog results for lookup, master-detail, and hierarchical relationship fields. Available in: both Salesforce Administrators specify the restrictions by configuring filter criteria that compare fields and values Classic (not available in all on: orgs) and Lightning Experience • The current record (source) • The lookup object (target) Available in: All Editions except for Database.com. • The user's record, permissions, and role • Records directly related to the target object USER PERMISSIONS For example, you can: • Restrict the Account Name field on opportunities to allow only accounts with a record type To manage lookup filters: of Customer, filtering out Partner and Competitor. • Customize Application • Restrict the Account Name field on opportunities to allow only active accounts. • Restrict the Contact field on cases to allow only contacts associated with the account specified in the Account Name field on the case record. • Restrict the Account Name field on cases to allow only users with the “International Sales” profile to create or edit cases for accounts outside the United States.
Tip: When you define a lookup filter, you can choose from a list of filter criteria that Salesforce suggests. The list is based on the relationships between objects in your org. To see the suggested criteria, select Insert Suggested Criteria. In Salesforce Classic, administrators can make lookup filters required or optional. In Lightning Experience, all lookup filters are required, even if admins specify them as optional in Setup. • For fields with required lookup filters, values that match the lookup filter criteria appear in the lookup dialog. When editing the record, users can't save invalid values that they type in the field. If a user tries to save an invalid value, Salesforce displays an error message, which administrators can customize. • For fields with optional lookup filters (Salesforce Classic only), values that match the lookup filter criteria appear in the lookup dialog. To remove the filter and view all search results for the lookup field, users can select Show all results in the lookup dialog. Also, optional lookup filters let users save values that don't match the lookup filter criteria without Salesforce displaying any error message. Lookup filter criteria can compare fields on the source object with different types of fields on the target object as long as the fields are compatible.
Source Object Field Type Compatible Target Object Field Types
Currency Currency, Roll-Up Summary
Date Date, Date/Time, Roll-Up Summary
336 Extend Salesforce with Clicks, Not Code Customize Fields
Date/Time Date, Date/Time, Roll-Up Summary
Hierarchy Hierarchy, Lookup, Master-Detail
Lookup Hierarchy, Lookup, Master-Detail
Master-Detail Lookup, Hierarchy, Master-Detail
Number Number, Percent, Roll-Up Summary
Percent Number, Percent, Roll-Up Summary
Picklist Text, Text Area, Email, URL
Roll-Up Summary Currency, Number, Date, Date/Time, Roll-Up Summary
Supported Objects Salesforce supports lookup filters on relationship fields that point to: • Accounts • Assets • Badges • Badges Received • Business Hours • Campaigns • Cases • Contacts • Content Folders • Contracts • Endorsements • Entitlements • Ideas • Leads • Opportunities • Order Products • Orders • Products • Quotes • Service contracts • Skill Users • Skills • Social Personas • Solutions • Thanks • User Provisioning Accounts
337 Extend Salesforce with Clicks, Not Code Customize Fields
• User Provisioning Logs • User Provisioning Requests • Users • Work Order Line Items • Work Orders • Zones • Custom objects
Define Lookup Filters Delete or Deactivate Lookup Filters View a List of Lookup Filters for a Target Object Dependent Lookups Considerations for Lookup Filters Notes on Using Lookup Filters with Person Accounts Lookup Filters Best Practices Lookup Filter Examples Limitations on Lookup Filters
Define Lookup Filters
1. You can create lookup filters for new relationship fields in step 3 of the custom field wizard. EDITIONS a. From the management settings for the field’s object, go to Fields. b. Click Edit next to the name of the lookup or master-detail relationship field to which you Available in: both Salesforce Classic (not available in all want to apply the filter. orgs) and Lightning 2. In the Lookup Filter Options section, click Show Filter Settings. Experience 3. Specify the filter criteria a record must meet to be a valid value. To specify criteria, click Insert Available in: All Editions Suggested Criteria and choose from a list of suggested criteria, or manually enter your own except for Database.com. criteria. To enter your own criteria: a. In the first column, click the lookup icon or start typing in the text box and select a field. USER PERMISSIONS b. In the second column, select an operator. To define lookup filters: c. In the third column, select Value if Salesforce should compare the field in the first column • Customize Application with a static value, or select Field if Salesforce should compare the field in the first column with the value of another field. d. In the fourth column, enter the value or select the field that Salesforce should compare with the field in the first column.
Note: • Click Add Filter Logic to add Boolean conditions. • Select a suggested field from the Field text box. You can only select fields on the current record, the lookup object, or the user record. You can also choose related fields that are one relationship away from the lookup object. Salesforce assists you by listing the available fields and relationships when you click the lookup icon or click inside the text box. • Lookup filter criteria can compare fields of different types as long as they are compatible.
338 Extend Salesforce with Clicks, Not Code Customize Fields
• Value-based filters are supported in Lightning Experience and Salesforce Classic.
4. Specify whether the filter is required or optional. For fields with optional lookup filters (Salesforce Classic only), values that match the lookup filter criteria appear in the lookup dialog. To remove the filter and view all search results for the lookup field, users can select Show all results in the lookup dialog. Also, optional lookup filters let users save values that don't match the lookup filter criteria without Salesforce displaying any error message.
Note: In Lightning Experience, all filters are required, even if admins specify them as optional in Setup. There’s no Show all results view. For required lookup filters, specify whether you want Salesforce to display the standard error message or a custom message when a user enters an invalid value.
5. Optionally, enter text to display in the lookup search dialog. Consider text that guides users in their searches and explains the business rule that the lookup filter implements. 6. Leave Enable this filter selected. 7. Save your changes.
SEE ALSO: Considerations for Lookup Filters Dependent Lookups Lookup Filter Examples Find Object Management Settings
Delete or Deactivate Lookup Filters
1. From the managements settings for the relationship field’s object, go to Fields. EDITIONS 2. Scroll to the Custom Fields & Relationships related list. 3. Click the name of the field containing the lookup filter. Available in: both Salesforce Classic (not available in all 4. Click Edit. orgs) and Lightning 5. To deactivate the lookup filter, deselect Enable this filter, then save your changes. Experience Deactivating a lookup filter preserves the lookup filter configuration but: Available in: All Editions • Prevents it from applying to the relationship field except for Database.com. • Prevents it from impacting the cross-object references limit • Removes it as a dependency for fields referenced in the lookup filter criteria USER PERMISSIONS
6. To delete the lookup filter, click Clear Filter Criteria, then save your changes. To define lookup filters: • Customize Application Deleting a lookup filter permanently removes it. You can’t recover deleted lookup filters.
SEE ALSO: Dependent Lookups Considerations for Lookup Filters Find Object Management Settings
339 Extend Salesforce with Clicks, Not Code Customize Fields
View a List of Lookup Filters for a Target Object
You can quickly see a list of all of the lookup filters that restrict the values of each target object. This EDITIONS is useful when creating similar filters for a target object. Also, lookup filters that reference fields on related objects count against the cross-object reference limit, which is the number of unique Available in: both Salesforce relationships allowed for a target object. The Related Lookup Filters list lets you see which lookup Classic (not available in all filters might impact that limit. orgs) and Lightning To see which lookup filters affect the limit for a particular target object, from the management Experience settings for the object, go to Related Lookup Filters. Available in: All Editions except for Database.com. SEE ALSO: Dependent Lookups USER PERMISSIONS Considerations for Lookup Filters To define lookup filters: • Customize Application
Dependent Lookups
A dependent lookup is a relationship field with a lookup filter that references fields on the source EDITIONS object. For example, you can configure the case Contact field to only show contacts associated with the account selected in the case Account Name field. Available in: both Salesforce When a user changes the value of a referenced field on the source object, Salesforce immediately Classic and Lightning verifies that the value in the dependent lookup still meets the lookup filter criteria. If the value Experience doesn't meet the criteria, an error message is displayed and users can't save the record until the Available in: All Editions value is valid. If the referenced field on the source object is a lookup, master-detail, or hierarchy field, users can't USER PERMISSIONS change its value by typing. Instead, users must click the lookup icon and select a value in the lookup search dialog. To manage dependent lookups: Tip: Dependent lookups are supported in Visualforce pages. • Customize Application
SEE ALSO: Define Lookup Filters Lookup Filter Examples
340 Extend Salesforce with Clicks, Not Code Customize Fields
Considerations for Lookup Filters
• On the Fields page, the icon indicates all fields with active lookup filters. The icon EDITIONS indicates that the lookup filter is required. • The lookup filters you create in Salesforce also appear in the partner portal and Customer Portal. Available in: both Salesforce • Lookup filters are case-sensitive. Classic (not available in all orgs) and Lightning • If you convert a required lookup filter with a custom error message to be optional, Salesforce Experience deletes the message. • If you create a lookup filter that invalidates an existing value for that field, the value persists. Available in: All Editions However, when a user edits the record, Salesforce displays an error message and requires the except for Database.com. user to change the invalid value before saving. • You can’t save changes that cause required lookup filters on related records to contain invalid USER PERMISSIONS values. To manage lookup filters: • Versions 16.0 and higher of the Salesforce API support lookup filters. Lookup filters are enforced • Customize Application when you load data through the API. • If you configure a lookup filter to show inactive users only, the relationship field has no valid options. Inactive users are never valid for relationship fields that point to the User object. • If you create a filtered lookup on a field that looks up to another object, deploy both objects into the organization at the same time. • If the field criteria include a master-detail relationship field, lookup field filters don’t work. • If the value of a controlling field invalidates the value of a dependent master-detail relationship field, Salesforce doesn’t display an error message. • Dependent lookups are supported in Visualforce pages. • In Lightning Experience, a lookup filter doesn’t work if a field referenced in the filtered lookup criteria isn't added to the page layout. When a user opens the lookup dialog box, the value being searched is automatically deleted. To avoid this issue, add the missing field that is being used in the lookup field filter criteria to the page layout. • Knowledge articles don’t support lookup filters. • Value-based filters are supported in Lightning Experience and Salesforce Classic. • If an unlocked 2GP package installs a lookup filter, then a later version of the package deletes that lookup filter, the lookup filter isn’t removed from the subscriber org. The lookup filter must be deleted manually instead. • When changing ownership of a record in Salesforce Classic, fields on the record that have active lookup filters aren’t validated. As a workaround, we recommend doing lookup filter validation for a record’s fields before changing the record’s owner.
Spanning Relationships in Lookup Filters Filter criteria can include fields related to the target object (one level only). For example, a lookup field points to a contact. The lookup filter can reference fields on the account related to the contact using the Account Name relationship field. The lookup field can also reference fields on the contact related to the contact via the Reports To relationship field. For required lookup filters, each field referenced on a related lookup object counts against the number of unique relationships allowed for the referenced object. The relationships aren’t counted against the source object. For example, the two unique relationships described above count against the number allowed for the Contact object. Optional lookup filters don't count against the limit on the number of unique relationships allowed per object. To see which lookup filters affect the limit for a particular target object, from the management settings for the object, go to Related Lookup Filters.
341 Extend Salesforce with Clicks, Not Code Customize Fields
Lookup Filters vs. Validation Rules Validation rules and lookup filters achieve similar ends, but offer different advantages. Use a lookup filter: • To improve user efficiency by limiting the number of available options in a lookup search dialog. • To improve user efficiency by automating filters on lookup search dialogs that your users manually set. Use a validation rule: • If you're close to the maximum number of lookup filters allowed. • To implement a complex business rule that requires you to use a formula. Formulas can reference fields that basic filter criteria can't reference, such as fields on the parent of the source object. Formulas can also use functions. For example, use ISNEW to apply the rule only on record creation, or ISCHANGED to apply the rule only when a field changes.
SEE ALSO: Lookup Filters Dependent Lookups
Notes on Using Lookup Filters with Person Accounts
If your organization uses person accounts, note the following: EDITIONS • Person Accounts don't support Contact filters; however, Person Accounts support Account filters. For example, if the Account field has a dependent lookup filter that's added to a Person Available in: both Salesforce Account, dependent lookups are supported. If the Contact field has a dependent lookup filter Classic (not available in all that's added to a Person Account, dependent lookups aren't supported. orgs) and Lightning Experience • Lookup filter criteria on Account Name only apply to business accounts, not person accounts. For example, your lookup filter criteria is Account Name does not contain book. Available in: All Editions Business accounts with “book” in the name, such as John’s Bookstore, aren’t valid. Person except for Database.com. accounts with “book” in the name, such as John Booker, are valid. The person accounts show in the lookup dialog for the Account field. If you must filter on the name for a person account, use the First Name or Last Name fields instead. • To restrict the values of a lookup field to one type of account (person or business), use the Is Person Account field in your lookup filter criteria. For example, to restrict a lookup to only person accounts, include the following in your lookup filter criteria: Is Person Account equals True. • You can't package lookup filters that reference standard fields specific to person accounts, such as the Email and Title fields.
SEE ALSO: Lookup Filters
342 Extend Salesforce with Clicks, Not Code Customize Fields
Lookup Filters Best Practices
Custom Help EDITIONS Define custom help for fields with lookup filters to let users know about the business rule the filter enforces. For example, if the lookup filter restricts the Account Name on opportunities Available in: both Salesforce to only allow active accounts, define custom help that states You can only associate Classic (not available in all active accounts with opportunities. orgs) and Lightning Error Messages Experience Customize lookup filter error messages to guide users who type invalid values. For example, if Available in: All Editions the lookup filter restricts the Account Name on opportunities to only allow active accounts, except for Database.com. define an error message that states Value doesn't exist or isn't an active account.
Important: Salesforce translates the standard error message for required lookup filters, but not custom error messages. Use the Translation Workbench to translate lookup filter custom error messages. To restore the standard error message after modifying it, click Reset to default message. Working with Master-Detail Relationship Fields When creating a lookup filter on a master-detail relationship field, verify that the current values of the field on all of the detail records meet the criteria you specify. If you specify criteria that an existing value doesn't meet, Salesforce prevents the user from saving changes to the detail record. If this occurs, the user must first modify the value on the master record to meet the criteria. For example, consider a custom object with a master-detail relationship field that points to accounts. If you define a lookup filter that excludes all accounts with a Create Date before 01/01/2009, verify that no existing records of that custom object have a master-detail relationship with any account created before 2009. A quick way to do this is to create a report that shows all accounts with a Create Date before 01/01/2009. Profile-Based Lookup Filters Use Current User Profile: ID in filter criteria to define different filter criteria for different users, or to let administrators enter values that don't match the criteria. Avoid using Current User Profile: Name due to technical limitations on standard profiles. If you enter Current User Profile: Name or Profile: Name in the Field column of your lookup filter criteria, Salesforce displays a lookup icon in that row. Click the lookup icon to select from a list of existing profiles rather than typing profile names. Record IDs vs. Record Names To reference a specific record in filter criteria, use the ID of the record instead of its name. IDs are always unique whereas names are not. Testing After creating a lookup filter, test it to make sure it is not too restrictive. Depending on their permissions, some users may have read-only access to some relationship fields; ensure your lookup filters don't prevent those users from editing records critical to their job functions. Dependent Lookups on Page Layouts and Mini Page Layouts in the Console When designing page layouts with dependent lookups: • If a dependent lookup is above its controlling field on a layout, make its lookup filter optional or redesign the layout. Moving a required dependent lookup above its controlling field may confuse users who typically start from the top of a page when entering data. • Ensure that both the controlling and dependent fields are visible so users can correct invalid values.
343 Extend Salesforce with Clicks, Not Code Customize Fields
Lookup Filters and the Lookup Filter Fields Search Layout Don’t reference the same fields in both lookup filter criteria and the Lookup Filter Fields search layout. Users might assume that results from their custom search override administrator-controlled lookup filters.
SEE ALSO: Lookup Filters
Lookup Filter Examples
EDITIONS Record Types in Lookup Filters If the value of a relationship field should only consist of records with a particular record type, specify Available in: both Salesforce the record type in a lookup filter. For example, if the Account Name field on opportunities Classic (not available in all should only have accounts with a Customer Account custom record type, define the following orgs) and Lightning lookup filter to restrict users to only creating or editing opportunities associated with accounts that Experience have a Customer Account record type, excluding accounts with Partner Account and Competitor Available in: All Editions Account record types: except for Database.com.
Filter Criteria Record types available in: Account Name: Account Record Type equals value Customer Professional, Enterprise, Account Performance, Unlimited, Custom Error Message and Developer Editions Account does not exist or is not a customer account. Lookup Window Text USER PERMISSIONS You can only associate customer accounts to an opportunity. Search results only display customer accounts. To define lookup filters: • Customize Application
Record Status in Lookup Filters If the value of a relationship field should only consist of records with particular status, specify the status in a lookup filter. For example, consider a Job Application object with a relationship field that points to the Position object. If the relationship field should only have open positions, define the following lookup filter to restrict users to only creating or editing job applications for positions with the Status field set to Open: Filter Criteria Position: Status equals value Open Custom Error Message Position does not exist or is not an open position. Lookup Window Text You can associate only open positions with job applications. Search results display open positions only.
Profiles in Lookup Filters When a business rule does not apply to users with every profile, use the Current User Profile global variable fields to define lookup filters that only affect users with a particular profile.
344 Extend Salesforce with Clicks, Not Code Customize Fields
For example, the following lookup filter on the Case object Account Name field restricts users with a “Domestic Sales” profile to only creating or editing opportunities associated with accounts that have a billing country of “USA” while allowing other users to associate opportunities with any account: Filter Criteria 1. Current User Profile: Name equals value Domestic Sales 2. Account Name: Billing Country equals value USA 3. Current User Profile: Name not equal to value Domestic Sales Filter Logic (1 AND 2) OR 3 Custom Error Message Account does not exist or the account billing country is not USA. Domestic sales reps can only create opportunities for accounts in the United States. Lookup Window Text Search results show only United States accounts in the for domestic sales representatives. You can modify the above example to simultaneously restrict users with a “Global Sales” custom profile to only associating opportunities to accounts with a non-US billing country: Filter Criteria 1. Current User Profile: Name equals value Global Sales 2. Account Name: Billing Country not equal to value USA 3. Current User Profile: Name equals value Domestic Sales 4. Account Name: Billing Country equals value USA 5. Current User Profile: Name not equal to value Global Sales, Domestic Sales Filter Logic (1 AND 2) OR (3 AND 4) OR 5 Custom Error Message Account does not exist or the account billing country is not in your sales area. Sales reps can only create opportunities for accounts in their sales area. Lookup Window Text Search results only display accounts in your region.
Important: If you do not include line 5 in the filter criteria, users who are not in Global Sales or Domestic Sales cannot select or save any values on account records.
Roles in Lookup Filters When a business rule does not apply to users in every role, use the Current User Role global variable fields to define lookup filters that only affect users with particular roles. For example, in a recruiting application that has a Position object with a lookup field to a Compensation Package object, you can restrict users from editing or creating positions that have an executive compensation plan unless they are executive administrators or vice presidents. To do this, define the following lookup filter on the Position object Compensation Package Name field: Filter Criteria 1. Current User Role: Name does not start with value VP
345 Extend Salesforce with Clicks, Not Code Customize Fields
2. Current User Role: Name does not equal value Executive Administrator 3. Compensation Package: Plan Type does not equal value Executive 4. Current User Role: Name starts with value VP 5. Current User Role: Name equals value Executive Administrator Filter Logic ((1 OR 2) AND 3) OR (4 OR 5) Custom Error Message The compensation plan does not exist, or you have selected an executive compensation plan but do not have access to create executive positions. Lookup Window Text Search results only display compensation plans that are relevant to positions you are allowed to create.
Important: Include the condition you are testing and the opposite condition. In this example, lines 1, 2, and 3 of the filter criteria ensure that users who are not VPs or Executive Administrators cannot select Executive compensation plans, while lines 4 and 5 ensure that VPs and Executive Administrators can select Executive compensation plans.
Blank Values in Lookup Filters Your lookup filter criteria might reference a field that users often leave blank. You can design your lookup filter criteria to accept blank values by using the Add Filter Logic in the filter criteria to create an OR condition. For example, if you have a Partner Contact custom field on opportunities, restrict the field to only allow contacts that are associated to an account with a Partner Account record type, or private contacts not associated with any account. Filter Criteria 1. Partner Contact: Account: Account Record Type equals value Partner Account 2. Partner Contact: Account: Account Name equals value Filter Logic 1 OR 2 Custom Error Message The partner contact must be associated with a partner account, or must be a private contact. Lookup Window Text Search results only display contacts from partner accounts or your private contacts.
User IDs in Lookup Filters Using user IDs in optional lookup filters can significantly improve user efficiency by first showing lookup search dialog results that are most relevant to the user while still allowing users to see all results if necessary. For example, on a lookup field to accounts, you can create an optional lookup filter that restricts the search results to accounts that the user owns in the search lookup dialog results. If the user is looking for an account that someone else owns, the user can remove the filter. Filter Criteria Current User: User ID equals Field Account: Owner ID Lookup Window Text By default, search results only display accounts you own. To search all accounts, click “Show all results.”
346 Extend Salesforce with Clicks, Not Code Customize Fields
Simple Dependent Lookups If the value of a relationship field should depend on the value of another relationship field on the current record, specify the field to field comparison in the criteria. For example, if the case Contact Name field should only have contacts associated to the account specified in the case Account Name field, use the following lookup filter: Filter Criteria Contact Name: Account ID equals field Case: Account ID Custom Error Message Contact does not exist or is not associated to the case account. Lookup Window Text Search results only display contacts associated to the case account.
Note: When comparing lookup fields in lookup filter criteria, Salesforce always uses the ID of the relationship field, not the name.
Complex Lookup Filters and Dependent Lookups Achieving complex business rules with lookup filters often involves combing your rules with filter logic and fields of various types. For example, consider an app for booking conference rooms that has the following data model:
Object Fields
Meeting • Meeting Name • Office lookup to the Office object • Projector Required checkbox • Number of Participants number field • Conference Room lookup to the Conference Room object
Conference Room • Conference Room Name • Has Projector checkbox • Number of Seats Available number field • Conference Room Location lookup to the Office object
Office • Office Name
The following lookup filter on the meeting Conference Room field restricts the valid values to conference rooms that have a projector if the meeting requires one, as well as the necessary number of seats: Filter Criteria 1. Meeting: Projector Required equals field Meeting Conference Room: Has Projector 2. Meeting: Projector Required equals value False 3. Conference Room: Number of Seats Available greater or equal field Meeting: Number of Participants Filter Logic (1 OR 2) AND 3
347 Extend Salesforce with Clicks, Not Code Customize Fields
Custom Error Message Conference room not found or is insufficient for your meeting. Lookup Window Text Search results only display conference rooms that can support your meeting requirements. To refine the valid values even further, incorporate the office where the conference room is located: Filter Criteria 1. Meeting: Projector Required equals field Meeting Conference Room: Has Projector 2. Meeting: Projector Required equals value False 3. Conference Room: Number of Seats Available greater than field Meeting: Number of Participants 4. Meeting: Office equals Field Conference Room: Conference Room Location Filter Logic (1 OR 2) AND 3 AND 4 Custom Error Message Conference room not found or is insufficient for your meeting. Lookup Window Text Search results only display conference rooms that can support your meeting requirements.
SEE ALSO: Considerations for Lookup Filters
Limitations on Lookup Filters These limitations apply to lookup filters. • Lookup filter criteria can’t reference these types of fields: – Relationship fields on activities – System fields that are always read only, such as Created By and Modified By – Relationship fields that support queues, such as Case Owner and Lead Owner
• Each object can have up to five active required lookup filters. In Salesforce Classic, you can also have an unlimited number of optional lookup filters. If you reach the limit of required lookup filters, create optional filters. When a user saves a record, use validation rules to enforce your business rule. In Lightning Experience, all lookup filters are required. • Lookup filters aren’t available for external lookup relationship fields. • Lookup filters on currency fields don't convert currencies. For example, your organization uses multiple currencies and there’s lookup filter criteria Expected Revenue greater than 100000. The lookup shows all records with an Expected Revenue field value greater than 100,000, regardless of the currency. • You can’t use special date values, such as “Today” or “This Month,” in lookup filter criteria. • You can’t delete fields that are referenced in an active lookup filter. • You can’t change the field type of fields referenced by an active lookup filter. • You can add up to 10 criteria rows in a lookup filter.
348 Extend Salesforce with Clicks, Not Code Customize Fields
• Lookup filter criteria can’t reference these types of fields on the source object: – Autonumber – Email – Encrypted – Formula
Note: Formula fields containing "$USER", "$USERROLE", "$PROFILE", or "$SOURCE" are supported.
– GeoLocation – Long text area – Multi-select picklist – Roll-up summary – Text – Text (Encrypted) – Text area (Rich) – Text area (Long) – Time – URL
• Lookup auto-completion doesn’t work for user lookups with other dropdown lists. Auto-completion is primarily for organizations that have set up either a partner portal or customer portal. • In enhanced list views, you can’t change fields that dependent lookup filter criteria reference. • Lookup filters don’t support mass owner changes. If your lookup filter criteria reference the Owner field, performing a mass owner change can result in incorrect values. The incorrect values aren’t noticeable until you try to save the record. • If a formula references global merge fields that the lookup filter doesn’t support, the lookup filter can’t reference the formula. • Lookup filter criteria on Account Name only apply to business accounts, not person accounts. For example, your lookup filter criteria is Account Name does not contain book. Business accounts with “book” in the name, such as John’s Bookstore, aren’t valid. Person accounts with “book” in the name, such as John Booker, are valid. The person accounts show in the lookup dialog for the Account field. If you must filter on the name for a person account, use the First Name or Last Name fields instead.
Fields: What’s Different or Not Available in the Salesforce Mobile App
Not every Lightning Experience feature is in the Salesforce mobile app. Find out what’s different. EDITIONS
Fields Available in: Lightning Experience and the Unsupported Fields Salesforce mobile app for • division fields iOS and Android Combo Boxes Available in: all editions • Combo boxes, which combine a picklist with a text field, aren’t available. Typically the text field is available but the picklist is not. Lookup Fields • User-defined lookup filter fields aren't supported. • You can’t create a record from a lookup field like you can in Lightning Experience.
349 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Lookup fields in Salesforce Classic show record names regardless of sharing permissions. As a result, users can see the names of records that they can’t access. In Lightning Experience and the Salesforce mobile app, lookup fields respect sharing permissions and only show the name of records that the user can access. The one exception is owner lookup fields, which always display the name of the record's owner, regardless of sharing permissions. Picklist Fields • Controlling and dependent picklists are supported, but doesn’t display indicators on create and edit pages for these fields. To determine if a picklist field is dependent, and which picklist field controls it, switch to the full site. • Disabled picklists aren’t grayed out like they are in the full site. Phone Number Fields • The keypad that displays in phone number fields doesn’t include parentheses, hyphens, or periods, and doesn’t apply any phone number formatting when you save the record. To apply a specific phone number format, edit the record in the full site. Rich Text Area Fields Support for rich text area fields varies by the version of the Salesforce mobile app and the type of device.
App Version View Rich Text Area Fields Edit Rich Text Area Fields Salesforce for Android Yes Yes
Salesforce for iOS Yes Yes
User Fields • While user detail pages aren’t available in the app, user fields are supported and appear on user profiles, in related lists, and so forth. • There are some issues when these user fields appear in related lists or mobile cards. – The Company Name field is blank if an internal user is viewing a mobile card or related list entry related to another internal user. If the referenced user is an external user, the company name appears correctly. – The Active field is blank unless the user is inactive.
Calculate Field Values With Formulas
A formula is an algorithm that derives its value from other fields, expressions, or values. Formulas EDITIONS can help you automatically calculate the value of a field based on other fields. Watch a Demo: Getting Started With Formulas (Salesforce Classic) Available in: both Salesforce Classic and Lightning This video gives a brief introduction to Salesforce formulas, accessing the formulas editor in the Experience app, and how to use the editor tools to create formulas. Available in: All Editions Where are Formulas Used in Salesforce? Reports and Approvals are Many areas in Salesforce use formulas. Before you begin using formulas, review the differences not available in in their uses. Database.com Formula Data Types The data type of a formula determines the type of data you expect returned from your formula. Elements of a Formula A formula can contain references to the values of fields, operators, functions, literal values, or other formulas.
350 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Formula Operators and Functions Use these operators and functions when building formulas. All functions are available everywhere that you can include a formula—such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified. Using Date, Date/Time, and Time Values in Formulas Date formulas are useful for managing payment deadlines, contract ages, or any other features of your organization that are time or date dependent. Build a Formula Field Your custom formula fields require special attributes. Formula Field Limits and Restrictions Before you create formula fields, be aware of their limits and limitations. Formula Best Practices You can use the Formula Editor in Salesforce to construct a simple formula with a few clicks. But what if you want to build something more complex? Use these tips to help you map out formula logic and make it easier to troubleshoot errors. Examples of Advanced Formula Fields Review examples of formula fields for various types of apps that you can use and modify for your own purposes. Formulas: How Do I ... ? Common Formula Errors Review common errors that can occur with formulas and how to fix them.
Where are Formulas Used in Salesforce?
Many areas in Salesforce use formulas. Before you begin using formulas, review the differences in EDITIONS their uses. Available in: both Salesforce Use Formulas for: To: Classic and Lightning Approval Processes Define the criteria a record must meet to enter the approval process. Experience
Approval Steps Define the criteria a record must meet to enter the approval step. Available in: All Editions Reports and Approvals are Assignment Rules for Define the criteria the lead or case must meet for it to be assigned. not available in Leads and Cases Database.com Auto-Response Rules for Define the criteria a lead or case must meet to trigger an auto-response Leads and Cases rule.
Case Escalation Rules Specify criteria a case must meet for it to be escalated.
Custom Buttons and Define the content for custom links and buttons. Links
Custom Fields Create custom formula fields that automatically calculate a value based on other values, merge fields, or expressions. Users can view formula fields on record detail pages but can’t see the underlying algorithm or edit the value of a formula field.
Note: Custom formula fields are not available in Connect Offline, Web-to-Lead forms, or Web-to-Case forms.
351 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use Formulas for: To: Custom Summary Formulas in Automatically calculate more totals based on existing report summaries using the values, merge Reports fields, or expressions you specify. Users can’t change these totals.
Data Validations Verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can include a formula such as CloseDate >= TODAY().
Default Field Values Apply a value to a custom field when a user creates a record. Use formulas to define a default value such as TODAY() + 7. Users can change a default value. Default field values can be based on a formula using values, merge fields, or expressions you specify.
Escalation Rules Define the criteria that a case must meet to be escalated.
Formula Fields Automatically calculate the value of a custom field using the values, merge fields, or expressions you specify. Users can’t change the value of a formula field.
Reports Create custom summary formulas in your reports to calculate more totals based on the existing summaries in that report.
S-Controls Define the content for s-controls.
Validation Rules Prevent users from entering an invalid value in a standard or custom field. Validation rules can be based on formulas and display an error message to users when the value they enter is not valid.
Workflow Field Updates Automatically change the value of a field to a value you specify. The formula can include other values, merge fields, or expressions. You can set field updates to occur as a result of a workflow rule or an approval process.
Workflow Rules Define the criteria a record must meet to trigger a workflow rule.
Visualforce Pages Define the content for Visualforce pages.
Common Formula Processes
When are they Read only? Can include Can specify null Can include executed? functions? handling? references to parent merge fields? Default Field Values Record creation No Yes No No
Formula Fields Record display Yes Yes Yes Yes
Validation Rules Record save Not applicable Yes No Yes
Workflow Rules Record save Not applicable Yes No Yes
Approval Processes Record submitted Not applicable Yes No Yes for approval
Field Updates Workflow or Not applicable Yes No Yes approval process
352 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
When are they Read only? Can include Can specify null Can include executed? functions? handling? references to parent merge fields? Custom Summary Report display Yes Yes, a limited subset Yes No Formulas for Reports of functions
Formula Data Types The data type of a formula determines the type of data you expect returned from your formula.
Data Type Description Checkbox Returns a true or false value. The field appears as a checkbox in record detail pages and reports. Use True for checked values and False for unchecked values.
Currency Returns a number in currency format of up to 18 digits with a currency sign.
Note: Salesforce uses the round-half-to-even tie-breaking rule for currency fields. For example, 23.5 becomes 24, 22.5 becomes 22, −22.5 becomes −22, and −23.5 becomes −24.
Date Returns data that represents a day on the calendar. The current date can be acquired by calling the built-in function TODAY() in a formula. This data type is not available for custom summary formulas in reports.
Date/Time Returns data that represents a moment in time. A date/time field includes the date and also the time of day including hour, minutes, and seconds. You can insert the current date and time in a formula using the NOW() function. This data type is not available for custom summary formulas in reports.
Number Returns a positive or negative integer or decimal of up to 18 digits. Salesforce uses the round half up tie-breaking rule for numbers in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35.
Percent Returns a number in percent format of up to 18 digits followed by a percent sign. Percent data is stored as a decimal divided by 100, which means that 90% is equal to 0.90.
Text Returns a string of up to 3900 characters. To display text in addition to the formula output, insert that text in quotes. Use the text data type for text, text area, URL, phone, email, address, and auto-number fields. This data type isn’t available for custom summary formulas in reports.
Note: Text area isn’t a supported data type.
353 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Data Type Description Time Returns data that represents a moment in time, without the date. A time field includes the time of day by hour, minutes, seconds, and milliseconds. You can insert the current time in a formula using the TIMENOW() function.
Note: In formula expressions, use the international date format (ISO) for text arguments. For example, use TIMEVALUE("11:30:00.000") instead of TIMEVALUE("11:30 AM").
SEE ALSO: Build a Formula Field
Elements of a Formula A formula can contain references to the values of fields, operators, functions, literal values, or other formulas. Use any or all of these elements to build a formula.
Element Description Name Literal A text string or number you enter that is not calculated or changed. For example, if you have a value that’s always multiplied Value by 2% of an amount, your formula would contain the literal value of 2% of that amount:
ROUND((Amount*0.02), 2)
This example contains every possible part of a formula: • A function called ROUND used to return a number rounded to a specified number of decimal places. • A field reference called Amount. • An operator, *, that tells the formula builder to multiply the contents of the Amount field by the literal value, 0.02. • A literal number, 0.02. Use the decimal value for all percents. To include actual text in your formula, enclose it in quotes. • The last number 2 in this formula is the input required for the ROUND function that determines the number of decimal places to return.
Field Reference the value of another custom or standard field using a merge field. The syntax for a merge field is field_name Reference for a standard field or field_name__c for a custom field. The syntax for a merge field on a related object is object_name__r.field_name. Use the Insert Field button or the drop-down list to insert a merge field in your formula where necessary. To reference a field from a custom metadata type record, use
$CustomMetadata.CustomMetadataTypeAPIName.RecordAPIName.FieldAPIName
.
Function A system-defined formula that can require input from you and returns a value or values. For example, TODAY() does not require input but returns the current date. The TEXT(value) function requires your percent, number, or currency input and returns text.
354 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Element Description Name
Operator A symbol that specifies the type of calculation to perform or the order in which to do it. For example, the + symbol specifies two values should be added. The open and close parentheses specify which expressions you want evaluated first.
Comment An annotation within a formula that begins with a forward slash followed by an asterisk (/*). and concludes with an asterisk followed by a forward slash (*/). For example,
/*This is a formula comment*/
Comments are ignored when processing a formula. Comments are useful for explaining specific parts of a formula to anyone viewing the formula definition. For example:
AND( /*competitor field is required, check to see if field is empty */ LEN(Competitor__c) = 0, /* rule only enforced for ABCD record types */ RecordType.Name = "ABCD Value", /* checking for any closed status, allows for additional closed picklist values in the future */ CONTAINS(TEXT(StageName), "Closed") )
You can also use comments to comment out sections of your formula when debugging and checking the syntax to locate errors in the formula.
Note: • Nesting comments causes a syntax error. For example, you cannot save a formula that has the following:
/* /* comment */ */
• Commenting out a whole formula causes a syntax error. • Comments count against the character and byte size limits in formulas.
Formula Operators and Functions Use these operators and functions when building formulas. All functions are available everywhere that you can include a formula—such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified.
Note: • Within an email template, merge fields can only be used in formula functions and operations when the merge field belongs to the record the email will be related to, otherwise these fields won’t resolve. • Extraneous spaces in the samples below are ignored.
• Math Operators • Logical Operators • Text Operators • Date and Time Functions • Logical Functions
355 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Math Functions • Text Functions • Summary Functions • Advanced Functions
Math Operators
Operator Description + (Add) Calculates the sum of two values.
- (Subtract) Calculates the difference of two values.
* (Multiply) Multiplies its values.
/ (Divide) Divides its values.
^ (Exponentiation) Raises a number to a power of a specified number.
() (Open Parenthesis and Specifies that the expressions within the open parenthesis and close parenthesis are evaluated first. All Close Parenthesis) other expressions are evaluated using standard operator precedence.
Logical Operators
Operator Description = and == (Equal) Evaluates if two values are equivalent. The = and == operators are interchangeable.
<> and != (Not Equal) Evaluates if two values aren’t equivalent.
< (Less Than) Evaluates if a value is less than the value that follows this symbol.
> (Greater Than) Evaluates if a value is greater than the value that follows this symbol.
<= (Less Than or Equal) Evaluates if a value is less than or equal to the value that follows this symbol.
>= (Greater Than or Equal) Evaluates if a value is greater than or equal to the value that follows this symbol.
&& (AND) Evaluates if two values or expressions are both true. Use this operator as an alternative to the logical function AND.
|| (OR) Evaluates if at least one of multiple values or expressions is true. Use this operator as an alternative to the logical function OR.
Text Operators
Operator Description & (Concatenate) Connects two or more strings.
356 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Date and Time Functions
Function Description ADDMONTHS Returns the date that is the indicated number of months before or after a specified date. If the specified date is the last day of the month, the resulting date is the last day of the resulting month. Otherwise, the result has the same date component as the specified date.
DATE Returns a date value from year, month, and day values you enter. Salesforce displays an error on the detail page if the value of the DATE function in a formula field is an invalid date, such as February 29 in a non-leap year.
DATEVALUE Returns a date value for a date/time or text expression.
DATETIMEVALUE Returns a year, month, day, and GMT time value.
DAY Returns a day of the month in the form of a number between 1 and 31.
HOUR Returns the local time hour value without the date in the form of a number from 1 through 24.
MILLISECOND Returns a milliseconds value in the form of a number from 0 through 999.
MINUTE Returns a minute value in the form of a number from 0 through 60.
MONTH Returns the month, a number between 1 (January) and 12 (December) in number format of a given date.
NOW Returns a date/time representing the current moment.
SECOND Returns a seconds value in the form of a number from 0 through 60.
TIMENOW Returns a time value in GMT representing the current moment. Use this function instead of the NOW function if you only want to track time, without a date.
TIMEVALUE Returns the local time value without the date, such as business hours.
TODAY Returns the current date as a date data type.
WEEKDAY Returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday.
YEAR Returns the four-digit year in number format of a given date.
Logical Functions
Function Description AND Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false.
BLANKVALUE Determines if an expression has a value and returns a substitute expression if it doesn’t. If the expression has a value, returns the value of the expression.
CASE Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn't equal to any values, it returns the else_result.
IF Determines if expressions are true or false. Returns a given value if true and another value if false.
357 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Function Description ISBLANK Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE.
ISCLONE Checks if the record is a clone of another record and returns TRUE if one item is a clone. Otherwise, returns FALSE.
ISNEW Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE.
ISNULL Determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE.
Important: Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas.
ISNUMBER Determines if a text value is a number and returns TRUE if it is. Otherwise, it returns FALSE.
NOT Returns FALSE for TRUE and TRUE for FALSE.
NULLVALUE Determines if an expression is null (blank) and returns a substitute expression if it is. If the expression is not blank, returns the value of the expression.
Important: Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas.
OR Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false.
PRIORVALUE Returns the previous value of a field.
Math Functions
Function Description ABS Calculates the absolute value of a number. The absolute value of a number is the number without its positive or negative sign.
CEILING Rounds a number up to the nearest integer, away from zero if negative.
DISTANCE Calculates the distance between two locations in miles or kilometers.
EXP Returns a value for e raised to the power of a number you specify.
FLOOR Returns a number rounded down to the nearest integer, towards zero if negative.
GEOLOCATION Returns a geolocation based on the provided latitude and longitude. Must be used with the DISTANCE function.
LN Returns the natural logarithm of a specified number. Natural logarithms are based on the constant e value of 2.71828182845904.
358 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Function Description LOG Returns the base 10 logarithm of a number.
MAX Returns the highest number from a list of numbers.
MCEILING Rounds a number up to the nearest integer, towards zero if negative.
MFLOOR Rounds a number down to the nearest integer, away from zero if negative.
MIN Returns the lowest number from a list of numbers.
MOD Returns a remainder after a number is divided by a specified divisor.
ROUND Returns the nearest number to a number you specify, constraining the new number by a specified number of digits.
SQRT Returns the positive square root of a given number.
Text Functions
Function Description BEGINS Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't.
BR Inserts a line break in a string of text.
CASESAFEID Converts a 15-character ID to a case-insensitive 18-character ID.
CONTAINS Compares two arguments of text and returns TRUE if the first argument contains the second argument. If not, returns FALSE.
FIND Returns the position of a string within a string of text represented as a number.
GETSESSIONID Returns the user’s session ID.
HTMLENCODE Encodes text and merge field values for use in HTML by replacing characters that are reserved in HTML, such as the greater-than sign (>), with HTML entity equivalents, such as >.
HYPERLINK Creates a link to a URL specified that is linkable from the text specified.
IMAGE Inserts an image with alternate text and height and width specifications.
INCLUDES Determines if any value selected in a multi-select picklist field equals a text literal you specify.
ISPICKVAL Determines if the value of a picklist field is equal to a text literal you specify.
JSENCODE Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (').
JSINHTMLENCODE Encodes text and merge field values for use in JavaScript inside HTML tags by replacing characters that are reserved in HTML with HTML entity equivalents and inserting escape characters before unsafe JavaScript characters. JSINHTMLENCODE(someValue) is a convenience function that is equivalent to JSENCODE(HTMLENCODE((someValue)). That is, JSINHTMLENCODE first encodes someValue with HTMLENCODE, and then encodes the result with JSENCODE.
LEFT Returns the specified number of characters from the beginning of a text string.
359 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Function Description LEN Returns the number of characters in a specified text string.
LOWER Converts all letters in the specified text string to lowercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided.
LPAD Inserts characters you specify to the left-side of a text string.
MID Returns the specified number of characters from the middle of a text string given the starting position.
RIGHT Returns the specified number of characters from the end of a text string.
RPAD Inserts characters that you specify to the right-side of a text string.
SUBSTITUTE Substitutes new text for old text in a text string.
TEXT Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. Also, converts picklist values to text in approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, validation rules, formula fields, field updates, and custom buttons and links.
TRIM Removes the spaces and tabs from the beginning and end of a text string.
UPPER Converts all letters in the specified text string to uppercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided.
URLENCODE Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with %20, and exclamation points are replaced with %21.
VALUE Converts a text string to a number.
Summary Functions The following functions are available with summary, matrix, and joined reports.
Function Description PARENTGROUPVAL This function returns the value of a specified parent grouping. A “parent” grouping is any level above the one containing the formula. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels.
PREVGROUPVAL This function returns the value of a specified previous grouping. A “previous” grouping is one that comes before the current grouping in the report. Choose the grouping level and increment. The increment is the number of columns or rows before the current summary. The default is 1; the maximum is 12. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels.
360 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Advanced Functions
Function Description CURRENCYRATE Returns the conversion rate to the corporate currency for the given currency ISO code. If the currency is invalid, returns 1.0.
GETRECORDIDS Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list.
IMAGEPROXYURL Securely retrieves external images and prevents unauthorized requests for user credentials.
INCLUDE Returns content from an s-control snippet. Use this function to reuse common code in many s-controls.
ISCHANGED Compares the value of a field to the previous value and returns TRUE if the values are different. If the values are the same, this function returns FALSE.
JUNCTIONIDLIST Returns a JunctionIDList based on the provided IDs.
LINKTO Returns a relative URL in the form of a link (href and anchor tags) for a custom s-control or Salesforce page.
PREDICT Returns an Einstein Discovery prediction for a record based on the specified record ID or for a list of fields and their values.
REGEX Compares a text field to a regular expression and returns TRUE if there is a match. Otherwise, it returns FALSE. A regular expression is a string used to describe a format of a string according to certain syntax rules.
REQUIRESCRIPT Returns a script tag with source for a URL you specify. Use this function when referencing the Lightning Platform AJAX Toolkit or other JavaScript toolkits.
URLFOR Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page.
VLOOKUP Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function.
Formula Operators and Functions A–H Formula Operators and Functions I–Z
SEE ALSO: Examples of Advanced Formula Fields Time Custom Field
Formula Operators and Functions A–H Use the following operators and functions when building formulas. Click the name of the operator or function to view more details. All functions are available everywhere that you can include a formula such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified.
Note: Extraneous spaces in the samples are ignored.
361 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
+ (Add)
Description: Calculates the sum of two values.
Use: value1 + value2 and replace each value with merge fields, expressions, or other numeric values.
Formula Field Example: Amount + Maint_Amount__c + Services_Amount__c This formula calculates the sum of the product Amount, maintenance amount, and services fees. Maint amount and Service Fees are custom currency fields.
Report Example: EMAIL_OPT_OUT:SUM + DO_NOT_CALL:SUM calculates all Email Opt Out fields plus all Do Not Call fields on the leads in your report. This formula is a number data type that returns a positive integer.
Validation Rule Example: Let’s say you have a custom object that allows users to track the total number of hours worked in a week. Use the following example to ensure that users can’t save a time card record with more than 40 hours in a work week.
Monday_Hours__c + Tuesday_Hours__c + Wednesday_Hours__c + Thursday_Hours__c + Friday_Hours__c > 40
Use a formula like this one in a validation rule to display the following error message when the total number of hours entered for each work day is greater than 40: “Your total hours can’t exceed 40.” This example requires five custom fields on your custom object, one for each day of work.
- (Subtract)
Description: Calculates the difference of two values.
Use: value1 - value2 and replace each value with merge fields, expressions, or other numeric values.
Example: Amount - Discount_Amount__c This formula calculates the difference of the product Amount less the Discount Amount. Discount Amount is a custom currency field.
Report Example: AMOUNT:SUM - Product.Discount_Amount__c:SUM calculates the difference of all Amount fields and all Discounted Amount custom fields on the products in your report. This formula is a currency data type that returns a currency sign and decimal places.
* (Multiply)
Description: Multiplies its values.
362 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: value1 * value2 and replace each value with merge fields, expressions, or other numeric values.
Example: Consulting_Days__c * 1200 This formula calculates the number of consulting days times 1200 given that this formula field is a currency data type and consulting charges a rate of $1200 per day. Consulting Days is a custom field.
Report Example: RowCount * AGE:AVG calculates the record count times the average age value of your report. This formula is a number data type that returns a positive or negative integer or decimal.
/ (Divide)
Description: Divides its values.
Use: value1 / value2 and replace each value with merge fields, expressions, or other numeric values.
Example: AnnualRevenue/ NumberOfEmployees This formula calculates the revenue amount per employee using a currency field.
IF(NumberOfOpportunities > 0, NumberOfWonOpportunities / NumberOfOpportunities, null)
This formula calculates the win rate of opportunities on a campaign.
Report Example: % Won Opportunities WON:SUM / RowCount calculates the percent of Won opportunities using a record count representing the number of all opportunities in your report. This formula is a number data type that returns a positive or negative integer. % Difference between Cost and Sales Price (TOTAL_PRICE:SUM - QUANTITY:SUM * Product2.Cost__c:SUM) / (QUANTITY:SUM * Product2.Cost__c:SUM) calculates the average percent difference between what a product costs and its selling price on a product-by-product level. Product2.Cost__c:SUM is a custom currency field named Cost on products, which includes the cost of each product. This formula is a percent data type that returns a positive or negative integer. For best results, use this formula on a summary Opportunities with Products report that is summarized by Product Name and includes summary totals for Quantity, Total Price, and Cost.
^ (Exponentiation)
Description: Raises a number to a power of a specified number.
Use: number^integer and replace number with a merge field, expression, or another numeric value; replace integer with a merge field that contains an integer, expression, or any integer.
Example: NumberOfEmployees^4 calculates the number of employees to the 4th power.
363 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Report Example: ACTIVE:SUM ^ 2 calculates the number of active Salesforce users to the 2nd power for administration. This formula is a number data type that returns a positive integer.
Tips: Avoid replacing integer with a negative number.
() (Open Parenthesis and Close Parenthesis)
Description: Specifies that the expressions within the open parenthesis and close parenthesis are evaluated first. All other expressions are evaluated using standard operator precedence.
Use: (expression1) expression2... and replace each expression with merge fields, expressions, or other numeric values.
Example: (Unit_Value__c - Old_Value__c) / New_Value__c calculates the difference between the old value and new value divided by the new value.
Report Example: (DURATIONHOURS:SUM * RowCount) / 24 calculates the duration of all event times the record count per 24 hours. This formula is a percent data type that returns a positive or negative integer or decimal, representing what percent of a day is spent on events.
= and == (Equal)
Important: Don’t use this function for a null comparison, such as MyDateTime__c == null. Use ISBLANK instead.
Description: Evaluates if two values are equivalent. The = and == operators are interchangeable.
Use: expression1=expression2 or expression1 == expression2, and replace each expression with merge fields, expressions, or other numeric values.
Example: Due Date Due Date = CreatedDate + 5 returns true if the due date is equal to five days following a record’s created date. Commission Amount
IF(Probability =1, ROUND(Amount*0.02, 2), 0)
This formula calculates the 2% commission amount of an opportunity that has a probability of 100%. All other opportunities have a commission value of 0. Possible results: • An opportunity with a Probability of 90% has a commission of 0. • An opportunity with a Probability of 100% and an Amount of $100,000 has a commission of $2,000.
<> and != (Not Equal)
Important: Don’t use this function for a null comparison, such as MyDateTime__c != null. Use ISBLANK instead.
364 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Description: Evaluates if two values aren’t equivalent.
Use: expression1 <> expression2 or expression1 != expression2, and replace each expression with merge fields, expressions, or other numeric values.
Example: IF(Maint_Amount__c + Services_Amount__c<> Amount, "DISCOUNTED", "FULL PRICE")
This formula displays DISCOUNTED on product if its maintenance amount and services amount don’t equal the product amount. Otherwise, displays FULL PRICE. Note that this example uses two custom currency fields for Maint Amount and Services Amount.
< (Less Than)
Description: Evaluates if a value is less than the value that follows this symbol.
Use: value1 < value2 and replace each value with merge fields, expressions, or other numeric values.
Example: IF(AnnualRevenue < 1000000, 1, 2) assigns the value 1 with revenues less than one million and the value 2 to revenues greater than one million.
> (Greater Than)
Description: Evaluates if a value is greater than the value that follows this symbol.
Use: value1 > value2 and replace each value with merge fields, expressions, or other numeric values.
Example: IF(commission__c > 1000000, "High Net Worth", "General") assigns the High Net Worth value to a commission greater than one million. Note, this is a text formula field that uses a commission custom field.
<= (Less Than or Equal)
Description: Evaluates if a value is less than or equal to the value that follows this symbol.
Use: value1 <= value2 and replace each value with merge fields, expressions, or other numeric values.
Example: IF(AnnualRevenue <= 1000000, 1, 2) assigns the value 1 with revenues less than or equal to one million and the value 2 with revenues greater than one million.
>= (Greater Than or Equal)
Description: Evaluates if a value is greater than or equal to the value that follows this symbol.
365 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: value1 >= value2 and replace each value with merge fields, expressions, or other numeric values.
Example: IF(Commission__c >= 1000000, "YES", "NO") assigns the YES value with a commission greater than or equal to one million. Note, this is a text formula field that uses a custom currency field called Commission.
&& (AND)
Description: Evaluates if two values or expressions are both true. Use this operator as an alternative to the logical function AND.
Use: (logical1) && (logical2) and replace logical1 and logical2 with the values or expressions that you want evaluated.
Example: IF((Price<100 && Quantity<5),"Small", null) This formula displays Small if the price is less than 100 and quantity is less than five. Otherwise, this field is blank.
|| (OR)
Description: Evaluates if at least one of multiple values or expressions is true. Use this operator as an alternative to the logical function OR.
Use: (logical1) || (logical2) and replace any number of logical references with the values or expressions you want evaluated.
Example: IF((ISPICKVAL(Priority, "High")) || (ISPICKVAL(Status , "New")), ROUND(NOW()-CreatedDate, 0), null) This formula returns the number of days a case has been open if the Status is new or the Priority is high. If the case was opened today, this field displays a zero.
Validation Rule Example: (Discount_Rate__c < 0) || (Discount_Rate__c > 0.40)
This validation rule formula displays the following error message when the Discount Rate custom field isn’t between 0 and 40%: "Discount Rate cannot exceed 40%."
& (Concatenate)
Description: Connects two or more strings.
Use: string1&string2 and replace each string with merge fields, expressions, or other values.
Example: "Expense-" & Trip_Name__c & "-" & ExpenseNum__c This formula displays the text Expense- followed by trip name and the expense number. This is a text formula field that uses an expense number custom field.
366 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
ABS
Description: Calculates the absolute value of a number. The absolute value of a number is the number without its positive or negative sign.
Use: ABS(number) and replace number with a merge field, expression, or other numeric value that has the sign you want removed.
Example: ABS(ExpectedRevenue) calculates the positive value of the Expected Revenue amount regardless of whether it’s positive or negative.
ADDMONTHS
Description: Returns the date that is the indicated number of months before or after a specified date. If the specified date is the last day of the month, the resulting date is the last day of the resulting month. Otherwise, the result has the same date component as the specified date.
Use: ADDMONTHS (date, num) and replace date with the start date and num with the number of months to be added.
Example: ADDMONTHS (StartDate, 5) Adds 5 months to the start date. For example, if the start date is September 20, 2017, the resulting date is February 20, 2018, If the start date is September 30, 2017, the resulting date is February 28, 2018.
AND
Description: Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false. Use this function as an alternative to the operator && (AND).
Use: AND(logical1,logical2,...) and replace logical1,logical2,... with the values that you want evaluated.
Formula Field Example: IF(AND(Price<1,Quantity<1),"Small", null) This formula displays Small if the price and quantity are less than one. This field is blank if the asset has a price or quantity greater than one.
BEGINS
Description: Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't.
Use: BEGINS(text, compare_text) and replace text, compare_text with the characters or fields you want to compare.
367 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: IF(BEGINS (Product_type__c, "ICU"), "Medical", "Technical") This example returns the text Medical if the text in any Product Type custom text field begins with ICU. For all other products, it displays Technical.
Tips: • This function is case-sensitive so be sure your compare_text value has the correct capitalization. • When using this function in a validation rule or workflow rule, fields that are blank are considered valid. For example, if you have a validation rule that tests to see if the serial number of an asset begins with “3,” all assets that have a blank serial number are considered valid.
BLANKVALUE
Description: Determines if an expression has a value and returns a substitute expression if it doesn’t. If the expression has a value, returns the value of the expression.
Use: BLANKVALUE(expression, substitute_expression) and replace expression with the expression you want evaluated; replace substitute_expression with the value you want to replace any blank values.
Example: Example 1 BLANKVALUE(Department, “Undesignated”) This formula returns the value of the Department field if the Department field contains a value. If the Department field is empty, this formula returns the word Undesignated. Example 2 (BLANKVALUE(Payment_Due_Date__c, StartDate +5) This formula returns the date five days after the contract start date whenever Payment Due Date is blank. Payment Due Date is a custom date field.
Tips: • Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas. • A field is not empty if it contains a character, blank space, or zero. For example, a field that contains a space inserted with the spacebar is not empty. • Use the BLANKVALUE function to return a specified string if the field doesn't have a value; use the ISBLANK function if you only want to check if the field has a value. • If you use this function with a numeric field, the function only returns the specified string if the field doesn't have a value and isn't configured to treat blank fields as zeroes.
BR
Description: Inserts a line break in a string of text.
Use: BR()
368 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: CASE(ShippingCountry, "USA", ShippingStreet & BR() & ShippingCity & ", " & ShippingState & " " & ShippingPostalCode & BR() & ShippingCountry, "France", ShippingStreet & BR() & ShippingPostalCode & " " & ShippingCity & BR() & ShippingCountry, "etc")
This formula field displays a formatted mailing address for a contact in standard format, including spaces and line breaks where appropriate depending on the country.
Tips: • Don't remove the parentheses after the function name. • Keep the parentheses empty. They don't contain values. • Remember to surround the BR() with concatenation operators: &. • Avoid using this function in mail merge templates. • This function isn't available in custom buttons and links, s-controls, or reports.
CASE
Description: Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn't equal to any values, it returns the else_result.
Use: CASE(expression,value1, result1, value2, result2,..., else_result) and replace expression with the field or value you want compared to each specified value. Replace each value and result with the value that must be equivalent to return the result entry. Replace else_result with the value you want returned when the expression doesn't equal any values.
Formula Field Example: Days Open for Cases Use this example of a custom formula field called Days Open to display different text depending on the number of days a case has been open:
CASE(Days_Open__c, 3, "Reassign", 2, "Assign Task", "Maintain")
The following text is displayed: • “Reassign” for any case open three days. • “Assign Task” for any case open two days. • “Maintain” for all other cases. Last Activity Month
369 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This formula field displays the month of the last activity or None if there are no activities.
CASE(MONTH(LastActivityDate), 1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", 7, "July", 8, "August", 9, "September", 10, "October", 11, "November", 12, "December", "None")
Default Value Example: Discount Rate Use the following default value formula to insert a different discount rate on an opportunity based on the department of the person creating the opportunity:
CASE(User.Department, "IT", 0.25, "Field", 0.15, 0)
In this example, the formula inserts a discount rate of 25% on any opportunity created by a user in the IT department or 15% on any opportunity created by someone in the Field department. A zero is applied if the creator doesn't belong to either of these departments. This is a custom percent field on opportunities that uses the standard user field Department. Product Language You might want to associate a product with its language so that your users know the type of documentation or adapter to include. Use the following default value formula to automatically set the language of a product based on the country of the user creating the product. In this example, the default value is Japanese if the user's country is Japan and English if the user's country is US. If neither is true, the default value unknown is inserted into the Product Language field.
CASE($User.Country , "Japan", "Japanese", "US", "English","unknown")
Tips: • Be sure your value1, value2... expressions are the same data type. • Be sure your result1, result2... expressions are the same data type. • CASE functions can’t contain functions that return true or false. Instead, make true or false expressions return numbers such as:
CASE(1, IF(ISPICKVAL (Term__c, "12"), 1, 0), 12 * Monthly_Commit__c, IF(ISPICKVAL(Term__c, "24"), 1, 0), 24 * Monthly_Commit__c, 0)
In this formula, Term is a picklist field that is multiplied by the Monthly Commit whenever it contains the value 1 for true.
• The else_result value is required.
370 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• CASE functions return an error whenever any of the expressions return an error, regardless of which one should be returned. For example, CASE(Field__c,"Partner", "P", "Customer", "C", LEFT(Field__c, -5)) returns an error even if the value of the field is “Partner” or “Customer” because the last statement is illogical. • If the field in your CASE function is blank, it returns your else_result value. For example, this formula: CASE(Days_Open__c, 3, "Reassign", 2, "Assign Task", "Maintain") displays Maintain if the Days Open field is blank, 0, or any value other than 2 or 3. • Use CASE functions to determine if a picklist value is equal to a particular value. For example the formula CASE(Term__c, "12", 12 * Monthly_Commit__c, "24", 24 * Monthly_Commit__c, 0) multiplies the Monthly Commit amount by 12 whenever the Term is 12 or multiplies the Monthly Commit amount by 24 whenever the Term is 24. Otherwise, the result is zero.
CASESAFEID
Description: Converts a 15-character ID to a case-insensitive 18-character ID.
Use: CASESAFEID(id) and replace id with the object’s ID.
Example: CASESAFEID (Id)
This formula replaces the 15-character ID with the 18-character, case-insensitive ID.
Tips: • Convert to 18-character IDs for better compatibility with Excel. • The CASESAFEID function is available everywhere that you can define a formula except reports and s-controls.
CEILING
Description: Rounds a number up to the nearest integer, away from zero if negative.
Use: CEILING(number) and replace number with the field or expression you want rounded.
Example: CEILING(2.5) returns 3, which is 2.5 rounded up to the nearest integer. CEILING(-2.5) returns -3, which is -2.5 rounded away from zero for a negative number.
CONTAINS
Description: Compares two arguments of text and returns TRUE if the first argument contains the second argument. If not, returns FALSE.
Use: CONTAINS(text, compare_text) and replace text with the text that contains the value of compare_text.
371 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: IF(CONTAINS(Product_Type__c, "part"), "Parts", "Service")
This formula checks the content of a custom text field named Product_Type and returns Parts for any product with the word “part” in it. Otherwise, it returns Service. Note that the values are case-sensitive, so if a Product_Type field contains the text “Part” or “PART,” this formula returns Services.
Tips: • This function is case-sensitive so be sure your compare_text value has the correct capitalization. • When using this function in a validation rule or workflow rule, fields that are blank are considered valid. For example, if you have a validation rule that tests to see if the serial number of an asset contains “A,” all assets that have a blank serial number are considered valid. • The CONTAINS function doesn't support multi-select picklists. Use INCLUDES to see if a multi-select picklist has a specific value.
CURRENCYRATE
Description: Returns the conversion rate to the corporate currency for the given currency ISO code. If the currency is invalid, returns 1.0.
Use: CURRENCYRATE(currency_ISO_code) and replace currency_ISO_code with a currency ISO code, such as “USD”.
Example: CURRENCYRATE(”USD”) returns the conversion rate to US dollars.
DATE
Description: Returns a date value from year, month, and day values you enter. Salesforce displays an error on the detail page if the value of the DATE function in a formula field is an invalid date, such as February 29 in a non-leap year.
Use: DATE(year,month,day) and replace year with a four-digit year, month with a two-digit month, and day with a two-digit day.
Example: DATE(2005, 01, 02) creates a date field of January 2, 2005.
DATEVALUE As of Winter ’20, the DATAVALUE() formula option provides more accurate daylight savings time values without workarounds. The option avoids an existing one-hour discrepancy when processing times between 11:00 PM and 1:00 AM. From Setup, in the Quick Find box, enter Company Information. Under Locale Settings, select Improve DATEVALUE() accuracy for DST.
Important: If your org's custom formulas include workarounds that adjust date values between 11:00 PM and 1:00 AM, remove them before enabling this setting. If you don't remove the workarounds, your data could be inaccurate. Enabling the preference can also increase the compiled size of existing formulas with the DATEVALUE() function.
Description: Returns a date value for a date/time or text expression.
372 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: DATEVALUE(expression) and replace expression with a date/time or text value, merge field, or expression.
Example: Closed Date DATEVALUE(ClosedDate) displays a date field based on the value of the Date/Time Closed field. Date Value DATEVALUE("2005-11-15") returns November 15, 2005 as a date value.
Tips: • If the field referenced in the function isn't a valid text or date/time field, the formula field displays #ERROR! • When entering a date, surround the date with quotes and use the following format: YYYY-MM-DD, that is, a four-digit year, two-digit month, and two-digit day. • If the expression doesn't match valid date ranges, such as the MM isn't between 01 and 12, the formula field displays #ERROR! • Dates and times are always calculated using the user’s time zone, except in list views, reports, and related lists. These items calculate dates and times using Coordinated Universal Time.
DATETIMEVALUE
Description: Returns a year, month, day, and GMT time value.
Use: DATETIMEVALUE(expression) and replace expression with a date/time or text value, merge field, or expression.
Example: Closed Date DATETIMEVALUE(ClosedDate) displays a date field based on the value of the Date/Time Closed field. Date Value DATETIMEVALUE("2005-11-15 17:00:00") returns November 15, 2005 5:00 PM GMT as a date and time value.
Tips: • DATETIMEVALUE is always calculated using GMT time zone and can’t be changed. • When entering a specific date, surround the date with quotes and use the following format: YYYY-MM-DD, that is, a four-digit year, two-digit month, and two-digit day. • If the expression doesn't match valid date ranges, such as the MM isn't between 01 and 12, the formula field displays #ERROR!
DAY
Description: Returns a day of the month in the form of a number between 1 and 31.
Use: DAY(date) and replace date with a date field or value such as TODAY().
373 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: DAY(Code_Freeze__c) returns the day in your custom code freeze date. Note this doesn't work on date/time fields.
DISTANCE
Description: Calculates the distance between two locations in miles or kilometers.
Use: DISTANCE(mylocation1, mylocation2, 'unit') and replace mylocation1 and mylocation2 with two location fields, or a location field and a value returned by the GEOLOCATION function. Replace unit with mi (miles) or km (kilometers).
Examples: Distance between two geolocation fields DISTANCE(warehouse_location__c, store_location__c, 'mi') This formula returns the distance, in miles, between the warehouse and the store. In this example, warehouse_location__c and store_location__c are the names of two custom geolocation fields. Distance between an address field and a geolocation field DISTANCE(BillingAddress, store_location__c, 'mi') This formula returns the distance, in miles, between an account’s billing address and a store. In this example, BillingAddress is the standard billing address field on an Account object, and store_location__c is the name of a custom geolocation field. Distance between a custom geolocation field and fixed coordinates DISTANCE(warehouse_location__c, GEOLOCATION(37.775,-122.418), 'km') This formula returns the distance, in kilometers, between the warehouse and the known latitude and longitude 37.775°, -122.418° (San Francisco). Distances with conditions IF(DISTANCE(warehouse_location__c, ShippingAddress, 'mi')<10, "Near", "Far") This formula updates a text formula field to Near if the distance between the warehouse and the account shipping address compound field is less than 10 miles. Otherwise, it updates the text field to Far.
Tip: Although DISTANCE can be calculated in miles or kilometers, the unit isn't returned in the calculation. If possible, include the unit of measure in the name of your distance formula field, so users know whether the distance is in miles or kilometers.
Tips: • The DISTANCE function returns a number data type. Distance is always calculated in decimals, even if you’re displaying the geolocation notation in degrees, minutes, and seconds in the user interface. Specify the number of decimal places to show when you create a custom field. • The DISTANCE function isn’t available in reports, but it can be used in list views. To use DISTANCE in your reports, set up a formula field, and then reference the field in your reports. • DISTANCE is the only formula function that can use GEOLOCATION parameters. • There are limitations on DISTANCE accuracy and equality calculations.
374 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
– DISTANCE supports only the logical operators > and <, returning values within (<) or beyond (>) a specified radius. – Distance is calculated as a straight line, regardless of geography and topography between the two points. For more details, see “How SOQL Calculates and Compares Distances” in the SOQL and SOSL Reference.
EXP
Description: Returns a value for e raised to the power of a number you specify.
Use: EXP(number) and replace number with a number field or value such as 5.
Example: Exponent of a Literal Value EXP(3) This formula returns the value of e to the third power. Compound Interest Principal__c * EXP(Rate__c * Years__c) This formula calculates the compound interest based on a custom currency field for principal, custom percent field for rate, and custom number field for years.
FIND
Description: Returns the position of a string within a string of text represented as a number.
Use: FIND(search_text, text[, start_num]) and replace search_text with the string you want to find, replace text with the field or expression you want to search, and replace start_num with the number of the character from which to start searching from left to right.
Example: Street Address FIND(" ", Street) returns the character position of the first space in the Street field. You can use this number to find out the length of the street address as a means of separating a street address from street name in an address field. Deriving Website Addresses SUBSTITUTE(Email, LEFT(Email, FIND("@", Email)), "www.") finds the location of the @ sign in a person's email address to determine the length of text to replace with a “www.” as a means of deriving their website address.
Tips: • Be sure to remove the brackets, [ and ], from your formula before validating it. • If the field referenced in your text parameter is blank, the formula field displays 0. • Your search_text parameter is case-sensitive and can't contain any wildcard characters. • If your search doesn't return any results, a 0 displays in the field.
375 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• The start_num parameter is optional. If you don't enter a start_num value, the formula uses the value one, or the first character in the string. • If your start_num isn't greater than zero, a 0 displays in the field. • If your start_num is greater than the length of the text, a 0 displays in the field. • When entering your start_num parameter, remember that some fields like the Website field are unique because a http:// is automatically appended to the beginning of the text you enter. • The first character in a string is designated as one rather than zero.
FLOOR
Description: Returns a number rounded down to the nearest integer, towards zero if negative.
Use: FLOOR(number) and replace number with a number field or value such as 5.245.
Example: FLOOR(2.5) returns 2, which is 2.5 rounded down to the nearest integer. FLOOR(-2.5) returns -2, which is -2.5 rounded towards zero for a negative number.
GEOLOCATION
Description: Returns a geolocation based on the provided latitude and longitude. Must be used with the DISTANCE function.
Use: GEOLOCATION(latitude, longitude) and replace latitude and longitude with the corresponding geolocation, numerical code values.
Examples: Distance between a custom geolocation field and fixed coordinates DISTANCE(warehouse_location__c, GEOLOCATION(37.775,-122.418), 'km') This formula returns the distance, in kilometers, between the warehouse and the known latitude and longitude 37.775°, -122.418° (San Francisco).
Tips: • The GEOLOCATION function returns a location data type that can be used only by, and must be used with, the DISTANCE function. The GEOLOCATION function doesn’t work on its own.
GETRECORDIDS
Description: Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list.
Use: {!GETRECORDIDS(object_type)} and replace object_type with a reference to the custom or standard object for the records you want to retrieve.
376 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Custom Button Example: {!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")} var records = {!GETRECORDIDS($ObjectType.Sample)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one row") } else { for (var n=0; nIn this example, all selected case records are updated with a Status of New. To set this up in your org, create a custom list button for cases with the following attributes: • Display Type is List Button • Behavior is Execute JavaScript • Content Source is OnClick JavaScript Paste the sample code above into the content of your custom button. Finally, add the list button to the page layout that contains the Cases related list, such as accounts or opportunities. Users can select any number of cases in the related list and click the list button to change the status of those cases at once. Notice the check for records[0] == null, which displays a message to users when they don't select at least one record in the list.
Tips: • Use global variables to access special merge fields for s-controls, custom buttons, and links. • Activities are special types of objects. Use {!GETRECORDIDS($ObjectType.Task)} when creating a task list button. Use {!GETRECORDIDS($ObjectType.Event)} when creating an event list button. • This function is only available in custom buttons, links, and s-controls.
GETSESSIONID
Description: Returns the user’s session ID.
Use: GETSESSIONID()
Example: HYPERLINK ("https://www.myintegration.com?sId="& GETSESSIONID() & "?&rowID="&Name & "action=CreateTask","Create a Meeting Request")
creates a link to an application outside of Salesforce, passing the parameters so that it can connect to Salesforce via the API and create the necessary event.
Tips: Important: $Api.Session_ID and GETSESSIONID() return the same value, an identifier for the current session in the current context. This context varies depending on where the global variable or function is evaluated. For example, if you use either in a custom formula field, and that field is displayed on a standard page layout in Salesforce Classic, the referenced session is a basic Salesforce session. That same field (or the underlying variable or formula result), when used in a Visualforce page, references a Visualforce session instead.
377 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Session contexts are based on the domain of the request. That is, the session context changes whenever you cross a hostname boundary, such as from .salesforce.com to .vf.force.com or .lightning.force.com. Session identifiers from different contexts, and the sessions themselves, are different. When you transition between contexts, the old session is replaced by the new one, and the old session is no longer valid. The session ID also changes at this time. Normally Salesforce transparently handles session hand-off between contexts, but if you’re passing the session ID around yourself, you might need to re-access $Api.Session_ID or GETSESSIONID() from the new context to ensure a valid session ID. Not all sessions are created equal. In particular, sessions obtained in a Lightning Experience context have reduced privileges, and don't have API access. You can't use these session IDs to make API calls. {!$Api.Session_ID} isn’t generated for guest users.
HOUR
Description: Returns the local time hour value without the date in the form of a number from 1 through 24.
Use: HOUR(time) and replace time with a time value or value such as TIMENOW().
Examples: HOUR(TIMEVALUE(ClosedDate)) displays only the hour in a time field based on the value of the Time Closed field. HOUR(TIMEVALUE("17:30:45.125")) returns 17.
HTMLENCODE
Description: Encodes text and merge field values for use in HTML by replacing characters that are reserved in HTML, such as the greater-than sign (>), with HTML entity equivalents, such as >.
Use: {!HTMLENCODE(text)} and replace text with the merge field or text string that contains the reserved characters.
Example: If the merge field foo__c contains Enter the user's name, {!HTMLENCODE(foo__c)} results in: <B>Enter the user's name</b>
Tips: This function is only available in custom buttons and links, and in Visualforce.
HYPERLINK
Description: Creates a link to a URL specified that is linkable from the text specified.
Use: HYPERLINK(url, friendly_name [,target]) and replace url with the Web address, replace friendly_name with the link text, and, optionally, replace target with the window or frame in which to display the content.
378 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: Creating Events
HYPERLINK("/00U/e? retURL=%2F006x0000001T8Om&what_id=" & Id, "Create Event")
adds a link called Create Event that, when clicked, creates an event that is associated with the current object. Phone Dialer HYPERLINK("http://servername/call?id=" & Id & "&phone=" & Phone, Phone)creates a linkable phone number field that automatically dials the phone number when clicked. In this example, replace "servername" and "call" with the name of your dialing tool and the command it uses to dial. The merge field, Id, inserts the identifier for the contact, lead, or account record. The first Phone merge field tells the dialing tool what number to call and the last Phone merge field uses the value of the Phone field as the linkable text the user clicks to dial.
Tips: • Hyperlink formula fields are of type text. • Include the protocol and URL in quotes as in HYPERLINK("http://www.cnet.com", "cnet"). • Avoid using text functions such as LEN, LEFT, or RIGHT on HYPERLINK function results. • The URL can’t contain JavaScript. This increases security for your org. Using JavaScript is permitted in packages, sandbox copies, and change sets. • Use a relative link to link to Salesforce pages. If your full link is https://yourInstance.salesforce.com/00U/e, then its relative link is /00U/e. Relative links allow the hyperlink to work correctly on all Salesforce pages. Use the relative URL in a hyperlink formula to add it to a search layout. Make sure to prepend your relative URL with a forward slash “/”. • Use the $Api variable to reference API URLs. • Be sure to remove the brackets, [ and ], from your formula before validating it. • The target parameter is optional. If you don't specify a target, the link opens in a new browser window. Some common target parameters are: _blank Displays link in a new unnamed window. _self Displays link in the same frame or window as the element that refers to it. _parent Displays link in the immediate frameset parent of the current frame. This value is the same as _self if the current frame has no parent. _top Displays link in the full original window, canceling any other frames. This value is the same as _self if the current frame has no parent. For more information on basic HTML tags, consult an HTML reference on the Internet.
379 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• The HYPERLINK function is available everywhere that you can define a formula except default values, field updates, s-controls, validation rules, approval processes, custom buttons and links, and workflow rules.
SEE ALSO: Formula Operators and Functions I–Z Formula Operators and Functions Tips for Working with Hyperlink Formula Fields
Formula Operators and Functions I–Z Use the following operators and functions when building formulas. Click the name of the operator or function to view more details. All functions are available everywhere that you can include a formula such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified.
Note: Extraneous spaces in the samples are ignored.
IF
Description: Determines if expressions are true or false. Returns a given value if true and another value if false.
Use: IF(logical_test, value_if_true, value_if_false) and replace logical_test with the expression you want evaluated; replace value_if_true with the value you want returned if the expression is true; replace value_if_false with the value you want returned if the expression is false.
Formula Field Example: Overdue Payments IF(AND(Payment_Due_Date__c < TODAY(),Payment_Status__c ="UNPAID") , "PAYMENT OVERDUE", null) This formula determines if the payment due date is past and the payment status is “UNPAID.” If so, returns the text “PAYMENT OVERDUE” and if not, leaves the field blank. This example uses a custom date field called Payment Due Date and a text custom field called Payment Status. Insert Tax Rate Use this default value formula to set the tax rate of an asset based on the user's city. Create a custom percent field with the following default value:
IF($User.City = "Napa", 0.0750, IF($User.City = "Paso Robles", 0.0725, IF($User.City = "Sutter Creek", 0.0725, IF($User.City = "Los Olivos", 0.0750, IF($User.City = "Livermore", 0.0875, null ) ) ) ) )
380 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Custom Button Example: {! IF(Sample.BillingCountry = "US", "http://maps.google.com/maps?q="&Sample.BillingStreet& "+"&Sample.BillingCity&"+"&Sample.BillingState&"+ "&Sample.BillingCountry, (IF(Sample.BillingCountry = "UK", "http://maps.google.co.uk/maps?q="&Sample.BillingStreet &"+"&Sample.BillingCity&"+"&Sample.BillingCountry, "http://maps.google.com"))) }
This example uses the IF function to determine if an address is in the United States or United Kingdom so that it can use the appropriate type of Google map to display the address.
Tips: • Make sure your value_if_true and value_if_false expressions are the same data type. • When using an IF function with the $Profile.UserType variable to determine the type of Salesforce user license the logged in user has, use the following values: – Standard for Salesforce – PowerPartner for PRM User – CustomerSuccess for Customer Portal User – PowerCustomerSuccess for Customer Portal Manager For example, use the following formulas to determine if the logged in user has the license type in quotes:
IF(ISPICKVAL($Profile.UserType ,"Standard"), 100, 0.1)
IF(ISPICKVAL($Profile.UserType ,"PowerPartner"), 100, 0.1)
IF(ISPICKVAL($Profile.UserType ,"CustomerSuccess"), 100, 0.1)
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
IMAGE
Description: Inserts an image with alternate text and height and width specifications.
Use: IMAGE(image_url, alternate_text, height, width) and replace image_url with the full path to the image. Replace alternate_text with the string of text you want to appear when the image can’t be rendered for some reason. This text can be used by screen reader software. Replace height with the vertical size of the image in pixels. Replace width with the horizontal size of the image in pixels. For reports, images aren't automatically resized to fit into a report column. Use the height and width parameters to explicitly size the image so it fits into the column without being partially cut off.
381 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: HYPERLINK("ymsgr:sendIM?" & Yahoo_Name__c, IMAGE("http://opi.yahoo.com/online?u=" & Yahoo_Name__c & "&m;=g&t;=0", "Yahoo")) This formula displays a clickable Yahoo! Messenger icon indicating if the person is logged on to the service. Users can click the icon to launch a Yahoo! Messenger conversation with the person. This example uses a custom text field called Yahoo Name on contacts where you can store the contact's Yahoo! Messenger ID.
Tips: • The height and width parameters are optional. • Use a text string to replace the image_url and alternate_text parameters. Surround each text string in quotes. • Use numbers to replace the height and width parameters. • Add images to your Documents tab if you want to display them elsewhere. For example, store the image of a product in a document folder, copy the URL to the document, and paste that URL in the image_url parameter of a formula field on the Products tab. • If you use Internet Explorer, you sometimes must to change your security settings so that Explorer doesn’t display a warning prompt when images use HTTP protocol. See the online help for Internet Explorer for instructions on changing your security settings. • The IMAGE function cannot include the GETSESSIONID function as one of its arguments. • The IMAGE function is available only in formula fields and email templates. • You can’t display an image related to a contact in a custom formula field if it’s referenced through a person account.
IMAGEPROXYURL
Description: Securely retrieves external images and prevents unauthorized requests for user credentials.
Use: and replace http://exampledomain.com/pic.png with your image.
Example: alt="Salesforce on Twitter" />
This IMAGEPROXYURL function retrieves and displays an image from Twitter’s image host, an external source. This function loads the Salesforce Twitter profile image over HTTPS. This function also prevents the image from making unauthorized requests for user credentials.
Tips: • Use IMAGEPROXYURL for all images hosted on servers you don’t control. • The rendered image URL can change at any time. Don’t copy and paste it anywhere. • Don’t use the rendered image URL outside of Salesforce.
382 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
INCLUDE
Description: Returns content from an s-control snippet. Use this function to reuse common code in many s-controls.
Use: {!INCLUDE(source, [inputs])} and replace source with the s-control snippet you want to reference. Replace inputs with any information you need to pass the snippet.
S-Control Example: Including Header Snippet
{! INCLUDE($SControl.Header_Snippet, [title = "My Title", theme = "modern"])}
This example references a snippet that provides a header for a page that you created to display in a Web tab. It displays the page title “My Title.” Use the $SControl global variable to reference a custom s-control. Including Input Parameters Use the following two examples to see how you can create a reusable snippet and include it in an s-control.
{!$Request.titleText}
This snippet requires two input parameters: titleTheme and titleText. It is a reusable HTML tag that presents a page title and theme based on input parameters. Next, create an s-control that includes this snippet:
{! INCLUDE($SControl.Title_Snippet, [titleTheme = "modern", titleText = "My Sample Title"]) } ... Insert your page specific content here ... This s-control uses the snippet titled Title_Snippet to display the title of the page “My Sample Title” and modern theme. Replace Insert your page specific content here with your own HTML content and use the s-control as the source of a Web tab to create your own pages in Salesforce.
Tips: • Because this function references an s-control snippet and does not copy it, it always runs the latest content of the s-control snippet. Remember that making a change to your s-control snippet affects all INCLUDE functions that refer to it. • Use the $Request global variable to access any information inside the snippet. • This function is only available in custom buttons, links, and s-controls.
INCLUDES
Description: Determines if any value selected in a multi-select picklist field equals a text literal you specify.
383 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: INCLUDES(multiselect_picklist_field, text_literal) and replace multiselect_picklist_field with the merge field name for the multi-select picklist; and replace text_literal with the multi-select picklist value you want to match in quotes.
Examples: INCLUDES(Hobbies__c, "Golf") returns TRUE if one of the selected values in the Hobbies custom multi-select picklist field is Golf.
Tips: • The text_literal expression must be of type text and enclosed in quotes. It cannot be a merge field or the result of a function. • Salesforce returns an error if any of the following occurs: – You do not provide a text_literal expression. – You provide an empty text_literal expression, such as "" or " ".
• Use ISBLANK to determine if a multi-select picklist field is empty. • Use the PRIORVALUE function inside the INCLUDES function to check if the previous value of a multi-select picklist field included a specific value. For example:
INCLUDES( PRIORVALUE(multiselect_picklist_field), text_literal )
ISBLANK
Description: Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE.
Use: ISBLANK(expression) and replace expression with the expression you want evaluated.
Example: (IF(ISBLANK(Maint_Amount__c), 0, 1) + IF(ISBLANK(Services_Amount__c), 0,1) + IF(ISBLANK(Discount_Percent__c), 0, 1) + IF(ISBLANK(Amount), 0, 1) + IF(ISBLANK(Timeline__c), 0, 1)) / 5
This formula takes a group of fields and calculates what percent of them are being used by your personnel. This formula field checks five fields to see if they are blank. If so, a zero is counted for that field. A “1” is counted for any field that contains a value, and this total is divided by five (the number of fields evaluated). This formula requires you to select the Treat blank fields as blanks option under Blank Field Handling while the Advanced Formula subtab is showing.
Tips: • Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas. • A field is not empty if it contains a character, blank space, or zero. For example, a field that contains a space inserted with the spacebar is not empty.
384 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Use the BLANKVALUE function to return a specified string if the field doesn't have a value; use the ISBLANK function if you only want to check if the field has a value. • If you use this function with a numeric field, the function only returns TRUE if the field has no value and is not configured to treat blank fields as zeroes. • If you use this function with a picklist, use ISBLANK(TEXT()) to convert the picklist items into a text value.
ISCHANGED
Description: Compares the value of a field to the previous value and returns TRUE if the values are different. If the values are the same, this function returns FALSE.
Use: ISCHANGED(field) and replace field with the name of the field you want to compare.
Validation Rule Example: The following validation rule prevents users from changing an object name after it has been created: ISCHANGED(Name). NOT(AND(ISCHANGED(Priority), ISPICKVAL(Priority, “Low”))) is a validation rule that ensures if a user changes the Priority of a case, the new priority cannot be “Low.” NOT(AND(ISCHANGED(CloseDate), OR(MONTH(CloseDate) <> MONTH(TODAY()), YEAR(CloseDate) <> YEAR(TODAY())),$Profile.Name <> "Sales Manager")) is a validation rule that prevents a user from changing the Close Date of an opportunity to a date outside of the current month and year unless that user has the “Sales Manager” profile.
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
Tips: • This function is available only in: – Assignment rules – Validation rules – Field updates – Workflow rules if the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited . – Formula criteria for executing actions in Process Builder.
• Use the NOT function to reverse the return values of TRUE and FALSE. • This function returns FALSE when evaluating any field on a newly created record. • If a text field was previously blank, this function returns TRUE when it contains any value. • For number, percent, or currency fields, this function returns TRUE when: – The field was blank and now contains any value – The field was zero and now is blank – The field was zero and now contains any other value
385 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
ISCLONE
Description: Checks if the record is a clone of another record and returns TRUE if one item is a clone. Otherwise, returns FALSE.
Use: ISCLONE()
Validation Rule Example: Use (ISCLONE() to create a validation rule on an object and identify a record that’s a clone of another record.
Tips: • This function cannot be used with fields. • Use the NOT function to reverse the return values of TRUE and FALSE.
ISNEW
Description: Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE.
Use: ISNEW()
Validation Rule Example: Use the following validation rule to prevent users from creating a record with a close date in the past. AND (ISNEW(), CloseDate < TODAY()) checks if the user is creating a new opportunity and, if so, ensures that the Close Date is today or after today. Use this validation rule to ensure users add at least one product to an opportunity after they have created it.
NOT(OR(ISNEW(),HasOpportunityLineItem))
In this example, the validation rule formula displays the following error message when an existing opportunity does not have any products: “You must add products to this opportunity before saving.” This does not display an error on the initial save because they cannot add products until after saving the record initially; but it prevents them from resaving or closing an opportunity that does not contain products.
Tips: • This function is available only in validation rules, field updates, workflow rules, assignment rules, and processes. • Use the NOT function to reverse the return values of TRUE and FALSE. • This function always returns FALSE when used in a workflow rule with a time-based trigger. • This function always returns FALSE when used in a field update for an approval action.
ISNULL
Important: Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas.
Description: Determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE.
386 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: ISNULL(expression) and replace expression with the expression you want evaluated.
Example: (IF(ISNULL(Maint_Amount__c), 0, 1) + IF(ISNULL(Services_Amount__c), 0,1) + IF(ISNULL(Discount_Percent__c), 0, 1) + IF(ISNULL(Amount), 0, 1) + IF(ISNULL(Timeline__c), 0, 1)) / 5
This formula takes a group of fields and calculates what percent of them are being used by your personnel. This formula field checks five fields to see if they are blank. If so, a zero is counted for that field. A “1” is counted for any field that contains a value, and this total is divided by five (the number of fields evaluated). This formula requires you to select the Treat blank fields as blanks option under Blank Field Handling while the Advanced Formula subtab is showing.
Validation Rule Example: AND(ISPICKVAL(StageName, "Closed Won"), ISNULL(Project_Start_Date__c))
This validation rule makes the Project Start Date custom date field conditionally required whenever the stage is Closed Won.
Tips: • Text fields are never null, so using this function with a text field always returns false. For example, the formula field IF(ISNULL(new__c) 1, 0) is always zero regardless of the value in the New field. For text fields, use the ISBLANK function instead. • Multi-select picklist fields are never null in s-controls, buttons, and email templates, so using this function with a multi-select picklist field in those contexts always returns false. • Empty date and date/time fields always return true when referenced in ISNULL functions. • Don’t use ISNULL for date/time fields. • Choose Treat blank fields as blanks for your formula when referencing a number, percent, or currency field in an ISNULL function. Choosing Treat blank fields as zeroes gives blank fields the value of zero so none of them will be null. • Merge fields can be handled as blanks, which can affect the results of components like s-controls because they can call this function. • When using a validation rule to ensure that a number field contains a specific value, use the ISNULL function to include fields that do not contain any value. For example, to validate that a custom field contains a value of '1', use the following validation rule to display an error if the field is blank or any other number:
OR(ISNULL(field__c), field__c<>1)
ISNUMBER
Description: Determines if a text value is a number and returns TRUE if it is. Otherwise, it returns FALSE.
Use: ISNUMBER(text) and replace text with the merge field name for the text field.
387 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Validation Rule Example: OR(LEN(Bank_Account_Number__c) <> 10, NOT(ISNUMBER(Bank_Account_Number__c)))
This validation rule ensures a custom text field called Bank Account Number is a number of 10 digits and is not blank.
Tips: • This function returns FALSE for blank values. • The ISNUMBER function is not aware of your locale. For example, ISNUMBER("123,12") and ISNUMBER("1 000") return FALSE even if the user's locale is “French.” • Chinese, Japanese, Korean, and special characters including a space return FALSE. • The ISNUMBER function returns TRUE for scientific formatting such as “2E2” or “123.123.”
ISPICKVAL
Description: Determines if the value of a picklist field is equal to a text literal you specify.
Use: ISPICKVAL(picklist_field, text_literal) and replace picklist_field with the merge field name for the picklist; replace text_literal with the picklist value in quotes. text_literal cannot be a merge field or the result of a function.
Examples: Contract Activation IF(ISPICKVAL(Status, "Activated"), NOW()-ActivatedDate, null) calculates the number of days since the contract was activated. If the contract status is not “Activated,” this field is blank. Commission Amounts
IF(ISPICKVAL(StageName, "Closed Won"), ROUND(Amount *0.02, 2), 0)
This example calculates the commission amount for any opportunity that has a “Closed Won” stage. The value of this field will be the amount times 0.02 for any closed/won opportunity. Open or lost opportunities will have a zero commission value. Competitor-Triggered Workflow
ISPICKVAL(Stage, “Closed Lost”) && INCLUDES(Competitor__c, “Acme”)
In a workflow rule or process, this formula configures Salesforce to trigger the associated actions if the Competitor multi-select picklist field on a lost business is Acme.
Tips: • Replace picklist_field with a custom or standard field of type picklist. • Your text_literal expression must be of type text and enclosed in quotes. It cannot be a merge field or the result of a function. • Use CASE functions to determine if a picklist value is equal to a particular value.
388 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• When using the ISPICKVAL function to return the previous value of a picklist field, include the PRIORVALUE function inside the ISPICKVAL function as in this example:
ISPICKVAL(PRIORVALUE (picklist_field), text_literal)
JSENCODE
Description: Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (').
Use: {!JSENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters.
Example: If the merge field foo__c contains Enter the user's name, {!JSENCODE(foo__c)} results in: \u003CB\u003EEnter the user\'s name\u003C\/b\u003E
Tips: This function is only available in custom buttons and links, and in Visualforce.
JSINHTMLENCODE
Description: Encodes text and merge field values for use in JavaScript inside HTML tags by replacing characters that are reserved in HTML with HTML entity equivalents and inserting escape characters before unsafe JavaScript characters. JSINHTMLENCODE(someValue) is a convenience function that is equivalent to JSENCODE(HTMLENCODE((someValue)). That is, JSINHTMLENCODE first encodes someValue with HTMLENCODE, and then encodes the result with JSENCODE.
Use: {!JSINHTMLENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters.
Example: If the merge field foo__c contains Enter the user's name, {!JSINHTMLENCODE(foo__c)} results in: <B>Enter the user's name</b>
Tips: • This function is only available in custom buttons and links, and in Visualforce.
JUNCTIONIDLIST
Description: Returns a JunctionIDList based on the provided IDs. A JunctionIDList is a string array of referenced ID values that represent the many-to-many relationship of an underlying junction entity.
Use: JUNCTIONIDLIST(id, id,...) and replace id with the Salesforce ID you want to use.
389 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: JUNCTIONIDLIST(Case.ContactId) This formula returns the case’s contact record ID. When used on the email action for cases, you can use this formula as a predefined value for the To Recipients field. Using this formula as a predefined value for the field ensures that sent emails are always associated with a Salesforce record. In the case feed publisher, users see the contact name instead of the ID or email address.
Tips: • You can enter IDs only. • You can use the JUNCTIONLISTID formula with the To Recipients, CC Recipients, and BCC Recipients fields to send emails to multiple contacts and users. However, these fields work only with the email action for cases.
LEFT
Description: Returns the specified number of characters from the beginning of a text string.
Use: LEFT(text, num_chars) and replace text with the field or expression you want returned; replace num_chars with the number of characters from the left you want returned.
Example: TRIM(LEFT(LastName, 5)) & "-" & TRIM(RIGHT(SSN__c, 4)) This formula displays the first five characters of a name and the last four characters of a social security number separated by a dash. Note that this example uses a text custom field called SSN.
Tips: • Reference auto-number fields as text fields in formulas. • If the num_chars value is less than zero, Salesforce replaces the value with zero.
LEN
Description: Returns the number of characters in a specified text string.
Use: LEN(text) and replace text with the field or expression whose length you want returned.
Example: LEN(PartNumber__c) This formula returns the number of characters in a Product Code field.
LINKTO
Description: Returns a relative URL in the form of a link (href and anchor tags) for a custom s-control or Salesforce page.
Use: {!LINKTO(label, target, id, [inputs], [no override]} and replace label with the text for the link, target with the URL, and id with a reference to the record. Inputs are optional and can include any additional parameters you want to add to the link. The no override argument is also optional and defaults to “false.” It applies to targets for standard Salesforce pages such as $Action.Account.New. Replace no override with “true” when you
390 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
want to display a standard Salesforce page regardless of whether you have defined an override for it elsewhere.
S-Control Example: New Account S-Control
{!LINKTO("Create a New Account", $Action.Account.New, $ObjectType.Account)} This example allows users to click a link to create a new account. It is useful in account list views or Web tabs where you want users to create an account directly from that page. Use the $Action global variable to access the new account page in Salesforce. New Email Window S-Control
{!LINKTO("Email link", "mailto:support@yourcompany.com?subject=Please%20Help")}; This example launches a new email window addressed to support@yourcompany.com with the subject “Please Help” whenever a user clicks “Mail link.” Link to Another S-Control
{!LINKTO("Check for duplicates", $Scontrol.dedup_account, Account.Id)} Use this example to generate a page containing a hyperlink labeled “Check for duplicates.” When users click this link, Salesforce runs your custom s-control. This example assumes you have already created a custom s-control to find duplicate accounts and merge their information.
Tips: • Avoid using this function in an inline s-control if you want it to open in a new window. • Enclose multiple inputs in brackets to indicate they are together:
{!LINKTO("View Case", $Action.Case.View, Case.Id, [parm1="A", parm2="B"])}
• Set inputs to null if you do not have any to pass yet you want to set the no override argument:
{!LINKTO("View Case", $Action.Case.View, Case.Id, null, true)}
• When you override the tab home page for a standard or custom tab, use the tab’s $Action global variable as the target value, and the tab’s object type for the id value. For example, LINKTO("Accounts Tab", $Action.Account.Tab, $ObjectType.Account) • This function is only available in custom buttons, links, and s-controls.
391 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
LN
Description: Returns the natural logarithm of a specified number. Natural logarithms are based on the constant e value of 2.71828182845904.
Use: LN(number) and replace number with the field or expression for which you want the natural logarithm. Note: the LN function is the inverse of the EXP function.
Example: LN(10) returns the natural logarithm of 10, which is 2.30. LN(Value__c) returns the natural logarithm of a custom number field called Value.
LOG
Description: Returns the base 10 logarithm of a number.
Use: LOG(number) and replace number with the field or expression from which you want the base 10 logarithm calculated.
Example: Salary LOG(Salary__c) calculates the logarithm of a person’s salary. In this example, Salary is a custom currency field. Hydrogen -LOG(Hydrogen__c) calculates the pH and acidity using the LOG function and a custom number field called Hydrogen, which represents the concentration of Hydrogen ions in the liquid measured in moles per liter.
LOWER
Description: Converts all letters in the specified text string to lowercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided.
Use: LOWER(text, [locale]) and replace text with the field or text you wish to convert to lowercase, and locale with the optional two-character ISO language code or five-character locale code, if available.
Example: MYCOMPANY.COM LOWER("MYCOMPANY.COM") returns “mycompany.com.” Ticker Symbol LOWER(TickerSymbol) returns the text in Ticker Symbol in lower case characters. Applying Turkish Language Locale Rules The Turkish language has two versions of the letter “i”: one dotted and one dotless. The locale rules for Turkish require the ability to capitalize the dotted i, and allow the dotless I to be lowercase. To correctly use the LOWER() function with the Turkish language locale, use the Turkish locale code tr in the LOWER() function as follows: LOWER(text, "tr")
392 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This ensures that Salesforce does not transform any dotted i in the text to a dotless I.
LPAD
Description: Inserts characters you specify to the left-side of a text string.
Use: LPAD(text, padded_length[, pad_string]) and replace the variables: • text is the field or expression you want to insert characters to the left of. • padded_length is the number of total characters in the text that will be returned. • pad_string is the character or characters that should be inserted. pad_string is optional and defaults to a blank space. If the value in text is longer than pad_string, text is truncated to the size of padded_length.
Example: Field Name: Padding LPAD(Name, 20) truncates the Name field after 20 characters. For example, if the name is mycompany.com, the value returned is "mycompany.com." My_Company: No Change LPAD('my_company.com', 14, 'z') returns “my_company.com” without change because it has 14 characters. Field Name Padded with Z LPAD(Name, 15, 'z') returns the name “zmycompany.com.” Field Name: Truncating LPAD(Name, 2) truncates the name after the second character. For example, if the name is mycompany.com, the value returned is “my.”
Tips: Leading blank spaces and zeros are omitted.
MAX
Description: Returns the highest number from a list of numbers.
Use: MAX(number, number,...) and replace number with the fields or expressions from which you want to retrieve the highest number.
Example: Service Charge MAX(0.06 * Total_Cost__c, Min_Service_Charge__c) In this example, the formula field calculates a service charge of 6% of the total cost or a minimum service charge, whichever is greater. Note that Min Service Charge is a custom currency field with a default value of $15. However, you could make it a formula field if your minimum service charge is always the same amount.
393 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Book Royalties
MAX(0.10 * Pages__c, (Retail_Price__c * 0.07) * Total_Sold__c)
This formula determines which amount to pay in royalties for a book. It displays the greater of two amounts: $0.07 for each book sold or $0.10 per page. It assumes you have custom number fields for Pages and Total Sold and a custom currency field for Retail Price. Commissions
MAX($User.Commission_Percent__c * Price, Price * Account_Discount__c, 100)
This formula determines what commission to log for an asset based on which is greater: the user's commission percentage of the price, the price times the discount percent stored for the account or 100 dollars. This example assumes you have two custom percent fields on users and assets.
MCEILING
Description: Rounds a number up to the nearest integer, towards zero if negative.
Use: MCEILING(number)
Example: MCEILING(2.5) returns 3, which is 2.5 rounded up to the nearest integer. MCEILING(-2.5) returns -2, which is -2.5 rounded up towards zero for a negative number.
MFLOOR
Description: Rounds a number down to the nearest integer, away from zero if negative.
Use: MFLOOR(number)
Example: MFLOOR(2.5) returns 2, which is 2.5 rounded down to the nearest integer. MFLOOR(-2.5) returns -3, which is -2.5 rounded away from zero for a negative number.
MID
Description: Returns the specified number of characters from the middle of a text string given the starting position.
Use: MID(text, start_num, num_chars) and replace text with the field or expression to use when returning characters; replace start_num with the number of characters from the left to use as a starting position; replace num_chars with the total number of characters to return.
Example: MID(Division, 3, 4) returns four characters of the Division name beginning with the third character from the left. On a user record, this represents the department code.
394 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
MILLISECOND
Description: Returns a milliseconds value in the form of a number from 0 through 999.
Use: MILLISECOND(time) and replace time with a time value or value such as TIMENOW().
Examples: MILLISECOND(TIMEVALUE(ClosedDate)) displays only the milliseconds in a time field based on the value of the Time Closed field. MILLISECOND(TIMEVALUE("17:30:45.125")) returns 125.
MIN
Description: Returns the lowest number from a list of numbers.
Use: MIN(number, number,...) and replace number with the fields or expressions from which you want to retrieve the lowest number.
Example: 401K Matching
MIN(250, Contribution__c /2)
This example formula determines which amount to provide in employee 401K matching based on a matching program of half of the employee's contribution or $250, whichever is less. It assumes you have custom currency field for Contribution. Bonus
MIN(Gross__c * Bonus_Percent__c, Performance__c / Number_of_Employees__c)
This example determines an employee's bonus amount based on the smallest of two amounts: the employee's gross times bonus percent or an equally divided amount of the company's performance amount among all employees. It assumes you have custom number field for Number of Employees, a custom percent field for Bonus Percent, and currency custom fields for the employee's Gross and company's Performance.
MINUTE
Description: Returns a minute value in the form of a number from 0 through 60.
Use: MINUTE(time) and replace time with a time value or value such as TIMENOW().
Examples: MINUTE(TIMEVALUE(ClosedDate)) displays only the minutes in a time field based on the value of the Time Closed field. MINUTE(TIMEVALUE("17:30:45.125")) returns 30.
MOD
Description: Returns a remainder after a number is divided by a specified divisor.
395 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: MOD(number, divisor) and replace number with the field or expression you want divided; replace divisor with the number to use as the divisor.
Example: MOD(3, 3) returns 0 MOD(4, 3) returns 1 MOD(123, 100) returns 23 You might want to prevent users from scheduling meetings on a Saturday or Sunday. Use the following example to apply a validation rule to a custom date field called My Date.
CASE(MOD(My_Date__c - DATE(1900, 1, 7), 7), 0, 0, 6, 0, 1) = 0
This example displays the following error message when the value of My Date is not Monday through Friday: “My Date is not a weekday.”
MONTH
Description: Returns the month, a number between 1 (January) and 12 (December) in number format of a given date.
Use: MONTH(date) and replace date with the field or expression for the date containing the month you want returned.
Example: SLA Expiration MONTH(SLAExpirationDate__c) returns the month that your service-level agreement expires. This example uses a custom date field called SLA Expiration Date. Current Month MONTH(TODAY()) returns the current month in a number format. For example, the month of February would be the value “2.”
NOT
Description: Returns FALSE for TRUE and TRUE for FALSE.
Use: NOT(logical) and replace logical with the expression that you want evaluated.
Example: IF(NOT(ISPICKVAL(Status, "Closed")), ROUND(NOW()-CreatedDate, 0), null checks to see if a variable is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number of days open rounded to zero decimal places. If the variable is not open, this field is blank.
396 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
NOW
Description: Returns a date/time representing the current moment.
Use: NOW()
Example: IF(ISPICKVAL(Status, "Open"), ROUND(NOW()-CreatedDate, 0), null) This formula checks to see if a lead is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number of days open rounded to zero decimal places. If the lead is not open, this field is blank.
Tips: • Do not remove the parentheses. • Keep the parentheses empty. They do not need to contain a value. • Use a date/time field in a NOW function instead of a date field. Created Date and Last Modified Date are date/time fields whereas Last Activity Date is a date field. • Use TODAY if you prefer to use a date field. • Dates and times are always calculated using the user’s time zone. • Use addition and subtraction operators with a NOW function and other date/time fields to return a number, representing number of days. For example NOW() - CreatedDate calculates the number of days since the created date of a record. In this example, the formula field data type is a number. • Use addition and subtraction operators with a NOW function and numbers to return a date and time. For example NOW() +5 calculates the date and time five days ahead of now. In this example, the formula field data type is a date/time.
NULLVALUE
Important: Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas.
Description: Determines if an expression is null (blank) and returns a substitute expression if it is. If the expression is not blank, returns the value of the expression.
Use: NULLVALUE(expression, substitute_expression) and replace expression with the expression you want to evaluate; replace substitute_expression with the value you want to replace any blank values.
Example: (NULLVALUE(Sample_Due_Date__c, StartDate +5) This formula returns the date five days after the start date whenever Sample Due Date is blank. Sample Due Date is a custom date field.
Tips: • Avoid using this function with text fields because they are never null even when they are blank. Instead, use the BLANKVALUE function to determine if a text field is blank. • Don’t use NULLVALUE for date/time fields.
397 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Choose Treat blank fields as blanks for your formula when referencing a number, percent, or currency field in a NULLVALUE function. Choosing Treat blank fields as zeroes gives blank fields the value of zero so none of them will be null. • Use the same data type for both the expression and substitute_expression.
OR
Description: Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false. Use this function as an alternative to the operator || (OR).
Use: OR(logical1, logical2...) and replace any number of logical references with the expressions you want evaluated.
Formula Field Example: IF(OR(ISPICKVAL(Priority, "High"), ISPICKVAL(Status, "New")), ROUND(NOW()-CreatedDate, 0), null) This formula returns the number of days a case has been open if the Status is new or the Priority is high. If the case was opened today, this field displays a zero.
Validation Rule Example: OR(Sample_Rate__c < 0, Sample_Rate__c > 0.40)
This validation rule formula displays the following error message when the Sample Rate custom field is not between 0 and 40%: “SampleRate cannot exceed 40%.”
PARENTGROUPVAL
Description: This function returns the value of a specified parent grouping. A “parent” grouping is any level above the one containing the formula. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels.
Use: Summary and Joined: PARENTGROUPVAL(summary_field, grouping_level) Matrix: PARENTGROUPVAL(summary_field, parent_row_grouping, parent_column_grouping) Where summary_field is the summarized field value, grouping_level is GRAND_SUMMARY or the API name of the parent level group for summary reports, and parent_row_level and parent_column_level are the parent levels for matrix reports. In reports with multiple grouping levels, you can set the grouping_level to be any group level higher than the formula display level.
Example: TOTAL_PRICE:SUM/PARENTGROUPVAL(TOTAL_PRICE:SUM, GRAND_SUMMARY)
This formula calculates, for each product, its relative size compared to the grand total. In this example, the report is a summary of opportunities and their products, grouped by Product Name.
398 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
PREDICT
Description: Returns an Einstein Discovery prediction for a record based on the specified record ID or for a list of fields and their values.
Use: PREDICT(PredDefId, [recordId] | [field, value, ...]). Replace PredDefId with the Prediction Definition ID of a deployed prediction in your org. Specify the recordId of the record to predict or a list of fields and their associated values ([field, value, ...]).
Examples: Example with recordId
PREDICT($SmartDataDiscovery.PredictionDefinitions.Recommende_kFjqS_1370.Id, Id)
This example calls the PREDICT function and passes a prediction definition and recordId. Example with List of Fields and Values
PREDICT($SmartDataDiscovery.PredictionDefinitions.Recommende_kFjqS_1370.Id,
‘Customer_Typec’, Text(Customer_Typec), ‘List_Price__c’, List_Price__c)
This example calls the PREDICT function and passes a prediction definition and list of fields with associated values.
Tips: • The specified PredDefId must link to a deployed and active prediction in your Salesforce org. To insert a value, select PredDefId, click Insert Field, select SmartDataDiscovery > Prediction Definitions, select an available prediction, select Prediction Definition Id, and then click Insert.
Note: The syntax for PredDefId must match the following pattern:
$SmartDataDiscovery.PredictionDefinitions..Id
• If you specify a recordId, the function returns a prediction for the data values in that record. • If you specify a list of field names and values, the function returns a prediction for the data values you provided. Be sure to provide all the fields that the prediction requires as input. • Getting predictions from Einstein Discovery predictions requires the View Einstein Discovery Recommendations system permission. To learn more, see Learn About Einstein Discovery Permissions and Permission Sets. • The PREDICT function is available when defining formulas for the following Process Automation components: approval processes, flows, processes (in Process Builder), workflow rules, and Next Best Action. • The PREDICT function is not supported in formula-based fields on Salesforce objects. • To learn more, see Get Predictions in Process Automation Formulas.
399 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
PREVGROUPVAL
Description: This function returns the value of a specified previous grouping. A “previous” grouping is one that comes before the current grouping in the report. Choose the grouping level and increment. The increment is the number of columns or rows before the current summary. The default is 1; the maximum is 12. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels.
Use: PREVGROUPVAL(summary_field, grouping_level [, increment])
Where summary_field is the name of the grouped row or column, grouping_level is the API name of the peer level group whose summary value for the previous grouping is used, and increment is the number of groupings previous. In reports with multiple grouping levels, you can specify the grouping_level to be the same group level as the formula display level or a group level higher than the formula display level.
Example: AMOUNT:SUM - PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE)
This formula calculates, for each month, the difference in amount from the previous month shown in the report. In this example, the report is an opportunity matrix with columns grouped by Close Date and rows by Stage.
PRIORVALUE
Description: Returns the previous value of a field.
Use: PRIORVALUE(field)
Validation Rule Example: The following validation rule prevents users from changing the expected revenue of an opportunity after it is closed: AND(PRIORVALUE(Amount) > Amount, IsClosed).
Tips: • This function is available only in: – Assignment rules – Validation rules – Field updates – Workflow rules if the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited . – Formula criteria for executing actions in Process Builder.
• This function does not return default values. • When users create a new record, this function returns the value of the field referenced rather than null. For example, if you create an account named “Acme,” PRIORVALUE(Account.Name) returns Acme.
400 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• When using the ISPICKVAL function to return the previous value of a picklist field, include the PRIORVALUE function inside the ISPICKVAL function as in this example:
ISPICKVAL(PRIORVALUE (picklist_field), text_literal)
• Use the PRIORVALUE function inside the INCLUDES function to check if the previous value of a multi-select picklist field included a specific value. For example:
INCLUDES( PRIORVALUE(multiselect_picklist_field), text_literal )
REGEX
Description: Compares a text field to a regular expression and returns TRUE if there is a match. Otherwise, it returns FALSE. A regular expression is a string used to describe a format of a string according to certain syntax rules.
Use: REGEX(text, regex_text) and replace text with the text field, and regex_text with the regular expression you want to match.
Validation Rule Example: This example ensures that a custom field called SSN matches a regular expression representing a valid social security number format of the form 999-99-9999.
NOT( OR( LEN (SSN__c) = 0, REGEX(SSN__c, "[0-9]{3}-[0-9]{2}-[0-9]{4}") ) )
Tips: • Regular expression syntax is based on Java Platform SE 6 syntax. However, backslash characters (\) must be changed to double backslashes (\\) because backslash is an escape character in Salesforce. • The Salesforce regular expression engine matches an entire string as opposed to searching for a match within a string. For example, if you are searching for the name Marc Benioff, use the regular expression, .*Marc Benioff.*, to find a match in a string like the following:
According to Marc Benioff, the social enterprise increases customer success.
If you use the regular expression, Marc Benioff, the only string that this regular expression will match is:
Marc Benioff
401 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Capture groups and substitutions are ignored. • This function is available everywhere formulas exist except formula fields and custom buttons and links.
REQUIRESCRIPT
Description: Returns a script tag with source for a URL you specify. Use this function when referencing the Lightning Platform AJAX Toolkit or other JavaScript toolkits.
Use: {!REQUIRESCRIPT(url)} and replace url with the link for the script that is required. For the AJAX Toolkit:
{!requireScript("/soap/ajax/13.0/connection.js")}
Returns:
Custom Button Example: {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} var c = new sforce.SObject("Case"); c.id = "{!Case.Id}"; c.Status = "New"; result = sforce.connection.update([c]); window.location.reload();
This example sets the Status of a case to “New” whenever a user clicks a custom button from the case detail page. To set this up in your organization, define a custom button for cases that has the following attributes: • Display Type is “Detail Page Button” • Behavior is “Execute JavaScript” • Content Source is “OnClick JavaScript” Next, paste the content above into your custom button definition and add it to your case page layouts.
Tips: • Use global variables to access special merge fields for s-controls. • Use this function when creating custom buttons or links where you have set Behavior to “Execute JavaScript” and Content Source to “OnClick JavaScript” because the script tag must be outside the OnClick code. • This function is only available for custom buttons and links that have Content Source set to “OnClick JavaScript.” • When working in Visualforce, use INCLUDESCRIPT instead.
RIGHT
Description: Returns the specified number of characters from the end of a text string.
402 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: RIGHT(text, num_chars) and replace text with the field or expression you want returned; replace num_chars with the number of characters from the right you want returned.
Example: TRIM(LEFT(LastName, 5))&"-"&TRIM(RIGHT(SSN__c, 4)) displays the first five characters of a name and the last four characters of a social security number separated by a dash. Note that this assumes you have a text custom field called SSN.
Tips: • Reference auto-number fields as text fields in formulas. • If the num_chars value is less than zero, Salesforce replaces the value with zero.
ROUND
Description: Returns the nearest number to a number you specify, constraining the new number by a specified number of digits.
Use: ROUND(number, num_digits) and replace number with the field or expression you want rounded; replace num_digits with the number of decimal places you want to consider when rounding.
Example: ROUND (1.5, 0) = 2 ROUND (1.2345, 0) = 1 ROUND (-1.5, 0) = -2 ROUND (225.49823, 2) = 225.50 Simple Discounting ROUND(Amount-Amount* Discount_Percent__c,2) Use this formula to calculate the discounted amount of an opportunity rounded off to two digits. This example is a number formula field on opportunities that uses a custom percent field called Discount Percent.
Tips: • Enter zero for num_digits to round a number to the nearest integer. • Salesforce automatically rounds numbers based on the decimal places you specify. For example, a custom number field with two decimal places stores 1.50 when you enter 1.49999. • Salesforce uses the round half-up rounding algorithm. Half-way values are always rounded up. For example, 1.45 is rounded to 1.5. –1.45 is rounded to –1.5. • The decimal numbers displayed depend on the decimal places you selected when defining the field in the custom field wizard. The num_digits represents the number of digits considered when rounding.
RPAD
Description: Inserts characters that you specify to the right-side of a text string.
403 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: RPAD(text, padded_length[, 'pad_string']) and replace the variables: • text is the field or expression after which you want to insert characters. • pad_length is the number of total characters in the text string that will be returned. • pad_string is the character or characters to insert. pad_string is optional and defaults to a blank space. If the value in text is longer than pad_string, text is truncated to the size of padded_length.
Example: Field Name: Padding Default RPAD(Name, 20) truncates the Name field after 20 characters. For example, if the name is mycompany.com, the value returned is “mycompany.com.” My_Company: No Change RPAD('my_company.com', 14, 'z') returns “my_company.com” without change because it has 14 characters. Field Name: Padding with a Character RPAD(Name, 15, 'z') returns “mycompany.comz” . Field Name: Truncating RPAD(Name, 2) truncates the name after the second character. For example, if the name is mycompany.com, the value returned is “my.”
Tips: Ending blank spaces are omitted.
SECOND
Description: Returns a seconds value in the form of a number from 0 through 60.
Use: SECOND(time) and replace time with a time value or value such as TIMENOW().
Examples: SECOND(ClosedDate) displays only the seconds in a time field based on the value of the Time Closed field. SECOND(TIMEVALUE("17:30:45.125")) returns 45.
SQRT
Description: Returns the positive square root of a given number.
Use: SQRT(number) and replace number with the field or expression you want computed into a square root.
Example: SQRT(25)returns the square root of 25, which is 5. Amplitude SQRT(Amplitude__c) returns the square root of a custom number field representing the amplitude of an earthquake.
404 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips: • Calculating the square root of a negative number results in an error on the detail page. • Avoid division by zero errors by including an IF function such as: IF(Amplitude__c >= 0, SQRT(Amplitude__c), null).
SUBSTITUTE
Description: Substitutes new text for old text in a text string.
Use: SUBSTITUTE(text, old_text, new_text) and replace text with the field or value for which you want to substitute values, old_text with the text you want replaced, and new_text with the text you want to replace the old_text.
Example: SUBSTITUTE(Name, "Coupon", "Discount")returns the name of an opportunity that contains the term “Coupon” with the opportunity name plus “Discount” wherever the term “Coupon” existed. SUBSTITUTE(Email, LEFT(Email, FIND("@", Email)), "www.") finds the location of the @ sign in a person's email address to determine the length of text to replace with a “www.” as a means of deriving their website address.
Tips: • Each term provided in quotes is case-sensitive. • If the old_text appears more than once, each occurrence is replaced with the new_text value provided, even when that results in duplicates.
TEXT
Description: Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. Also, converts picklist values to text in approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, validation rules, formula fields, field updates, and custom buttons and links.
Use: TEXT(value) and replace value with the field or expression you want to convert to text format. Avoid using any special characters besides a decimal point (period) or minus sign (dash) in this function.
Example: Expected Revenue in Text TEXT(ExpectedRevenue) returns the expected revenue amount of an opportunity in text format without a dollar sign. For example, if the Expected Revenue of a campaign is "$200,000," this formula field displays “200000.” Asset ID SerialNumber &"-"& TEXT(Quantity) returns an asset ID number starting with the serial number and ending with the quantity separated by a dash. The Serial Number field is already text but the Quantity field is a number, requiring the TEXT function before it.
405 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use Picklist Values in Math Equations
VALUE(LEFT(TEXT(Quantity), 5)) * Unit
This formula multiplies the first five numbers of the Quantity picklist by the Unit numeric field. Compare Two Picklists
IF(TEXT(bug_status) = TEXT(case_status), “Match”, “Out of Sync”)
This formula compares the values of the bug_status picklist with values of the case_status picklist. Display Picklist Values From Parent Records
TEXT(Account.Industry)
This formula field on opportunities shows the industry of the associated account. Concatenate Picklist Values
TEXT(Account.Industry) & " - " & TEXT(Account.SubIndustry__c)
This formula field on opportunities shows the industry and subindustry of the associated account.
Validation Rule Examples: Block the Save of a Closed Opportunity CONTAINS(TEXT(Status), "Closed") returns TRUE if the Status picklist contains the value “Closed,” such as “Closed Won” and “Closed Lost.” This validation rule formula blocks users from saving changes to a closed opportunity. Use Numeric Functions on Numeric Picklist Values VALUE(LEFT(TEXT(Quantity), 5)) * Unit > 10000 multiplies the first five numbers of the Quantity picklist by the Unit numeric field, and returns TRUE if the result is greater than 10,000. Directly Compare Two Picklists TEXT(bug_status) = TEXT(case_status) compares the values of the bug_status picklist with values of the case_status picklist, and returns TRUE if they are equal.
Tips: • The returned text is not formatted with any currency, percent symbols, or commas. • Values are not sensitive to locale. For example, 24.42 EUR is converted into the number 24.42. • Percents are returned in the form of a decimal. • Dates are returned in the form of YYYY-MM-DD, that is, a four-digit year and two-digit month and day. • Date/time values are returned in the form of YYYY-MM-DD HH:MM:SSZ where YYYY is a four-digit year, MM is a two-digit month, DD is a two-digit day, HH is the two-digit hour, MM are the minutes, SS are the seconds, and Z represents the zero meridian indicating the time is returned in UTC time zone. • Picklist fields are supported in TEXT functions used in these kinds of formulas: validation rules, approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, formula fields, field updates, and custom buttons and links. In other formulas, use ISPICKVAL or CASE when referencing a picklist field.
406 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• If the text value you enter is a URL, the text automatically converts as a hyperlink.
TIMENOW
Description: Returns a time value in GMT representing the current moment. Use this function instead of the NOW function if you only want to track time, without a date.
Use: TIMENOW()
Example: IF(ISPICKVAL( Rating , "Hot"), TIMENOW(), TIMEVALUE(CreatedDate)) This formula checks to see if a lead is rated “Hot” and if so, returns the current time. Otherwise it returns the time since someone created the lead.
Tips: • Do not remove the parentheses. • Keep the parentheses empty. They do not need to contain a value. • Use TODAY if you prefer to use a date field. • The displayed value is based on the organization’s Locale settings.
TIMEVALUE
Description: Returns the local time value without the date, such as business hours.
Use: TIMEVALUE(value) and replace value with a date/time or text value, merge field, or expression.
Examples: TIMEVALUE(ClosedDate) displays a time value based on the value of the Date/Time Closed field. TIMEVALUE("17:30:45.125") returns 5:30 PM.
Tips: • The displayed value is based on the organization’s Locale settings. • Don’t use TIMEVALUE on a time field. A time field’s value is already in time format. For example, for a time field with API name timefield__c, TIMEVALUE(timefield__c) doesn’t do anything.
TODAY
Description: Returns the current date as a date data type.
Use: TODAY()
Example: TODAY()-Sample_date_c calculates how many days in the sample are left.
Validation Rule Example: SampleDate < TODAY()
This example ensures that users cannot change the Sample Date to any date in the past.
407 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips: • Do not remove the parentheses. • Keep the parentheses empty. They do not need to contain a value. • Use a date field with a TODAY function instead of a date/time field. Last Activity Date is a date field whereas Created Date and Last Modified Date are date/time fields. • See NOW if you prefer to use a date/time field. • Dates and times are always calculated using the user’s time zone. • Use addition and subtraction operators with a TODAY function and other date fields to return a number, representing number of days. For example TODAY()-LastActivityDate calculates the number of days since the last activity date. In this example, the formula field data type is a number. • Use addition and subtraction operators with a TODAY function and numbers to return a date. For example TODAY() +5 calculates the date five days ahead of today. In this example, the formula field data type is a date.
TRIM
Description: Removes the spaces and tabs from the beginning and end of a text string.
Use: TRIM(text) and replace text with the field or expression you want to trim.
Example: TRIM(LEFT(LastName,5))& "-" & RIGHT(FirstName, 1) returns a network ID for users that contains the first five characters of their last name and first character of their first name separated by a dash.
UPPER
Description: Converts all letters in the specified text string to uppercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided.
Use: UPPER(text, [locale]) and replace text with the field or expression you wish to convert to uppercase, and locale with the optional two-character ISO language code or five-character locale code, if available.
Example: MYCOMPANY.COM UPPER("mycompany.com") returns “MYCOMPANY.COM.” MYCOMPANY.COM 123 UPPER("Mycompany.com 123") returns “MYCOMPANY.COM 123.” Applying Turkish Language Locale Rules The Turkish language has two versions of the letter i: one dotted and one dotless. The locale rules for Turkish require the ability to capitalize the dotted i, and allow the dotless I to be lowercase. To correctly use the UPPER() function with the Turkish language locale, use the Turkish locale code tr in the UPPER() function as follows: UPPER(text, "tr")
408 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This ensures that any dotted i in the text does not transform to a dotless I.
URLENCODE
Description: Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with %20, and exclamation points are replaced with %21.
Use: {!URLENCODE(text)} and replace text with the merge field or text string that you want to encode.
Example: If the merge field foo__c contains Mark's page, {!URLENCODE(foo_c)} results in: %3CB%3EMark%27s%20page%3C%2Fb%3E
Tips: • This function is only available in custom buttons and links, and in Visualforce. • Custom buttons and links with URL content sources have separate encoding settings. If you use the URLENCODE function to encode a custom button or link that has an encoding setting specified, Salesforce first encodes the URL according to the custom button or link setting, then encodes the result. For example, if the URL in a custom link contains a space and its encoding setting is UTF8, Salesforce first encodes the space to a plus sign (+), then the URLENCODE function converts the plus sign to its character code, %2B. • When you include the standard Account field on opportunities (Opportunity.Account) in the URLENCODE function, the value of the field is the account ID, not the account name. To encode the account name, create a custom cross-object formula field on opportunities that spans to the account name, and use that field in the URLENCODE function instead of Opportunity.Account. For example, if the cross-object formula is AccountNameFormula__c, use the following:
http://www.google.com/search?q={!URLENCODE (Opportunity.AccountNameFormula__c)}
URLFOR
Description: Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page.
Use: {!URLFOR(target, [id], [inputs], [no override])} and replace target with the URL or action, s-control, or static resource merge variable, id with an optional reference to the record, and inputs with any optional parameters. The no override argument is also optional and defaults to “false.” It applies to targets for standard Salesforce pages such as $Action.Account.New. Replace no override with “true” when you want to display a standard Salesforce page regardless of whether you have defined an override for it elsewhere. The input values can be dynamic. For example, to include an account ID, specify:
{!URLFOR($Page.myVisualforcePage, null, [accountId=Account.Id])}
409 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
The resulting URL includes a parameter with the ID, such as:
https://instance.salesforce.com/apex/myVisualforcePage?accountId=001B0000002txol
You can also use non-string variables, like an SObject variable. For example, if you supply [myAccountParam=Account], the value is converted to a string, and the URL contains ?MyAccountParam=001B0000002txol. You can also use a parameter to supply a static value, such as [param1=55].
Note: Because parameter names are static, you can’t use a variable to determine the parameter name. For example, if you use [myVariable=”value”] and set myVariable to “param1”, the resulting URL includes ?myVariable=value1 and not the param1 value.
Visualforce Example:
In this example, the component references a .jpg file contained within a .zip file that has been uploaded as a static resource. When uploaded, the name of the static resource was defined as TestZip, and the path to the image within the resource is images/Bluehills.jpg.
Tips: • Use global variables to access special merge fields for actions, s-controls, and static resources. • If an input parameter name begins with any character other than a letter or dollar sign ($), enclose it in quotation marks. • Enclose multiple inputs in brackets to indicate they are together:
{!URLFOR($Action.Case.View, Case.Id, [param1="A", param2="B"])}
• Set inputs to null if you do not have any to pass yet you want to set the no override argument:
{!URLFOR($Action.Case.View, Case.Id, null, true)}
• When you override a standard action, that action is no longer available in Salesforce. For example, if you override the new account action, that affects the New button on all pages, such as the account detail page, account related lists on other detail pages, and the Create New dropdown list in the sidebar. To override a standard action yet still access it, use the no override argument in your s-control to reference that action. • When you override the tab home page for a standard or custom tab, use the tab’s $Action global variable as the target value, and the tab’s object type for the id value. For example, URLFOR($Action.Account.Tab, $ObjectType.Account). • This function is only available in custom buttons, links, s-controls, and Visualforce pages.
VALUE
Description: Converts a text string to a number.
410 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: VALUE(text) and replace text with the field or expression you want converted into a number.
Example: Lead Number VALUE(Lead_Number__c) returns a number for the text value in the auto-number field Lead Number. This can be useful if you want to use the Lead Number field in a calculation. Note that auto-number fields are actually text fields and must be converted to a number for numeric calculations. Round Robin Lead Assignment MOD(VALUE(Lead_Number__c), 3) This formula is for a custom formula field named Round_Robin_ID that assigns each lead a value of 0, 1, or 2. This formula uses a custom auto-number field called Lead Number that assigns each lead a unique number starting with 1. The MOD function divides the lead number by the number of lead queues available (three in this example) and returns a remainder of 0, 1, or 2. Use the value of this formula field in your lead assignment rules to assign lead records to different queues. For example: • Round_Robin_ID = 0 is assigned to Queue A • Round_Robin_ID = 1 is assigned to Queue B • Round_Robin_ID = 2 is assigned to Queue C
Tips: Make sure the text in a VALUE function doesn’t include special characters other than a decimal point (period) or minus sign (dash). If the text in a VALUE function is a non-numerical/invalid format, the formula isn’t calculated and resolves to a blank value. For example, the formula 1 + VALUE(Text_field__c) produces these results: • If Text field is 123, the result is 124. • If Text field is blank, the result is blank. • If Text field is $123, the result is blank. • If Text field is EUR123, the result is blank.
VLOOKUP
Description: Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function.
Use: VLOOKUP(field_to_return, field_on_lookup_object, lookup_value) and replace field_to_return with the field that contains the value you want returned, field_on_lookup_object with the field on the related object that contains the value you want to match, and lookup_value with the value you want to match.
Validation Rule Example: This example checks that a billing postal code is valid by looking up the first five characters of the value in a custom object called Zip_Code__c that contains a record for every valid zip code in the US. If the zip code is not found in the Zip_Code__c object or the billing state does not match the corresponding State_Code__c in the Zip_Code__c object, an error is displayed.
AND( LEN(BillingPostalCode) > 0, OR(BillingCountry = "USA", BillingCountry = "US"),
411 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
VLOOKUP( $ObjectType.Zip_Code__c.Fields.State_Code__c, $ObjectType.Zip_Code__c.Fields.Name, LEFT(BillingPostalCode,5)) <> BillingState )
Note: • Use this example when the billing country is US or USA. • You can download US zip codes in CSV file format from http://zips.sourceforge.net.
Tips: • The field_to_return must be an auto number, roll-up summary, lookup relationship, master-detail relationship, checkbox, date, date/time, email, number, percent, phone, text, text area, or URL field type. • The field_on_lookup_object must be the Record Name field on a custom object. • The field_on_lookup_object and lookup_value must be the same data type. • If more than one record matches, the value from the first record is returned. • The value returned must be on a custom object. • You cannot delete the custom field or custom object referenced in this function. • This function is only available in validation rules.
WEEKDAY
Description: Returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday.
Use: WEEKDAY(date)
Example: WEEKDAY(customdate1__c) returns the day of the week for the given date in customdate1__c.
YEAR
Description: Returns the four-digit year in number format of a given date.
Use: YEAR(date) and replace date with the field or expression that contains the year you want returned.
Example: YEAR(TODAY())- YEAR(Initial_Meeting__c) returns the number of years since your initial meeting with a client. This example uses a custom date field called Initial Meeting.
SEE ALSO: Formula Operators and Functions A–H Formula Operators and Functions
412 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Using Date, Date/Time, and Time Values in Formulas
Date formulas are useful for managing payment deadlines, contract ages, or any other features of EDITIONS your organization that are time or date dependent. Two data types are used for working with dates: Date and Date/Time. One data type, Time, is Available in: both Salesforce independent of the date for tracking time such as business hours. Most values that are used when Classic and Lightning working with dates are of the Date data type, which store the year, month, and day. Some fields, Experience such as CreatedDate, are Date/Time fields, meaning they not only store a date value, but also Available in: All Editions a time value (stored in GMT but displayed in the users’ time zone). Date, Date/Time, and Time fields are formatted in the user’s locale when viewed in reports and record detail pages. A Time value’s precision is in milliseconds. A Date/Time value’s precision is in seconds. You can use operations like addition and subtraction on Date, Date/Time, and TIme values to calculate a future date or elapsed time between two dates or times. If you subtract one date from another, for example, the resulting value will be the difference between the two initial values in days (Number data type). The same operation between two Date/Time values returns a decimal value indicating the difference in number of days, hours, and minutes. The same operation between two Time values returns millisecond For example, if the difference between two Date/Time values is 5.52, that means the two values are separated by five days, 12 hours (0.5 of a day), and 28 minutes (0.02 of a day). You can also add numeric values to Dates and Date/Times. For example, the operation TODAY() + 3 returns three days after today’s date. For more information and examples of working with dates, see the list of Sample Date Formulas. Throughout the examples, the variables date and date/time are used in place of actual Date and Date/Time fields or values. Keep in mind that complex date functions tend to compile to a larger size than text or number formula functions, so you might run into issues with formula compile size. See Tips for Reducing Formula Size for help with this problem.
TODAY(), NOW() and TIMENOW() The TODAY() function returns the current day, month, and year as a Date data type. This function is useful for formulas where you are concerned with how many days have passed since a previous date, the date of a certain number of days in the future, or if you just want to display the current date. The NOW() function returns the Date/Time value of the current moment. It’s useful when you are concerned with specific times of day as well as the date. The TIMENOW() function returns a value in GMT representing the current time without the date. Use this function instead of the NOW() function if you want the current hour, minute, seconds, or milliseconds. This value is useful for tracking time like work shifts or elapsed time, For details on how to convert between Date values and Date/Time values, see Converting Between Date/Time and Date.
The DATE() Function The DATE() function returns a Date value, given a year, month, and day. Numerical Y/M/D values and the YEAR(), MONTH(), and DAY() functions are valid parameters for DATE(). For example DATE( 2013, 6, 1 ) returns June 1, 2013. Similarly, DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 3, 1) returns the Date value of the first day three months from today in the current year, assuming the date is valid (for example, the month falls between 1 and 12). If the inputted Y/M/D values result in an invalid date, the DATE() function returns an error, so error checking is an important part of working with Date values. You can read about methods for handling invalid dates in Sample Date Formulas.
413 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Converting Between Date/Time and Date Date and Date/Time aren’t interchangeable data types, so when you want to perform operations between Date and Date/Time values, you need to convert the values so they are both the same type. Some functions (such as YEAR(), MONTH(), and DAY()) also only work on Date values, so Date/Time values must be converted first. Use the DATEVALUE( date/time ) function to return the Date value of a Date/Time. For example, to get the year from a Date/Time, use YEAR( DATEVALUE( date/time ) ) ). You can convert a Date value to a Date/Time using the DATETIMEVALUE( date ) function. The time will be set to 12:00 a.m. in Greenwich Mean Time (GMT), and then converted to the time zone of the user viewing the record when it’s displayed. For a user located in San Francisco, DATETIMEVALUE( TODAY() ) returns 5:00 p.m. on the previous day (during Daylight Saving Time) rather than 12:00 a.m. of the current day. See A Note About Date/Time and Time Zones for more information.
Converting Between Date/Time and Time The TIMEVALUE() function returns a Time data type value in “HH:MM:SS.MS” (hours:minutes:seconds.milliseconds) format using a 24-hour clock. Numerical H/M/S/MS values and the HOUR(), MINUTE(), SECONDS(), and MILLISECONDS() functions are valid parameters for TIMEVALUE(). Use the TIMEVALUE(value) function to return the Time value of a Date/Time type, text, merge field or expression. For example, extract the time from a ClosedDate Date/Time value with TIMEVALUE(ClosedDate).
Converting Between Date and Text If you want to include a date as part of a string, wrap the Date value in the TEXT() function to convert it to text. For example, if you want to return today’s date as text, use:
"Today's date is " & TEXT( TODAY() )
This returns the date in the format “YYYY-MM-DD” rather than in the locale-dependent format. You can change the format by extracting the day, month, and year from the date first and then recombining them in the format you want. For example:
"Today's date is " & TEXT( MONTH( date ) ) & "/" & TEXT( DAY( date ) ) & "/" & TEXT( YEAR( date ) ) )
You can also convert text to a Date so you can use the string value with your other Date fields and formulas. You’ll want your text to be formatted as “YYYY-MM-DD”. Use this formula to return the Date value:
DATEVALUE( "YYYY-MM-DD" )
Converting Between Date/Time and Text You can include Date/Time values in a string using the TEXT() function, but you need to be careful of time zones. For example, consider this formula:
"The current date and time is " & TEXT( NOW() )
In this formula, NOW() is offset to GMT. Normally, NOW() would be converted to the user’s time zone when viewed, but because it’s been converted to text, the conversion won’t happen. So if you execute this formula on August 1st at 5:00 PM in San Francisco time (GMT-7), the result is “The current date and time is 2013–08–02 00:00:00Z”.
414 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
When you convert a Date/Time to text, a “Z” is included at the end to indicate GMT. TEXT( date/time ) returns “Z” if the field is blank. So if the Date/Time value you’re working with might be blank, check for this before converting to text:
IF( ISBLANK( date/time ), "", TEXT( date/time ) )
To convert a string to a Date/Time value, use DATETIMEVALUE() passing in a string in the format “YYYY-MM-DD HH:MM:SS”. This method returns the Date/Time value in GMT.
Converting Between Time and Text If you want to include time as part of a string, wrap the Time value in the TEXT() function to convert it to text. For example, if you want to return the current time as text, use:
"The time is " & TEXT( TIMENOW() )
This function returns the time in the format “HH:MM:SS.MS”. You can also convert text to a Time data type so you can use the string value with your other Time fields and formulas. Format your text as “HH:MM:SS.MS” on a 24-hour clock. Use the TIMEVALUE() function:
TIMEVALUE("17:30:45.125")
A Note About Date/Time and Time Zones Date and Date/Time values are stored in GMT. When a record is saved, field values are adjusted from the user’s time zone to GMT, and then adjusted back to the viewer’s time zone when displayed in record detail pages and reports. With Date conversions this doesn't pose a problem, since converting a Date/Time to a Date results in the same Date value. When working with Date/Time fields and values, however, the conversion is always done in GMT, not the user’s time zone. Subtracting a standard Date/Time field from another isn’t a problem because both fields are in the same time zone. When one of the values in the calculation is a conversion from a Text or Date value to a Date/Time value, however, the results are different. Let’s say a San Francisco user enters a value of 12:00 AM on August 2, 2013 in a custom Date/Time field called Date_Time_c. This value is stored as 2013–08–02 07:00:00Z, because the time difference in Pacific Daylight Time is GMT-7. At 12:00 p.m. PDT on August 1st, the user views the record and the following formula is run:
Date_Time_c - NOW()
In the calculation, NOW() is 2013–08–01 19:00:00Z, and then subtracted from 2013–08–02 07:00:00Z, to return the expected result of 0.5 (12 hours). Suppose that instead of NOW(), the formula converts the string “2013–08–01 12:00:00” to a Date/Time value:
Date_Time_c - DATETIMEVALUE( "2013-08-01 12:00:00" )
In this case, DATETIMEVALUE( “2013–08–01 12:00:00” ) is 2013–08–01 12:00:00Z, and returns a result of 0.79167, or 19 hours. There’s no way to determine a user’s time zone in a formula. If all of your users are in the same time zone, you can adjust the time zone difference by adding or subtracting the time difference between the users’ time zone and GMT to your converted values. However, since
415 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
time zones can be affected by Daylight Saving Time, and the start and end dates for DST are different each year, this is difficult to manage in a formula. We recommend using Apex for transactions that require converting between Date/Time values and Text or Date values.
SEE ALSO: Tips for Building Formulas Time Custom Field
Build a Formula Field
Your custom formula fields require special attributes. EDITIONS Note: The Getting Started with Formulas (Salesforce Classic) help video includes a live demo of these steps. Available in: both Salesforce Classic (not available in all 1. Begin building a formula field the same way you create a custom field. See Create Custom Fields orgs) and Lightning on page 218. Experience 2. Select the data type for the formula. Choose the appropriate data type for your formula based Available in: All Editions on the output of your calculation. See Formula Data Types on page 353. 3. Choose the number of decimal places for currency, number, or percent data types. This setting USER PERMISSIONS is ignored for currency fields in multicurrency organizations. Instead, the Decimal Places for your currency setting apply. Salesforce uses the round half up tie-breaking rule for numbers To view formula field details: in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35. • View Setup and 4. Click Next. Configuration 5. Build your formula. Formula fields can contain up to 3,900 characters, including spaces, return To create, change, or delete formula fields: characters, and comments. If your formula requires more characters, create separate formula • Customize Application fields and reference them in another formula field. The maximum number of displayed characters after an evaluation of a formula expression is 1,300 a. If you are building a formula in the Advanced Formula tab or for approvals or rules, such as workflow, validation, assignment, auto-response, or escalation, click Insert Field, choose a field, and click Insert. To create a basic formula that passes specific Salesforce data, select the Simple Formula tab, choose the field type in the Select Field Type drop-down list, and choose one of the fields listed in the Insert Field drop-down list. Build cross-object formulas to span to related objects and reference merge fields on those objects. b. To insert an operator, choose the appropriate operator icon from the Insert Operator drop-down list. c. Optionally, click the Advanced Formula tab to use functions and view other operators and merge fields. Functions are prebuilt formulas that you can customize with your input parameters. d. To insert a function, double-click its name in the list, or select it and click Insert Selected Function. To filter the list of functions, choose a category from the Functions drop-down list. Select a function and click Help on this function to view a description and examples of formulas using that function. e. Consider adding comments to your formula, especially if it is complicated. Comments must begin with a forward slash followed by an asterisk (/*), and conclude with an asterisk followed by a forward slash (*/). Comments are useful for explaining specific parts of a formula to anyone viewing the formula definition. For example:
AND( /*competitor field is required, check to see if field is empty */ LEN(Competitor__c) = 0, /* rule only enforced for ABCD record types */ RecordType.Name = "ABCD Value",
416 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
/* checking for any closed status, allows for additional closed picklist values in the future */ CONTAINS(TEXT(StageName), "Closed") )
6. To check your formula for errors, click Check Syntax. 7. Optionally, enter a description of the formula in the Description box. 8. If your formula references any number, currency, or percent fields, choose an option for handling blank fields. To give any blank fields a zero value, choose Treat blank fields as zeros. To leave these fields blank, choose Treat blank fields as blanks. 9. Click Next. 10. Set the field-level security to determine whether the field should be visible for specific profiles, and click Next. 11. Choose the page layouts that should display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is automatically added to the bottom of the user detail page. 12. Click Save to finish or Save & New to create more custom fields.
Note: Because formula fields are automatically calculated, they are read-only on record detail pages and do not update last modified date fields. Formula fields are not visible on edit pages. In account formulas, all business account fields are available as merge fields. However, account fields exclusive to person accounts such as Birthdate and Email are not available.
Tips for Building Formulas What Is a Cross-Object Formula?
SEE ALSO: Elements of a Formula Merge Fields for Formulas Tips for Building Formulas Formula Operators and Functions
Tips for Building Formulas
Watch a Demo: Formulas: Tips and Gotchas (Salesforce Classic) EDITIONS • Formula fields that a user can see may reference fields that are hidden or read only using field-level security. If the formula field contains sensitive information, use field-level security to Available in: both Salesforce hide it. Classic and Lightning Experience • You can add activity formula fields to task and event page layouts. Note that a task-related formula field on an event page layout may not be useful. Likewise, event-related formula fields Available in: All Editions on task page layouts may not be useful. • To determine if a record is a task or event, use the IsTask merge field. For example:
IF(IsTask, "This is a task", "This is an event")
417 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips for Working with Date and Date/Time Formula Fields Tips for Working with Hyperlink Formula Fields Use these tips to understand how links open from formula custom fields that contain a HYPERLINK function. Tips for Using Merge Fields in Formulas Tips for Working with Number Formula Fields Tips for Working with Picklist and Multi-Select Picklist Formula Fields Tips for Referencing Record Types in Formulas Reference record types in formulas if you want different workflow rules, validation rules, and lookup filters to apply to different record types. Tips for Working with Text Formula Fields
SEE ALSO: Build a Formula Field Common Formula Errors
Tips for Working with Date and Date/Time Formula Fields
• Dates and times are always calculated using the user’s time zone. EDITIONS • Date and date/time fields can’t be used interchangeably. The name alone may not indicate if a field is a date or date/time. For example, Created Date and Last Modified Date Available in: both Salesforce are date/time fields whereas Last Activity Date is a date field. Use the DATEVALUE Classic and Lightning function to convert a date/time field into a date field. Experience
Note: The Created Date and Last Modified Date fields display only the Available in: All Editions date, not the date and time.
• Use addition and subtraction operators with date or date/time fields to calculate duration. For example, subtract a date from another date to calculate the number of days between the two. Likewise, you can subtract the date/time from another date/time to get the number of days between the two as a number. See NOW or TODAY for suggested use. • Use addition and subtraction operators with numbers to return another date or date/time. For example, {!CreatedDate} + 5 calculates the date and time five days after a record’s created date. Note that the expression returns the same data type as the one given; a date field plus or minus a number returns a date, and a date/time field plus or minus a number returns a date/time. • When calculating dates using fractions, Salesforce ignores any numbers beyond the decimal. For example: TODAY() + 0.7 is the same as TODAY() + 0, which is today’s date. TODAY() + 1.7 is the same asTODAY() + 1, which is tomorrow’s date. TODAY() + (-1.8) is the same as TODAY() + (-1), which is yesterday’s date.
• To calculate the value of two fractions first, group them within parentheses. For example: TODAY() + 0.5 + 0.5 is the same as TODAY() + 0 + 0, which is today’s date. TODAY() + (0.5+0.5) is the same as TODAY() + 1, which is tomorrow’s date.
• Years can’t be zero and must be between -4713 and 9999.
SEE ALSO: Tips for Building Formulas
418 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips for Working with Hyperlink Formula Fields
Use these tips to understand how links open from formula custom fields that contain a HYPERLINK EDITIONS function. If you have formula custom fields that contain a HYPERLINK function, the server generates an Available in: both Salesforce HTML anchor for the link. For example, this function: HYPERLINK("/apex/VF_TEST", Classic and Lightning "VFLINK",'_self') generates this HTML output: VFLINK HYPERLINK . If the function doesn't contain a target Available in: All Editions attribute, it defaults to a value of target="_blank" in the generated HTML. A value of "_blank" opens the link in a new window or tab, outside of Lightning Experience or the Lightning Console.
Note: The HYPERLINK function doesn’t support the biztel protocol on record home pages for custom objects in Lightning Experience. The Lightning Experience Honors Target Values for Hyperlinks in Formula Fields critical update ensures that the target value for hyperlinks is honored, whether it's explicitly configured or set by default. If you have enabled the critical update, you can keep the target page within Lightning navigation by adding a value of target="_self" to your formula field HYPERLINK functions. If you specify something other than target="_self", the link opens with standard browser navigation outside of Lightning Experience. If you haven’t enabled the critical update, relative links open in a new tab regardless of the target value.
Note: This critical update is automatically enabled in Summer ’20. Both before and after enabling the critical update, external links always open in a new tab, regardless of the target value.
Link Type Target Expected Behavior Example Relative Visualforce page or _self The Visualforce page or image HYPERLINK("/apex/VFPAGE", image opens in Lightning Experience "Visualforce Page", or Console inside the same tab. "_self")
Relative Visualforce page or _blank The Visualforce page or image HYPERLINK("/img/logo214", image opens outside of Lightning "Logo", "_blank") Experience or Console in a new tab.
Note: A critical update that is available in Winter ’19 and automatically enabled in Summer ’19 on May 17, 2019 controls this behavior. If you don’t enable the critical update, these links open inside Lightning Experience or Console in a new tab.
External website _self The website opens in a new tab. HYPERLINK("http://salesforce.com", "Salesforce", "_self")
419 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Link Type Target Expected Behavior Example
External website _blank The website opens in a new tab. HYPERLINK("http://salesforce.com", "Salesforce", "_blank")
Tips for Using Merge Fields in Formulas
• Delegated administrators need to have access to custom objects to access the objects’ merge EDITIONS fields from formulas. • In account formulas, all business account fields are available as merge fields. However, account Available in: both Salesforce fields exclusive to person accounts such as Birthdate and Email are not available. Classic and Lightning • You can’t use formula fields that include related object merge fields in roll-up summary fields. Experience • Formulas and roll-up summary fields can’t reference fields on external objects. Available in: All Editions • Using RecordType.Id can make your formula less readable; when you do use it, write in-line comments into the formula to clarify. • To determine if a record is a task or event, use the IsTask merge field. For example:
IF(IsTask, "This is a task", "This is an event")
• To reference the unique identifier for your Salesforce organization in a formula, insert the $Organization.Id merge field. This merge field can display anywhere formula fields can except in reports. • Some merge fields display as radio buttons but function like picklist fields when referenced in a formula. Use the values “Read,” “Edit,” and “None” in a formula when referencing: – $UserRole.CaseAccessForAccountOwner – $UserRole.OpportunityAccessForAccountOwner – CaseAccessLevel (on Territory) – OpportunityAccessLevel (on Territory) Use the values “Read,” “Edit,” and “All” in a formula when referencing: – AccountAccessLevel (on Territory)
• If you create a contacts formula field that references account merge fields, that field can be included in contact page layouts but should not be included in person accounts page layouts. The formula field will display a value of #Error on the person accounts page.
SEE ALSO: Tips for Building Formulas
420 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips for Working with Number Formula Fields
• Use the decimal version of a percent when working with percent fields in formulas. For example, EDITIONS IF(Probability =1...) for 100% probability or IF(Probability =0.9...) for 90% probability. Available in: both Salesforce • Reference auto-number fields as text fields in formulas. Classic and Lightning • The output of your formula must be less than 19 digits. Experience • Formulas can contain a mix of numbers, percents, and currencies as in this example: Available in: All Editions AnnualRevenue / NumberOfEmployees. • Salesforce uses the round half up tie-breaking rule for numbers in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35.
SEE ALSO: Tips for Building Formulas
Tips for Working with Picklist and Multi-Select Picklist Formula Fields
• You can use special picklist fields in your formulas, such as IsEscalated for cases and EDITIONS IsWon for opportunities. • Picklist fields can only be used in these functions: Available in: both Lightning – ISPICKVAL—Compares the value of a picklist to a single value. Experience and Salesforce Classic – CASE—Compares the value of a picklist to multiple values. – TEXT—Returns a picklist value’s API Name so that you can work with a reference to the Available in: All Editions value (even if the displayed value changes) in functions that support text values, such as CONTAINS. (Available in only flow formula resources, formula fields, validation rules, and workflow field updates.)
• Multi-select picklist fields can only be used in these functions: – CONTAINS (in Process Builder in which the criteria for executing actions is set to Conditions are met) – INCLUDES – ISBLANK – ISNULL – ISCHANGED (Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited) – PRIORVALUE (Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited)
SEE ALSO: Tips for Building Formulas
421 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips for Referencing Record Types in Formulas
Reference record types in formulas if you want different workflow rules, validation rules, and lookup EDITIONS filters to apply to different record types. For example, you can: Available in: both Salesforce Classic and Lightning • Create a workflow rule on accounts that emails different teams based on the account record Experience type the user selects when creating the account. • Create a validation rule on opportunities that allows only members of the North American sales Available in: All Editions team to save opportunities with the Domestic record type. Record types available in: When possible, use RecordTypeId instead of RecordType.Name to reference a specific Professional, Enterprise, record type. While RecordType.Name makes a formula more readable, you must update the Performance, Unlimited, formula if the name of the record type changes, whereas the ID of a record type never changes. and Developer Editions Also, RecordType.Name requires a cross-object reference to the record type, while RecordTypeId doesn’t. However, if you are deploying formulas across organizations (for example, between sandbox and production), use RecordType.Name because IDs are not the same across organizations. Avoid using $RecordType in formulas, except in default value formulas. Instead, use the RecordType merge field (for example, Account.RecordType.Name) or the RecordTypeId field on the object.
SEE ALSO: Tips for Building Formulas
Tips for Working with Text Formula Fields
• Before using the HYPERLINK function, consider the differences between hyperlinks and custom EDITIONS links. – Hyperlink formula fields are just like other custom fields that you can show in list views and Available in: both Salesforce reports. Classic and Lightning – Custom links appear on detail pages in a predefined section; hyperlink formula fields can Experience appear on a detail page wherever you specify. Available in: All Editions – Using custom links, you can specify display properties such as window position and opening in a separate popup position; hyperlink formula fields open in a new browser window by default or you can specify a different target window or frame. – Your formulas can reference custom links. Before deleting a custom link, make sure that it’s not referenced in a formula field. – Hyperlink formula fields that contain relative URLs to Salesforce pages, such as /rpt/reportwizard.jsp, can be added to list views, reports, and related lists. However, use a complete URL, including the server name and https://, in your hyperlink formula before adding it to a search layout.
• To insert text in your formula field, surround the text with quotation marks. For example, to display “CASE: 123,” use this formula "CASE: "& CaseNumber__c. • Use the backslash (\) character before a quote or backslash to insert it as a literal value in your output. For example, "Trouble\\Case \"Ticket\": " in your formula displays Trouble\Case "Ticket": on detail pages. • In Salesforce Classic, Knowledge articles show URLs from Formula (Text) fields as plain text. In Lightning Experience, Knowledge articles show such URLs as clickable links.
SEE ALSO: Tips for Building Formulas
422 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
What Is a Cross-Object Formula?
A Cross-object formula is a formula that spans two related objects and references merge fields on EDITIONS those objects. A cross-object formula can reference merge fields from a master (“parent”) object if an object is on the detail side of a master-detail relationship. A cross-object formula also works with Available in: both Salesforce lookup relationships. Classic and Lightning You can reference fields from objects that are up to 10 relationships away. A cross-object formula Experience is available anywhere formulas are used except when creating default values. Available in: all editions Note: If you create a formula that references a field on another object and display that formula in your page layout, users can see the field on the object even if they don’t have access to that object record. For example, if you create a formula field on the Case object that references an account field, and display that formula field in the case page layout, users can see this field even if they don’t have access to the account record. You can't include an object as the lookup field in a formula. To reference an object, reference the object's ID field or another field on the object. For example, Account.Owner is invalid because it references the object directly. Account.Owner.FirstName or Account.OwnerId are valid references for your formula.
Building Cross-Object Formulas in the Simple Formula Tab Build Cross-Object Formulas in the Advanced Formula Tab Tips for Building Cross-Object Formulas
SEE ALSO: Build a Formula Field
Building Cross-Object Formulas in the Simple Formula Tab
To create a cross-object formula when building a formula in the Simple Formula tab, enter the EDITIONS relationship names of the objects to which you are spanning followed by the field you want to reference. Separate the relationship names of each object and the field with periods. Available in: both Salesforce Example: For example, enter Contact.Account.Name to reference the Account Classic and Lightning Name for a contact associated with a case in a formula field on the Case object. Be sure to Experience use the relationship names of the objects, not the labels. Although the relationship name is Available in: All Editions often the same as the object name, it is technically the field name of the relationship field. To reference the parent account name from Account object, the syntax is Parent.Name, USER PERMISSIONS not Account.Name. When referencing a custom object, add two underscores and the letter r to its name. For example, Position__r.title__c references the Job Title To create or change field (title__c) on a Position custom object. cross-object formulas: • Customize Application Note: If you create a formula that references a field on another object and display that formula in your page layout, users can see the field on the object even if they don’t have access to that object record. For example, if you create a formula field on the Case
423 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
object that references an account field, and display that formula field in the case page layout, users can see this field even if they don’t have access to the account record.
SEE ALSO: Build Cross-Object Formulas in the Advanced Formula Tab What Is a Cross-Object Formula?
Build Cross-Object Formulas in the Advanced Formula Tab
To create a cross-object formula when building a formula in the Advanced Formula tab or for EDITIONS approvals or rules, such as workflow, validation, assignment, auto-response, or escalation rules, click Insert Field, then click the related object to list its fields. Related objects are denoted by a “>” sign. Available in: both Salesforce Note: If you create a formula that references a field on another object and display that Classic and Lightning formula in your page layout, users can see the field on the object even if they don’t have Experience access to that object record. For example, if you create a formula field on the Case object that Available in: All Editions references an account field, and display that formula field in the case page layout, users can see this field even if they don’t have access to the account record. USER PERMISSIONS Example: The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile To create or change cross-object formulas: name, as expected. In list views and reports, the value is the internal value of the associated • Customize Application profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example:
IF (OR (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name = "PT2"), "Standard", "Not Standard")
None of the above applies to profile names referenced by the $Profile global variable.
SEE ALSO: Building Cross-Object Formulas in the Simple Formula Tab What Is a Cross-Object Formula?
Tips for Building Cross-Object Formulas
• Cross-object formulas that reference currency fields convert the value to the currency of the EDITIONS record that contains the formula. If the referenced currency field is from a custom setting, the field value isn’t converted to the record’s currency. Available in: both Salesforce • Salesforce allows a maximum of 10 unique relationships per object in cross-object formulas. Classic and Lightning The limit is cumulative across all formula fields, rules, and lookup filters. For example, if two Experience different formulas on opportunities reference two different fields of an associated account, only Available in: All Editions one unique relationship exists (from opportunities to accounts). • You can’t reference cross-object formulas in roll-up summary fields.
424 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• In cross-object formulas, you can’t reference merge fields for objects related to activities. For example, merge fields for contacts and accounts aren’t available in task and event formulas. • In cross-object formulas, you can’t reference fields from contacts through person accounts. For more information, see Using custom formula fields with person accounts.
Using the Owner Field Some objects support different object types for the Owner field, such as a User, Queue, or Calendar. On objects that support this behavior, when creating a cross-object formula using Owner, you must be explicit about the owner type you’re referencing. For example, if you need owner email and you don’t use queues, your formula would be Owner:User.Email. If you do use queues, your formula could be
IF( ISBLANK( Owner:User.Id ), Owner:Queue.QueueEmail, Owner:User.Email )
Here’s how you would select Owner object fields on a Lead in the Advanced formula tab:
Note: • Owner references aren’t supported in Visualforce pages. For example, on a page with Case as a controller, you can’t include {!Case.Owner:User.FirstName}. However, you can include an existing spanning formula on a Visualforce page. For example, if you have a custom text formula MyFormula__c on a Case with value Owner:User.FirstName, you can include {!Case.MyFormula__c} on your Visualforce page. • Owner references aren’t supported on the Queue object. For example, you can't reference Owner:Queue.Owner.Email. • If your formula has Owner:User.fieldname and Owner:Queue.fieldname, both of these count against the limit of 10 unique relationships per object in cross-object formulas. • On objects that don’t support Queues, User is implicit when referencing Owner. Your formula should be Owner.fieldname, not Owner:User.fieldname.
Using Profile.Name The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile name, as expected. In list views and reports, the value is the internal value of the associated profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example:
IF (OR (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name =
425 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
"PT2"), "Standard", "Not Standard")
None of the above applies to profile names referenced by the $Profile global variable.
SEE ALSO: Build Cross-Object Formulas in the Advanced Formula Tab What Is a Cross-Object Formula?
Formula Field Limits and Restrictions
Before you create formula fields, be aware of their limits and limitations. EDITIONS • Formula fields have these limits. – Character limit—Formula fields can contain up to 3,900 characters, including spaces, return Available in: both Salesforce Classic and Lightning characters, and comments. If your formula needs more characters, create separate formula Experience fields and reference them in another formula field. Available in: All Editions Note: The maximum number of displayed characters after an evaluation of a formula expression is 1,300.
– Save size limit—Formula fields can’t exceed 4,000 bytes when saved. The save size is different from the number of characters if you use multi-byte characters in your formula. – Compile size limit—Formula fields can’t exceed 5,000 bytes when compiled. The compile size is the size of the formula (in bytes) including all of the fields, values, and formulas it references. There is no direct correlation between the compile size and the character limit. Some functions, such as TEXT, DATEVALUE, DATETIMEVALUE, and DATE significantly increase the compile size.
Tip: For tips on how to rework your formulas to avoid these limits, see Tips for Reducing Formula Size
• Default value formulas for a record type can only reference fields for that record type. However, formula fields and formulas for approvals or rules for a record type can reference fields for that record type as well as any records that are related through a lookup or master-detail relationship. For example, a formula for a validation rule on opportunities can reference merge fields for accounts and campaigns as well as opportunities, and a formula field on accounts can reference fields for cases. • You can’t use long text area, encrypted, or Description fields in formulas. • The value of a field can’t depend on another formula that references it. • You can’t delete fields referenced in formulas. Remove the field from the formula before deleting it. • Campaign statistic fields can’t be referenced in formulas for field updates, approval processes, workflow rules, or validation rules, but can be referenced in custom formula fields. • The UI escapes HTML tags used in formula fields. To create an HTML element, replace your HTML with a function, like HYPERLINK or IMAGE. • Custom formula fields from contacts can’t be referenced through person accounts. For more information, see Using custom formula fields with person accounts.
SEE ALSO: Tips for Building Formulas Build a Formula Field
426 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Formula Best Practices
You can use the Formula Editor in Salesforce to construct a simple formula with a few clicks. But EDITIONS what if you want to build something more complex? Use these tips to help you map out formula logic and make it easier to troubleshoot errors. Available in: both Salesforce Thank you: Special thanks to Trailblazer Chris Emmett for contributing this content. Classic and Lightning Experience
Available in: All Editions Tip 1: Put Every Function on a Separate Line It’s easy to fall into the habit of keeping an entire formula on a single line, especially when the formula is small. Putting each function on its own line makes the formula easier to read and troubleshoot. These examples show the same formula, first with no line breaks, and then with each function on a separate line.
IF(AND(ISBLANK(myDate_c),active_c=true),"Missing Date","Not Applicable")
IF( AND( ISBLANK(myDate_c), active_c=true ), "Missing Date", "Not Applicable" )
Tip 2: Indent Sections Within Parentheses When your formula involves multiple functions, indentation helps visually isolate each function and makes it easier to identify errors, such as misplaced characters. In this example, with indentation, you see that the bulk of the formula sits within a single IF statement and that the AND statement contains two functions. Inside the AND statement, the function ISBLANK is enclosed in parentheses.
IF( AND( ISBLANK(myDate_c), active_c=true ), "Missing Date", "Not Applicable" )
Indentation can also help you zero in on mistakes. With a flat layout, it’s difficult to see that an extra “)” is included after the ISBLANK statement, and there are no visual clues about how the formula is structured.
IF( AND( ISBLANK(myDate_c) ), active_c=true ), "Missing Date", "Not Applicable" )
427 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
The indented layout makes it easy see the formula’s structure. You can quickly find and remove the extra character so that the AND statement is correctly formatted.
IF( AND( ISBLANK(myDate_c) ), active_c=true ), "Missing Date", "Not Applicable" )
Tip 3: Write Statement and Function Names in Uppercase All the examples here use uppercase letters for statement and function names, such as IF, AND, and ISBLANK. Using uppercase for these terms creates a clear distinction between functions and parameters and brings some visual clarity to a complex formula.
Tip 4: Handle Null and Required Input Field Values These examples reference a field called myDate__c and use the ISBLANK check to confirm that the field is populated. It’s important to verify the contents of any field in a formula. Without this verification, a formula can fail. For example, if you add a second date to the formula and perform a greater than operation, include the ISBLANK check for the second date to ensure that the formula executes correctly.
IF( AND( ISBLANK(myDate__c), ISBLANK(mySecondDate__c), active__c=true, mySecondDate__c > myDate__c ), "Missing Date", "Not Applicable" )
428 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Examples of Advanced Formula Fields
Review examples of formula fields for various types of apps that you can use and modify for your EDITIONS own purposes. This document contains custom formula samples for the following topics. For details about using Available in: both Salesforce the functions included in these samples, see Formula Operators and Functions on page 355. Classic and Lightning Experience
Sample Account Management Formulas Available in: All Editions Sample Account Media Service Formulas Sample Case Management Formulas USER PERMISSIONS
Sample Commission Calculations Formulas To view formula field details: Sample Contact Management Formulas • View Setup and Configuration Sample Data Categorization Formulas To create, change, or delete Sample Date Formulas formula fields: Sample Discounting Formulas • Customize Application Sample Employee Services Formulas Sample Expense Tracking Formulas Sample Financial Calculations Formulas Sample Image Link Formulas Sample Integration Link Formulas Sample Lead Management Formulas Sample Metric Formulas Sample Opportunity Management Formulas Sample Pricing Formulas Sample Scoring Calculations Formulas
SEE ALSO: Formulas: How Do I ... ? Tips for Building Formulas
Sample Account Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: All Editions
429 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Account Rating This formula evaluates Annual Revenue, Billing Country, and Type, and assigns a value of “Hot,” “Warm,” or “Cold.”
IF (AND (AnnualRevenue > 10000000, CONTAINS (CASE (BillingCountry, "United States", "US", "America", "US", "USA", "US", "NA"), "US")), IF(ISPICKVAL(Type, "Manufacturing Partner"), "Hot", IF(OR (ISPICKVAL (Type, "Channel Partner/Reseller"), ISPICKVAL(Type, "Installation Partner")), "Warm", "Cold")), "Cold")
In addition, you can reference this Account Rating formula field from the contact object using cross-object formulas.
Account.Account_Rating__c
Account Region This formula returns a text value of “North,” “South,” “East,” “West,” or “Central” based on the Billing State/Province of the account.
IF(ISBLANK(BillingState), "None", IF(CONTAINS("AK:AZ:CA:HA:NV:NM:OR:UT:WA", BillingState), "West", IF(CONTAINS("CO:ID:MT:KS:OK:TX:WY", BillingState), "Central", IF(CONTAINS("CT:ME:MA:NH:NY:PA:RI:VT", BillingState), "East", IF(CONTAINS("AL:AR:DC:DE:FL:GA:KY:LA:MD:MS:NC:NJ:SC:TN:VA:WV", BillingState), "South", IF(CONTAINS("IL:IN:IA:MI:MN:MO:NE:ND:OH:SD:WI", BillingState), "North", "Other"))))))
Contract Aging This formula calculates the number of days since a contract with an account was activated. If the contract Status is not “Activated,” this field is blank.
IF(ISPICKVAL(Contract_Status__c, "Activated"), NOW() - Contract_Activated_Date__c, null)
Sample Account Media Service Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce BBC™ News Search Classic and Lightning Experience This formula creates a link to a BBC news search site based on the Account Name. Available in: All Editions
HYPERLINK( "http://www.bbc.co.uk/search/news/?q="&Name, "BBC News")
430 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Bloomberg™ News Search This formula creates a link to an account's ticker symbol on the Bloomberg website.
HYPERLINK( "http://www.bloomberg.com/markets/symbolsearch?query="&TickerSymbol, "Bloomberg News")
CNN™ News Search This formula creates a link to a CNN news search site using the Account Name.
HYPERLINK( "http://http://www.cnn.com/search/?query="&Name, "CNN News")
MarketWatch™ Search This formula creates a link to an account's ticker symbol on the Marketwatch.com website.
HYPERLINK( "http://www.marketwatch.com/investing/stock/"&TickerSymbol, "Marketwatch")
Google™ Search This formula creates a link to a Google search site using the Account Name.
HYPERLINK( "http://www.google.com/#q="&Name, "Google")
Google News Search This formula creates a link to a Google news search site using the Account Name.
HYPERLINK( "http://news.google.com/news/search?en&q="&Name, "Google News")
Yahoo!™ Search This formula creates a link to a Yahoo! search site using the Account Name.
HYPERLINK( "http://search.yahoo.com/search?p="&Name, "Yahoo Search")
431 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Yahoo! News Search This formula creates a link to a Yahoo! news search site using the Account Name.
HYPERLINK( "http://news.search.yahoo.com/search/news?p="&Name, "Yahoo News")
Sample Case Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: Salesforce Autodial Classic This formula creates a linkable phone number field that automatically dials the phone number Available in: All Editions when clicked. In this example, replace "servername" and "call" with the name of your dialing tool and the command it uses to dial. The merge field, Id, inserts the identifier for the contact, lead, or account record. The first Phone merge field tells the dialing tool what number to call and the last Phone merge field uses the value of the Phone field as the linkable text the user clicks to dial.
HYPERLINK("http://servername/call?id=" & Id & "&phone=" & Phone, Phone)
Case Categorization This formula displays a text value of “RED,” “YELLOW,” or “GREEN,” depending on the value of a case age custom text field.
IF(DaysOpen__c > 20, "RED", IF(DaysOpen__c > 10, "YELLOW", "GREEN") )
Case Data Completeness Tracking This formula calculates the percentage of specific custom fields that contain data. The formula checks the values of two custom number fields: Problem Num and Severity Num. If the fields are empty, the formula returns the value “0.” The formula returns a value of “1” for each field that contains a value and multiplies this total by fifty to give you the percentage of fields that contain data.
(IF(ISBLANK(Problem_Num__c), 0, 1) + IF(ISBLANK(Severity_Num__c ), 0,1)) * 50
Suggested Agent Prompts This formula prompts an agent with cross-sell offers based on past purchases.
CASE(Product_Purch__c, "Printer", "Extra toner cartridges", "Camera", "Memory cards", "Special of the day")
432 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Suggested Offers This formula suggests a product based on the support history for a computer reseller. When the Problem custom field matches a field, the formula field returns a suggestion.
CASE(Problem__c, "Memory", "Suggest new memory cards", "Hard Drive failure", "Suggest new hard drive with tape backup", "")
Sample Commission Calculations Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Commission Amounts for Opportunities Classic and Lightning Experience The following is a simple formula where commission is based on a flat 2% of the opportunity Amount. Available in: All Editions
IF(ISPICKVAL(StageName, "Closed Won"), ROUND(Amount *0.02, 2), 0)
This example calculates the commission amount for any opportunity that has a “Closed Won” stage. The value of this field will be the amount times 0.02 for any closed/won opportunity. Open or lost opportunities will have a zero commission value.
Commission Deal Size This formula calculates a commission rate based on deal size, returning a 9% commission rate for deals over 100,000 and an 8% commission rate for smaller deals.
IF(Amount > 100000, 0.09, 0.08 )
Commission Greater Than or Equal To This formula assigns the YES value with a commission greater than or equal to one million. Note, this is a text formula field that uses a custom currency field called Commission.
IF(Commission__c >= 1000000, "YES", "NO")
Commission Maximum This formula determines what commission to log for an asset based on which is greater: the user's commission percentage of the price, the price times the discount percent stored for the account or 100 dollars. This example assumes you have two custom percent fields on users and assets.
MAX($User.Commission_Percent__c * Price, Price * Account_Discount__c, 100)
433 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Contact Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Contact's Account Discount Percent Classic and Lightning Experience This percent formula displays the account's Discount Percent field on the contacts page. Available in: All Editions
Account.Discount_Percent__c
Contact's Account Name This formula displays the standard Account Name field on the contacts page.
Account.Name
Contact's Account Phone This formula displays the standard Account Phone field on the contacts page.
Account.Phone
Contact's Account Rating Use this formula to display the Account Rating field on the contacts page.
CASE(Account.Rating, "Hot", "Hot", "Warm", "Warm", "Cold", "Cold", "Not Rated")
Contact's Account Website This formula displays the standard Account Website field on the contacts page.
Account.Website
If the account website URL is long, use the HYPERLINK function to display a label such as “Click Here” instead of the URL. For example:
IF(Account.Website="", "", IF( OR(LEFT(Account.Website, 7) = "http://",LEFT(Account.Website, 8) = "https://"), HYPERLINK( Account.Website , "Click Here" ), HYPERLINK( "http://" & Account.Website , "Click Here" ) ) )
This formula also adds the necessary "http://" or "https://" before a URL if neither were included in the URL field.
Contact's LinkedIn™ Profile You can configure a link that appears on your contacts' profile page that sends you to their LinkedIn profile. To do so: 1. From the object management settings for contacts, go to Buttons, Links, and Actions.
434 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
2. Click New Button or Link. 3. Enter a Label for this link, like LinkedInLink. 4. Enter this formula in the content box:
http://www.linkedin.com/search/fpsearch?type=people&keywords ={!Contact.FirstName}+{!Contact.LastName}
5. Click Save. Remember to add this link to the Contact page layout in order for it to show up.
Contact Identification Numbering This formula displays the first five characters of a name and the last four characters of a social security number separated by a dash. Note that this example uses a text custom field called SSN.
TRIM(LEFT(LastName, 5)) & "-" & TRIM(RIGHT(SSN__c, 4))
Contact Preferred Phone This formula displays the contact’s preferred contact method in a contact related list—work phone, home phone, or mobile phone—based on a selected option in a Preferred Phone custom picklist.
CASE(Preferred_Phone__c, "Work", "w. " & Phone, "Home", "h. " & HomePhone, "Mobile", "m. " & MobilePhone, "No Preferred Phone")
Contact Priority This formula assesses the importance of a contact based on the account rating and the contact's title. If the account rating is Hot or the title starts with Executive, then the priority is high (P1). If the account rating is Warm or the title starts with VP then the priority is medium (P2), and if the account rating is Cold then the priority is low (P3).
IF(OR(ISPICKVAL(Account.Rating, "Hot"), CONTAINS(Title, "Executive")), "P1",
IF(OR(ISPICKVAL(Account.Rating, "Warm"), CONTAINS(Title, "VP")), "P2",
IF(ISPICKVAL(Account.Rating, "Cold"), "P3",
"P3") ) )
435 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Contact Yahoo! ID This formula displays a clickable Yahoo! Messenger icon indicating if the person is logged on to the service. Users can click the icon to launch a Yahoo! Messenger conversation with the person. This example uses a custom text field called Yahoo Name on contacts where you can store the contact's Yahoo! Messenger ID.
HYPERLINK("ymsgr:sendIM?" & Yahoo_Name__c, IMAGE("http://opi.yahoo.com/online?u=" & Yahoo_Name__c & "&m;=g&t;=0", "Yahoo"))
Dynamic Address Formatting This formula field displays a formatted mailing address for a contact in standard format, including spaces and line breaks where appropriate depending on the country.
CASE(ShippingCountry, "USA", ShippingStreet & BR() & ShippingCity & ", " & ShippingState & " " & ShippingPostalCode & BR() & ShippingCountry, "France", ShippingStreet & BR() & ShippingPostalCode & " " & ShippingCity & BR() & ShippingCountry, "etc")
Telephone Country Code This formula determines the telephone country code of a contact based on the Mailing Country of the mailing address.
CASE(MailingCountry, "USA", "1", "Canada", "1", "France", "33", "UK", "44", "Australia", "61", "Japan", "81", "?")
Unformatted Phone Number This formula removes the parentheses and dash characters from North American phone numbers. This is necessary for some auto-dialer software.
IF(Country_Code__c = "1", MID( Phone ,2, 3) & MID(Phone,7,3) & MID(Phone,11,4), Phone)
436 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Data Categorization Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Deal Size Large and Small Classic and Lightning Experience This formula displays “Large Deal” for deals over one million dollars or “Small Deal” for deals under one million dollars. Available in: All Editions
IF(Sales_Price__c > 1000000, "Large Deal", "Small Deal")
Deal Size Small This formula displays Small if the price and quantity are less than one. This field is blank if the asset has a price or quantity greater than one.
IF(AND(Price<1,Quantity<1),"Small", null)
Product Categorization This formula checks the content of a custom text field named Product_Type and returns Parts for any product with the word “part” in it. Otherwise, it returns Service. Note that the values are case-sensitive, so if a Product_Type field contains the text “Part” or “PART,” this formula returns Services.
IF(CONTAINS(Product_Type__c, "part"), "Parts", "Service")
Sample Date Formulas
EDITIONS Find the Day, Month, or Year from a Date Use the functions DAY( date ), MONTH( date ), and YEAR( date ) to return their Available in: both Salesforce numerical values. Replace date with a value of type Date (for example, TODAY()). Classic and Lightning Experience To use these functions with Date/Time values, first convert them to a date with the DATEVALUE() function. For example, DAY( DATEVALUE( date/time )). Available in: All Editions
Find Out If a Year Is a Leap Year This formula determines whether a year is a leap year. A year is only a leap year if it’s divisible by 400, or if it’s divisible by four but not by 100.
OR( MOD( YEAR( date ), 400 ) = 0, AND( MOD( YEAR( date ), 4 ) = 0, MOD( YEAR( date ), 100 ) != 0 ) )
437 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Find Which Quarter a Date Is In For standard quarters, you can determine which quarter a date falls in using this formula. This formula returns the number of the quarter that date falls in (1–4) by dividing the current month by three (the number of months in each quarter) and taking the ceiling.
CEILING( MONTH ( date ) / 3 )
The formula for shifted quarters is similar, but shifts the month of the date by the number of months between January and the first quarter of the fiscal year. The following example shows how to find a date’s quarter if Q1 starts in February instead of January.
CEILING( ( MONTH ( date ) - 1 ) / 3)
ITo check whether a date is in the current quarter, add a check to compare the date’s year and quarter with TODAY()’s year and quarter.
AND( CEILING( MONTH( date ) / 3 ) = CEILING( MONTH( TODAY() ) / 3 ), YEAR( date ) = YEAR( TODAY() ) )
Find the Week of the Year a Date Is In To find the number of a date’s week of the year, use this formula:
IF( CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7) > 52, 52, CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7) )
To find the current week number, determine the days to date in the current year and divide that value by 7. The IF() statement ensures that the week number the formula returns doesn’t exceed 52. So if the given date is December 31 of the given year, the formula returns 52, even though it’s more than 52 weeks after the first week of January.
Find Whether Two Dates Are in the Same Month To determine whether two Dates fall in the same month, say for a validation rule to determine whether an opportunity Close Date is in the current month, use this formula:
AND( MONTH( date_1 ) == MONTH( date_2 ), YEAR( date_1 ) == YEAR( date_2 ) )
Find the Last Day of the Month The easiest way to find the last day of a month is to find the first day of the next month and subtract a day.
IF( MONTH( date ) = 12, DATE( YEAR( date ), 12, 31 ), DATE( YEAR( date ), MONTH ( date ) + 1, 1 ) - 1 )
438 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Display the Month as a String Instead of a Number To return the month as a text string instead of a number, use:
CASE( MONTH( date ), 1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", 7, "July", 8, "August", 9, "September", 10, "October", 11, "November", "December" )
If your organization uses multiple languages, you can replace the names of the month with a custom label:
CASE( MONTH( date ), 1, $Label.Month_of_Year_1, 2, $Label.Month_of_Year_2, 3, $Label.Month_of_Year_3, 4, $Label.Month_of_Year_4, 5, $Label.Month_of_Year_5, 6, $Label.Month_of_Year_6, 7, $Label.Month_of_Year_7, 8, $Label.Month_of_Year_8, 9, $Label.Month_of_Year_9, 10, $Label.Month_of_Year_10, 11, $Label.Month_of_Year_11, $Label.Month_of_Year_12 )
Find and Display the Day of the Week from a Date To find the day of the week from a Date value, use a known Sunday, for example, January 7, 1900, and subtract it from the date, for example, TODAY(), to get the difference in days. The MOD() function finds the remainder of this result when divided by 7 to give the numerical value of the day of the week between 0 (Sunday) and 6 (Saturday). The formula below finds the result and then returns the text name of that day.
CASE( MOD( date - DATE( 1900, 1, 7 ), 7 ), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3, "Wednesday", 4, "Thursday", 5, "Friday", "Saturday" )
439 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This formula only works for dates after 01/07/1900. If you work with older dates, use the same process with any Sunday before to your earliest date, for example, 01/05/1800. You can adjust this formula if your week starts on a different day. For example, if your week starts on Monday, you can use January 8, 1900 in your condition. The new formula looks like this:
CASE( MOD( date - DATE( 1900, 1, 8 ), 7 ), 0, "Monday", 1, "Tuesday", 2, "Wednesday", 3, "Thursday", 4, "Friday", 5, "Saturday", "Sunday" )
Like the formula for getting the name of the month, if your organization uses multiple languages, you can replace the names of the day of the week with a variable like $Label.Day_of_Week_1, and so on.
Find the Next Day of the Week After a Date To find the date of the next occurrence of a particular day of the week following a given Date, get the difference in the number of days of the week between a date and a day_of_week, a number 0–6 where 0 = Sunday and 6 = Saturday. By adding this difference to the current date, you can find the date of the day_of_week. The IF() statement in this formula handles cases where the day_of_week is before the day of the week of the date value (for example date is a Thursday and day_of_week is a Monday) by adding 7 to the difference.
date + ( day_of_week - MOD( date - DATE( 1900, 1, 7 ), 7 ) ) + IF( MOD( date - DATE( 1900, 1, 7 ), 7 ) >= day_of_week, 7, 0 )
You can substitute either a constant or another field in for the day_of_week value based on your needs.
Find the Number of Days Between Two Dates To find the number of days between two dates, date_1 and date_2, subtract the earlier date from the later date: date_1 — date_2 You can alter this slightly if you want to determine a date that’s a certain number of days in the past. For example, to create a formula to return true if some date field is more than 30 days before the current date and false otherwise, use a formula such as the following:
TODAY() - 30 > date
Find the Number of Business Days Between Two Dates Calculating how many business days passed between two dates is slightly more complex than calculating total elapsed days. The basic strategy is to choose a reference Monday from the past and find out how many full weeks and any additional portion of a week have
440 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
passed between the reference date and your date. These values are multiplied by five for a five-day work week, and then the difference between them is taken to calculate business days.
(5 * ( FLOOR( ( date_1 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_1 - DATE( 1900, 1, 8), 7 ) ) ) - (5 * ( FLOOR( ( date_2 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_2 - DATE( 1900, 1, 8), 7 ) ) )
In this formula, date_1 is the more recent date and date_2 is the earlier date. If your work week runs shorter or longer than five days, replace all fives in the formula with the length of your week.
Find the Number of Months Between Two Dates To find the number of months between two dates, subtract the year of the earlier date from the year of the later date and multiply the difference by 12. Next, subtract the month of the earlier date from the month of the later date, and add that difference to the value of the first set of operations.
((YEAR(date_1) - YEAR(date_2))*12) + (MONTH(date_1) - MONTH(date_2))
Add Days, Months, and Years to a Date If you want to add a certain number of days to a date, add that number to the date directly. For example, to add five days to a date, the formula is date + 5. Adding years to a date is fairly simple, but do check that the future date is valid. That is, adding five years to February 29 (a leap year) results in an invalid date. The following formula adds num_years to date by checking if the date is February 29 and if the future date is not in a leap year. If these conditions hold true, the formula returns March 1 in the future year. Otherwise the formula sets the Date to the same month and day num_years in the future.
IF( AND( MONTH( date ) = 2, DAY( date ) = 29, NOT( OR( MOD( YEAR( date ) + num_years, 400 ) = 0, AND( MOD( YEAR( date ) + num_years, 4 ) = 0, MOD( YEAR( date ) + num_years, 100 ) != 0 ) ) ) ), DATE( YEAR( date ) + num_years, 3, 1), DATE( YEAR( date ) + num_years, MONTH( date ), DAY( date ) ) )
Adding months to a date is slightly more complicated because months vary in length and the cycle of months restart with each year. So a valid day in one month, January 31, might not be valid in another month, February 31. A simple solution is to approximate each month’s length as 365/12 days:
date + ( ( 365 / 12 ) * Number_months )
441 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This formula is a good estimate but it doesn’t return an exact date. For example, if you add two months to April 30 using this method, the formula will return June 29 instead of June 30. Returning an exact date depends on your organization’s preference. For example, when you add one month to January 31, should it return February 28, the last day of the next month, or March 2, 30 days after January 31? This formula does the following: • Returns March 1 if the future month is a February and the day is greater than 28. This portion of the formula performs the same for both leap and non-leap years. • Returns the first day of the next month if the future month is April, June, September, or November and the day is greater than 30. • Otherwise, it returns the correct date in the future month. This example formula adds two months to a given date. You can modify the conditions on this formula if you prefer different behaviors for dates at the end of the month.
DATE( YEAR( date ) + FLOOR( ( MONTH ( date ) + 2 - 1 ) / 12 ), MOD( MONTH ( date ) + 2 - 1 + IF( DAY ( date ) > CASE( MOD( MONTH( date ) + 2 - 1, 12 ) + 1, 2, 28, 4, 30, 6, 30, 9, 30, 11, 30, 31 ), 1, 0 ), 12 ) + 1, IF( DAY( date ) > CASE( MOD( MONTH( date ) + 2 - 1, 12 ) + 1, 2, 28, 4, 30, 6, 30, 9, 30, 11, 30, 31 ), 1, DAY( date ) ) )
If you use these formulas for expiration dates, you can subtract a day from the return value to make sure that some action is completed before the calculated date.
Add Business Days to a Date This formula finds three business days from a given date.
CASE( MOD( date - DATE( 1900, 1, 7 ), 7 ), 3, date + 2 + 3, 4, date + 2 + 3, 5, date + 2 + 3, 6, date + 1 + 3, date + 3 )
This formula finds the day of the week of the date field value. If the date is a Wednesday, Thursday, or Friday, the formula adds five calendar days, two weekend days, three weekdays, to the date to account for the weekend. If date is a Saturday, you need four
442 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
additional calendar days. For any other day of the week Sunday Tuesday, simply add three days. You can easily modify this formula to add more or fewer business days. The tip for getting the day of the week is useful to use to adjust this formula.
Find the Hour, Minute, or Second from a Date/Time To get the hour, minute, and second from a Date/Time field as a numerical value, use the following formulas where TZoffset is the difference between the user’s time zone and GMT. For hour in 24–hour format:
VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) )
For hour in 12–hour format:
IF( OR( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 0, VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 12 ), 12, VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) - IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, 0, 12 ) )
For minutes:
VALUE( MID( TEXT( date/time - TZoffset ), 15, 2 ) )
For seconds:
VALUE( MID( TEXT( date/time - TZoffset ), 18, 2 ) )
And, to get “AM” or “PM” as a string, use:
IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, "AM", "PM" )
To return the time as a string in “HH:MM:SS A/PM” format, use the following formula:
IF( OR( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 0, VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 12 ), "12", TEXT( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) - IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, 0,
443 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
12 ) ) ) & ":" & MID( TEXT( date/time - TZoffset ), 15, 2 ) & ":" & MID( TEXT( date/time - TZoffset ), 18, 2 ) & " " & IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, "AM", "PM" )
When working with time in formula fields, always consider the time difference between your organization and GMT. See A Note About Date/Time and Time Zones on page 415 for more information about the time zone offset used in this formula.
Find the Elapsed Time Between Date/Times To find the difference between two Date values as a number, subtract one from the other like so: date_1 — date_2 to return the difference in days. Finding the elapsed time between two Date/Time values is slightly more complex. This formula converts the difference between two Date/Time values, datetime_1 and datetime_2, to days, hours, and minutes.
IF( datetime_1 - datetime_2 > 0 , TEXT( FLOOR( datetime_1 - datetime_2 ) ) & " days " & TEXT( FLOOR( MOD( (datetime_1 - datetime_2 ) * 24, 24 ) ) ) & " hours " & TEXT( ROUND( MOD( (datetime_1 - datetime_2 ) * 24 * 60, 60 ), 0 ) ) & " minutes", "" )
Find the Number of Business Hours Between Two Date/Times The formula to find business hours between two Date/Time values expands on the formula to find elapsed business days. It works on the same principle of using a reference Date/Time, in this case 1/8/1900 at 16:00 GMT, or 9:00 AM PDT, and then finding your Dates’ respective distances from that reference. The formula rounds the value it finds to the nearest hour and assumes an 8–hour, 9:00 AM5:00 PM work day.
ROUND( 8 * ( ( 5 * FLOOR( ( DATEVALUE( date/time_1 ) - DATE( 1900, 1, 8) ) / 7) + MIN(5, MOD( DATEVALUE( date/time_1 ) - DATE( 1900, 1, 8), 7) + MIN( 1, 24 / 8 * ( MOD( date/time_1 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1 ) ) ) ) ) - ( 5 * FLOOR( ( DATEVALUE( date/time_2 ) - DATE( 1900, 1, 8) ) / 7) + MIN( 5, MOD( DATEVALUE( date/time_2 ) - DATE( 1996, 1, 1), 7 ) +
444 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
MIN( 1, 24 / 8 * ( MOD( date/time_2 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1) ) ) ) ) ), 0 )
You can change the eights in the formula to account for a longer or shorter work day. If you live in a different time zone or your work day doesn’t start at 9:00 AM, change the reference time to the start of your work day in GMT. See A Note About Date/Time and Time Zones for more information.
SEE ALSO: Using Date, Date/Time, and Time Values in Formulas Examples of Advanced Formula Fields Tips for Building Formulas
Sample Discounting Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Maintenance and Services Discount Classic and Lightning Experience This formula field uses two custom currency fields: Maintenance Amount and Services Amount. It displays “Discounted” on an opportunity if its maintenance amount and services amount Available in: All Editions do not equal the opportunity Amount standard field value. Otherwise, it displays "Full Price."
IF(Maintenance_Amount__c + Services_Amount__c <> Amount, "Discounted", "Full Price")
Opportunity Discount Amount This formula calculates the difference of the product Amount less the Discount Amount. Discount Amount is a custom currency field.
Amount - Discount_Amount__c
Opportunity Discount Rounded Use this formula to calculate the discounted amount of an opportunity rounded off to two digits. This example is a number formula field on opportunities that uses a custom percent field called Discount Percent.
ROUND(Amount-Amount* Discount_Percent__c,2)
Opportunity Discount with Approval This formula adds a “Discount Approved” checkbox to an opportunity. It uses conditional logic to check the value of the approval flag before calculating the commission.
IF(Discount_Approved__c, ROUND(Amount – Amount * DiscountPercent__c, 2), Amount)
445 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Employee Services Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Bonus Calculation Classic and Lightning Experience This example determines an employee's bonus amount based on the smallest of two amounts: the employee's gross times bonus percent or an equally divided amount of the company's performance Available in: All Editions amount among all employees. It assumes you have custom number field for Number of Employees, a custom percent field for Bonus Percent, and currency custom fields for the employee's Gross and company's Performance.
MIN(Gross__c * Bonus_Percent__c, Performance__c / Number_of_Employees__c)
Employee 401K This example formula determines which amount to provide in employee 401K matching based on a matching program of half of the employee's contribution or $250, whichever is less. It assumes you have custom currency field for Contribution.
MIN(250, Contribution__c /2)
Hours Worked Per Week This formula uses a custom tab to enable time tracking of hours worked per day. It uses a formula field to sum the hours per week.
MonHours__c + TuesHours__c + WedsHours__c + ThursHours__c + FriHours__c
Total Pay Amount This formula determines total pay by calculating regular hours multiplied by a regular pay rate, plus overtime hours multiplied by an overtime pay rate.
Total Pay = IF(Total_Hours__c <= 40, Total_Hours__c * Hourly_Rate__c, 40 * Hourly_Rate__c + (Total_Hours__c - 40) * Overtime_Rate__c)
Sample Expense Tracking Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Expense Identifier Classic and Lightning Experience This formula displays the text Expense- followed by trip name and the expense number. This is a text formula field that uses an expense number custom field. Available in: All Editions
"Expense-" & Trip_Name__c & "-" & ExpenseNum__c
446 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Mileage Calculation This formula calculates mileage expenses for visiting a customer site at 35 cents a mile.
Miles_Driven__c * 0.35
Sample Financial Calculations Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Compound Interest Classic and Lightning Experience This formula calculates the interest, you will have after T years, compounded M times per year. Available in: All Editions
Principal__c * ( 1 + Rate__c / M ) ^ ( T * M) )
Compound Interest Continuous This formula calculates the interest that will have accumulated after T years, if continuously compounded.
Principal__c * EXP(Rate__c * T)
Consultant Cost This formula calculates the number of consulting days times 1200 given that this formula field is a currency data type and consulting charges a rate of $1200 per day. Consulting Days is a custom field.
Consulting_Days__c * 1200
Gross Margin This formula provides a simple calculation of gross margin. In this formula example, Total Sales and Cost of Goods Sold are custom currency fields.
Total_Sales__c - Cost_of_Goods_Sold__c
Gross Margin Percent This formula calculates the gross margin based on a margin percent.
Margin_percent__c * Items_Sold__c * Price_item__c
Payment Due Indicator This formula returns the date five days after the contract start date whenever Payment Due Date is blank. Payment Due Date is a custom date field.
(BLANKVALUE(Payment_Due_Date__c, StartDate +5)
447 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Payment Status This formula determines if the payment due date is past and the payment status is “UNPAID.” If so, it returns the text “PAYMENT OVERDUE” and if not, it leaves the field blank. This example uses a custom date field called Payment Due Date and a text custom field called Payment Status on contracts.
IF( AND(Payment_Due_Date__c < TODAY(), ISPICKVAL(Payment_Status__c, "UNPAID")), "PAYMENT OVERDUE", null )
Sample Image Link Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Yahoo! Instant Messenger™ Image Classic and Lightning Experience This formula displays an image that indicates whether a contact or user is currently logged in to Yahoo! Instant Messenger. Clicking the image launches the Yahoo! Instant Messenger window. This Available in: All Editions formula uses a custom text field called Yahoo Name to store the contact or user’s Yahoo! ID.
IF(ISBLANK(Yahoo_Name__c),"", HYPERLINK("ymsgr:sendIM?" & Yahoo_Name__c, IMAGE("http://opi.yahoo.com/online?u=" & Yahoo_Name__c & "&m=g&t=0", " ")))
Flags for Case Priority This formula displays a green, yellow, or red flag image to indicate case priority.
IMAGE( CASE( Priority, "Low", "/img/samples/flag_green.gif", "Medium", "/img/samples/flag_yellow.gif", "High", "/img/samples/flag_red.gif", "/s.gif"), "Priority Flag")
Color Squares for Case Age This formula displays a 30 x 30 pixel image of a red, yellow, or green, depending on the value of a Case Age custom number field.
IF( Case_Age__c > 20, IMAGE("/img/samples/color_red.gif", "red", 30, 30), IF( Case_Age__c > 10, IMAGE("/img/samples/color_yellow.gif", "yellow", 30, 30), IMAGE("/img/samples/color_green.gif", "green", 30, 30) ))
448 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Traffic Lights for Status This formula displays a green, yellow, or red traffic light images to indicate status, using a custom picklist field called Project Status. Use this formula in list views and reports to create a “Status Summary” dashboard view.
IMAGE( CASE(Project_Status__c, "Green", "/img/samples/light_green.gif", "Yellow", "/img/samples/light_yellow.gif", "Red", "/img/samples/light_red.gif", "/s.gif"), "status color")
Stars for Ratings This formula displays a set of one to five stars to indicate a rating or score.
IMAGE( CASE(Rating__c, "1", "/img/samples/stars_100.gif", "2", "/img/samples/stars_200.gif", "3", "/img/samples/stars_300.gif", "4", "/img/samples/stars_400.gif", "5", "/img/samples/stars_500.gif", "/img/samples/stars_000.gif"), "rating")
Consumer Reports™—Style Colored Circles for Ratings This formula displays a colored circle to indicate a rating on a scale of one to five, where solid red is one, half red is two, black outline is three, half black is four, and solid black is five.
IMAGE( CASE(Rating__c, "1", "/img/samples/rating1.gif", "2", "/img/samples/rating2.gif", "3", "/img/samples/rating3.gif", "4", "/img/samples/rating4.gif", "5", "/img/samples/rating5.gif", "/s.gif"), "rating")
Horizontal Bars to Indicate Scoring This formula displays a horizontal color bar (green on a white background) of a length that is proportional to a numeric score. In this example, the maximum length of the bar is 200 pixels.
IMAGE("/img/samples/color_green.gif", "green", 15, Industry_Score__c * 2) & IMAGE("/s.gif", "white", 15, 200 - (Industry_Score__c * 2))
449 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Integration Link Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Application API Link Classic (not available in all orgs) and Lightning This formula creates a link to an application outside Salesforce, passing the parameters so that it Experience can connect to Salesforce via the SOAP API and create the necessary event. Available in: All Editions
HYPERLINK ("https://www.myintegration.com?sId=" & GETSESSIONID() & "?&rowID=" & Name & "action=CreateTask","Create a Meeting Request")
Important: $Api.Session_ID and GETSESSIONID() return the same value, an identifier for the current session in the current context. This context varies depending on where the global variable or function is evaluated. For example, if you use either in a custom formula field, and that field is displayed on a standard page layout in Salesforce Classic, the referenced session is a basic Salesforce session. That same field (or the underlying variable or formula result), when used in a Visualforce page, references a Visualforce session instead. Session contexts are based on the domain of the request. That is, the session context changes whenever you cross a hostname boundary, such as from .salesforce.com to .vf.force.com or .lightning.force.com. Session identifiers from different contexts, and the sessions themselves, are different. When you transition between contexts, the old session is replaced by the new one, and the old session is no longer valid. The session ID also changes at this time. Normally Salesforce transparently handles session hand-off between contexts, but if you’re passing the session ID around yourself, you might need to re-access $Api.Session_ID or GETSESSIONID() from the new context to ensure a valid session ID. Not all sessions are created equal. In particular, sessions obtained in a Lightning Experience context have reduced privileges, and don't have API access. You can't use these session IDs to make API calls. {!$Api.Session_ID} isn’t generated for guest users.
Shipment Tracking Integration This formula creates a link to FedEx, UPS, or DHL shipment tracking websites, depending on the value of a Shipping Method custom picklist field. Note that the parameters shown in this example for FedEx, UPS, and DHL websites are illustrative and do not represent the correct parameters for all situations.
CASE(Shipping_Method__c, "Fedex", HYPERLINK("http://www.fedex.com/Tracking?ascend_header=1&clienttype =dotcom&cntry_code=us&language=english&tracknumbers= "& tracking_id__c,"Track"), "UPS", HYPERLINK("http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion =5.0&sort_by=status&loc=en_US&InquiryNumber1= "& tracking_id__c & "&track.x=32&track.y=7", "Track") , "DHL", HYPERLINK("http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber=" & tracking_id__c,"Track"), "")
450 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Skype™ Auto Dialer Integration This formula creates a linkable phone number field that automatically dials the phone number via the Skype VOIP phone application. It requires installation of the Skype application (a third-party product not provided by Salesforce) on your desktop.
HYPERLINK("callto://+" & Country_Code__c & Phone_Unformatted__c, Phone)
Sample Lead Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Lead Aging (for open leads) Classic and Lightning Experience This formula checks to see if a lead is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number Available in: All Editions of days open rounded to zero decimal places. If the lead is not open, this field is blank.
IF(ISPICKVAL(Status, "Open"), ROUND(NOW()-CreatedDate, 0), null)
Lead Data Completeness This formula calculates the percent of certain lead fields that your sales personnel enter. The formula field checks the values of two custom number fields: Phone and Email. If the fields are empty, the formula returns the value “0.” The formula returns a value of “1” for each field that contains a value and multiplies this total by fifty to give you the percentage of fields that contain data.
(IF(Phone = "", 0, 1) + IF(Email = "", 0, 1) ) * 50
Lead Numbering This formula returns a number value for the text value in the auto-number field Lead Number. This can be useful if you want to use the Lead Number field in a calculation, such as round-robin or other routing purposes. Note that auto-number fields are text fields and must be converted to a number for numeric calculations.
VALUE(Lead_Number__c)
Round-Robin Assignment of Cases or Leads The following formula example for leads assumes you have three lead queues and you want to assign an equal number of incoming leads to each queue. You can also assign cases using a similar formula.
MOD(VALUE(Lead_Number__c), 3)
This formula is for a custom formula field named Round_Robin_ID that assigns each lead a value of 0, 1, or 2. This formula uses a custom auto-number field called Lead Number that assigns each lead a unique number starting with 1. The MOD function divides the lead number by the number of lead queues available (three in this example) and returns a remainder of 0, 1, or 2. Use the value of this formula field in your lead assignment rules to assign lead records to different queues. For example: • Round_Robin_ID = 0 is assigned to Queue A • Round_Robin_ID = 1 is assigned to Queue B • Round_Robin_ID = 2 is assigned to Queue C
451 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Metric Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Temperature Conversion Classic and Lightning Experience This formula converts Celsius degrees to Fahrenheit. Available in: All Editions
1.8 * degrees_celsius__c + 32
Unit of Measure Conversion This formula converts miles to kilometers.
Miles__c * 1.60934
Sample Opportunity Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Expected Product Revenue Classic and Lightning Experience This formula calculates total revenue from multiple products, each with a different probability of closing. Available in: All Editions
ProductA_probability__c * ProductA_revenue__c + ProductB_probability__c * ProductB_revenue__c
Maintenance Calculation This formula calculates maintenance fees as 20% of license fees per year. Maintenance Years is a custom field on opportunities.
Amount * Maint_Years__c * 0.2
Monthly Subscription-Based Calculated Amounts This formula calculates an opportunity amount based on a monthly subscription rate multiplied by the subscription period.
Monthly_Amount__c * Subscription_Months__c
Monthly Value This formula divides total yearly value by 12 months.
Total_value__c / 12
452 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Opportunity Additional Costs This formula calculates the sum of the product Amount, maintenance amount, and services fees. Maint amount and Service Fees are custom currency fields.
Amount + Maint_Amount__c + Services_Amount__c
Opportunity Categorization This formula uses conditional logic to populate an Opportunity category text field, based on the value of the Amount standard field. Opportunities with amounts less than $1500 are “Category 1,” those between $1500 and $10000 are “Category 2,” and the rest are “Category 3.” This example uses nested IF statements.
IF(Amount < 1500, "Category 1", IF(Amount > 10000, "Category 3", "Category 2"))
Opportunity Data Completeness This formula takes a group of fields and calculates what percent of them are being used by your personnel. This formula field checks five fields to see if they are blank. If so, a zero is counted for that field. A “1” is counted for any field that contains a value, and this total is divided by five (the number of fields evaluated). This formula requires you to select the Treat blank fields as blanks option under Blank Field Handling while the Advanced Formula subtab is showing.
(IF(ISBLANK(Maint_Amount__c), 0, 1) + IF(ISBLANK(Services_Amount__c), 0,1) + IF(ISBLANK(Discount_Percent__c), 0, 1) + IF(ISBLANK(Amount), 0, 1) + IF(ISBLANK(Timeline__c), 0, 1)) / 5
Opportunity Expected License Revenue This formula calculates expected revenue for licenses based on probability of closing.
Expected_rev_licenses__c * Probability
Opportunity Revenue Text Display This formula returns the expected revenue amount of an opportunity in text format without a dollar sign. For example, if the Expected Revenue of a campaign is “$200,000,” this formula field displays “200000.”
TEXT(ExpectedRevenue)
Opportunity Total Deal Size This formula calculates the sum of maintenance and services amounts.
Amount + Maint_Amount__c + Services_Amount__c
Opportunity Total Price Based on Units This formula generates proposal pricing based on unit price and total volume.
Unit_price__c * Volume__c * 20
453 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Professional Services Calculation This formula estimates professional service fees at an average loaded rate of $1200 per day. Consulting Days is a custom field on opportunities.
Consulting_Days__c * 1200
Stage-Based Sales Document Selection This formula Identifies a relevant document in the Documents tab based on opportunity Stage. Use document IDs in the form of “00l30000000j7AO.”
CASE(StageName, "Prospecting", "Insert 1st Document ID", "Qualification", "Insert 2nd Document ID", "Needs Analysis", "Insert 3rd Document ID", "Value Proposition", ... ) )
Sales Coach This formula creates a hyperlink that opens a stage-specific document stored in the Documents tab. It uses the previously defined custom formula field that identifies a document based on opportunity Stage. See Stage-Based Sales Document Selection on page 454.
HYPERLINK("/servlet/servlet.FileDownload?file=" & Relevant_Document__c, "View Document in New Window")
Shipping Cost by Weight This formula calculates postal charges based on weight.
package_weight__c * cost_lb__c
Shipping Cost Percentage This formula calculates shipping cost as a fraction of total amount.
Ship_cost__c / total_amount__c
Tiered Commission Rates This formula calculates the 2% commission amount of an opportunity that has a probability of 100%. All other opportunities will have a commission value of zero.
IF(Probability = 1, ROUND(Amount * 0.02, 2), 0)
454 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Total Contract Value from Recurring and Non-Recurring Revenue This formula calculates both recurring and non-recurring revenue streams over the lifetime of a contract.
Non_Recurring_Revenue__c + Contract_Length_Months__c * Recurring_Revenue__c
Sample Pricing Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Total Amount Classic and Lightning Experience This formula calculates a total amount based on unit pricing and total units. Available in: All Editions
Unit_price__c * Total_units__c
User Pricing This formula calculates a price per user license.
Total_license_rev__c / Number_user_licenses__c
Sample Scoring Calculations Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Lead Scoring Classic and Lightning Experience This formula scores leads, providing a higher score for phone calls than website requests. Available in: All Editions
CASE(LeadSource, "Phone", 2, "Web", 1, 0)
Here's a formula that scores a lead based on his or her rating:
CASE(1, IF(ISPICKVAL(Rating, "Hot"), 1, 0), 3, IF(ISPICKVAL(Rating, "Warm"), 1, 0), 2, IF(ISPICKVAL(Rating, "Cold"), 1, 0), 1))
Customer Success Scoring This formula uses a simple scoring algorithm to rank customers a high score for positive survey results in Salesforce.
Survey_Question_1__c * 5 + Survey_Question_2__c *2
455 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Formulas: How Do I ... ?
EDITIONS Common Math Calculations • Add numbers? Available in: both Salesforce Classic and Lightning • Convert text into a number? Experience • Divide numbers? Available in: All Editions • Multiply numbers? Some How Do I's are not • Round numbers? relevant to Database.com • Subtract numbers?
Common Text Functions USER PERMISSIONS • Check if a field contains specified text? To view formula field details: • View Setup and • Check if a picklist field contains a specified value? Configuration • Combine first and last names? To create, change, or delete • Convert numbers into text? formula fields: • Create a hyperlink field? • Customize Application
Advanced Formulas • Calculate Commission Amounts for Opportunities? • Set Up Round-Robin Assignment of Cases or Leads? • Set Up Opportunity Discount Rounded?
Custom Summary Formulas for Reports • Calculate the sum of all leads that have Email Opt Out and Do Not Call fields selected? • Calculate the difference of all Amount fields and all Discounted Amount fields on opportunities? • Calculate the average age of all opportunities? • Calculate what percent of all opportunities are closed won? • Calculate the number of active Salesforce users to the 2nd power for administration? • Calculate the duration of all activities (minutes) times the number of records per 24 hours? • Calculate the average percent margin on a product-by-product level across many opportunities? • Calculate the percentage of one product compared to all products in closed opportunities? • Calculate the change in revenue from opportunities between months?
Cross-Object Formulas • Display a Percent field from a parent object? • Display a text field from a parent object? • Display a phone number field from a parent object? • Display a picklist field from a parent object? • Display a URL field from a parent object?
456 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Common Formula Errors
Review common errors that can occur with formulas and how to fix them. EDITIONS • “#Error!” displays for a formula field whenever an error occurs while calculating the value of a formula. To resolve the error, check your formula. Available in: both Salesforce Classic and Lightning – Is the formula dividing by zero? If so, check if the denominator of your expression is zero Experience and provide an alternative value. For example, the following campaign formula field is blank if the number of opportunities is zero: Available in: All Editions
IF(NumberOfOpportunities > 0, NumberOfWonOpportunities / NumberOfOpportunities, null)
– Is the formula calculating a value larger than the maximum value of the current type? If so, you can append L to numeric values to make them Long so the intermediate products will be Long and no overflow occurs. For example, the following example shows how to correctly compute the amount of milliseconds in a year by multiplying Long numeric values.
Long MillsPerYear = 365L * 24L * 60L * 60L * 1000L; Long ExpectedValue = 31536000000L;
System.assertEquals(MillsPerYear, ExpectedValue);
– Is the formula calculating the square root of a negative number? If so, use an IF function similar to the one above to check if the value is a positive number. – Is the formula calculating the LOG of a negative number? If so, use an IF function similar to the one above to make sure that the number is positive. – Is the formula using the VALUE function with text that contains special characters? For examples of special characters, see Formula Operators and Functions on page 355. – Make sure the formula does not contain a HYPERLINK function within a text function, such as LEFT( HYPERLINK("http://MYCOMPANY.ORG ", "MYCOMPANY ") , 5). – Is the formula disabled or referencing a disabled formula field? Salesforce disables formula fields when they are deleted and they remain disabled after they are restored. To enable disabled formula fields, edit and save the field. For more information on deleted custom fields and restoring them, see Manage Deleted Custom Fields on page 244.
• “#Too Big!” displays if your formula output is over 18 digits. When this happens, check your formula for calculations that could result in more than 18 digits. Avoid multiplying large numbers, raising a large number to a power, or dividing by a very small number. • CASE functions return an error whenever any of the expressions return an error, regardless of which one should be returned. For example, CASE(Field__c,"Partner", "P", "Customer", "C", LEFT(Field__c, -5)) returns an error even if the value of the field is “Partner” or “Customer” because the last statement is illogical. • Prevent division by zero errors by including an IF function that determines if the value of a field is zero. For example, IF(Field__c =0,0, 25/Field__c).
457 Extend Salesforce with Clicks, Not Code Generate Emails From Records
Generate Emails From Records
A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. For example, you can place a merge field in an email template so that the greeting includes the recipient’s name rather than a generic “Hello!”. Available in: both Salesforce You can use merge fields within custom formula fields, s-controls, custom links, custom buttons, Classic and Lightning Visualforce pages, and when you create email or mail merge templates. Experience Merge field names are determined when you create a new custom field or object. Field Name The available merge fields is automatically populated based on what you type into Field Label. You can customize this vary according to which field if you want, but keep in mind that the name must: Salesforce edition you have. • Only use underscores and alphanumeric characters • Begin with a letter and end with a letter • Not include spaces • Not contain two consecutive underscores
Important: Ensure that the custom field name and label are unique for that object. • If a standard and custom field have identical names or labels, the merge field displays the custom field value. • If two custom fields have identical names or labels, the merge fieldcan display an unexpected value. If you create a field label called Email and a standard field labeled Email exists, the merge field is unable to distinguish between the fields. Adding a character to the custom field name makes it unique. For example, Email2. To find the merge field name for an object or field in Salesforce, visit the object or field’s detail page and refer to Field Name. To incorporate merge fields, use the editor in the respective feature. Salesforce provides valid merge fields in each editor for all related standard and custom objects. If you’re using the Connect for Office Word add-in to create mail merge templates, you’ll see a complete list of valid merge fields to insert.
Merge Field Syntax A merge field’s syntax can vary depending on where you use the field. To make sure that you use the correct syntax, select merge fields from the dropdown list in the editor where you use the merge field. Merge Fields for Validation Rules Merge Fields for Formulas Merge Fields for Cross-Object Formulas A Cross-object formula is a formula that spans two related objects and references merge fields on those objects. Merge Field Tips Here are a few pointers for getting the most out of merge fields.
458 Extend Salesforce with Clicks, Not Code Generate Emails From Records
Merge Field Syntax
A merge field’s syntax can vary depending on where you use the field. To make sure that you use EDITIONS the correct syntax, select merge fields from the dropdown list in the editor where you use the merge field. Available in: both Salesforce Custom objects and fields are always appended with __c when referenced. The object precedes Classic and Lightning field labels, and all spaces convert to underscores. For example, Account.CreatedDate Experience Created Date references the standard field for the account object. The available merge fields In standard relationships, the name of the relationship is the master object. For example, you can vary according to which reference the account name from a contact validation rule using Account.Name. You can Salesforce edition you have. reference the phone number of the account creator from an opportunity product formula field using Opportunity.Account.CreatedBy.Phone. In custom relationships, the name of the relationship is the value specified in Field Name with __r appended to it. For example, you can reference contact email from a custom object validation rule using Contact__r.Email.
Merge Fields for Validation Rules
A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. Available in: both Salesforce Syntax and Formatting Classic and Lightning Experience When you insert a merge field in a validation rule, the syntax consists of the object, a period, and the field name. For example, $User.State corresponds with a user’s state or province. Available in: Essentials, Contact Manager, Group, A merge field’s syntax can vary depending on where you’re using the field. To make sure you’re Professional, Enterprise, using the correct syntax, select merge fields from the drop-down list in the editor where you’re Performance, Unlimited, using the merge field. The merge fields for validation rules correspond directly with the fields in Developer, and your app. Database.com Editions For a list of fields in an object, from the management settings for the object, go to the fields section.
Important: • If two or more custom objects have matching names or labels, only one of the objects appears when you select from available merge fields. Make sure that all custom objects have unique names and labels so that you can select merge fields from any of the objects.
Limitations Validation rules can’t reference merge fields for: • Auto number fields, such as Requisition Number • Compound fields, such as addresses, first and last names, dependent picklists, and dependent lookups
Note: Validation rules can reference merge fields individual address fields, such as Billing City.
• Campaign statistic fields, including statistics for individual campaigns and campaign hierarchies
Tips • Some merge fields display as radio buttons but function like picklist fields when referenced in a formula.
459 Extend Salesforce with Clicks, Not Code Generate Emails From Records
Use the values “Read,” “Edit,” and “None” in a formula when referencing: – $UserRole.CaseAccessForAccountOwner – $UserRole.OpportunityAccessForAccountOwner – CaseAccessLevel (on Territory) – OpportunityAccessLevel (on Territory) Use the values “Read,” “Edit,” and “All” in a formula when referencing: – AccountAccessLevel (on Territory)
• Use the RecordType.Id merge field in your formula to apply different validations for different record types.
SEE ALSO: Find Object Management Settings
Merge Fields for Formulas
A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. Available in: both Salesforce Syntax and Formatting Classic (not available in all orgs) and Lightning Merge fields for formulas aren’t enclosed in curly braces or preceded by an exclamation point, nor Experience are they preceded by the type of record. For example: AccountNumber. To ensure you’re using the correct syntax, use the Insert Field button or the drop-down list in the formula editor. Available in: All Editions
SEE ALSO: Tips for Using Merge Fields in Formulas Build a Formula Field
Merge Fields for Cross-Object Formulas
A Cross-object formula is a formula that spans two related objects and references merge fields on EDITIONS those objects. A merge field is a field you can put in an email template, mail merge template, custom link, or Available in: Salesforce formula to incorporate values from a record. Classic (not available in all orgs) A cross-object formula can reference merge fields from a master (“parent”) object if an object is on the detail side of a master-detail relationship. A cross-object formula also works with lookup Available in: All editions relationships. For example, you can write a cross-object formula that references the Account Name for a contact associated with a case. In this example, you would type Contact.Account.Name in a formula on the Case object.
Syntax and Formatting Merge fields for formulas aren’t enclosed in curly braces or preceded by an exclamation point. Use the relationship names of the objects, not the labels. Although the relationship name is often the same as the object name, it is technically the field name of the relationship field.
460 Extend Salesforce with Clicks, Not Code Manage Your Notifications with Notification Builder
To reference the parent account name from Account object, the syntax is Parent.Name, not Account.Name. When referencing a custom object, add two underscores and the letter r to its name. For example, Position__r.title__c references the Job Title field (title__c) on a Position custom object.
Limitations You can’t reference: • Merge fields for objects related to activities. For example, merge fields for contacts and accounts are not available in task and event formulas. • The $RecordType global variable—it only resolves to the record containing the formula, not the record to which the formula spans. Starting with the Spring ’13 release, when you create a new formula the $RecordType global variable is only available for default value formulas. The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile name, as expected. In list views and reports, the value is the internal value of the associated profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example:
IF (OR (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name = "PT2"), "Standard", "Not Standard")
None of the above applies to profile names referenced by the $Profile global variable.
Merge Field Tips
Here are a few pointers for getting the most out of merge fields. EDITIONS To make sure you’re using the correct syntax, select merge fields from the merge field picker. • To use a merge field as the destination of a link, insert the merge field after http://. Available in: both Salesforce Classic and Lightning • Salesforce rounds decimal values referenced in merge fields on email templates to three digits Experience regardless of locale. The available merge fields • You can store the name of an account, contact, or lead in your organization’s default language vary according to which (the local name), in addition to the account or user’s default language (the standard name). If Salesforce edition you have. the local name is blank, the standard merge field name is used. • To reference a stand-alone file, use $Resource., where is the name you specified when you uploaded the resource. • If you're using the Translation Workbench to translate custom field names, users can look up merge fields in their chosen language. • You can’t use a lookup field as a merge field in an email template. You can, however, create a hidden formula field on the page layout that pulls the value from the lookup field. Then include the hidden field in the email template.
Manage Your Notifications with Notification Builder
Keep your users in the know with timely notifications, whether they’re at their desks or on the go. Choose whether standard Salesforce notifications, like Chatter notifications, appear on desktop, mobile, or at all. Create custom notifications to give your users new information and reminders, or replace a standard notification.
461 Extend Salesforce with Clicks, Not Code Send Custom Notifications
Send Custom Notifications Send custom notifications when important events occur. Alert an account owner if a new support case is logged while trying to close a deal. Send a notification for a workflow built entirely with custom objects. Or replace a standard notification with a custom notification to include a message and recipients tailored to your needs. Manage Notification Delivery Settings Choose the desktop and mobile delivery channels for custom and standard notification types. The delivery channels for custom types can be edited for supported Salesforce-provided apps and apps installed from a managed package. The delivery channels for standard types can be edited for supported Salesforce-provided apps only. Considerations for Notification Builder Before you begin managing your desktop and mobile notifications, learn about the considerations specific to custom notifications and notification delivery settings.
SEE ALSO: Salesforce Mobile App Notification Types
Send Custom Notifications Send custom notifications when important events occur. Alert an account owner if a new support case is logged while trying to close a deal. Send a notification for a workflow built entirely with custom objects. Or replace a standard notification with a custom notification to include a message and recipients tailored to your needs. 1. Create a Notification Type Create notification types to send custom notifications via a process in Process Builder, a flow in Flow Builder, Apex code, or the invocable action API. You can create multiple custom notifications from a notification type.
Note: If you create a custom notification type with a mobile delivery channel in Winter ’20 or later, you must manually enable the Salesforce mobile app and any other supported apps in Notification Delivery Settings.
2. Send a Custom Notification from a Process Add the Send Custom Notification action to a process, then add recipients and content. or Learn about Other Ways to Send a Custom Notification We’ve made it easy to build notifications using clicks, not code. But if your business needs are more complex, we also support flows and programmatic solutions.
462 Extend Salesforce with Clicks, Not Code Send Custom Notifications
Create a Notification Type
Create notification types to send custom notifications via a process in Process Builder, a flow in Flow EDITIONS Builder, Apex code, or the invocable action API. You can create multiple custom notifications from a notification type. Available in: Lightning 1. Enter Notification Builder in the Quick Find box in Setup, then select Custom Experience Notifications. Available in: all editions, 2. Click New and add your Custom Notification Name and API Name, and supported channels. except Database.com Channel Description USER PERMISSIONS Desktop Sends a notification to the desktop notification tray.
Mobile Sends an in-app and push notification to enabled supported apps. To view notification types: • View Setup and Configuration Note: Mobile in-app notifications require the Enable in-app notifications setting. Mobile push notifications depend on a user’s device-level and, if available, app-level push To create and edit notification types: notification settings. Push notifications for the Salesforce mobile app require the Enable • Customize Application push notifications setting.
Note: If you created a custom notification type with a mobile delivery channel before Winter ’20, your notification is automatically delivered to the Salesforce mobile app. If you create a custom notification type with a mobile delivery channel in Winter ’20 or later, you must manually enable the Salesforce mobile app and any other supported apps in Notification Delivery Settings.
3. Save your notification type. 4. If you enable the mobile channel, you must enable the supported apps for your notification type. a. From Setup, enter Notification Builder in the Quick Find box, then select Notification Delivery Settings. b. Choose your custom notification type, and select Edit from the dropdown menu. c. Select the supported applications for your notification type and save.
463 Extend Salesforce with Clicks, Not Code Send Custom Notifications
Send a Custom Notification from a Process
Add the Send Custom Notification action to a process, then add recipients and content. EDITIONS • Before you begin, make sure that the custom notification type you want to call from your process exists. If not, create the notification type on page 463. Available in: both Salesforce • Before you can add an action to your process, you must define the process properties, configure Classic and Lightning the process trigger, and add process criteria. If you’re new to creating processes, learn more in Experience Process Builder help. Available in: Essentials, After you’ve created an action and selected Send Custom Notification for the type, fill in the Professional, Enterprise, relevant fields to add the action to your process. Performance, Unlimited, and Developer Editions 1. Enter an easily recognizable name for this action. The name appears on the canvas and helps you differentiate this action from others in your USER PERMISSIONS process. The name truncates to fit on the canvas.
2. Select a notification type. To create, edit, or view processes: 3. Select a recipient category, and designate or find a recipient ID. • Manage Flow • Current User — The user who initiated the record change, platform event, or process that AND triggered the process. This option is useful for confirmation notifications, such as a successful View All Data submission of a form. • Find User — The user who receives the notification each time this action is executed. • User Field from a Record — A user referenced via UserId on the record that initiated the process or on a related record. • Find Group — All users in the group that receives the notification each time this action is executed. • Find Queue — All users in the queue that receives the notification each time this action is executed. • Account Field from a Record — All users on the account team for an account referenced via AccountId on the record that initiated the process or on a related record. This option is available if you’ve enabled account teams for your org. • Opportunity Field from a Record — All users on the opportunity team for an opportunity referenced via OpportunityId on the record that initiated the process or a related record. This option is available if you’ve enabled team selling for your org. • Owner Field from a Record — An owner or queue referenced via OwnerId on the record that initiated the process or a related record. With this option, you can send a notification to all record owners, regardless of whether the owner is an individual owner or a queue.
4. Write a helpful notification title and body using text and merge fields.
Note: The content of custom push notifications depends on the Display full content push notifications setting. If full content push notifications are not enabled, only the notification title is sent.
5. Save the action.
Other Ways to Send a Custom Notification We’ve made it easy to build notifications using clicks, not code. But if your business needs are more complex, we also support flows and programmatic solutions.
Tip: To see how to specify the target using JSON, see pageReference.
464 Extend Salesforce with Clicks, Not Code Send Custom Notifications
Flow Builder Flow Core Action: Send Custom Notification The Send Custom Notification action is available in Flow Builder. Add it to your flow, then add recipients and content. Some tips specific to custom notifications: • To query for the Notification Type ID directly from a flow, add the Get Record element to your flow and filter by API name. If you’ve installed a notification type via a managed package, filter by the namespace prefix as well as the API name. • To add recipients, define Recipient ID as a resource. Then add values to your Recipient ID collection by adding the Assignment element to your flow. If you’re new to creating flows, learn even more in Flow help.
Apex CustomNotification Use the CustomNotification Apex class to create, configure, and send custom notifications from Apex code, such as a trigger. When possible, create and send custom notifications from Apex rather than via API call. It’s less code, and more efficient.
API CustomNotificationType Use the CustomNotificationType object to create notification types and query for your Custom Notification Type ID. It’s available for the following APIs: • Metadata • Tooling • Lightning Platform REST and SOAP customNotificationAction Invocable Action Use the customNotificationAction action to send custom notifications to desktop and delivery channels.
465 Extend Salesforce with Clicks, Not Code Manage Notification Delivery Settings
Manage Notification Delivery Settings
Choose the desktop and mobile delivery channels for custom and standard notification types. The EDITIONS delivery channels for custom types can be edited for supported Salesforce-provided apps and apps installed from a managed package. The delivery channels for standard types can be edited for Available in: Lightning supported Salesforce-provided apps only. Experience 1. From Setup, enter Notification Builder in the Quick Find box, then select Available in: all editions, Notification Delivery Settings. except Database.com 2. Choose the notification type, and select Edit from the dropdown menu. Notification Delivery Settings shows you only the notification types available for your org. USER PERMISSIONS 3. Select the channels and applications for your notification type, and save. To view notification delivery Only the delivery channels and mobile applications supported for the notification type are settings: listed. • View Setup and Configuration If a channel for a custom notification type created in your org is listed but unavailable, enable it in Custom Notifications in Setup. To edit notification delivery settings: Note: Mobile in-app notifications require the Enable in-app notifications setting. Mobile • Customize Application push notifications depend on a user’s device-level and, if available, app-level push notification settings. Push notifications for the Salesforce mobile app require the Enable push notifications setting.
SEE ALSO: Connect REST API Developer Guide: Notification Settings Resources Metadata API Developer Guide: NotificationTypeConfig
Considerations for Notification Builder Before you begin managing your desktop and mobile notifications, learn about the considerations specific to custom notifications and notification delivery settings.
Custom Notifications • In orgs created in Winter ’21 or later, the Send Custom Notifications user permission is required to trigger the Send Custom Notification action in flows that run in user context, REST API calls, and Apex callouts. The Send Custom Notifications user permission isn’t required to trigger the Send Custom Notification action in process or flows that run in system context. • If you created a custom notification type with a mobile delivery channel before Winter ’20, your notification is automatically delivered to the Salesforce mobile app. If you create a custom notification type with a mobile delivery channel in Winter ’20 or later, you must manually enable the Salesforce mobile app and any other supported apps in Notification Delivery Settings. • You can create up to 500 custom notification types. • Each notification can have up to 10,000 users as recipients. However, you can add an action to the same process within Process Builder or to the same flow in Flow Builder to have more recipients. • Your org saves your most recent 1 million custom notifications for view in notification trays. Your org can save up to 1.2 million custom notifications, but it trims the amount to the most recent 1 million notifications when you reach the 1.2 million limit. • An org can execute up to 10,000 notification actions per hour. When you exceed this limit, no more notifications are sent in that hour, and all unsent notifications are lost. Notification actions resume in the next hour.
466 Extend Salesforce with Clicks, Not Code Considerations for Notification Builder
For example, your notification action processes are triggered 10,250 times between 4:00 and 4:59. Salesforce executes the first 10,000 of those actions. The remaining 250 notifications aren’t sent and are lost. Salesforce begins executing notification actions again at 5:00.
• When you send a custom notification from a process, the Target ID for the notification is the record that started the process. However, target records that don't have their own detail page (for example, a case comment, which appears only in a Case Comment related list) don't support direct navigation. Use Flow Builder to send the notification from a flow and specify either a different Target ID or Target Page Reference.
Tip: To see how to specify the target using JSON, see pageReference.
• Custom notification title and body fields support plain text only. • The content of custom push notifications depends on the Display full content push notifications setting. If full content push notifications aren’t enabled, only the notification title is sent.
Notification Delivery Settings • When you disable a delivery channel for a standard or custom notification type, you pause the delivery of a notification. However, a notification is still created and stored whenever an existing notification type is triggered. If you enable a delivery channel for an existing notification type, the stored notifications become visible in the notification tray for that delivery channel. • Mobile in-app notifications require the Enable in-app notifications setting. Mobile push notifications depend on a user’s device-level and, if available, app-level push notification settings. • In the Salesforce mobile app: – Mobile push notifications require the Enable push notifications setting. – A push notification for an individual notification type depends on a user’s app-level Push Notification Settings. If the mobile channel is enabled for a notification type, but a user disables push notifications for that type, the user doesn’t receive a push notification. – If you enable the mobile delivery channel for a notification type after you’ve disabled it, users’ Push Notification Settings for that type default to enabled.
• A desktop notification can be delivered in real time to up to 1,000 concurrently logged-in recipients. Additional concurrently logged-in recipients must refresh their Salesforce page to see their latest notifications. Recipients who aren't logged in see their notifications as expected upon login.
SEE ALSO: Considerations for Salesforce Mobile App Notifications
467 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events
Define and Manage Platform Events
Use platform events to connect business processes in Salesforce and external sources through the EDITIONS exchange of real-time event data. Platform events are secure and scalable. Define fields to customize your platform event data. Available in both Salesforce By using platform events, publishers can send custom event data through Apex, a process, a flow, Classic and Lightning or an API. Subscribers can receive custom event messages from Salesforce or an external system Experience using Apex, CometD clients, processes, or flows. Based on the event message data, subscribers can Available in: Performance, process custom business logic, such as sending an email or logging a case. For example, a software Unlimited, Enterprise, and system monitoring a printer can make an API call to publish an event when the ink is low. The Developer Editions custom printer event can contain custom fields for the printer model, serial number, and ink level. The event is processed in Salesforce by an Apex trigger that places an order for a new cartridge. USER PERMISSIONS Platform events simplify the process of communicating changes and responding to them without writing complex logic. Publishers and subscribers communicate with each other through events. To create and edit platform Multiple subscribers can listen to the same event and carry out different actions. event definitions: • Customize Application Define Your Platform Event To define a platform event in Salesforce Classic or Lightning Experience: 1. From Setup, enter Platform Events in the Quick Find box, then select Platform Events. 2. On the Platform Events page, click New Platform Event. 3. Complete the standard fields, and optionally add a description. 4. For Publish Behavior, choose when the event message is published in a transaction. • Publish After Commit to have the event message published only after a transaction commits successfully. Select this option if subscribers rely on data that the publishing transaction commits. For example, a process publishes an event message and creates a task record. A second process that is subscribed to the event is fired and expects to find the task record. Another reason for choosing this behavior is when you don't want the event message to be published if the transaction fails. • Publish Immediately to have the event message published when the publish call executes. Select this option if you want the event message to be published regardless of whether the transaction succeeds. Also choose this option if the publisher and subscribers are independent, and subscribers don't rely on data committed by the publisher. For example, the immediate publishing behavior is suitable for an event used for logging purposes. With this option, a subscriber might receive the event message before data is committed by the publisher transaction.
5. Click Save. 6. To add a field, in the Custom Fields & Relationships related list, click New. 7. Follow the custom field wizard to set up the field properties.
Note: • If you change the publish behavior, expect up to a 5-minute delay for the change to take effect. • In Lightning Experience, platform events aren’t shown in the Object Manager’s list of standard and custom objects and aren’t available in Schema Builder.
A platform event is a special kind of Salesforce entity, similar in many ways to an sObject. An event message is an instance of a platform event, similar to how a record is an instance of a custom object. Unlike custom objects, you can’t update or delete event records. You
468 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events
also can’t view event records in the Salesforce user interface, and platform events don’t have page layouts. When you delete a platform event definition, it’s permanently deleted.
Standard Fields Platform events include standard fields. These fields appear on the New Platform Event page.
Field Description Label Name used to refer to your platform event in a user interface page.
Plural Label Plural name of the platform event.
Starts with a vowel sound If it’s appropriate for your org’s default language, indicate whether the label is preceded by “an” instead of “a.”
Object Name Unique name used to refer to the platform event when using the API. In managed packages, this name prevents naming conflicts with package installations. Use only alphanumeric characters and underscores. The name must begin with a letter and have no spaces. It cannot end with an underscore or have two consecutive underscores.
Description Optional description of the object. A meaningful description helps you remember the differences between your events when you view them in a list.
Deployment Status Indicates whether the platform event is visible to other users.
Custom Fields In addition to the standard fields, you can add custom fields to your custom event. Platform event custom fields support only these field types. • Checkbox • Date • Date/Time • Number • Text • Text Area (Long) The maximum number of fields that you can add to a platform event is the same as for a custom object. See Salesforce Features and Edition Allocations.
ReplayId System Field Each event message is assigned an opaque ID contained in the ReplayId field. The ReplayId field value, which is populated by the system when the event is delivered to subscribers, refers to the position of the event in the event stream. Replay ID values are not guaranteed to be contiguous for consecutive events. For example, the event following the event with ID 999 can have an ID of 1,025. A subscriber can store a replay ID value and use it on resubscription to retrieve events that are within the retention window. For example,
469 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events
a subscriber can retrieve missed events after a connection failure. Subscribers must not compute new replay IDs based on a stored replay ID to refer to other events in the stream.
EventUuid System Field A universally unique identifier (UUID) that identifies a platform event message. This field is available in API version 52.0 and later. The API version corresponds to the version that an Apex trigger is saved with, or the version specified in a CometD subscriber endpoint.
API Name Suffix for Custom Platform Events When you create a platform event, the system appends the __e suffix to create the API name of the event. For example, if you create an event with the object name Low Ink, the API name is Low_Ink__e. The API name is used whenever you refer to the event programmatically, for example, in Apex. API names of standard platform events, such as AssetTokenEvent, don’t include a suffix.
Event Subscribers The Subscriptions related list shows all triggers, processes, and platform event–triggered flows that are subscribed to a platform event. CometD subscribers, such as your own CometD client or the empApi Lightning component, aren't listed in this page. The list shows the replay ID of the event that the system last processed (Last Processed Id field) and the event last published (Last Published Id field). Knowing which replay ID was last processed is useful when there’s a gap in the events published and processed. For example, if a trigger contains complex logic that causes a delay in processing large batches of incoming events.
Note: For high-volume platform events, the Last Published Id value is not available and is always shown as Not Available.
Also, the Subscriptions list shows the state of each subscriber, which can be one of the following. • Running—The subscriber is actively listening to events. If you modify the subscriber, the subscription continues to process events. • Error— The subscriber was disconnected and stopped receiving published events. A trigger reaches this state when it exceeds the number of maximum retries with the EventBus.RetryableException. Trigger assertion failures and unhandled exceptions don’t cause the error state. We recommend limiting the retries to fewer than nine times to avoid reaching this state. When you fix and save the trigger, or for a managed package trigger, if you redeploy the package, the trigger resumes automatically from the tip, starting from new events. Also, you can resume a trigger subscription in the subscription detail page that you access from the platform event page. • Suspended—The subscriber is disconnected and can’t receive events because a Salesforce admin suspended it or due to an internal error. You can resume a trigger subscription in the subscription detail page that you access from the platform event page. To resume a process, deactivate it and then reactivate it. If you modify the subscriber, the subscription resumes automatically from the tip, starting from new events.
Note: Only one “Process” subscriber appears in the Subscriptions related list for all paused flow interviews that are subscribed to the platform event. Processes and platform event–triggered flows are listed individually. Also, information about event subscribers is exposed in the EventBusSubscriber object. You can query this object to obtain details about subscribers.
Suspend or Resume an Apex Trigger Subscription Resume a suspended trigger subscription where it left off, starting from the earliest available event message that is stored in the event bus. If you want to bypass event messages that are causing errors or are no longer needed, you can resume a subscription from the tip, starting from new event messages.
470 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events
To manage a trigger subscription: 1. In the Subscriptions related list, click Manage next to the Apex trigger. 2. In the subscription detail page, choose the appropriate action. • To suspend a running subscription, click Suspend. • To resume a suspended subscription, starting from the earliest event message that is available in the event bus, click Resume. • To resume a suspended subscription, starting from new event messages, click Resume from Tip.
You can’t manage subscriptions for flows and processes through the Subscriptions related list.
Note: • After you modify a subscriber, the subscription resumes automatically. For more information, see the Event Subscribers section. • If you click Resume for a trigger that is in the error state, the trigger skips the events that were retried with EventBus.RetryableException. The subscription starts with the unprocessed events sent after the error state and that are within the retention window.
Platform Event Considerations Field-Level Security All platform event fields are read only by default, and you can’t restrict access to a particular field. Field-level security permissions don’t apply and the event message contains all fields. Enforcement of Field Attributes Platform event records are validated to ensure that the attributes of their custom fields are enforced. Field attributes include the Required and Default attributes, the precision of number fields, and the maximum length of text fields. Permanent Deletion of Event Definitions When you delete an event definition, it’s permanently removed and can’t be restored. Before you delete the event definition, delete the associated triggers. Published events that use the definition are also deleted. Renaming Event Objects Before you rename an event, delete the associated triggers. If the event name is modified after clients have subscribed to this event, the subscribed clients must resubscribe to the updated topic. To resubscribe to the new event, add your trigger for the renamed event object. No Associated Tab Platform events don’t have an associated tab because you can’t view event records in the Salesforce user interface. No SOQL Support You can’t query event messages using SOQL. No Record Page Support in Lightning App Builder When creating a record page in Lightning App Builder, platform events that you defined show up in the list of objects for the page. However, you can’t create a Lightning record page for platform events because event records aren’t available in the user interface. Platform Events in Package Uninstall When uninstalling a package with the option Save a copy of this package's data for 48 hours after uninstall enabled, platform events aren’t exported. Event Volume in Package Installations and Upgrades Installing a managed or unmanaged package that contains a standard-volume platform event causes the event type to be saved as high volume in the subscriber org. Upgrading a managed package doesn't change the event volume in the subscriber org.
471 Extend Salesforce with Clicks, Not Code Manage Your Domains
No Support in Professional and Group Editions Platform events aren’t supported in Professional and Group Edition orgs. Installation of a package that contains platform event objects fails in those orgs.
SEE ALSO: Platform Events Developer Guide
Manage Your Domains
You can configure domains and their site associations to suit your organization’s unique needs. For EDITIONS example, you can set up a single domain to host your Experience Cloud, Lightning Platform, and Site.com sites. Or perhaps you want a single site on more than one domain. Available in: both Salesforce Sites and domains can have a many-to-many relationship. Each domain can have up to 200 sites, Classic and Lightning and each site can be associated with up to 500 domains. Each Experience Cloud site has two sites. Experience Hosting your Experience Cloud, Lightning Platform, and Site.com sites on one domain can simplify Available in: Professional, your domain requirements. For Site.com sites, consider hosting them on the same domain as your Enterprise, Performance, Salesforce Sites because you can access Visualforce pages and access Apex code more easily. and Unlimited Editions There are also reasons why you would have a site on more than one domain. For example, let’s say you have a parent company with two distinct brands. Each brand has its own registered domain, USER PERMISSIONS but you want them both to point to the parent website. Because you can have a site exist on more than one domain, you can point both brand domains to a single parent website. To manage domains: To host one or more sites on a domain, you must set up custom URLs for each site. Custom URLs • You must have Site.com, uniquely distinguish the sites within that domain. Let’s say you have a domain called Salesforce Sites, or Experience Cloud Sites www.ourdomain.com and you want to host two sites called siteone and sitetwo. You enabled. create custom URLs by associating ourdomain.com to each site using a custom path. This results in two custom URLs: http://www.ourdomain.com/siteone and http://www.ourdomain.com/sitetwo. When web users access the domain using one of the URLs, the custom path determines which site within the domain they see.
Add a Domain Add a domain and choose how it’s going to be served. Options to Serve a Custom Domain Salesforce supports multiple options to configure how your domain is served. Whether you serve content for your domain through one of Salesforce’s content delivery networks (CDNs), or an external provider, we strongly recommend using HTTPS. Enable External HTTPS on a Domain Enabling External HTTPS lets you tell Salesforce that a non-Salesforce host or service serves your domain. Use this option if you route your domain through your own server or content delivery network (CDN) account instead of routing it through Salesforce. Naked Domains A naked domain is a domain name server (DNS) name that can’t be a canonical name record (CNAME). An example is hello.com, without the “www” subdomain. You can set up a naked domain in a Salesforce org, but it can require work on your part to maintain and optimize it. Add a Custom URL Define your domain and site relationships by creating custom URLs, which consist of domains and custom path prefixes.
472 Extend Salesforce with Clicks, Not Code Add a Domain
Manage Domains and Custom URLs You can add a custom URL to an existing domain, rename a domain, update its HTTPS service option, activate changes to a domain, or delete a custom URL from a particular domain. Test Your Custom Domains in a Sandbox Develop and test your custom domains for Salesforce Sites and Experience Cloud sites within a sandbox before deploying them to production. Delete a Domain You can delete domains from your org, but you can’t delete a domain that is attached to a published site. Deleting Custom URLs You can delete custom URLs from your organization using the Domain Management page.
Add a Domain
Add a domain and choose how it’s going to be served. EDITIONS Before you add a domain in your org, we recommend evaluating the available domain configuration options. Available in: both Salesforce Classic and Lightning 1. From Setup, enter Domains in the Quick Find box, then select Domains. Experience 2. Click Add a Domain. Available in: Professional, 3. Enter the domain name. Enterprise, Performance, 4. Choose the HTTPS domain configuration option you want to serve this domain with. Optionally, and Unlimited Editions specify a CNAME value if you’re using a non-Salesforce provider to serve your domain.
Note: In Professional Edition orgs with Pardot, you must choose Salesforce serves the USER PERMISSIONS domain over HTTPS using a Salesforce content delivery network (CDN) partner. To view a domain: 5. To avoid vulnerabilities during HTTP redirects and to have supported web browsers always use • View Setup and secure HTTPS connections for your domain, select Allow HSTS preloading registration. This Configuration setting adds the preload directive to the HSTS header. After you enable this setting, you To add a domain: must submit your domain at https://hstspreload.org. • Customize Application OR View Setup and Note: This setting applies only to domains that are eligible for HSTS preloading. Domain Configuration plus either names can consist of a public suffix plus one additional label, For example, a Site.com Publisher example.com and example.co.uk are eligible, but www.example.com, license or Create and Set www.example.co.uk, and sub.example.com aren’t eligible. Up Experiences To edit or delete a domain: 6. Add a certificate if you have already set up a CA-signed certificate that supports this domain. • Customize Application 7. Click Save. To add another domain, click Save & New. Salesforce validates ownership based on the fully qualified domain name (FQDN) you use when adding a domain to your org. Salesforce has three different ways to validate an FQDN using the domain name system (DNS). Only one method is required to add the domain to your org. You can find the 18-character org ID at the top of the Domain Edit page. • Your FQDN in DNS is a canonical name (CNAME) record that points to [YourFQDN].[Your18charOrgId].live.siteforce.com. – For example, let’s say you’re adding www.example.com to your org and your 18-character org ID is 00dxx0000001ggceai. The CNAME record in DNS points to www.example.com.00dxx0000001ggceai.live.siteforce.com. – Your domain name must be a CNAME record for Salesforce to serve your domain, except for the special case of a naked domain.
473 Extend Salesforce with Clicks, Not Code Add a Domain
• Your FQDN in DNS has a TXT record that equals your 18-character org ID. – After the FQDN is added to your org, you can delete this TXT record because it’s needed only for adding the domain to your org. – This option is useful when setting up a custom domain for an FQDN that points to another service or server with A or AAAA records in DNS. This option allows the domain, its custom URLs, and its sites to be ready to take over the domain’s live service before you update your FQDN record in DNS to a CNAME pointing to [YourFQDN].[Your18charOrgId].live.siteforce.com.
• Your FQDN is a subdomain of another domain in your org. – This option is useful when setting up a custom domain for an FQDN that points to another service or server with a CNAME record in DNS. Updating the DNS CNAME to point to [YourFQDN].[Your18charOrgId].live.siteforce.com takes down the existing website until you have the domain fully set up in your org. Instead, you can add the parent domain to your org using the TXT record validation. Then add the FQDN as a subdomain, which automatically validates because it’s now a subdomain of another domain in your org. Your FQDN in DNS updates to point to [YourFQDN].[Your18charOrgId].live.siteforce.com only after you have the domain, its custom URLs, and its sites fully set up in your org. This process gives your web users a smoother transition.
With the exception of sandbox orgs, a single FQDN is meant to exist in only one org. In some circumstances, the Salesforce service allows adding an FQDN to more than one org, but that isn’t a supported capability. Before pointing your domain name’s CNAME to a new target name, ensure that the target name exists in the DNS by using dig or nslookup. The target of your CNAME depends on when you create your domain name. • To use HTTPS for domain names added before the Summer ’13 release, adjust your CNAME to point to the FQDN followed by .live.siteforce.com instead of to the org’s force.com subdomain. For example, if your pre-Summer ’13 domain is www.example.com, its CNAME target is www.example.com.live.siteforce.com instead of example.force.com. • Domain names added in Summer ’13 or earlier don’t have the 18-character org ID in the CNAME target. • Domain names added in Summer ’13 or later point to the location for setting up HTTPS in a custom domain. • Domain names added in Winter ’14 or later use a CNAME that points to the FQDN followed by your org’s 18-character ID and .live.siteforce.com. For example, if your domain name is www.example.com and your 18-character org ID is 00dxx0000001ggxeay, its CNAME target is www.example.com.00dxx0000001ggxeay.live.siteforce.com. Every custom domain that you want Salesforce to serve must exist in an org that you control. The FQDN must be a CNAME that points to its own unique [YourFQDN].[Your18charOrgId].live.siteforce.com target or alternative. Configuration errors can prevent your domain from functioning properly. For the changes to take effect, activate the domain after its provisioning status becomes Awaiting Activation. If you receive notice requiring you to enroll in CDN, activate your domain. When setting up HTTPS or renaming a domain, the domain’s live traffic doesn’t use the provisioned HTTPS option or new domain name until the domain is activated. Until activation occurs, the domain’s live traffic uses its previously provisioned HTTPS option and domain name.
Important: Salesforce is unable to serve a top-level domain, such as example.com, using the built-in CDN. We can only serve subdomains, such as www.example.com or parts.example.com. If your site needs a top-level domain served from CDN, host it on a CDN outside of Salesforce.
Note: Only orgs allowed to use the Salesforce CDN partner HTTPS option must activate changes to a domain.
SEE ALSO: Naked Domains
474 Extend Salesforce with Clicks, Not Code Options to Serve a Custom Domain
Options to Serve a Custom Domain
Salesforce supports multiple options to configure how your domain is served. Whether you serve EDITIONS content for your domain through one of Salesforce’s content delivery networks (CDNs), or an external provider, we strongly recommend using HTTPS. Available in: both Salesforce Each option represents a unique way to configure your domain. Dashed lines in the images represent Classic and Lightning DNS configurations, and solid lines represent user traffic flow through HTTP and HTTPS. Experience Salesforce serves the domain over HTTPS on Salesforce’s servers using your HTTPS Available in: Professional, certificate. Enterprise, Performance, This option requires a CA-signed certificate using Certificate and Key Management for your and Unlimited Editions domain. Use a wildcard or Subject Alternative Name certificate to support all domains hosted by sites in your org.
Note: This option is unavailable in Hyperforce orgs.
This image represents how user traffic is routed when you use Salesforce to serve your domain with your HTTPS certificate, where: 1. Your custom domain This is the custom domain you want to add to your org. You control the DNS configuration through your DNS vendor. The domain name is also referred to as the fully qualified domain name (FQDN). Point your domain to the Salesforce internal CNAME (2). 2. Salesforce’s internal CNAME When you add a custom domain to your org, Salesforce creates a CNAME for you, so you have a unique, consistent, and reliable DNS entry point to your org. The CNAME is in the format of:[YourFQDN].[Your18charOrgId].live.siteforce.com. [YourFQDN] is the name of your custom domain. [Your18charOrgId] is your unique 18-character org ID, which is found at the top of the Add Domain page. 3. Salesforce secure server This server hosts your HTTPS certificate and creates secure connections for users. 4. Salesforce content Content that Salesforce is hosting for you in Salesforce sites or Experience Cloud sites. Salesforce serves the domain over HTTPS using a Salesforce content delivery network (CDN) partner. This option allows only Experience Cloud sites to be linked to the domain. New custom domains selecting this option use a single certificate. Only one domain is displayed on the certificate. Ten single certificates are available with the purchase of an Experience Cloud license. Contact your account representative if more certificates are needed.
475 Extend Salesforce with Clicks, Not Code Options to Serve a Custom Domain
In Summer ’21 and earlier, you could choose to use a shared certificate. Shared certificates aren’t recommended. With Experience Cloud shared certificates for CDN, the certificate that your domain uses is shared with other customers. Also, the list of domains on the same certificate can change at any time and without notice.
Important: Professional Edition orgs with Pardot must use this option when serving a custom domain.
This image represents how Salesforce routes traffic for a custom domain over a partner CDN network, where: 1. Your custom domain that points to the Salesforce internal CNAME. 2. Salesforce’s internal CNAME that points to the Salesforce CDN partner 3. Salesforce’s content delivery network partner (CDN) User traffic is pointed to the CDN partner, which acts as an intermediary for your Salesforce content. 4. Salesforce content on Experience Cloud sites.
Note: If you enable the Experience Cloud CDN feature, this domain uses Akamai, a third-party CDN service, to optimize its content delivery. All information sent to or returned by this domain, which includes data submitted to the domain, web page content returned from the domain, data tables on those pages, images, files, JavaScript code, style sheets, and static resources, are stored and transmitted by Akamai. Akamai can offer different privacy and security protections for such data than that offered by Salesforce. Salesforce isn’t responsible for the privacy and security of the data that is shared with Akamai as a result of your decision to enable this feature. A non-Salesforce host or service serves this domain over HTTPS. This option allows you to serve the domain using a non-Salesforce host or service. Specify the hostname of the external server or host so Salesforce’s CNAME can point to it.
Note: Make sure your CDN setup honors origin caching headers.
476 Extend Salesforce with Clicks, Not Code Options to Serve a Custom Domain
This diagram represents how Salesforce routes traffic when you use a non-Salesforce host or service to serve your domain, where: 1. Your custom domain that points to the Salesforce internal CNAME. 2. Salesforce’s internal CNAME that points to the non-Salesforce service provider or host. 3. Non-Salesforce host or service Typically, the third-party CDN service or your external server has a hostname (external CNAME). Specify this hostname in the external hostname field on the domain configuration page. 4. Salesforce content on Salesforce sites or Experience Cloud sites. Temporary non-HTTPS domain Salesforce serves your domain using HTTP instead of HTTPS. Attempting to use HTTPS typically displays a certificate mismatch error in the user’s web browser and users can also experience a connection timeout.
Note: As a security best practice, we recommend that you select one of the HTTPS options. However, if you’re in the process of configuring DNS or adding a subdomain whose CNAME points to another service, you can select this option. Previously, this option was named Salesforce serves the domain over HTTP without support for HTTPS access.
This diagram represents how Salesforce serves your domain and content over HTTP, where: 1. Your custom domain that points to the Salesforce internal CNAME. 2. Salesforce’s internal CNAME that points to a secure Salesforce server.
477 Extend Salesforce with Clicks, Not Code Enable External HTTPS on a Domain
3. Salesforce server, which is secure but it doesn’t host an HTTPS certificate for your custom domain. We don’t recommend using this HTTPS configuration. 4. Salesforce content on Salesforce sites or Experience Cloud sites.
Enable External HTTPS on a Domain
Enabling External HTTPS lets you tell Salesforce that a non-Salesforce host or service serves your EDITIONS domain. Use this option if you route your domain through your own server or content delivery network (CDN) account instead of routing it through Salesforce. Available in: both Salesforce Note: Before enabling External HTTPS on a domain, note these important considerations. Classic and Lightning Experience • This option is only for domains that use your own server or CDN to serve HTTPS. You can’t set the HTTPS options on domains managed by Salesforce, such as subdomains of Available in: Professional, force.com, my.salesforce-sites.com, and my.site.com. Enterprise, Performance, and Unlimited Editions • To enable a custom domain for testing in a sandbox org and enable HTTPS on it, you must create the custom domain in Salesforce production. See Test Your Custom Domains in a Sandbox.
To enable External HTTPS on a domain, click Edit from the domain list page or from a domain’s detail page, and then select A non-Salesforce host or service serves this domain over HTTPS.
Dashed lines in diagrams represent DNS configurations, and solid lines represent user traffic flow through HTTP and HTTPS. In this image: 1. Your custom domain To use External HTTPS, configure your domain's CNAME to point to the internal CNAME that Salesforce creates for your domain. Work with your DNS vendor to update your domain’s CNAME. 2. Salesforce’s internal CNAME that points to the non-Salesforce service provider or host. When you add a custom domain to your org, Salesforce creates a CNAME for you, so that you have a unique, consistent, and reliable DNS entry point to your org. The CNAME is in the format of:[YourFQDN].[Your18charOrgId].live.siteforce.com. [YourFQDN] is the name of your custom domain. [Your18charOrgId] is your unique 18-character org ID, shown at the top of the Add Domain page. 3. Non-Salesforce host or service Typically, the third-party CDN service has a unique CNAME. Specify this hostname in the external hostname field in your domain configuration. If you’re hosting the domain yourself, then specify the public hostname of your host. 4. Salesforce content on Salesforce sites or Experience Cloud sites.
478 Extend Salesforce with Clicks, Not Code Enable External HTTPS on a Domain
If the domain for which you’re enabling External HTTPS has only Site.com custom URLs unrelated to Experience Cloud sites, manually publish the affected Site.com sites via the Site.com Studio to implement the changes. If at least one Experience Cloud site or a Salesforce site exists on the same domain as a Site.com site related to an Experience Cloud site, publishing the changes to enable External HTTPS is automatic on that domain. For more ways to configure custom domains, see Options to Serve a Custom Domain.
Note: To maximize the security of connections to your domain, we recommend that you submit your HTTPS domain for HTTP Strict Transport Security (HSTS) preloading. Enable the Allow HSTS preloading registration setting, then submit your domain at https://hstspreload.org.
Caching When caching responses, your CDN must honor the Salesforce Cache-Control response header. Specifically, make sure that your CDN follows these rules when it operates as a reverse-proxy server. • Your CDN must cache responses only when public exists in the Salesforce Cache-Control response header. • If private, no-store, or no-cache exists in the Salesforce Cache-Control response header, the CDN must not cache that response. • To determine the cache duration, the CDN must use s-maxage, if present in the Salesforce Cache-Control response header. If s-maxage isn’t present, then the CDN must use max-age. The CDN must never increase the cache duration, regardless of whether it’s derived from s-maxage or max-age.
Request Configuration To use the External HTTPS option, configure your proxy or CDN service so that the requests sent to Salesforce contain the originally requested Host HTTP header. This means that your custom domain name must be used as the Host HTTP header value, which is the domain that users see in their original web browser request. When processing an incoming request without a cached response, your proxy or CDN service must forward (proxy) the request to the Salesforce Host using HTTPS while passing through the incoming request's originally requested Host HTTP header value. If enhanced domains are enabled, forward your proxy or CDN requests to these hostnames, based on your configuration.
Hyperforce Target Hostname Yes Your Salesforce Site’s my.salesforce-sites.com subdomain. • Production org example: MyDomainName.my.salesforce-sites.com • Sandbox example: MyDomainName--SandboxName.sandbox.my.salesforce-sites.com
No Your org’s instanced URL, in the format InstanceName.force.com. • Production org example: na87.force.com • Sandbox example: cs34.force.com
If enhanced domains aren’t enabled, forward your proxy or CDN requests to these hostnames, based on your configuration.
Experience Salesforce Target Hostname Cloud sites Sites Yes Yes or no Your Experience Cloud site’s force.com subdomain. • Production org example: ExperienceCloudSitesSubdomain.force.com
479 Extend Salesforce with Clicks, Not Code Enable External HTTPS on a Domain
Experience Salesforce Target Hostname Cloud sites Sites
• Sandbox example: SandboxName-ExperienceCloudSitesSubdomainName.InstanceName.force.com
No Yes Your Salesforce Site’s secure.force.com subdomain or force.com subdomain. • Production org example: SalesforceSitesSubdomain.secure.force.com • Sandbox example: SandboxName-SalesforceSitesSubdomain.InstanceName.force.com
No No Your org’s instanced URL, in the format InstanceName.force.com. • Production org example: na87.force.com • Sandbox example: cs34.force.com
Tip: You can find your org’s instance name on the Company Information page in Setup.
As an example, let’s say you have a custom domain of www.example.com, which is served by an external host or CDN. When a web browser requests https://www.example.com/hello/world, your external host sends the request to Salesforce at https://MyDomainName.my.salesforce-sites.com/hello/world, while setting the Host header to www.example.com. Salesforce then processes the request at MyDomainName.my.salesforce-sites.com as a request for www.example.com with a path of /hello/world. If the Host header isn’t set to a known custom domain, such as if it's set to www.unknown-domain.com, then Salesforce doesn’t process the request properly.
SEE ALSO: Manage Domains and Custom URLs Manage Your Domains
480 Extend Salesforce with Clicks, Not Code Naked Domains
Naked Domains
A naked domain is a domain name server (DNS) name that can’t be a canonical name record EDITIONS (CNAME). An example is hello.com, without the “www” subdomain. You can set up a naked domain in a Salesforce org, but it can require work on your part to maintain and optimize it. Available in: both Salesforce You can’t set a CNAME record on a naked domain because of a DNS limitation. This limitation creates Classic and Lightning complications because normally you would configure your domain’s CNAME to point to your Experience internal Salesforce CNAME, Available in: Professional, [YourFQDN].[Your18CharOrgId].live.siteforce.com. Enterprise, Performance, To bypass this limitation, a few DNS vendors have implemented a CNAME behavior for naked and Unlimited Editions domains to mimic the standard CNAME behavior. If you want to use naked domains, we recommend that you use a DNS vendor that supports this workaround. It makes it easier to maintain your USER PERMISSIONS domain’s DNS configuration by eliminating the need to dynamically monitor and update your naked domain's “A” records. It also avoids unexpected downtime events related to certificate updates To view a domain: or infrastructure adjustments. Plus, this behavior allows each end user around the world to get • View Setup and directed automatically to an IP address that is geographically closest. Configuration This workaround is a relatively new feature. The industry hasn’t agreed what to call it yet, so each To add a domain: vendor has their own proprietary name for it. Here are some examples of vendors that provide this • Customize Application CNAME behavior for naked domains and how they refer to it. OR View Setup and Configuration plus either • Akamai: Zone Apex Mapping a Site.com Publisher • Amazon Route 53: Alias record license or Create and Set Up Experiences • Cloudflare: CNAME Flattening To edit or delete a domain: • Dyn: Alias record • Customize Application • NS1: ALIAS record • UltraDns: Apex Alias There are two different techniques for configuring naked domains based on the functionality provided by your DNS provider.
My DNS Provider Supports CNAME Behavior for Naked Domains If your DNS provider supports bypassing the DNS limitation, use their DNS configuration system to point your naked domain to your domain’s internal Salesforce CNAME. Use the format [YourFQDN].[Your18CharOrgId].live.siteforce.com.
My DNS Vendor Doesn’t Support CNAME Behavior for Naked Domains If your DNS vendor doesn’t support bypassing the DNS limitation, you must add “A” records for the fully qualified domain name (FQDN) to your DNS. You must also comply with the following requirements. • To add the naked domain to your Salesforce org as a custom domain, you must add a TXT record that contains the 18-character org ID to your DNS. • To use HTTPS with a naked domain, use one of the following options: Salesforce serves the domain over HTTPS, on Salesforce's servers, using your HTTPS certificate or A non-Salesforce host or service serves this domain over HTTPS. – If you use the Salesforce serves the domain over HTTPS, on Salesforce's servers, using your HTTPS certificate option, the IP addresses that you can use in “A” DNS records are enumerated in the Certificate IP Addresses related list on the domain’s certificate. If you change the domain to use another certificate, the IP addresses aren’t the same IP addresses that the previous certificate used.
481 Extend Salesforce with Clicks, Not Code Add a Custom URL
– Although the IP addresses of a certificate typically don’t change, they can change when Salesforce adjusts the infrastructure that handles custom HTTPS domains. Periodically monitor the list of IP addresses associated with your certificate and modify your DNS “A” records to stay synchronized with that list. – If you return all the IP addresses of a certificate during DNS lookups, some users of your naked domain probably don’t connect to their closest endpoint. Some DNS services support setting up a global server load balancer (GSLB) configuration with these IP addresses. A GSLB can maximize the performance of your naked domain around the world. If the GSLB includes monitoring, that can prevent or minimize regional outages when the active Salesforce endpoints serving your certificate go down, whether scheduled or unscheduled.
• If your naked domain doesn’t use HTTPS, you can use the IP addresses that your org’s Salesforce Sites MyDomainName.my.salesforce-sites.force.com DNS entry resolves to. You can also use the IP addresses that your org’s Experience Cloud sites MyDomainName.my.site.com DNS entry resolves to. These IP addresses change without notice, so monitor your website’s functionality. When changes occur, for example during maintenance, quickly update your naked domain’s DNS “A” records to the new IP addresses.
Note: If you’re not using enhanced domains, your org’s Salesforce Sites and Experience Cloud sites URLs are different. For details, see My Domain URL Formats in Salesforce Help. Except for sandbox orgs, a single FQDN is meant to exist in only one org. In some circumstances, the Salesforce service allows adding a single FQDN to more than one org, but that isn’t a supported capability.
SEE ALSO: My Domain URL Formats
Add a Custom URL
Define your domain and site relationships by creating custom URLs, which consist of domains and EDITIONS custom path prefixes. You can use the same path prefix for more than one domain, but not more than once within the Available in: both Salesforce same domain. When adding a custom URL, the first character of the path must be a slash (/) to Classic and Lightning indicate the root. You can extend the path after the slash. For example, if the domain name is Experience https://oursite.com and the path prefix is /products, the site URL is Available in: Professional, https://oursite.com/products. If you add the custom URL to the root, the URL is Enterprise, Performance, https://oursite.com. and Unlimited Editions If you want to set a preferred custom URL for authenticated pages and email that links to the Salesforce site or Experience Cloud site, select Site Primary Custom URL. This option is available USER PERMISSIONS for the root path for Lightning Platform and Experience Clouds sites, but not for Site.com sites. For Experience Cloud sites and Salesforce Sites, if you don’t select a primary URL, the first https To view custom URLs: custom URL in the site, determined alphabetically, is used for authenticated pages and email. If • View Setup and there’s no https custom URL, your Salesforce Sites domain is used. Configuration 1. From Setup, enter Custom URLs in the Quick Find box, then select Custom URLs. To add, edit, and delete custom URLs: 2. Click New Custom URL. • Customize Application 3. Enter a domain name. OR View Setup and Configuration plus either Important: Avoid entering personal information in your domain name. Instead, enter a Site.com Publisher only public information. license or Create and Set Up Experiences 4. Enter a site name.
482 Extend Salesforce with Clicks, Not Code Manage Domains and Custom URLs
5. Enter a unique path. 6. Click Save.
Example: In the Custom URLs table, even though the domain name and path are in separate columns, the URLs consist of the combination of the two.
Manage Domains and Custom URLs
You can add a custom URL to an existing domain, rename a domain, update its HTTPS service EDITIONS option, activate changes to a domain, or delete a custom URL from a particular domain. On the Domain Detail page, you can: Available in: both Salesforce Classic and Lightning • Edit the domain name, HTTPS service option, and certificate—Click Edit in the Domain Detail Experience section. • Delete the domain—Click Delete in the Domain Detail section. Available in: Professional, Enterprise, Performance, • Activate provisioned changes to the domain—Click Activate, if available, in the Domain Detail and Unlimited Editions section. • Add a custom URL—Click New Custom URL. USER PERMISSIONS • Edit a custom URL— Click Edit on a custom URL row. • Delete a custom URL— Click Del on a custom URL row. To view a domain: • View the site if it is published—Click View on a custom URL row. • View Setup and Configuration • Jump to a site—Click the site name below the site label. To add a domain: • Jump to an attached certificate—Click the certificate name next to Certificate and Key. • Customize Application • Check whether the domain has External HTTPS enabled. Only domains that don’t point to the OR View Setup and yourdomain.your18characterOrgId.live.siteforce.com CNAME target Configuration plus either have this option available. a Site.com Publisher license or Create and Set Note: You can’t edit a domain record whose name ends with .force.com, Up Experiences *.my.site.com, or *.salesforce-sites.com. To rename the domain, contact To edit or delete a domain: Salesforce Customer Support. • Customize Application To access the Domain Detail page: 1. From Setup, enter Domains in the Quick Find box, then select Domains. USER PERMISSIONS
2. In the Domain Name column, click the domain name. To view custom URLs: Note: If your domain is set to http and you edit the domain to use https instead, you • View Setup and Configuration must republish the Site.com sites that are attached to the domain and unrelated to Experience Cloud sites. To add, edit, and delete custom URLs: • Customize Application OR View Setup and Configuration plus either a Site.com Publisher license or Create and Set Up Experiences
483 Extend Salesforce with Clicks, Not Code Test Your Custom Domains in a Sandbox
Test Your Custom Domains in a Sandbox
Develop and test your custom domains for Salesforce Sites and Experience Cloud sites within a EDITIONS sandbox before deploying them to production.
Note: Government Cloud, Public Cloud, and Hyperforce orgs are currently excluded from Available in: both Salesforce Custom Domains in Sandbox. Classic (not available in all orgs) and Lightning Experience Set Up Your Sandbox Custom Domain Available in: Enterprise, Create a custom domain and use it for testing Salesforce Sites and Experience Cloud sites in Performance, Unlimited, your sandbox. and Developer Editions Activate Your Custom Domain in Production After developing and testing your custom domains for Salesforce Sites and Experience Cloud sites within a sandbox, deploy them to production. Considerations for Custom Domains in Sandboxes Review how to prevent errors when you refresh, clone, or delete a sandbox associated with a custom domain.
Set Up Your Sandbox Custom Domain
Create a custom domain and use it for testing Salesforce Sites and Experience Cloud sites in your EDITIONS sandbox.
Note: Government Cloud, Public Cloud, and Hyperforce orgs are currently excluded from Available in: both Salesforce Custom Domains in Sandbox. Classic (not available in all orgs) and Lightning Before setting up your custom domain in your sandbox, create the Salesforce Sites and Experience Experience Cloud sites that you want to access from the custom domain in your sandbox. Available in: Enterprise, 1. Create the custom domain in Salesforce production. Performance, Unlimited, a. From Setup in production, enter Domains in the Quick Find Box and select Domains. and Developer Editions b. To add a domain, click Add or, to edit an existing domain, click Edit next to the domain name. USER PERMISSIONS c. On the Domain screen, select an HTTPS option other than the Salesforce CDN. To add a domain: Note: See Enable External HTTPS on a Domain for configuration advice when selecting • View Setup and A non-Salesforce host or service that serves this domain over HTTPS as the Configuration HTTPS Option for your sandbox custom domain. To edit or delete a domain: • Customize Application d. Select your sandbox in the Associated Org field. To view custom URLs: e. Click Save. • View Setup and After you save your changes, the domain is provisioned. Once the provisioning process is Configuration complete, you receive an email and the domain status changes to Awaiting Activation. To add, edit, and delete custom URLs: 2. To finish adding your custom domain, activate the provisioned custom domain. • Customize Application a. From Setup in production, enter Domains in the Quick Find Box and select Domains. If OR View Setup and Configuration plus either the provisioning process is complete, your custom domain’s status is Awaiting Activation. a Site.com Publisher b. Click Activate next to your custom domain. license or Create and Set Up Experiences
484 Extend Salesforce with Clicks, Not Code Test Your Custom Domains in a Sandbox
3. Log in to the sandbox to finish updating the sandbox Saleforce Sites and Experience Cloud sites domains. a. From Setup in your sandbox org, enter Custom URLs in the Quick Find Box and select Custom URLs. b. Click New Custom URL. c. On the Custom URL screen, select your custom domain in the Domain field. d. Optional: specify a path in the Path field. e. Select your Salesforce Site or Experience Cloud site in the Sites field. f. Click Save.
Your custom domain is ready for testing. Once you complete your testing, you can activate the custom domain in production.
SEE ALSO: Enable External HTTPS on a Domain Setting Up Salesforce Sites Set Up an Experience Cloud Site Activate Your Custom Domain in Production
Activate Your Custom Domain in Production
After developing and testing your custom domains for Salesforce Sites and Experience Cloud sites EDITIONS within a sandbox, deploy them to production. Before activating your custom domain in production, Set Up Your Sandbox Custom Domain on Available in: both Salesforce page 484 and complete testing. Also, create the Salesforce Sites and Experience Cloud sites that Classic (not available in all you want to access from the custom domain in production. orgs) and Lightning Experience 1. Update the custom domain. a. From Setup in production, enter Domains in the Quick Find Box and select Domains. Available in: Enterprise, Performance, Unlimited, b. Select Add to add a domain or Edit to edit an existing domain. and Developer Editions c. On the Domain screen, select an HTTPS option other than the Salesforce CDN. d. Select your Production in the new Associated Org field. USER PERMISSIONS
e. Click Save. To add a domain: After you save your changes, the domain is provisioned. Once the provisioning process is • View Setup and complete, you receive an email and the domain status changes to Awaiting Activation. Configuration To edit or delete a domain: 2. Update your production Salesforce Sites and Experience Cloud sites domains. • Customize Application Custom URLs a. From Setup in your production org, enter in the Quick Find Box and select To view custom URLs: Custom URLs. • View Setup and b. Click New Custom URL. Configuration c. On the Custom URL screen, select your custom domain in the Domain field. To add, edit, and delete custom URLs: d. Optional: specify a path in the Path field. • Customize Application e. Select your Salesforce Site or Experience Cloud site in the Sites field. OR View Setup and Configuration plus either f. Click Save. a Site.com Publisher license or Create and Set Up Experiences
485 Extend Salesforce with Clicks, Not Code Test Your Custom Domains in a Sandbox
Note: To create Custom URLs with different paths for other Salesforce Sites and Experience Cloud sites, repeat this step.
3. Activate the provisioned custom domain. a. From Setup in production, enter Domains in the Quick Find Box and select Domains. If the provisioning process is complete, your custom domain’s status is Awaiting Activation. b. Click Activate next to your custom domain.
SEE ALSO: Setting Up Salesforce Sites Set Up an Experience Cloud Site
Considerations for Custom Domains in Sandboxes
Review how to prevent errors when you refresh, clone, or delete a sandbox associated with a custom EDITIONS domain. Available in: both Salesforce Feature Exclusions Classic (not available in all orgs) and Lightning Government Cloud, Public Cloud, and Hyperforce orgs are currently excluded from Custom Domains Experience in Sandbox. Available in: Enterprise, Performance, Unlimited, Sandbox Refreshes from Production and Developer Editions When you refresh a sandbox from its owning production Salesforce org, the custom domain remains associated with the sandbox in a provisioned but inactive state. After you activate the refreshed sandbox, log in and validate the sandbox Salesforce Sites and Experience Cloud sites domains from the Custom URLs Setup page.
Cloning a Sandbox You can create a sandbox by cloning an existing sandbox rather than using your production org as the source. When you activate a cloned sandbox, any custom domains associated with the sandbox remain associated with the inactive source sandbox. Until it’s reassociated with the cloned sandbox, any calls to the custom domain return an error. To associate your custom domain with the cloned sandbox, after the cloned sandbox is activated, log in to your production org. From the Domains Setup page, edit the custom domain and change the associated org to an org other than your sandbox. Save your changes and activate the domain. Then edit the custom domain again, and update the associated org to your sandbox. Save and activate your domain. After you reactivate the custom domain for your sandbox, log in to the sandbox and validate the sandbox Salesforce Sites and Experience Cloud sites domains from the Custom URLs Setup page.
Custom Domains Pointing to a Sandbox Experience Builder Site You must republish sandbox Experience Builder sites after refreshing or cloning a sandbox. Calls to a custom domain pointing to an Experience Builder site return an error until the site is published.
486 Extend Salesforce with Clicks, Not Code Delete a Domain
Deleting a Sandbox Before deleting a sandbox, log in to production and associate any custom domains for that sandbox with a different org. If you don’t update the domain in production, calls to the custom domain URL return an error.
SEE ALSO: Create, Clone, or Refresh a Sandbox
Delete a Domain
You can delete domains from your org, but you can’t delete a domain that is attached to a published EDITIONS site. Remove all custom URLs from the domain before you delete it. For Lightning Platform sites and Available in: both Salesforce Experience Cloud sites, the domain is deleted immediately, and users no longer have access to any Classic and Lightning site connected to that domain. For Site.com sites unrelated to Experience Cloud sites, the domain Experience remains active until you republish or unpublish the site. Available in: Professional, 1. From Setup, enter Domains in the Quick Find box, then select Domains. Enterprise, Performance, and Unlimited Editions 2. Next to the domain name, click Del. 3. Click OK. USER PERMISSIONS When you delete a domain with an unpublished site attached, it also deletes the custom URL associated with that site. To delete domains: • Customize Application SEE ALSO: Manage Your Domains
487 Extend Salesforce with Clicks, Not Code Deleting Custom URLs
Deleting Custom URLs
You can delete custom URLs from your organization using the Domain Management page. EDITIONS You can’t delete a URL that is attached to a published site. You’ll need to unpublish the site attached to the custom URL before you can delete it. For Lightning Platform sites, the URL is deleted Available in: both Salesforce immediately, and users no longer have access to any site connected to that URL. But with Site.com Classic and Lightning sites, the URL remains active until you republish the site. Experience To delete a URL from a domain: Available in: Professional, 1. From Setup, enter Custom URLs in the Quick Find box, then select Custom URLs. Enterprise, Performance, and Unlimited Editions 2. Click Del next to the URL name.
3. Click OK. USER PERMISSIONS
SEE ALSO: To view custom URLs: • View Setup and Manage Your Domains Configuration To add, edit, and delete custom URLs: • Customize Application OR View Setup and Configuration plus either a Site.com Publisher license or Create and Set Up Experiences
Build Your Own Web Site
You can use Experience Builder or Salesforce Sites to build out your Salesforce organization with custom pages and apps.
Site.com Site.com is a web content management system (CMS) that makes it easy to build dynamic, data-driven web pages quickly, edit content in real time, and manage your websites. Salesforce Sites Salesforce Sites enables you to create public websites and applications that are directly integrated with your Salesforce organization—without requiring users to log in with a username and password. You can publicly expose any information stored in your organization through a branded URL of your choice. And you can make the site's pages match the look and feel of your company’s brand.
488 Extend Salesforce with Clicks, Not Code Site.com
Site.com
Site.com is a web content management system (CMS) that makes it easy to build dynamic, EDITIONS data-driven web pages quickly, edit content in real time, and manage your websites.
Note: If you’re a new customer who’d like to create a site, portal, or community, Communities Available in: Salesforce are a great way to share information and collaborate with people outside your company, Classic (not available in all such as customers, partners, or employees. See Set Up and Manage Experience Cloud Sites orgs) to learn more. Available for purchase in: From the Site.com tab in the Site.com app, you can launch Site.com Studio, which provides a Enterprise, Performance, separate, dedicated environment for creating and editing pixel-perfect, custom websites. Site and Unlimited Editions administrators and designers can create and style web pages, and add features such as navigation Available (with limitations) menus, images, and text areas using drag-and-drop page elements, while ensuring the site's pages in: Developer Edition match the look and feel of the company's brand. And content contributors, such as marketing users, can browse and update website content directly in a simplified Site.com Studio environment. Additionally, websites built with Site.com benefit from running on Salesforce’s trusted global infrastructure.
Note: The features available in Site.com Studio vary depending on whether you're a site administrator, designer, or contributor.
The following examples illustrate a few ways to use Site.com: • Create an event site—Advertise upcoming events, such as grand openings, launches, or sales kick-offs on a public event site. • Promote new products—Launch new products into the market with a promotional website that helps drive sales. • Publish a support FAQ—Provide helpful information on a public website where customers can view solutions to their issues. • Create microsites and landing pages—Create temporary landing pages or targeted microsites for marketing campaigns. • Create a recruiting website—Post job openings to a public site and allow visitors to submit applications and resumes. • Publish a catalog of products—List all of your company's products on a public website, with model numbers and current prices pulled dynamically from your organization. • Post company press releases—Publish your company’s press releases and sort by publication date.
System Requirements To use Site.com Studio, we recommend: • Mozilla® Firefox® or Google® Chrome for best performance.
Note: Microsoft® Edge is supported, but it is strongly recommended that you do not use Internet Explorer®.
• Disabling the Firebug extension for Firefox, if installed, as it can impact performance. • A minimum browser resolution of 1024x768.
About Site.com Feature Licenses Planning and Implementing a Site.com Website Create a Site.com Community Creating a Site.com Site Importing and Managing Assets Editing Site.com Pages as a Designer or Site Administrator Site.com Page Elements
489 Extend Salesforce with Clicks, Not Code Site.com
Setting Up the Contributor’s Studio View Control what your contributors can do in Site.com Studio. Cascading Style Sheets Overview Site Branding Overview Branding provides a flexible way for you to define different aspects of your website’s brand. Once branding properties are defined, your editors can easily customize everything in one centralized place, the Branding Editor. When your website editors customize the properties, they get a preview of their branding changes immediately. Custom Site Properties Overview With custom site properties, you can define and store frequently occurring content on your site. For example, you can store your address and phone number as a custom property so that it can be reused by anyone who is editing your site. You can apply stored properties to pages, headers and footers, and widgets quickly by using expression language syntax. Site.com Data Services Overview Site.com data services combine many features that let you connect to standard and custom Salesforce objects. Retrieve data from your organization’s objects and dynamically display it on your site pages, or alternatively, gather and submit data from your customers. And when you update data in your Salesforce object, the changes are reflected automatically on the live site—no site updates required! Widgets Overview Widgets let you save time by building custom page elements that you and your team can reuse throughout the site. Multilingual Sites Overview Site.com Studio lets you to create different language versions of your site. And because all languages are maintained within the site, you don’t need to create and manage a separate site for each language. Content Lists and Categories Overview Events Overview Understanding the Contributor’s Page Editing View Previewing How Pages Appear on Mobile Devices With live mode, site administrators, designers, and contributors can preview how pages and templates appear on devices such as cell phones and tablets. Previewing Site.com Sites Site.comIP Restrictions Overview Managing Domains in Site.com Before you can publish your site to the Internet, you must set the site's domain information.
SEE ALSO: Setting Up Site.com Users Planning and Implementing a Site.com Website Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor
490 Extend Salesforce with Clicks, Not Code Site.com
About Site.com Feature Licenses
To access Site.com, each user in your organization must have a Site.com feature license. EDITIONS • The Site.com Publisher feature license allows the user to access Site.com Studio to create and style websites, control the layout and functionality of pages and page elements, and add and Available in: Salesforce edit content. Classic (not available in all • The Site.com Contributor feature license allows the user to access Site.com Studio to edit site orgs) content only. Available for purchase in: Consider what your users need to do in a site and purchase feature licenses accordingly. See the Enterprise, Performance, Site.com feature table for a complete list of the capabilities that come with each feature license. and Unlimited Editions After you purchase feature licenses, you can set up Site.com users. Available (with limitations) in: Developer Edition You can view the number of assigned feature licenses on your organization's profile.
Note: Organizations using Performance, Unlimited, or Enterprise Editions must purchase Site.com Publisher and Site.com Contributor feature licenses separately. Additionally, a Site.com Published Site license is required for each site that’s published to the Internet. For information on purchasing Site.com licenses, contact Salesforce. Developer Edition organizations contain two Site.com Publisher feature licenses and one Site.com Contributor feature license. Developer Edition organizations can’t publish sites. Communities users with the “Create and Set Up Communities” permission are assigned the role of site administrator in a community’s Site.com site. To let users who don’t have this permission edit the site, you must purchase and assign a Site.com Publisher or a Site.com Contributor feature license. Then you must assign a user role at the site level.
Setting Up Site.com Users About Site.com User Roles Managing Site.com Users and Roles About Site.com Features
SEE ALSO: About Site.com User Roles Managing Site.com Users and Roles
491 Extend Salesforce with Clicks, Not Code Site.com
Setting Up Site.com Users
Before users can access Site.com, you must allocate a Site.com feature license to each user and EDITIONS assign a user role at the site level. The features available when editing a site in Site.com Studio vary depending on these settings. Available in: Salesforce First, review the Site.com feature table for detailed information on the feature license, permissions, Classic (not available in all and role required for each user. orgs) After you’ve determined the appropriate access level required: Available for purchase in: 1. Allocate a feature license to the user by editing the user’s profile. To allocate: Enterprise, Performance, and Unlimited Editions • A Site.com Publisher feature license, select the Site.com Publisher User Available (with limitations) checkbox. in: Developer Edition • A Site.com Contributor feature license, select the Site.com Contributor User checkbox. After you allocate a feature license, users can access Site.com in the Lightning Platform app USER PERMISSIONS menu in the Salesforce header. To create or edit users: Note: If the checkboxes don't appear, verify that Site.com is enabled for your organization. • Manage Internal Users See About Site.com Feature Licenses on page 491.
2. Ensure the “View Setup and Configuration” permission is enabled. All users who create or edit websites in Site.com Studio need this permission. 3. Additionally, ensure that at least one user in your organization has both a Site.com feature license and the “Manage Users” permission. This way, someone can always reallocate user roles if a site’s users are accidentally deleted.
Warning: The “Manage Users” permission is powerful. It allows a user to manage all other users in your organization and not just Site.com.
4. Add users and assign user roles within a site. (When a user with the Site.com Publisher feature license creates a site, the user is automatically allocated the role of site administrator at the site level.) The feature license, permissions, and user role all determine what a user can do in each site. For example, to create an administrative user who can manage all sites in your organization, assign a Publisher feature license and assign the role of site administrator at the site level. For users who need only limited access to edit site content, but no administrative access, assign a Contributor feature license and a contributor role at the site level. Alternatively, to create a user who can manage roles in a site, but without the ability to publish, assign a Publisher feature license, the “Manage Users” permission, and the designer role at the site level.
Note: Any records created by unauthenticated guest users via a Site.com Site has the Site Guest User as the record's owner. Each site has one Site Guest User.
SEE ALSO: About Site.com User Roles
492 Extend Salesforce with Clicks, Not Code Site.com
About Site.com User Roles
Each Site.com user must have a user role assigned at the site level, which controls what each user EDITIONS can do in a site. Users can have only one role per site, but their roles can vary between sites. For example, a person can be a site administrator on one site and a contributor on another. Available in: Salesforce To manage user roles in a site, you must either be the site administrator for that site, or have a Classic (not available in all Site.com feature license and the “Manage Users” permission. orgs)
Note: Users with the “Create and Set Up Experiences” permission are assigned the role of Available for purchase in: site administrator in a community’s Site.com site. However, they don’t appear in the User Enterprise, Performance, Roles section on the Overview tab of Site.com Studio. and Unlimited Editions Users can have one of three roles at the site level: Available (with limitations) in: Developer Edition • Site administrator—Site administrators are users who can create and manage all site content. They can create sites, templates, style sheets, and pages, and also set up domains, publish sites, and assign user roles. This role requires the Site.com Publisher feature license. • Designer—Designers have the same control over site content as site administrators, but they can’t manage domains or publish sites. By default, they can’t assign roles unless they have the “Manage Users” permission. This role requires the Site.com Publisher feature license. • Contributor—Contributors have the most restricted access to content and can typically just edit page text and images. By default, they can’t assign roles unless they have the “Manage Users” permission. This role requires the Site.com Contributor feature license. See the Site.com feature table on page 495 for a detailed list each user role’s capabilities.
SEE ALSO: Managing Site.com Users and Roles Setting Up Site.com Users Setting Up the Contributor’s Studio View About Site.com Feature Licenses
493 Extend Salesforce with Clicks, Not Code Site.com
Managing Site.com Users and Roles
After you create a site, you can add other users and assign roles to them. If you haven’t assigned EDITIONS Site.com feature licenses to your users, you won’t be able to add them to a site.
Note: Communities users with the “Create and Set Up Communities” permission are assigned Available in: Salesforce the role of site administrator in a community’s Site.com site. However, they don’t appear in Classic (not available in all the User Roles section on the Overview tab of Site.com Studio. orgs) When assigning a user role, be sure to add one that’s compatible with the user’s Site.com license. Available for purchase in: When users log into Site.com, their licenses are checked against the role assigned to them at the Enterprise, Performance, site level. If the license doesn’t allow the permissions associated with the role, then the user is given and Unlimited Editions the permissions associated with the license. For example, if a user has a Site.com Contributor feature Available (with limitations) license, but is assigned a role of site administrator, they will only have Contributor permissions in: Developer Edition regardless of the assigned role.
To add users and assign roles: USER PERMISSIONS 1. On the Overview tab in Site.com Studio, click Site Configuration > User Roles. To manage Site.com users: 2. Click Add Users. • Site.com 3. In the Available Users section, highlight the user you want to add. Publisher User field enabled on the user 4. Select the role from the Add as drop-down list. detail page 5. Click the arrow to move the user to the Selected Users section. AND 6. Click Save. Site administrator role To delete users: assigned at the site level 1. In the User Roles view, select the user. 2. Click > Remove. 3. Click OK. To change a user’s role: 1. In the User Roles view, hover over the user’s role. 2. Click the arrow to display all the roles. 3. Select the new role. To delete or change the role of a group of users at the same time, use Bulk Actions. 1. In the User Roles view, select the check box beside each user’s name. 2. Click Bulk Actions. 3. Select the action. 4. Click Apply.
494 Extend Salesforce with Clicks, Not Code Site.com
Note: When updating the roles of several users at once, you can only assign the same role to all selected users.
SEE ALSO: Setting Up Site.com Users Setting Up the Contributor’s Studio View Planning and Implementing a Site.com Website About Site.com Features
About Site.com Features
The features available when editing a site in Site.com Studio vary depending on your Site.com EDITIONS feature license and also your user role for that particular site. This table lists the required feature licenses, permissions, and roles for many of the Site.com Studio Available in: Salesforce features. Classic (not available in all orgs) Note: Available for purchase in: • Communities users with the “Create and Set Up Communities” permission are assigned Enterprise, Performance, the role of site administrator in a community’s Site.com site. and Unlimited Editions • You can’t create, delete, or duplicate community sites in Site.com. Available (with limitations) in: Developer Edition Site.com Studio Feature Requirements Feature Feature Site.com Studio User Permissions License Role Assign feature license to user “Manage Internal profile Users”
Add users and roles at the site Publisher Site administrator Additionally, any level user with a Site.com feature license and the “Manage Users” permission.
Enable contributors to create Publisher Site administrator or pages, add content blocks and designer widgets, and edit content blocks and graphics
Create websites Publisher Users who create a site are automatically added to that site as a site administrator.
Delete websites Publisher Site administrator or designer
Import websites Publisher Users who import a site are automatically added to the
495 Extend Salesforce with Clicks, Not Code Site.com
Site.com Studio Feature Requirements Feature Feature License Site.com Studio User Role Permissions new site as a site administrator.
Export websites Publisher Site administrator or designer
Duplicate websites Publisher Site administrator or designer
Manage domains Publisher Site administrator (Unavailable for Developer Edition)
Add and edit IP restrictions Publisher Site administrator
Publish changes to the live website Publisher Site administrator (Unavailable for Developer Edition)
Create page templates Publisher Site administrator or designer
Create website pages Publisher or Site administrator or designer Contributor Contributor only if enabled by the site administrator or designer in the page template’s Properties pane.
Create and modify style sheets Publisher Site administrator or designer
Modify layout and design Publisher Site administrator or designer
Add page elements Publisher or Site administrator or designer Contributor Contributor can add content blocks and widgets only if enabled by the site administrator or designer.
Add data repeaters and other data-bound page Publisher Site administrator or designer elements
Modify the Guest User profile to set public Publisher Site administrator or designer “Manage Profiles and access permissions to Salesforce objects Permission Sets” and “Customize Application”
Import assets, such as images and files Publisher or Any assigned role Contributor
Edit content and images Publisher or Site administrator or designer Contributor Contributor only if enabled by the site administrator or designer in the page template’s Properties pane.
Preview website pages Publisher or Any assigned role Contributor
496 Extend Salesforce with Clicks, Not Code Site.com
Planning and Implementing a Site.com Website
There are many approaches to building a website. The process that best suits you depends on many EDITIONS factors, such as the size of your team and the tasks you're responsible for. If you're a site administrator or designer, you may be involved in every stage, including adding and Available in: Salesforce maintaining the site's content. Alternatively, you may have contributors who add, edit, and maintain Classic (not available in all this content. And if you're a contributor, you may be responsible for editing and updating all of the orgs) site's content, or you may work with other contributors, designers, and site administrators to bring Available for purchase in: the site to completion. Enterprise, Performance, This topic describes the various stages involved in creating a site with Site.com. and Unlimited Editions • Plan the Site Design and Page Layout (Site administrator or designer)—Before building the Available (with limitations) pages of the site, spend time planning the site design and basic layout. This stage is key to in: Developer Edition ensuring a consistent look and feel with the minimum amount of effort. From a hierarchical point of view, think about how many pages you need and whether they'll have subpages. Also consider how you want site visitors to navigate around your site. USER PERMISSIONS Next, plan the layout of the pages and identify the common elements that every page will have. To create or import Site.com In this example, the site has a header section that includes the company's logo and menu (1), sites: and a footer section (2). However, the main section of the home page (3) differs from the rest • Site.com of the site pages (4). Take note of these similarities and differences, because they will affect Publisher User how you create your site pages. field enabled on the user detail page To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
To edit only content in Site.com sites: • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level
497 Extend Salesforce with Clicks, Not Code Site.com
• Create the Site (Site administrator or designer)—Once you've completed the planning stage, you're ready to get started! Log into the Site.com app and go to the Site.com tab, where you can create your first site. Your new blank site opens in Site.com Studio, a powerful environment for building the pages of your site.
Note: Only users with the Site.com Publisher User field enabled on their user detail page can create and import sites.
• Import Assets (Site administrator or designer)—If you're working with a design agency, they may provide all of the files and assets you need, including a CSS style sheet. If you've created your own design, cut up the design and collect the assets, images, and files you plan to use in the site. Import the assets into Site.com Studio, where they appear in the Assets section of the Overview tab. • Create a Page Template (Site administrator or designer)—Once you've decided on the layout, the quickest and most effective method is to use page templates to build the basic layout and then base your site pages on it. Try to keep the design of your main page template simple to make it easier to modify in the future. For more complicated site designs, such as the example graphic, you can use the main page template as the basis for a child template to achieve maximum flexibility. When you create your page template, you can choose from predesigned layouts that include headers, footers, and columns, or you can create a blank page template. • Lay Out the Page (Site administrator or designer)—After you create the page template, you can modify the layout further to match the design of your site. • Create the Site Pages (Site administrator or designer)—Using the template as a base, you can quickly create the site pages, which automatically inherit all the elements of the page template. Or if you need a standalone page that doesn't follow the site's overall design, you can create a blank page instead. • Add Features and Page Elements (Site administrator or designer)—Use Site.com's prebuilt page elements to add features such as navigation menus, images, and data services, and include content blocks that contributors can edit. And add interactive, animated effects using events and actions. • Make Your Website Look Good (Site administrator or designer)—Take advantage of cascading style sheets (CSS) to develop the look and feel of your website. If you're not completely up to speed with CSS, the Style pane provides an easy, visual way to create and manage styles. Or if you're a CSS expert who likes to get straight into the code, you can hand-code the site's style sheets. • Add and Edit Content (Contributor)—At this stage, if you're a contributor, the site is usually ready for you to add and edit content such as text, images, videos, and hyperlinks. And as you work, you can upload any images or files you need. • Review and Test the Site (Contributor, designer, or site administrator)—Testing the changes to the pages of your site happens throughout the development cycle. As a contributor, designer, or site administrator, you should always preview your changes to ensure they display as expected in a browser. And if you're a site administrator or designer, you can send a preview link to the site's reviewers so they can review the finished product before it goes live. • Publish the Site (Site administrator only)—After testing is complete, you're ready to go live with your new site. Just set the site's domain information and then publish your changes to make your site live!
Site.com Tab Overview
498 Extend Salesforce with Clicks, Not Code Site.com
Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor Understanding the Site Administrator and Designer's Overview Tab Understanding the Contributors's Overview Tab
SEE ALSO: Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor Setting Up the Contributor’s Studio View
499 Extend Salesforce with Clicks, Not Code Site.com
Site.com Tab Overview
If you can't see the Site.com tab, go to the Site.com app. It's available in the Lightning Platform app EDITIONS menu in the Salesforce header. Then click the Site.com tab to view the list of your Site.com sites. From this page you can: Available in: Salesforce • Click New to create or import a site. Only users with the Site.com Publisher User Classic (not available in all field enabled on their user detail page can create and import sites. orgs) • Filter the sites you see by selecting a predefined list from the drop-down list. My Sites shows Available for purchase in: the sites you can access and your role. All Sites shows all the sites in your organization even if Enterprise, Performance, you don’t have access to some of them. and Unlimited Editions • Click Edit next to a site to open it in Site.com Studio. Available (with limitations) • Click Preview next to a site to see how it looks when rendered in a browser window. in: Developer Edition • Click next to a site to duplicate, export, or delete it. Only users with the Site.com Publisher User field enabled on their user detail page and the role of site administrator USER PERMISSIONS or designer can duplicate, export, and delete sites. If a site has been published, you can't delete it until you take it offline. To create or import Site.com • See the status of your site. sites: • Site.com – In Development—The site has never been published. Publisher User – Published—The site has been published at least once. field enabled on the user detail page • Click the title of any column to sort your site list. By default, sites are sorted by name. To build, edit, and manage Note: You can’t create, delete, or duplicate community sites in Site.com. Site.com sites: • Site.com Publisher User SEE ALSO: field enabled on the user detail page Using Site.com Studio as a Site Administrator or Designer AND Using Site.com Studio as a Contributor Site administrator or Planning and Implementing a Site.com Website designer role assigned at the site level
To edit only content in Site.com sites: • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level
500 Extend Salesforce with Clicks, Not Code Site.com
Using Site.com Studio as a Site Administrator or Designer
Site.com Studio provides a dedicated site-building environment for site administrators and designers. EDITIONS Using the many features available, you can: • Create page templates to base your site pages on. Available in: Salesforce • Create site pages. Classic (not available in all orgs) • Import assets, such as images and files. • Edit the site’s style sheet or create new style sheets. Available for purchase in: Enterprise, Performance, • View and edit a page or template. and Unlimited Editions • Add page elements to your site pages to provide features and functionality. Available (with limitations) • Use data services to connect to Salesforce objects to retrieve and display, or to submit data. in: Developer Edition • Create custom widgets that you and other users can reuse throughout the site. • Create a multilingual site that lets site visitors choose their preferred language. USER PERMISSIONS • Create events to add interactive and animated effects to your website. • Add IP restrictions to control site visitors’ access to the pages, page templates, folders, and To build, edit, and manage sites Site.com sites: assets in your site. • Site.com • Add URL redirects to inform users and search engines if site content has moved. Publisher User • Create folders to organize your site content. field enabled on the user detail page • Preview your site or generate an anonymous preview link to send to other users. AND • Manage the domain information for your site. Site administrator or • Publish your recent changes to the live site. designer role assigned • Duplicate, import, and export sites. at the site level
Note: To manage domains and • Designers can’t manage domains or publish content. publish Site.com sites: • Site.com • You can’t create, delete, or duplicate community sites in Site.com. Publisher User field enabled on the user detail page SEE ALSO: AND Understanding the Site Administrator and Designer's Overview Tab Site administrator role Planning and Implementing a Site.com Website assigned at the site level Setting Up the Contributor’s Studio View Site.com Tab Overview
501 Extend Salesforce with Clicks, Not Code Site.com
Using Site.com Studio as a Contributor
Site.com Studio provides a dedicated content-editing environment for contributors, where you EDITIONS can: • Open a page to edit it. Available in: Salesforce • Create site pages, if your site administrator or designer has enabled page creation. Classic (not available in all orgs) • Edit the page text. • Add images and hyperlinks to pages. Available for purchase in: Enterprise, Performance, • Add page elements to pages. and Unlimited Editions • Import assets, such as images and files. Available (with limitations) • Preview the site in a browser window. in: Developer Edition
SEE ALSO: USER PERMISSIONS Understanding the Contributors's Overview Tab Planning and Implementing a Site.com Website To edit only content in Site.com sites: Site.com Tab Overview • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level
502 Extend Salesforce with Clicks, Not Code Site.com
Understanding the Site Administrator and Designer's Overview Tab
As a site administrator or designer, when you open a site in Site.com Studio, it opens on the Overview EDITIONS tab. Here you can access and manage the site’s components and configure the site’s properties. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
To manage domains and publish Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator role assigned at the site level
To manage user roles: • Site.com Publisher User field enabled on the user detail page AND Site administrator role assigned at the site level OR Manage Users
503 Extend Salesforce with Clicks, Not Code Site.com
• Select a view (1) on the Overview tab to view its contents (2). – All Site Content—Create folders to organize your site content. In this view, you can also create pages, templates, and style sheets, and import assets. – Site Pages—Create site pages, open and edit pages, access page options, create site map links, and organize the site map. You can also switch between the default site map view ( ) and the list view ( ). – Page Templates—Create page templates to base your site pages on, open and edit existing templates, and access template options. – Style Sheets—Edit the site’s style sheet or create new style sheets. – Assets—Import and manage assets, such as images and files. – Widgets—Build custom widgets that can you and your team can reuse throughout the site. – Trash Can—Retrieve deleted items. When you delete a page, template, style sheet, or asset, it goes into the trash can. Deleted items remain in the trash can indefinitely. Retrieved items are restored to their original location. If the original location no longer exists, they are restored to the top-level root directory. – Change History—View information about recently published files. – Site Configuration—Configure site properties, add IP restrictions, create URL redirects, manage domain information, manage user roles, and add and manage site languages.
• Use the toolbar (3) to: – Import assets, such as images and files. – Publish recent changes. – Preview your site or generate an anonymous preview link to send to other users. – Duplicate or export the site, overwrite the site with a version from sandbox, or create a new site ( ).
• Use the site's pull-down menu (4) to:
504 Extend Salesforce with Clicks, Not Code Site.com
– Open recently accessed sites. – View Site.com Studio as your contributors see it to ensure that you set up the view correctly. – Exit Site.com Studio and return to Salesforce. – Create a new site. – Duplicate the site.
Note: You can’t create, delete, or duplicate community sites in Site.com.
SEE ALSO: Using Site.com Studio as a Site Administrator or Designer Planning and Implementing a Site.com Website Site.com
Understanding the Contributors's Overview Tab
As a contributor, when you open a site in Site.com Studio, it opens on the Overview tab. Here you EDITIONS can access and edit the site’s pages and content, and import images and files. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To edit only content in Site.com sites: • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level
505 Extend Salesforce with Clicks, Not Code Site.com
• Select a view (1) on the Overview tab to view its contents (2). – All Site Content—View all of the site’s pages, images, and files. – Site Pages—View and edit pages or create site pages, if available. – Assets—Import assets, such as images and files. – Site Configuration—Manage user roles in the site. This is available only if you have the “Manage Users” perm.
• Use the toolbar (3) to: – Import assets, such as images and files. – Preview the site in a browser window.
• Use the site's pull-down menu (4) to: – Open recently accessed sites. – Exit Site.com Studio and return to Salesforce.
SEE ALSO: Using Site.com Studio as a Contributor Site.com
Create a Site.com Community Each community has one associated Site.com site that lets you add custom, branded pages to your community. By default, Site.com pages are publicly available and don’t require login, but you can also create private pages that only community members can access.
Note: As of Spring ’15, the Community Template is no longer available for creating communities. If you already have a Site.com community that’s based on the Community Template, it will continue to work. For information on creating a community with a new Lightning Community template, see Create an Experience Cloud Site.
506 Extend Salesforce with Clicks, Not Code Site.com
Before You Begin Communities users with the “Create and Set Up Communities” permission automatically have full site administrator access to a community’s Site.com site. To let users who don’t have the permission edit the site, you must purchase and assign a Site.com Publisher or a Site.com Contributor feature license. And then you must assign a user role at the site level. See About Site.com User Roles on page 493.
Tips and Considerations • Users with the “Create and Set Up Experiences” permission are assigned the role of site administrator in a community’s Site.com site. However, they don’t appear in the User Roles section on the Overview tab of Site.com Studio. • You can’t create, delete, or duplicate community sites in Site.com. • When working with data-bound components, such as data repeaters and forms, keep in mind that the objects listed may not be available to site visitors. For authenticated visitors, their user profiles control object access on public and private pages. For unauthenticated visitors, the site’s guest user profile controls object access on public pages. • When adding forms to authenticated community pages in Site.com, set the current user for Salesforce objects that require the Owner ID field. Setting the current user (as opposed to the default guest user) lets you identify the authenticated user when the form is submitted. To set the current user for the Owner ID field, select the field in the form, and click Configure. Under Field Properties in the Properties pane, select Global Property as the source, and select Current userID as the value. • The home page, 404 page, login page, and self-registration page that you specify for Site.com Community sites in Site Configuration set the default pages for the Site.com Community site. These default URLs are used unless you specify different URLs in Community Management under Administration Pages and Administration Login & Registration . Community error pages are specified in Lightning Platform Setup, under Error Pages. • When your Site.com Community site is inactive, users are redirected to the Service Not Available page defined in Community Management under Pages. • The contributor’s view is not available by default for Site.com Community sites. However, you can use a Site.com Contributor license to grant contributor access to a specific user. See About Feature Licenses in the Site.com help for details. Alternatively, a user can preview the Site.com Community site as a contributor by appending ?iscontrib to the site’s URL. For example: MyDomainName.builder.salesforce-experience.com/?iscontrib
Use Site.com to Customize Your Community Create Branded Pages Overview When you create a Community site, Salesforce automatically creates a new Site.com site and associates it with your community. Site.com Authorization Overview Display Current Community User Information Site.com designers creating authenticated pages for a community site can display the current user’s information by accessing CurrentUser namespace expressions. Expressions Available for Displaying Current User Information Determine the URL of a Site.com Page Add Authenticated Site.com Pages to Community Tabs After you create a private Site.com page, you can add the page to a tab in your community. Add Chatter News or Group Feeds to Community Site.com Pages Use the Chatter News Feed to display a Chatter feed on your site pages, or display the feeds of a particular group using the Chatter Group Feed.
507 Extend Salesforce with Clicks, Not Code Site.com
Improve Performance with HTML Page Caching for Communities in Site.com HTML caching lets you improve the performance and page rendering of your community’s Site.com site by controlling how often the generated markup of the page is reloaded.
SEE ALSO: Use Site.com to Customize Your Community Set Up and Manage Experience Cloud Sites
Use Site.com to Customize Your Community
Communities users can use Site.com to build custom, branded pages for a community. There are EDITIONS many approaches to building custom pages for your community, but these are some of the typical stages involved: Available in: Salesforce • Import Assets—Collect the assets, images, and files you plan to use on your custom page. Classic (not available in all Import the assets into Site.com Studio, where they appear in the Assets section of the Overview orgs) tab. Available for purchase in: • Create Branded Pages—The quickest and easiest way to create branded pages is to use the Enterprise, Performance, Community Template, which is automatically included with all Site.com community sites. When and Unlimited Editions you create a new page based on the Community Template, the page includes all of the branded Available (with limitations) styles in your community, including the community’s header and footer. If you want even more in: Developer Edition control over the look and feel of your community page, you can create your own page template, drag community headers and footers to it from the Widgets section of the Page Elements pane, and add other community styles. USER PERMISSIONS
Note: As of Spring ’15, the Community Template is no longer available for creating To build, edit, and manage communities. If you already have a Site.com that’s based on the Communities Template, a community’s Site.com it will continue to work. For information on creating a community with a new Lightning custom pages: Community template, see Create an Experience Cloud Site. • Create and Set Up Communities • Use Branded CommunityStyles—Develop the look and feel of your custom pages by using OR the CommunityBranding style sheet, or by creating branded community styles in your own cascading style sheets (CSS). If you're not completely up to speed with CSS, the Style pane Site.com Publisher User provides an easy, visual way to create and manage styles. Or if you're a CSS expert who likes to field enabled on the user get straight into the code, you can hand-code community styles right in your own style sheets. detail page • Create Public Pages—Using the template as a base, you can quickly create pages, which AND automatically inherit all the elements of the page template. Or if you need a standalone page that doesn't follow the overall design, you can create a blank page instead. Site administrator or designer role assigned • Make Pages Private—By default, any page you create in Site.com Studio is publicly available. at the site level However, you can make pages private so that only logged-in Communities users can access them. • Add Features, Page Elements, and Community Widgets—Use Site.com's prebuilt page elements to add features such as navigation menus, images, content blocks, and community widgets. Retrieve data from your organization’s objects and dynamically display it on your site pages using data repeaters and data tables. Alternatively, gather and submit data from visitors using forms. • Add and Edit Content—At this stage, the page is usually ready for you to add and edit content such as text, images, videos, and hyperlinks. And as you work, you can upload any images or files you need.
508 Extend Salesforce with Clicks, Not Code Site.com
• Review and Test the Page—Testing the changes to your page happens throughout the development cycle. You should always preview your changes to ensure they display as expected in a browser. You can also send a preview link to reviewers so they can review the finished product before it goes live. • Publish the Page—After testing is complete, you're ready to make the page available to your community by publishing your changes. • Add Authenticated Pages to Your Community’s Tab—Now that the page is tested and published, if you’re working with authenticated pages, the final step is to add the page to a tab in your community. • Use Site.com in Sandbox—Site.com is now available on sandbox. When you create a sandbox copy from a production organization, you can include your Site.com sites. You can also copy your sandbox site back to production using the overwrite feature.
SEE ALSO: Create a Site.com Community Set Up and Manage Experience Cloud Sites Brand Your Salesforce Tabs + Visualforce Site
Create Branded Pages Overview
When you create a Community site, Salesforce automatically creates a new Site.com site and EDITIONS associates it with your community. With Site.com Community sites you can: Available in: Salesforce Classic (not available in all • Use the branded Community template to create Site.com pages for your community. orgs) Note: As of Spring ’15, the Community Template is no longer available for creating Available for purchase in: communities. If you already have a Site.com that’s based on the Communities Template, Enterprise, Performance, it will continue to work. For information on creating a community with a new Lightning and Unlimited Editions Community template, see Create an Experience Cloud Site. Available (with limitations) • Use the CommunityBranding style sheet to style Site.com pages by using CSS. in: Developer Edition • Create your own community CSS styles using a number of available Network namespace expressions.
Create Branded Pages from the Community Template Site.com Community sites include a branded template that you can use to create new community site pages. Apply Community Styles from the CommunityBranding Style Sheet The CommunityBranding style sheet contains a set of CSS styles created from Network namespace expressions. Create Styles in a CSS Style Sheet Branded styles are available in Site.com sites through Network namespace expressions. Expressions Available for Community Branding View the CommunityBranding Style Sheet The CommunityBranding style sheet contains a set of branded styles from your community.
509 Extend Salesforce with Clicks, Not Code Site.com
Create Branded Pages from the Community Template
Site.com Community sites include a branded template that you can use to create new community EDITIONS site pages.
Note: As of Spring ’15, the Community Template is no longer available for creating Available in: Salesforce communities. If you already have a Site.com community that’s based on the Community Classic (not available in all Template, it will continue to work. For information on creating a community with a new orgs) Lightning Community template, see Create an Experience Cloud Site. Available for purchase in: The styles for the Community Template come from the CommunityBranding style Enterprise, Performance, sheet, which is automatically included for all new Site.com Community sites. and Unlimited Editions To create branded pages from the Community Template: Available (with limitations) in: Developer Edition 1. On the Site.com Overview tab, hover over Site Pages and click New. 2. Type the new community page name. Page names can’t include spaces or special characters, such as #, ?, or @. USER PERMISSIONS 3. Make sure Community Template is selected for the page template. To build, edit, and manage a community’s Site.com 4. Click Create. custom pages: Note: • Create and Set Up Communities • Community branding options, such as headers, footers, and page colors, are set from the OR Administration > Branding section on the Experience Management page. Site.com • Empty community headers and footers, or headers that contain only images, won’t work Publisher User in Site.com. Be sure to specify customized HTML blocks for your community headers and field enabled on the user footers if you’re creating Site.com pages from the Community Template, or creating detail page community headers and footers using Network namespace expressions. AND • Community headers and footers are available as widgets in Site.com community pages. Site administrator or To add a community header or footer to a blank page, drag it to the page from the Widgets designer role assigned section of the Page Elements pane. at the site level
SEE ALSO: Create Branded Pages Overview View the CommunityBranding Style Sheet Site.com Page Templates Overview Creating Site.com Page Templates
510 Extend Salesforce with Clicks, Not Code Site.com
Apply Community Styles from the CommunityBranding Style Sheet
The CommunityBranding style sheet contains a set of CSS styles created from Network EDITIONS namespace expressions.
Note: As of Spring ’15, the Community Template is no longer available for creating Available in: Salesforce communities. If you already have a Site.com community that’s based on the Community Classic (not available in all Template, it will continue to work. For information on creating a community with a new orgs) Lightning Community template, see Create an Experience Cloud Site. Available for purchase in: The CommunityBranding style sheet is attached to the Community Template, and is Enterprise, Performance, responsible for the template’s branded look and feel. You can access the styles in the and Unlimited Editions CommunityBranding style sheet and apply them directly to elements on any page. Available (with limitations) in: Developer Edition To apply community styles using the CommunityBranding style sheet: 1. Make sure the CommunityBranding style sheet is attached to the Site.com page you want to brand. USER PERMISSIONS
Note: All Site.com pages based on the Community Template automatically have To build, edit, and manage the CommunityBranding style sheet attached to them. a community’s Site.com custom pages: 2. Select the element on the page you want to style. • Create and Set Up 3. Open the Style pane. Communities OR 4. Select Class. Site.com 5. Start typing “brand”. Publisher User A list of all of the available styles in the CommunityBranding styles sheet appears. field enabled on the user 6. Select the style you want to apply. detail page AND SEE ALSO: Site administrator or designer role assigned Create Branded Pages Overview at the site level Create Branded Pages from the Community Template View the CommunityBranding Style Sheet Creating and Using CSS Style Sheets
511 Extend Salesforce with Clicks, Not Code Site.com
Create Styles in a CSS Style Sheet
Branded styles are available in Site.com sites through Network namespace expressions. EDITIONS You can access a full list of available Network namespace expressions to create new community styles in any CSS style sheet. When you add an expression to a CSS rule, Site.com “pulls in” the style Available in: Salesforce as it’s defined in the community, and displays it on your page. Classic (not available in all orgs) To create community styles in a CSS style sheet: 1. Open an existing style sheet or create a new style sheet. (See Creating and Using CSS Style Available for purchase in: Sheets on page 584.) Enterprise, Performance, and Unlimited Editions 2. Click Edit Style Sheet Code. Available (with limitations) 3. Add a new community style rule by using any of the available Network expressions. You can in: Developer Edition create both ID styles and class styles. For example:
USER PERMISSIONS
To build, edit, and manage a community’s Site.com custom pages: • Create and Set Up Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
#main_content_block { background-color: {!Network.primaryColor}; color: {!Network.primaryComplementColor}; } .secondary_content_blocks{ background-color: {!Network.zeronaryColor}; color: {!Network.zeronaryComplementColor}; }
4. Apply the new styles to elements on other pages.
512 Extend Salesforce with Clicks, Not Code Site.com
Note: Remember, the style sheet that contains your community styles must be attached to the page containing your styled elements.
SEE ALSO: Create Branded Pages Overview Expressions Available for Community Branding Creating and Using CSS Style Sheets
Expressions Available for Community Branding
You can use the Network namespace expressions listed on this page to create your own EDITIONS Community styles. Community branding options, such as headers, footers, and page colors, are set from the Available in: Salesforce Administration > Branding section on the Experience Management page. Classic (not available in all orgs) Note: Available for purchase in: • Empty community headers and footers, or headers that contain only images, won’t work Enterprise, Performance, in Site.com. Be sure to specify customized HTML blocks for your community headers and and Unlimited Editions footers if you’re creating Site.com pages from the Community Template, or creating community headers and footers using Network namespace expressions. Available (with limitations) in: Developer Edition • Community headers and footers are available as widgets in Site.com community pages. To add a community header or footer to a blank page, drag it to the page from the Widgets section of the Page Elements pane.
Network Expression Corresponding Community Branding Page Element {!Network.header} Custom content of the community header.
{!Network.footer} Custom content of the community footer.
{!Network.zeronaryColor} The background color for the community header.
{!Network.zeronaryComplementColor} The font color used with zeronaryColor.
{!Network.primaryColor} The color used for active tabs in the community.
{!Network.primaryComplementColor} The font color used with primaryColor.
{!Network.secondaryColor} The color used for the top border of lists and tables in the community.
{!Network.tertiaryColor} The background color for section headers on edit and detail pages in the community.
{!Network.tertiaryComplementColor} The font color used with tertiaryColor.
{!Network.quaternaryColor} The background color for pages in the community.
513 Extend Salesforce with Clicks, Not Code Site.com
Network Expression Corresponding Community Branding Page Element {!Network.quaternaryComplementColor} The font color used with quaternaryColor.
SEE ALSO: Create Branded Pages Overview Create Styles in a CSS Style Sheet
View the CommunityBranding Style Sheet
The CommunityBranding style sheet contains a set of branded styles from your community. EDITIONS Community branding options, such as headers, footers, and page colors, are set from the Administration > Branding section on the Experience Management page. Available in: Salesforce Classic (not available in all To see the Community styles in the CommunityBranding style sheet, on the Site.com Overview orgs) tab, click Style Sheets, and click the CommunityBranding style sheet. The Community styles are listed on the left. To see the code for the style sheet, click Edit Style Sheet Code. Available for purchase in: Enterprise, Performance, A total of fourteen Community class styles are provided. These are the default contents of the style and Unlimited Editions sheet: Available (with limitations) in: Developer Edition
.brandZeronaryBgr { background-color: {!Network.zeronaryColor} !important; } .brandZeronaryFgr { color: {!Network.zeronaryComplementColor} !important; } .brandPrimaryBgr { background-color: {!Network.primaryColor} !important; } .brandPrimaryFgr { color: {!Network.primaryComplementColor} !important; } .brandPrimaryBrd2 { border-color: {!Network.primaryComplementColor} !important; } .brandPrimaryFgrBrdTop { border-top-color: {!Network.primaryComplementColor} !important; } .brandPrimaryBrd { border-top-color: {!Network.primaryColor} !important; } .brandSecondaryBrd { border-color: {!Network.secondaryColor} !important; } .brandSecondaryBgr { background-color: {!Network.secondaryColor} !important; } .brandTertiaryFgr {
514 Extend Salesforce with Clicks, Not Code Site.com
color: {!Network.tertiaryComplementColor} !important; } .brandTertiaryBgr { background-color: {!Network.tertiaryColor} !important; color: {!Network.tertiaryComplementColor} !important; background-image: none !important; } .brandTertiaryBrd { border-top-color: {!Network.tertiaryColor} !important; } .brandQuaternaryFgr { color: {!Network.quaternaryComplementColor} !important; } .brandQuaternaryBgr { background-color: {!Network.quaternaryColor} !important; }
SEE ALSO: Create Branded Pages Overview Create Branded Pages from the Community Template
Site.com Authorization Overview
As part of your site design, you might want to control what content is public and private to your EDITIONS site visitors. New sites are initially set so that all site resources, such as folders and pages, are public. You can change the default setting from the Authorization view found under Site Configuration. Available in: Salesforce The global site authorization options are: Classic • No Authorization (default)—All resources are public. Available in: Enterprise, • Requires Authorization—All resources are private. Performance, Unlimited, and Developer Editions • Custom—All resources are public by default, but can be made private. The No Authorization and Requires Authorization options let you quickly make your site either all public or all private. But, if you want to control access to individual pages, folders, and other resources, use the Custom option. Selecting Custom enables a Requires Authorization checkbox on the Actions menu for all resources throughout the site. You can define authorization at the site, folder, page, and individual resource level. As you mark items for authorization, a lock icon appears on them. After a resource, like a page, is marked as private, users who aren’t logged into Salesforce are asked to log in when they try to access it. Resources can inherit their privacy setting from folders. For example, when a resource, such as a site folder, is marked for authorization, anything placed in that folder inherits the folder’s authorization setting and becomes private. If you drag that resource into a public folder, it becomes public again. But, if you explicitly mark a resource as private using the Actions menu, and then drag it into a public folder, it still remains private because the privacy setting at the resource level dominates. When you use the Custom option, an authorization table appears in the Authorization view that lets you manage your private resources/items marked as private. You can remove authorization from a resource by either deleting it from the authorization table, or by deselecting the Requires Authorization box on the item itself.
Setting Custom Authorization
515 Extend Salesforce with Clicks, Not Code Site.com
Removing Site.com Authorization
SEE ALSO: Setting Custom Authorization Removing Site.com Authorization
Setting Custom Authorization
When you select Custom authorization, you get a great deal of flexibility in controlling access to EDITIONS your site. Not only can you control who has access to top level resources, like folders and pages, but you can also set access at the individual resource level. Available in: Salesforce Using Custom authorization at the folder level is a great way to make a large number of resources Classic private without having to mark them individually. Let’s say you periodically run sale offers for your Available in: Enterprise, paid users. If you drag all the sale pages into a special folder you mark for authorization, they instantly Performance, Unlimited, inherit the folder’s setting. Users will need to log in to access them. Plus, if you decide to make one and Developer Editions of the sale pages available to everyone, you can simply drag it back into a public folder, or to the root of the All Site Content area. USER PERMISSIONS 1. Open you site for editing. 2. Click Site Configuration > Authorization. To manage authorization: • You must be an 3. Select Custom. administrative user on 4. Click All Site Content. the site 5. Create a folder to hold the private pages if it doesn’t already exist. 6. From the folder’s Actions menu, select Requires Authorization. You’ll see the lock appear on the folder. It is now private. 7. Drag any pages you want to make private into the folder. A lock appears on them too.
Example: Let’s take another example. If you have a page that you’d like to keep private no matter where it resides, you can set its authorization using the Actions menu. After you set it at the individual resource level, it remains private even if you drag it into a folder that isn’t set to private. In other words, an resource marked private is always private until you deselect Requires Authorization on the Actions menu. If you check the Authorization page, you’ll see all folders and resources marked private are listed in the authorization table where you can view and delete them.
SEE ALSO: Removing Site.com Authorization
516 Extend Salesforce with Clicks, Not Code Site.com
Removing Site.com Authorization
You can remove authorization for a resource by either deleting it from the authorization table under EDITIONS Site Configuration, or by deselecting Requires Authorization from the menu. 1. Open your site for editing. Available in: Salesforce Classic 2. Click Site Configuration > Authorization. 3. From the authorization table, click Delete next to the item you want to remove. Alternatively, Available in: Enterprise, Performance, Unlimited, navigate to the All Site Content view. Select the resource. From the Actions menu, deselect and Developer Editions Requires Authorization.
Example: If a resource is explicitly marked as private using the Actions menu, then you must USER PERMISSIONS remove authorization from it using the Actions menu. For example, if a page marked private is dragged into a folder that’s public, it remains private. Likewise, if you drag it into a folder To manage authorization: that’s already private, and remove the authorization on that folder, the page will still be private. • You must be an administrative user on the site SEE ALSO: Setting Custom Authorization
Display Current Community User Information
Site.com designers creating authenticated pages for a community site can display the current user’s EDITIONS information by accessing CurrentUser namespace expressions. 1. Open the page on which you want to display the current community user's information. Available in: Salesforce Classic (not available in all 2. From the Page Elements pane, drag a Content Block or Custom Code page element onto orgs) the page. 3. Type {!CurrentUser. and the value that you want to display. Available for purchase in: For example, {!CurrentUser.firstName}. Enterprise, Performance, and Unlimited Editions Check the list of available expressions for displaying current user information. Available (with limitations) 4. Add any additional text you require. in: Developer Edition For example, Welcome back {!CurrentUser.firstName}!. 5. If you’re in a Content Block, click Save. If you’re in a Custom Code element, click Save and USER PERMISSIONS Close. To build, edit, and manage Note: If an unauthenticated user views a page that contains CurrentUser expressions, a community’s Site.com the current user information does not appear. For example, if an unauthenticated user viewed custom pages: a page that contained the above example, the user would see “Welcome back !” as the • Create and Set Up welcome message. Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
517 Extend Salesforce with Clicks, Not Code Site.com
Expressions Available for Displaying Current User Information
Use these CurrentUser namespace expressions to display authenticated user information on EDITIONS a Site.com community page. Available in: Salesforce CurrentUser Expression Displays Classic (not available in all {!CurrentUser.name} Combined first and last name of the user, as orgs) displayed on the user detail page. Available for purchase in: Enterprise, Performance, {!CurrentUser.firstName} First name of the user, as displayed on the user and Unlimited Editions edit page. Available (with limitations) {!CurrentUser.lastName} Last name of the user, as displayed on the user in: Developer Edition edit page.
{!CurrentUser.userName} Administrative field that defines the user’s login.
{!CurrentUser.email} Email address of the user.
{!CurrentUser.communityNickname} Name used to identify the user in a community.
{!CurrentUser.accountId} The account Id associated with the user. It shows a valid account id for Partner and Customer users. For all others, it is empty '000000000000000'.
{!CurrentUser.effectiveAccountId} The account Id associated with the effective account. It shows a valid account id for Partner and Customer users. For all others, it is empty '000000000000000'.
518 Extend Salesforce with Clicks, Not Code Site.com
Determine the URL of a Site.com Page
After you create a Site.com page, you can determine the page’s URL to: EDITIONS • Provide your users with a URL that lets them access a public page directly. • Create a link to the page from other pages, including Salesforce Sites and Visualforce pages. Available in: Salesforce Classic (not available in all • Make it the home page for your community using a URL redirect in Salesforce Sites. orgs) and Lightning • Add a private page to a web tab in your community. Experience
1. To determine the correct URL for the page: Available in: Enterprise, • From the Create Community wizard, click Customize. Performance, Unlimited, and Developer Editions • If you navigated away from the Create Community wizard, click Customize > Communities > All Communities, then click the Manage button next to the community name. USER PERMISSIONS
2. Click Administration Settings. To build, edit, and manage 3. Copy the URL displayed on the page and paste it into a text editor. a community’s Site.com custom pages: 4. To create a URL that points to: • Create and Set Up • The Site.com site’s home page, append /s/ to the URL. For example, Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
https://MyDomainName.my.site.com/ExperienceCloudSiteName/s/. • A specific Site.com page, append /s/, where is the name of the Site.com page. For example, https://MyDomainName.my.site.com/ExperienceCloudSiteName/s/promotion. The URL is case-sensitive and “s” must be lowercase.
Note: If you’re not using enhanced domains, your org’s Experience Cloud sites URL is different. For details, see My Domain URL Formats in Salesforce Help.
SEE ALSO: Add Authenticated Site.com Pages to Community Tabs Salesforce Sites URL Redirects
519 Extend Salesforce with Clicks, Not Code Site.com
Add Authenticated Site.com Pages to Community Tabs
After you create a private Site.com page, you can add the page to a tab in your community. EDITIONS In this case, you need to create a Web tab that points to your Site.com page. 1. In the Properties pane for your page, select Show Salesforce Header. Available in: Salesforce Classic (not available in all Selecting this option ensures that you see tabs in your community. orgs) and Lightning 2. Enter the tab name as it should appear on the tab in your community. Experience The web tab you create must have the same name. Available in: Enterprise, Performance, Unlimited, 3. Determine the correct URL for the page. and Developer Editions The URL must be in the following format https://MyDomainName.my.site.com/mycommunity/s/, USER PERMISSIONS where pagename matches the name of your page. To build, edit, and manage Note: If you’re not using enhanced domains, your org’s Experience Cloud sites URL is a community’s Site.com different. For details, see My Domain URL Formats in Salesforce Help. custom pages: 4. From Setup, enter Tabs in the Quick Find box, then select Tabs. • Create and Set Up Communities 5. In Web Tabs, click New and enter the name of the tab as it appears in the Tab Name field in OR your page properties. Site.com 6. On the Step 3 screen, paste the URL you created in the Button or Link URL text box. Publisher User 7. Return to the Create Community wizard and add the new tab to your community. field enabled on the user detail page To preview the private page in your community, you must publish your Site.com site. AND Note: You can’t publish your site from sandbox. Site administrator or designer role assigned at the site level SEE ALSO: Set Up and Manage Experience Cloud Sites Create Web Tabs My Domain URL Formats
520 Extend Salesforce with Clicks, Not Code Site.com
Add Chatter News or Group Feeds to Community Site.com Pages
Use the Chatter News Feed to display a Chatter feed on your site pages, or display the feeds of a EDITIONS particular group using the Chatter Group Feed. 1. Drag the News Feed or Group Feed from the Widgets section of the Page Elements pane Available in: Salesforce onto the page. Classic (not available in all When you add a widget to a page, it creates a copy or instance of the widget. You can’t edit orgs) and Lightning the content of a widget, but you can edit the properties. Experience 2. If you’re adding a group feed, enter the Group ID in the Properties pane. Available in: Enterprise, The Group ID determines which group feed is displayed on your page. You can include more Performance, Unlimited, than one group feed on a page if you want to show the feeds for multiple groups. and Developer Editions
3. Preview the page to test the feed, or use Live Mode to see how the feed renders in different USER PERMISSIONS mobile devices. Consider the following limitations when using a news or group feed in your community Site.com To build, edit, and manage sites: a community’s Site.com custom pages: • Chatter news and group feeds only appear if a user is logged in to the community. They don’t • Create and Set Up appear to guest users or in anonymous preview mode. Communities • Chatter news and group feeds may not render appropriately on pages less than 700px wide. OR We recommend a minimum page width of 700px to view full content. We also recommend Site.com using a white background. Publisher User • Chatter news and group feeds only inherit some page branding elements. field enabled on the user detail page AND Site administrator or designer role assigned at the site level
521 Extend Salesforce with Clicks, Not Code Site.com
Improve Performance with HTML Page Caching for Communities in Site.com
HTML caching lets you improve the performance and page rendering of your community’s Site.com EDITIONS site by controlling how often the generated markup of the page is reloaded. Lets say 100 people visit the page at the same time. Without caching, the page makes 100 separate Available in: Salesforce requests for the same markup, slowing performance considerably. However, with caching enabled, Classic (not available in all the page markup is requested and retrieved only once—the first time someone visits the page. orgs) Any subsequent page requests during a set time period are returned from the cache. When the Available for purchase in: specified time period expires, the cache is refreshed. Enterprise, Performance, Note: The caching duration applies only to community pages that are accessed by guest and Unlimited Editions users. When a user logs in to access the page, caching is disabled. Available (with limitations) in: Developer Edition 1. In Site.com Studio, open the page. 2. In the Cache Duration (Minutes) field of the Cache section of the Properties tab, specify the length of time to cache the page. USER PERMISSIONS By default, the caching duration of a page is set to 30 minutes. To build, edit, and manage To disable caching, set the page’s caching duration to 0. a community’s Site.com custom pages: • Create and Set Up Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
522 Extend Salesforce with Clicks, Not Code Site.com
Creating a Site.com Site
To get started with Site.com, create a new blank site: EDITIONS 1. On the Site.com tab in the Site.com app, click New. Alternatively, in Site.com Studio, click Create a New Site in the site's drop-down menu. Available in: Salesforce Classic (not available in all 2. Click Create a Blank Website. orgs) 3. Enter the site name. Available for purchase in: 4. Click Create. Your new website opens in Site.com Studio, where you can create page templates Enterprise, Performance, and site pages, and add functionality to it. and Unlimited Editions Note: You can’t create, delete, or duplicate community sites in Site.com. Available (with limitations) in: Developer Edition
Deleting a Site.com Site Duplicating a Site.com Site USER PERMISSIONS Exporting a Site.com Site To create or import Site.com sites: Importing a Site.com Site • Site.com Configuring Site Properties Publisher User Enable Clickjack Protection in Site.com field enabled on the user detail page Clickjacking is a type of attack that tricks users to click something, such as a button or link, because they perceive they are clicking something safe. Instead, the button or link performs malicious actions on your site, leading to data intrusion, unauthorized emails, changed credentials, or other site-specific results. Site.com Versioning Overview Each time you publish your site, it’s tracked as a version. You can restore your site back to one of the previously published versions. You can’t select individual components when restoring; you must restore the complete site. Creating URL Redirects in Site.com If you move or reorganize pages in your site, search engines may have trouble finding the new page locations. To avoid this, set up URL redirects to inform users and search engines that site content has moved. Importing External Websites into Site.com With Site.com Studio, you can import your existing website and recreate it automatically as a Site.com site. This saves you the time of having to re-code existing HTML pages. Copying and Overwriting a Site Sometimes, you might want to copy and replace your current production Site.com or Site.com community site with another site. Using the Metadata API to Deploy a Site As a user, you can migrate a site from sandbox to production. You can use the Metadata API to create a deployable package for Site.com sites and Site.com Communities sites.
SEE ALSO: Creating Site.com Page Templates Creating Site.com Pages Editing Site.com Pages as a Designer or Site Administrator
523 Extend Salesforce with Clicks, Not Code Site.com
Deleting a Site.com Site
You can delete any site that isn’t published. If the site is published, you must first unpublish it before EDITIONS you can delete it. See Taking a Site Offline on page 669. 1. On the Site.com tab in the Site.com app, select the site and click > Delete. Available in: Salesforce Classic (not available in all 2. Click OK. orgs) Note: You can’t create, delete, or duplicate community sites in Site.com. Available for purchase in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Exporting a Site.com Site Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
524 Extend Salesforce with Clicks, Not Code Site.com
Duplicating a Site.com Site
To create a copy of a site: EDITIONS 1. On the Site.com tab in the Site.com app, select the site and click > Duplicate. Alternatively, Available in: Salesforce on the Overview tab in Site.com Studio, click > Duplicate This Site. Classic (not available in all 2. Enter a name for the site. orgs) 3. Click Create. Available for purchase in: Enterprise, Performance, Note: and Unlimited Editions • If you’re creating a copy of a site that uses data services, you must set the data access Available (with limitations) permissions in the new site’s guest user profile. in: Developer Edition • You can’t create, delete, or duplicate community sites in Site.com.
USER PERMISSIONS SEE ALSO: To build, edit, and manage Creating a Site.com Site Site.com sites: Exporting a Site.com Site • Site.com Importing a Site.com Site Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
525 Extend Salesforce with Clicks, Not Code Site.com
Exporting a Site.com Site
You can export your site from Site.com to your hard drive. The site is exported in a packaged format EDITIONS with a .site extension, which you can import into another Salesforce organization. The maximum site size you can import is 2 GB. Available in: Salesforce 1. On the Site.com tab in the Site.com application, select the site and click > Export. Classic (not available in all orgs) Alternatively, on the Overview tab in Site.com Studio, click > Export This Site. Available for purchase in: 2. If the site is: Enterprise, Performance, • Smaller than 100 MB, select a location to save the exported .site file on your hard drive and and Unlimited Editions click Save. Available (with limitations) • Larger than 100 MB, you’ll receive an email when the export process has completed. Click in: Developer Edition the link in the email to download the exported .site file.
Note: USER PERMISSIONS
• Exporting a site doesn’t remove it from the current organization. To build, edit, and manage Site.com sites: • Site.com SEE ALSO: Publisher User Creating a Site.com Site field enabled on the user detail page Importing a Site.com Site AND Site administrator or designer role assigned at the site level
Importing a Site.com Site
You can import an exported Site.com site into your organization. The maximum site size you can EDITIONS import is 2 GB. When you import a site, you are given the site administrator role in the site. 1. On the Site.com tab in the Site.com app, click New. Alternatively, in Site.com Studio, click Create Available in: Salesforce a New Site in the site's drop-down menu. Classic (not available in all orgs) 2. Select Import a Site or Template. 3. Enter the site name. Available for purchase in: Enterprise, Performance, 4. Click Browse to locate the exported site on your hard drive. Exported sites have a .site extension. and Unlimited Editions 5. Click Create. Available (with limitations) in: Developer Edition Note: • If you’re importing a site that uses data services, you must set the data access permissions in the imported site’s guest user profile. Additionally, any data repeaters, data tables, data USER PERMISSIONS functions, or forms may need to be reconfigured. To create or import Site.com sites: • Site.com Publisher User field enabled on the user detail page
526 Extend Salesforce with Clicks, Not Code Site.com
• You can’t create, delete, or duplicate community sites in Site.com.
SEE ALSO: Creating a Site.com Site Exporting a Site.com Site
Configuring Site Properties
Set properties for the site, such as the home page, site name, and error page, and create an EDITIONS anonymous preview URL that allows other users to review the site before it goes live. The URL is always valid (unless you disable it) and shows the latest work in progress. It’s only available to the Available in: Salesforce people you send it to, and can’t be found by search engines. Classic (not available in all 1. On the Overview tab, click Site Configuration. orgs) 2. Click Edit. Available for purchase in: 3. In the Site Configuration view, you can: Enterprise, Performance, and Unlimited Editions • Replace the name in the Site Name field to rename the site. Available (with limitations) • See the Developer Name of the site. This read-only field may differ from the Site in: Developer Edition Name. The Developer Name is used by the Metadata API. • Select Enable Anonymous Preview to create a URL that allows other users to preview the site before it goes live. (Click the View Anonymous Preview option that appears in USER PERMISSIONS the Preview menu to access the preview URL, which you can copy and send to other users To build, edit, and manage to review and test your changes.) Enable Anonymous Preview is also available from the Site.com sites: Preview menu on the Overview tab. • Site.com • Access the site’s guest user profile. Publisher User • Set the clickjack protection level. field enabled on the user detail page • Determine whether guest users can view features available only in Lightning. If you disable Lightning Features for Guest Users, Lightning features don’t load. AND Site administrator or • Enable Content Sniffing Protection to force the browser to use the Content-Type header designer role assigned only. at the site level • Enable Browser Cross Site Scripting Protection to protect against reflected cross-site scripting attacks. • Select Referrer URL Protection to have the referrer header shows only Salesforce.com rather than the entire URL when loading pages. • Select the home page for your website in the Home Page drop-down list. • Site.com Community sites only: – Select the login page for your Site.com Community site in the Login Page drop-down list. – Select the page that you’ve set up for Site.com Community site users who don’t have accounts yet from the Registration Page drop-down list. – Select the Forgot Password page you’ve set up for your community using Site.com.
• Select a user-friendly error page in the 404 Page drop-down list to display when a page can't be found. It's a good idea to create a user-friendly error page to assist site visitors if they encounter a broken link.
4. Click Save.
527 Extend Salesforce with Clicks, Not Code Site.com
Note: • The home page, 404 page, login page, and self-registration page that you specify for Site.com Community sites in Site Configuration set the default pages for the Site.com Community site. These default URLs are used unless you specify different URLs in Community Management under Administration Pages and Administration Login & Registration . Community error pages are specified in Lightning Platform Setup, under Error Pages. • When your Site.com Community site is inactive, users are redirected to the Service Not Available page defined in Community Management under Pages.
SEE ALSO: Creating a Site.com Site Using Site.com Studio as a Site Administrator or Designer Enable Clickjack Protection in Site.com
Enable Clickjack Protection in Site.com
Clickjacking is a type of attack that tricks users to click something, such as a button or link, because EDITIONS they perceive they are clicking something safe. Instead, the button or link performs malicious actions on your site, leading to data intrusion, unauthorized emails, changed credentials, or other site-specific Available in: Salesforce results. Classic (not available in all Hidden iframes can be placed maliciously on site pages and entice users to click a button or link orgs) that appears below the hidden iframe. With clickjack protection, you can configure whether your Available for purchase in: browser allows frames over your site pages. The default clickjack level for Site.com is set to Allow Enterprise, Performance, framing by the same origin only. and Unlimited Editions You can set the clickjack protection for a site to one of these levels: Available (with limitations) • Allow framing by any page (no protection): The least secure level. in: Developer Edition • Allow framing of site pages on external domains (good protection): Allows framing of your site pages by pages on external domains that are added to the Trusted Domains for Inline USER PERMISSIONS Frames list. • Allow framing by the same origin only (recommended): The default level for sites. Allows To build, edit, and manage framing of site pages by pages with the same domain name and protocol security. Site.com sites: • Site.com • Don’t allow framing by any page (most protection): The most secure level, but it can cause Publisher User certain pages to appear as blank pages. To avoid this issue, use the default setting instead. field enabled on the user 1. In Site.com Studio, click Site Configuration > Edit. detail page 2. Select your preferred level of clickjack protection and save your changes. AND 3. If you chose to allow framing of your site pages on your external domains, specify the domains Site administrator or designer role assigned that you want to allow. at the site level a. From Setup in Salesforce Classic, enter Sites in the Quick Find box, and then select Sites. b. Click the site label to open the Site Details page. c. Click Add Domain in the Trusted Domains for Inline Frames section and enter the domain you want to allow iframes on. You can add up to 512 domains.
Tip: Added domains take effect only when Allow framing of site pages on external domains is selected.
528 Extend Salesforce with Clicks, Not Code Site.com
Note: Internet Explorer supports clickjack protection through the legacy X-Frame-Options HTTP Header only. This header supports sameorigin, deny (none), allowall, and allow-from uri. In particular, allow-from uri supports only one URI. To support a list for IE users, the framing site must identify itself to the site domain by passing in a query parameter in the iframe tag. For example, if you add https://example.com as a trusted external domain and your site URL is https://MyDomainName.my.site.com, then the page on https://example.com must make its iframe as follows:
You can also set the trusted external domain in the iframeDomain cookie. This method allows iframes if the _iframeDomain URL variable isn’t saved when navigating between pages in IE.
Cookie iframeDomainCookie = ApexPages.currentPage().getCookies().get('iframeDomain');
if (iframeDomainCookie == null) { iframeDomainCookie = new Cookie('iframeDomain','www.example.com');
// Set the new cookie for the page ApexPages.currentPage().setCookies(new Cookie[]{iframeDomainCookie}); }
SEE ALSO: Configuring Site Properties Enable Clickjack Protection in Experience Cloud Sites Create and Edit Salesforce Sites
Site.com Versioning Overview
Each time you publish your site, it’s tracked as a version. You can restore your site back to one of EDITIONS the previously published versions. You can’t select individual components when restoring; you must restore the complete site. Available in: Salesforce When working in Site.com Studio, you’re always working on an unpublished version of your site. Classic (not available in all It’s your working copy. When you restore a version, you overwrite your working copy, not your live orgs) site. You must publish the restored version before you see the change on your live site. Available for purchase in: In Site.com Studio, you’ll find your site versions in the Change History view on the Overview tab. Enterprise, Performance, Not all items in a site are reverted when you restore a version. Some things, like user roles, remain and Unlimited Editions unchanged even when you restore from a previous version. Everything in a site is under version Available (with limitations) control except: in: Developer Edition • Site name • Anonymous preview setting • Guest User Profile settings • Clickjack protection level • Domains and path prefixes • User role settings
529 Extend Salesforce with Clicks, Not Code Site.com
Restoring to a Previous Site Version The Change History list in Site.com Studio tracks all published versions of your site. You can select any previously published version and restore it. You can only restore an entire site, not parts of a site.
SEE ALSO: Restoring to a Previous Site Version
Restoring to a Previous Site Version
The Change History list in Site.com Studio tracks all published versions of your site. You can select EDITIONS any previously published version and restore it. You can only restore an entire site, not parts of a site. Available in: Salesforce Note: The restore version feature is not available in Communities. Classic (not available in all orgs) When working in Site.com Studio, you’re always working on an unpublished version of your site. Available for purchase in: It’s your working copy. When you restore a version, you overwrite your working copy, not your live Enterprise, Performance, site. You must publish the restored version before you see the change on your live site. and Unlimited Editions Warning: You can’t restore the working copy of your site after you revert to a previous Available (with limitations) version. Therefore, it’s a good idea to back up the working copy of the site before reverting in: Developer Edition to ensure you don’t lose any unpublished changes. To revert to a previously published site version: USER PERMISSIONS 1. Select the Overview tab. To build, edit, and manage 2. From the Change History view, select the version you want to restore. Site.com sites: 3. Click > Restore Version. • Site.com Publisher User 4. Click OK at the confirmation message. field enabled on the user After you restored your working site to a previous version, you can continue to make additional detail page changes until you’re ready to publish the site. AND Site administrator or designer role assigned at the site level
530 Extend Salesforce with Clicks, Not Code Site.com
Creating URL Redirects in Site.com
If you move or reorganize pages in your site, search engines may have trouble finding the new EDITIONS page locations. To avoid this, set up URL redirects to inform users and search engines that site content has moved. Available in: Salesforce You can use URL redirects to: Classic (not available in all orgs) • Maintain search engine ranking. For example, if you change a page’s name from “Gadgets” to “Widgets,” creating a redirect rule from /Gadgets to /Widgets lets you restructure the Available for purchase in: site without affecting your page ranking. Enterprise, Performance, • Make URLs more readable and memorable. For example, site visitors will find long or numeric and Unlimited Editions page names, such as /widget65AD890004ab9923, difficult to remember. Instead, you Available (with limitations) can provide them with a short, friendly URL, such as /widget, and create an alias that redirects in: Developer Edition to the correct page when the user uses the short URL alias. • Assist with migration from another system to Site.com if you’re still using the same domain. USER PERMISSIONS For example, if your old site ran on PHP, you can create a redirection rule from an old page, such as /index.php, to a new page in Site.com, such as /myNewPage. To build, edit, and manage To assign a redirect to a site page: Site.com sites: • Site.com 1. On the Overview tab, click Site Configuration > URL Redirects. Publisher User 2. Click Create a Redirect. field enabled on the user detail page 3. Specify the Redirect type: AND Option Description Site administrator or designer role assigned Permanent (301) Select this option if you want users and search at the site level engines to update the URL in their systems when visiting the page. Users visiting a page redirected with this type are sent seamlessly to the new page. Using a permanent redirect ensures that your URLs retain their search engine popularity ratings, and that search engines index the new page and remove the obsolete source URL from their indexes.
Temporary (302) Select this option if you want users and search engines to keep using the original URL for the page. Search engines interpret a 302 redirect as one that could change again at any time, and though they index and serve up the content on the new target page, they also keep the source URL in their indexes.
Alias Select this option if you don’t want the URL to change in the user’s browser, but you want to redirect to a different page. Search engines won’t be aware of the change or update their records.
531 Extend Salesforce with Clicks, Not Code Site.com
Option Description Alias redirects only work when you redirect from one Site.com page to another. You can’t create an alias to an external address.
4. Specify the former page location in the Redirect from field. • The page location must be a relative URL. • The page can have any valid extension type, such as .html or .php, and can contain parameters. Parameter order is irrelevant. • The URL can’t contain anchors, such as /siteprefix/page.html#target. • You can create just one redirection rule from a particular URL. If you create a new rule with the same Redirect From information, the old rule is overwritten.
5. Specify the new page location in the Redirect to field. This can be a relative URL or a fully-qualified URL with an http:// or https:// prefix. Unlike pages you’re redirecting from, pages you’re redirecting to can contain anchors. 6. To immediately enable the redirection rule, ensure Active is selected. To enable it at a later stage, deselect the property. 7. Click Save. The URL Redirects section displays all URL redirection rules you've created for your site. • Edit an assigned redirect rule by clicking > Edit Redirect. • Delete a redirect rule by clicking > Delete Redirect.
Importing External Websites into Site.com
With Site.com Studio, you can import your existing website and recreate it automatically as a EDITIONS Site.com site. This saves you the time of having to re-code existing HTML pages. Create a zipped file of your website and the content with the desired folder structure. Create a new Available in: Salesforce Site.com site and then import your zipped file. Classic (not available in all orgs) During the creation of the new Site.com site, all your HTML pages and assets are copied into the new site in the same locations they are in the zipped file. Here are some guidelines for importing Available for purchase in: assets. Enterprise, Performance, and Unlimited Editions • Some code in style sheets may not convert properly to the Site.com format. If this happens, you’ll receive a warning message. You can continue to import the zipped file or stop the import. Available (with limitations) If you continue, the style sheet imports and you can then manually attach it to your pages. in: Developer Edition • You can edit the
section of a page using Edit Head Markup in scripts section on the properties pane. This is useful for manually editing the HTML. • The maximum file size you can import is 50 MB unless you import and unzip a .zip file. In that case, you can import a .zip file of up to 200 MB if you select Unzip files during the import process. If your site is larger than 200MB when zipped, you can create more than one zipped file and import them individually. • Site.com attempts to format links correctly when importing a page. Links are checked in content blocks, custom code, and head script markup. You can check for any links that might still be broken on your page using the link checker. Open the page, select > Find Broken Links. A dialog displays showing any broken links. To fix the link, click Edit. The link opens in the HTML editor.SEE ALSO: Importing a Site.com Site
532 Extend Salesforce with Clicks, Not Code Site.com
Copying and Overwriting a Site
Sometimes, you might want to copy and replace your current production Site.com or Site.com EDITIONS community site with another site. You’ll first need to export a copy of your site from your . Once you have an exported .site file, Available in: Salesforce import that file into your production organization using the overwrite feature. Overwrite replaces Classic (not available in all your production site with the imported site. You can only overwrite sites that are the same type. orgs) For example, you can’t overwrite a Site.com site with a Site.com community site. Available for purchase in: 1. Create your .site file using the export feature in Site.com Studio. Enterprise, Performance, and Unlimited Editions 2. From Site.com Studio in your production site, click Site Actions > Overwrite This Site. Alternatively, if you have access to the Site.com tab in your organization, you can click next Available (with limitations) to the site name to find Overwrite. in: Developer Edition 3. Click Browse to find the .site file you exported. 4. Click OK at the overwrite warning. USER PERMISSIONS
Warning: You can’t revert once you have overwritten a site. To overwrite sites: • Site administrator or Here are a few tips when using overwrite. designer role assigned at the site level • You’ll need to publish the site you overwrote before changes take effect. • When copying a site, the production site is overwritten. So, be sure to backup your production site by exporting a .site file. • Overwrite does not copy data changes. For example, if you created a custom object to use in a repeater in the site you are copying from, that repeater won’t work in the production site until you create the same custom object. • If there are assets that exist in the production site that do not exist in the site you are copying from, they are moved to the trash can during the overwrite process so you can restore them if needed. • If your copied site has a different name than your production site, the production name is preserved and only the contents are changed. For example, if your site is called Site One and you overwrite your production site called Site Two, the production site is still called Site Two.
SEE ALSO: Exporting a Site.com Site Using the Metadata API to Deploy a Site
Using the Metadata API to Deploy a Site
As a user, you can migrate a site from sandbox to production. You can use the Metadata API to EDITIONS create a deployable package for Site.com sites and Site.com Communities sites.
Note: For information on deploying a Lightning community or a Salesforce Tabs + Visualforce Available in: Salesforce community, see Deploy a Community from Sandbox to Production. Classic (not available in all orgs) There are several tools that you can use to create a package: Available for purchase in: • Change sets (for Site.com and Site.com Communities sites only). The component type is called Enterprise, Performance, Site.com . and Unlimited Editions • Workbench, which works for creating all site types. The metadata type is called SiteDotCom. Available (with limitations) • Lightning Platform Migration Tool for Ant, which works for creating all site types. The metadata in: Developer Edition type is called SiteDotCom.
533 Extend Salesforce with Clicks, Not Code Site.com
If using change sets, select Site.com from the list and follow the prompts to create your package. If using Workbench or Lightning Platform as your tool, you must create a package.xml file. That file is submitted to the Metadata API to create a package.
Note: You can include a Guest User Profile in your package.xml file. If you do so, that Guest User Profile is linked to the site during deployment. The packaging process generates a folder that contains a content file and a metadata xml file. The content file name is [sitename].site. The metadata .xml file name is [sitename].site-meta.xml. If you deploy a package that doesn’t include a .site file, an empty site is created. If the package contains a site file, and the organization already contains a site with the same name, the site is updated.
Note: There is a file size limitation when using the Metadata API to deploy a site from sandbox to production. The assets in the .site file can’t be larger than 40 MB. The site gets created, but the assets show in the new site as broken. To fix the assets, export the assets from the sandbox environment separately and then import them into your new site. For help with the Metadata API, see the Metadata API Developer Guide. You can find help for change sets in the online help and for the Migration Tool Guide at https://developer.salesforce.com/page/Migration_Tool_Guide.
Sample Package.xml Files Here are some sample Site.com package.xml files.
SEE ALSO: Change Sets Sample Package.xml Files
Sample Package.xml Files
Here are some sample Site.com package.xml files. EDITIONS Here is a sample package.xml file for a Site.com site. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
xyzsite SiteDotCom 30.0
534 Extend Salesforce with Clicks, Not Code Site.com
Here is an example of a package.xml for a Salesforce Communities site. The package also includes a Guest User Profile.
xyzsite CustomSite xyzsite Network xyzsite1 SiteDotCom xyzsite Profile Profile 30.0
535 Extend Salesforce with Clicks, Not Code Site.com
Importing and Managing Assets
Contributors, publishers, and site administrators can import a variety of assets, such as images, EDITIONS HTML pages, and PDFs, to use in a website. You can import assets and files individually, or use a zipped file. When importing entire websites or large numbers of assets, it’s easier to create a zipped Available in: Salesforce file of the content with the desired folder structure. When importing the zipped file for a website, Classic (not available in all Site.com recreates your website and places everything in the same folder structure. orgs)
Note: Available for purchase in: • The maximum file size you can import is 50 MB unless you import and unzip a .zip file. In Enterprise, Performance, that case, you can import a .zip file of up to 200 MB if you select Unzip files during the and Unlimited Editions import process. Available (with limitations) in: Developer Edition The quickest way to import one or more files is to: 1. Select the files from your computer and drag them directly onto the Studio interface. This is supported for Mozilla® Firefox® and Google® Chrome only. You can drag individual files, or a USER PERMISSIONS zipped file. To build, edit, and manage 2. Depending on the types of files you’re importing, a dialog box may appear that lets you: Site.com sites: • Site.com • Select Unzip files to extract the contents of a .zip file. If the .zip file includes folders, this Publisher User structure is maintained in your site. field enabled on the user • Select Overwrite existing files to replace a file that already exists in the site. detail page • Select Convert CSS files into style sheets, if you're a site administrator or designer, to AND convert a CSS file into a style sheet that you can use to style your website. Site administrator or designer role assigned Note: If you import a .zip file that includes CSS files, and they fail to convert, they at the site level may not be valid. Try unchecking this option and then re-importing the .zip file. To edit only content in • Select Convert HTML files into pages to import HTML pages into your website. The Site.com sites: structure of the HTML page is maintained in your site, but the HTML is not validated during • Site.com import. Contributor User Alternatively, to import a single file: AND 1. Click Import.... Contributor role assigned at the site level 2. Click Browse... to locate the file. 3. Select the file and click Open. 4. Depending on the type of file you’re importing, you can: • Select Unzip files to extract the contents of a .zip file. If the .zip file includes folders, this structure is maintained in your site. • Select Overwrite existing files to replace a file that already exists in the site. • Select Convert CSS files into style sheets, if you're a site administrator or designer, to convert a CSS file into a style sheet that you can use to style your website.
Note: If you import a .zip file that includes CSS files, and they fail to convert, they may not be valid. Try unchecking this option and then re-importing the .zip file.
• Select Convert HTML files into pages to import HTML pages into your website. The structure of the HTML page is maintained in your site, but the HTML is not validated during import.
5. Click Import. A message appears indicating whether the file was imported successfully.
536 Extend Salesforce with Clicks, Not Code Site.com
6. Click . You can add images and videos to the text areas of your site pages, or create a hyperlink to any imported asset. If you're a site administrator or designer, you can add also add images directly to the page. View the list of imported assets in the Assets view on the Overview tab. You can also access assets in the All Site Content view, which displays the folder hierarchy of your site. • To view a thumbnail of an imported image, hover over it. • To save an asset to your computer, hover over or select it and click > Download. • To remove an asset from your site if you're a site administrator or designer, hover over or select it and click > Delete. If the asset is being used in your site, you see a confirmation message with a list of locations where that asset is in use. After an asset file is deleted, it exists in the Salesforce cache for up to 24 hours. After this it is permanently deleted from our systems.
Note: An asset may still be accessible if it's cached locally by a browser, or cached by an external system.
• To rename an asset on your site if you're a site administrator or designer, hover over the asset and click > Rename.
Exporting Assets Designers and site administrators can export all site assets separately from the .site file. You can export assets together or individually. Creating and Managing Folders As a site administrator or designer, you can create folders to manage your pages, style sheets, templates, and assets.
SEE ALSO: Adding Site.com Page Elements Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor Exporting Assets
537 Extend Salesforce with Clicks, Not Code Site.com
Exporting Assets
Designers and site administrators can export all site assets separately from the .site file. You EDITIONS can export assets together or individually. When you export all assets, the assets are exported to a zipped file that is named after the site Available in: Salesforce name—for example, sitename-Assets.zip. Classic (not available in all orgs) Export your assets from the Overview tab by clicking > Export Site Assets. Available for purchase in: To export a single asset, hover over the asset and select Download from the Actions menu. Enterprise, Performance, and Unlimited Editions Note: There is a file size limitation when using the Metadata API to deploy a site from sandbox to production. The assets in the .site file can’t be larger than 40 MB. The site gets created, Available (with limitations) in: Developer Edition but the assets show in the new site as broken. To fix the assets, export the assets from the sandbox environment separately and then import them into your new site. USER PERMISSIONS SEE ALSO: To build, edit, and manage Importing and Managing Assets Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
538 Extend Salesforce with Clicks, Not Code Site.com
Creating and Managing Folders
As a site administrator or designer, you can create folders to manage your pages, style sheets, EDITIONS templates, and assets. To create new folders: Available in: Salesforce Classic (not available in all 1. In the All Site Content view on the Overview tab, click New Folder. orgs) 2. Type in the folder name. Available for purchase in: 3. Click Create. Enterprise, Performance, Folders are created at the top level of the folder tree. Once created, you can drag them anywhere and Unlimited Editions in the tree structure. Likewise, you can drag and drop files into the folders you create. To rename, Available (with limitations) delete, and create sub-folders, right-click the folder or use the Actions menu ( ). in: Developer Edition Note: The site map remains the same regardless of how you arrange folders in the All Site Content view. USER PERMISSIONS
SEE ALSO: To build, edit, and manage Site.com sites: Understanding the Site Administrator and Designer's Overview Tab • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
539 Extend Salesforce with Clicks, Not Code Site.com
Editing Site.com Pages as a Designer or Site Administrator
When working with page templates and site pages, you can add content, structure, and style, all EDITIONS in one place. Open a page or template on the Overview tab by double-clicking it or hovering over it and clicking > Edit. The page opens as a new tab. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
• Using the Page Elements and Page Structure panes (1), you can search for and add page elements to a page, and reorder the page element hierarchy.
540 Extend Salesforce with Clicks, Not Code Site.com
• Using the Properties, Style, and Events panes (2), you can set properties, add style, and create events for a selected page or element. • Using the toolbar (3), you can: – Undo and redo your actions. – Cut, copy, or paste page elements. – Import assets, such as images and files. – Preview pages to see how they’ll appear when live on different devices. – Preview your site or generate an anonymous preview link to send to other users. – Publish your recent changes. – Access other page actions ( ), such as renaming or deleting the page.
• On the page canvas (4), you can lay out the page and select, edit, and move page elements.
Tip: • Hide the side panes to increase the canvas size by clicking and . To reopen a pane, click its icon. • As you edit a page, your changes are saved and the status icon ( ) on the page tab is updated automatically. • If the site page or page template is based on another template, editable page elements are highlighted with a blue border on the page.
Site.com Page Templates Overview Creating Site.com Page Templates Creating Editable Template Areas As the template creator, you specify which elements users can edit in pages based on the template. About Editable Page Elements When you mark a page element as Editable on a page template, that page element becomes editable in any child pages or templates derived from the parent template. Creating Site.com Pages Identifying Which Template a Site.com Page Uses Renaming, Duplicating, and Converting Pages Changing a Page’s Doctype Property The Document Type Definition (DTD) or doctype of a page defines which version of HTML it’s using. This information is used by some browsers to trigger a standard rendering mode. By default, each page’s doctype is set to HTML5, which is the latest version, but you can change it to XHTML 1.0.
SEE ALSO: Using Site.com Studio as a Site Administrator or Designer
541 Extend Salesforce with Clicks, Not Code Site.com
Site.com Page Templates Overview
Before you begin building the pages of your website, take some time to plan the pages you need, EDITIONS and in particular, which pages will have a similar layout. Once you've decided on the layout, the quickest method is to use a page template to build the basic layout. Available in: Salesforce Classic (not available in all About Page Templates orgs) A page template lets you define the layout and functionality of site pages in one location. By adding Available for purchase in: common page elements to the template and then basing site pages on it, you can achieve a Enterprise, Performance, consistent look and feel throughout your site. Page templates don't appear on your public site. and Unlimited Editions As the template creator, you specify which elements users can edit in pages based on the template. Available (with limitations) By default, a page element in a template is “locked,” so users can't edit its contents in any in: Developer Edition template-based page unless you mark the page element as “editable.” Conversely, when users edit an editable page element in a template-based page, their changes are specific to that page and don't affect your template. For example, this main page template contains a non-editable header and navigation menu that are common to all the pages in the site (1). The main template also has an editable center panel (2) to house the page-specific content of each page that's based on it.
Note: • Page templates must contain at least one editable page element. Otherwise, users can't edit site pages that are based on the template. • Panels are ideal for adding editable areas to page templates.
You can use page templates to: • Save time and effort by laying out the page structure and using it as a starting point when you create site pages. For example, you could design a template with a fixed header panel and side menu, and an editable center panel, to which you add page-specific page elements and content. • Quickly make global updates to the layout or style of your website, as any changes you make to the template's design are reflected immediately in all the pages that use it. • Control how other users (such as contributors or other site administrators and designers) can modify site pages. For example, you may allow contributors to edit specific content blocks only. • Ensure your template design remains pixel-perfect. When users edit a page that's based on a template, their changes don't affect your template. • Reuse common design elements by creating child templates. • Allow contributors to create site pages that are based on the template.
542 Extend Salesforce with Clicks, Not Code Site.com
About Child Templates Child templates are a useful way to reuse common design elements for more complicated page layouts. For example, your website will probably have elements that are the same on every page in your site, such as a navigation menu. However, several pages may have elements that are common only to them, such as pages in a subsection of your site that include a subsection header. By using a child template, which is a template that's based on another template, you can reuse the main template design. Using our main page template as a base, the child template inherits the non-editable header and navigation menu (1), and an editable center panel (2) where we add the non-editable subsection header (3). We also need to add a new editable center panel (4) because the center panel of the main template is editable only in pages directly based on the main template.
Now, any page based on the child template includes the non-editable main header, navigation menu, and subsection header, and an editable center panel (5) for that page's content.
Best Practices • Plan your site structure and the layout of your pages. Taking the time to plan your website first saves time when you build your site. • Identify which elements are common to all the pages of your site, such as navigation menus or headers, as these are the elements you can add to the page template. • Use page templates wherever possible to promote content reuse and save time. • Try to keep the design of your main page template as simple as possible to make it easier to modify in the future. For more complicated site designs, use child templates to achieve maximum flexibility.
SEE ALSO: Creating Site.com Page Templates Creating Site.com Pages Setting Up the Contributor’s Studio View Identifying Which Template a Site.com Page Uses
543 Extend Salesforce with Clicks, Not Code Site.com
Creating Site.com Page Templates
A page template lets you define the layout and functionality of site pages in one location. By adding EDITIONS common page elements to the template and then basing site pages on it, you can achieve a consistent look and feel throughout your site. And because a template-based page inherits the Available in: Salesforce template's elements, you can make site-wide changes from one location. Classic (not available in all You can create a page template from a layout, or if you've already created a template, you can use orgs) it as a base to create a child template, which lets you reuse the design of the main template. Available for purchase in: Enterprise, Performance, Creating a Page Template from a Layout and Unlimited Editions To start from scratch with a completely blank template or use a basic page layout: Available (with limitations) in: Developer Edition 1. Hover over Page Templates on the Overview tab and click New, or click New Page Template in the Page Templates view. 2. Enter the page template name. Template names can’t include special characters, such as #, ?, USER PERMISSIONS or @. To build, edit, and manage 3. Click Layouts and select either a blank page or a predefined page layout, such as a page with Site.com sites: a header and footer. • Site.com Publisher User Note: Predefined page layouts use panels to create columns, headers, and footers. These field enabled on the user panels use inline CSS to set their position, so you can easily modify the layout after the detail page page is created. However, if you're familiar with CSS and prefer using CSS rules, you can AND remove the inline style by selecting the panel, deleting the code from the Code tab in Site administrator or the Style pane ( ), and clicking Apply. designer role assigned at the site level 4. Choose a layout mode: • To expand the page to fill the width of the browser window, click Full width. • To set the page width, click Fixed width and enter the width.
5. Click Create. The page template opens. Next, you must complete the template.
Tip: • By default, any template you create is only available to other site administrators and designers in your organization. To let contributors create pages based on the template, select Available to Contributor in the Properties pane ( ). • You can also create templates by converting or duplicating other pages.
Creating a Child Template To use an existing template as a base for a child template: • The quickest option is to: 1. Select the template in the Page Templates view on the Overview tab and click > Create Child Template. Alternatively, click Page Actions > Create Child Template if the template is open. 2. Enter the page template name. Template names can’t include special characters, such as #, ?, or @. 3. Click Create. The child template opens.
• Alternatively:
544 Extend Salesforce with Clicks, Not Code Site.com
1. Hover over Page Templates on the Overview tab and click New, or click New Page Template in the Page Templates view. 2. Enter the page template name. Template names can’t include special characters, such as #, ?, or @. 3. Click Page templates and select the page template. 4. Click Create. The child page template opens.
Completing Your Template Once you've created a template, you must take the next steps to complete it: • Lay out the page template • Add other page elements to the template • Create editable areas • Create template-based site pages
SEE ALSO: Creating Editable Template Areas Identifying Which Template a Site.com Page Uses Site.com Page Templates Overview Setting Up the Contributor’s Studio View
Creating Editable Template Areas
As the template creator, you specify which elements users can edit in pages based on the template. EDITIONS To make a page element editable in derived pages or child templates, select it on the page template or in the Page Structure pane ( ) and click > Make Editable, or select Editable in the Available in: Salesforce Classic (not available in all Properties pane ( ). orgs)
When the page template is open, editable page elements are highlighted with a blue border on Available for purchase in: the page. They also display a pencil icon ( ) in the Page Structure pane and in the information Enterprise, Performance, popup that appears when you hover over the element on the page. and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage SEE ALSO: Site.com sites: About Editable Page Elements • Site.com Setting Up the Contributor’s Studio View Publisher User field enabled on the user Creating Site.com Page Templates detail page AND Site administrator or designer role assigned at the site level
545 Extend Salesforce with Clicks, Not Code Site.com
About Editable Page Elements
When you mark a page element as Editable on a page template, that page element becomes EDITIONS editable in any child pages or templates derived from the parent template. Consider these tips when creating editable page elements. Available in: Salesforce Classic (not available in all • Editable page elements are highlighted with a blue border in child pages and templates. orgs) • If you make a page element within a panel editable, you can’t also make the container panel editable. Available for purchase in: Enterprise, Performance, • Users can't alter the events, style, or properties of an editable page element in pages based on and Unlimited Editions the template. Available (with limitations) • Users can't resize, reposition, or delete editable page elements in pages based on the template. in: Developer Edition However, if the element's Auto Height property is enabled in the template, its height will adjust to fit the content of the template-based page. • Deleting an editable element from a page template removes it from all child pages and templates. • When you enable the Editable property of a page element, any pages or child templates based on the template also inherit the enabled status. In turn, the enabled status in the child template cascades to any of its children, and so on. If you don’t want its editability to cascade to any lower levels, disable the Editable property of a page element in a child template.
Editable Page Elements for Contributors • Contributors can modify editable content blocks in site pages based on the template. They can also edit content blocks that you place in an editable panel in template-based site pages.
Tip: To add a content block that only other site administrators or designers can edit, use custom code instead.
• Contributors can add content blocks to editable panels in site pages based on the template. If you make widgets available to contributors, they can also add them to editable panels. • Site administrators and designers can edit any page element you make editable.
Default Content in Editable Page Elements The content of all editable page elements on a child page or template is linked to the content of the editable elements on its parent page template. When you update the content of an editable page element on the parent template, the changes are pushed down to any child pages or page templates. However, if you modify the content of an editable page element at the child page or template level, you break the link between the elements, and any subsequent changes made to the page element on the parent template won't trickle down to its children. (To return control of the content to the parent template, select the editable page element on the page or in the Page Structure pane and click > Revert to Parent Content. When you do this, any custom content in the editable page element is lost.) Disabling the Editable property of a panel in a parent template overrides any changes made to that panel in child pages or templates. Changes to the panel at the child level disappear, and the panel reflects only the content from the parent template. However, the changes
546 Extend Salesforce with Clicks, Not Code Site.com
at the child level aren’t lost. Re-enabling the Editable property of the panel in the parent template restores the custom content previously added to its children. Any changes made to the element at the parent level will no longer show up.
SEE ALSO: Creating Editable Template Areas Setting Up the Contributor’s Studio View Creating Site.com Page Templates Editing and Working With Site.com Page Elements
Creating Site.com Pages
As a site administrator or designer, when you create a site page, you can choose to base it on a EDITIONS page template. If you're creating several site pages that have common page elements, such as a navigation menu, you can save time and effort and achieve a consistent look and feel by creating Available in: Salesforce a page template first and then basing your site pages on it. Alternatively, if none of your site pages Classic (not available in all have a similar structure or if you need to create a one-off site page that doesn't follow the overall orgs) site design, such as a home page, you can create a page based on a basic layout. Available for purchase in: Enterprise, Performance, Creating Site Pages from a Layout and Unlimited Editions Start from scratch with a completely blank page or use a basic page layout. Available (with limitations) 1. Hover over Site Pages on the Overview tab and click New, or click New > Site Page when in: Developer Edition the Site Pages view is open. 2. Enter the site page name. Page names can’t include spaces or special characters, such as #, ?, USER PERMISSIONS or @. To build, edit, and manage 3. Click Layouts and select either a blank page or a predefined page layout, such as a page with Site.com sites: a header and footer. • Site.com Note: Predefined page layouts use panels to create columns, headers, and footers. These Publisher User panels use inline CSS to set their position, so you can easily modify the layout after the field enabled on the user detail page page is created. However, if you're familiar with CSS and prefer using CSS rules, you can remove the inline style by selecting the panel, deleting the code from the Code tab in AND the Style pane ( ), and clicking Apply. Site administrator or designer role assigned 4. Choose a layout mode: at the site level • To expand the page to fill the width of the browser window, click Full width. • To set the page width, click Fixed width and enter the width.
5. Click Create. The site page opens.
Creating Site Pages from a Page Template If you created a page template, you can base your site pages on it. The quickest option is to: 1. Select the template in the Page Templates view and click > Create Page from Template. Alternatively, click Page Actions > Create Page from Template if the template is open.
547 Extend Salesforce with Clicks, Not Code Site.com
2. Enter the site page name. Page names can’t include spaces or special characters, such as #, ?, or @. 3. Click Create. The site page opens. Alternatively: 1. Hover over Site Pages on the Overview tab and click New, or click New > Site Page when the Site Pages view is open. 2. Enter the site page name. Page names can’t include spaces or special characters, such as #, ?, or @. 3. Click Page templates and select the page template. 4. Click Create. The site page opens.
Tip: You can also create pages by converting or duplicating other pages.
SEE ALSO: Editing Site.com Pages as a Designer or Site Administrator Adding Site.com Page Elements
Identifying Which Template a Site.com Page Uses
When you edit a template-based page, you can't modify its non-editable page elements. You also EDITIONS can't reposition, resize, or delete editable page elements, or alter the events, properties, or style associated with them. To update these elements or properties, you must edit them in the template Available in: Salesforce the page is based on. Classic (not available in all To identify which page template a site page is based on: orgs) • Hover over the site page in the Sites Pages view on the Overview tab. An information popup Available for purchase in: appears that displays the page template's name. Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user • Examine the Page Structure pane when the page is open. The template's name is displayed as detail page a link that you can click to open the template. AND Site administrator or designer role assigned at the site level
548 Extend Salesforce with Clicks, Not Code Site.com
Tip: To view and open the site pages associated with a particular page template, select or hover over the page template in the Page Templates view of the Overview tab and click > Edit Pages Based on Template. Click a listed site page to open it.
SEE ALSO: Creating Site.com Page Templates Site.com Page Templates Overview
Renaming, Duplicating, and Converting Pages
When working with pages and templates, you can perform common tasks, such as renaming, EDITIONS deleting, or duplicating pages. To access more page options, select or hover over a page on the Site Pages view of the Overview Available in: Salesforce tab and click . Classic (not available in all orgs) To access more template options, select or hover over a template in the Page Templates view of the Overview tab and click . Available for purchase in: Enterprise, Performance, Alternatively, if the page or template is open, click on the toolbar. and Unlimited Editions The available options vary for pages and templates: Available (with limitations) in: Developer Edition Select To... Edit Open the page or template for editing. Alternatively, double-click the USER PERMISSIONS page or template. To build, edit, and manage Rename Change the page or template name. Site.com sites: • Site.com Preview View the page in a browser window. Publisher User Duplicate Create a copy of the page or template. field enabled on the user detail page Duplicating a page template doesn’t duplicate the pages or templates AND based on it. Site administrator or Delete Remove a page or template. You can't delete a template that has designer role assigned at the site level pages based on it.
549 Extend Salesforce with Clicks, Not Code Site.com
Select To... Create Child Template Create a child template based on the selected template.
Create Page from Template Create a page based on the template.
Convert Site Page to Template Change the page into a template.
Convert Template to Site Page Change the template into a page. You can't convert a template that has pages based on it.
Edit Pages Based on Template View and open the site pages that are based on the selected page template.
Add IP Restrictions Control access to the page or template by restricting the range of permitted IP addresses. When you create a page that’s based on a template with IP restrictions, the page inherits the IP restrictions.
SEE ALSO: Editing Site.com Pages as a Designer or Site Administrator Using Site.com Studio as a Site Administrator or Designer
Changing a Page’s Doctype Property
The Document Type Definition (DTD) or doctype of a page defines which version of HTML it’s using. EDITIONS This information is used by some browsers to trigger a standard rendering mode. By default, each page’s doctype is set to HTML5, which is the latest version, but you can change it to XHTML 1.0. Available in: Salesforce When the page is open: Classic (not available in all orgs) 1. Select the page in the Page Structure pane. 2. In the Properties pane, select an option in the Doctype drop-down list. Available for purchase in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Available (with limitations) Changing a Page Element’s HTML Tag in: Developer Edition Adding Custom HTML Attributes HTML5 Semantic Page-Layout Tags USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
550 Extend Salesforce with Clicks, Not Code Site.com
Site.com Page Elements
Page elements are the building blocks of your site pages and page templates. Combined, they EDITIONS provide the page's structure and content. When a site page or page template is open in Site.com Studio, these page elements are available Available in: Salesforce to site administrators and designers. Classic (not available in all orgs)
Page Element Description Available for purchase in: Content Block Contains the page text, and can also house Enterprise, Performance, images, media, and hyperlinks. Also available to and Unlimited Editions contributors if the page has editable areas. Available (with limitations) in: Developer Edition Custom Code Lets you customize your site by adding markup, such as HTML and JavaScript for elements that aren't provided in Site.com Studio.
Image Adds images directly to the page.
Breadcrumb Adds a breadcrumb navigation element to the page.
Menu Creates a menu that lets users navigate through the pages of your site.
Panel Adds structure to the page and lets you group other page elements together.
Button Adds a button to the page. You can use the actions in the Events pane to add functionality to the button.
Form Lets you create web-to-lead forms or gather customer feedback, and submit the data to Salesforce objects.
Input Fields Provides several field types to add to forms or pages. When added to a form, binds to fields in the form’s object. See Input Field Types.
Data Element Must be contained in a data repeater. Binds to a field in the data repeater’s object and acts as a placeholder that shows the content of a specified field for the current record.
Data Function Connects to a standard or custom Salesforce object, performs calculations on the returned results, and displays the calculation on the page.
Data Repeater Connects to a Salesforce object and returns a dataset based on filters that you specify. Combines with data elements or custom code page elements to display the results on the page.
551 Extend Salesforce with Clicks, Not Code Site.com
Page Element Description Data Table Connects to a standard or custom Salesforce object, retrieves a data set based on the filter criteria that you specify, and displays one or more record as rows in the table.
Adding Site.com Page Elements Editing and Working With Site.com Page Elements Laying Out Site.com Pages Using Panels Positioning Panels Using CSS Adding Images Directly to the Page Adding Content Blocks to Pages Content blocks contain the text of your website pages, and can also house images, videos, and hyperlinks. Designers and site administrators can add content blocks to pages when in Design Mode. Adding Custom Code to Pages Custom code lets you customize your site using markup, such as HTML and JavaScript. About the Site Map and Page Hierarchy Adding Custom HTML Attributes You can add custom HTML attributes to pages and page elements, which are rendered on the HTML tag of the page element. For example, this is useful when working with third-party frameworks that render page elements differently based on certain attributes. Changing a Page Element’s HTML Tag By default, panels, data repeaters, data elements, custom code, and content blocks are each defined as a div, but you can change this to any other HTML tag using the HTML Tag property. This gives you greater flexibility and control over how the page element is displayed on the page. HTML5 Semantic Page-Layout Tags
SEE ALSO: Adding Site.com Page Elements Editing and Working With Site.com Page Elements
552 Extend Salesforce with Clicks, Not Code Site.com
Adding Site.com Page Elements
Page elements are the building blocks of your site pages and page templates. Panel elements add EDITIONS structure to your pages. You can think of both pages and panels as “containers” for the page elements that you add to them. Available in: Salesforce If a site page or page template is based on another page template, you can only add page elements Classic (not available in all to editable panels, which are highlighted with a blue border on the page. orgs) Pages, panels, data repeaters, and forms are “container” page elements, so you can add other page Available for purchase in: elements to them when the page is open. Enterprise, Performance, and Unlimited Editions • In the Page Elements pane ( ), either: Available (with limitations) – Drag the page element onto the page canvas or container page element. in: Developer Edition – Click the page element, select where to place it in the popup that appears, and click Apply.
• In the Page Structure pane ( ), hover over a container page element and click > Add USER PERMISSIONS Page Elements. Click the item you want to add or drag it onto the container page element. To build, edit, and manage • Select a container page element on the page and click > Add Page Elements. Click the Site.com sites: item you want to add or drag it into the container page element. • Site.com When you drag a page element into an editable panel, the page element displays a permitted icon Publisher User and a green border shows where you're placing the element. field enabled on the user detail page AND Site administrator or designer role assigned at the site level
If you try dragging a page element into a panel that isn't editable, the page element displays a not-permitted icon.
SEE ALSO: Editing and Working With Site.com Page Elements Adding Images Directly to the Page Adding Content Blocks to Pages Adding Custom Code to Pages Adding a Navigation Menu
553 Extend Salesforce with Clicks, Not Code Site.com
Editing and Working With Site.com Page Elements
The Page Structure pane ( ) displays the hierarchy of all elements on the page and is a very EDITIONS useful way of selecting, moving, and reordering elements, particularly for more complicated page designs. Available in: Salesforce Classic (not available in all • To select a page element, either click it on the page, or select it in the Page Structure pane. This orgs) highlights the element on the page and displays the item's selector bar and Actions menu ( ). Available for purchase in: • To edit a page element, such as a content block, image, or custom code, either: Enterprise, Performance, and Unlimited Editions – Double-click the element on the page. Available (with limitations) – Select the element on the page and click > Edit on its selector bar. in: Developer Edition – Select or hover over the element in the Page Structure pane and click > Edit. – Click Edit Content on the toolbar (for content blocks only). USER PERMISSIONS • To move a page element, either: To build, edit, and manage – Select the element on the page and drag it to the correct position, or click > Move Site.com sites: on its selector bar. • Site.com – Drag the item to your preferred location in the Page Structure pane, or select it and click Publisher User > Move > Direction. You can also drag all page elements other than panels to field enabled on the user your preferred location in the Page Structure pane. detail page AND • To resize a page element, select it and drag the resize handles to the correct size. If the corner Site administrator or resize handles are grayed out, it means the item's Auto Height property is enabled, which adjusts designer role assigned the height depending on its contents. To resize it to a set height, disable the property by either at the site level deselecting Auto Height in the Properties pane ( ), or by clicking one of the bottom resize handles and clicking Disable Auto Height in the popup message that appears.
Tip: If you disable the Auto Height property on an image, but you want it to retain its aspect ratio—the relationship of height to width—press and hold down the SHIFT key while you drag to resize it. Alternatively, if you're using CSS to style the page element, adjust the style of the class or ID that styles it.
• To delete an element, select it and either: – Click > Delete on the item's selector bar. – Press DELETE. – Click on the toolbar. – In the Page Structure pane, click > Delete.
If a site page or page template is based on another page template: • The content of all editable page elements on a child page or template is linked to the content of the editable elements on its parent page template. When you update the content of an editable page element on the parent template, the changes are pushed down to any child pages or page templates. However, if you modify the content of an editable page element at the child page or template level, you break the link between the elements, and any subsequent changes made to the page element on the parent template won't trickle down to its children. • You can't reposition or resize its page elements. However, if the element's Auto Height property is enabled in the template, the height will adjust to fit the content in the template-based page. To edit the page element, you must edit it in the page template. • You can't delete its page elements. To delete the page element, you must delete it from the page template.
554 Extend Salesforce with Clicks, Not Code Site.com
• You can't alter the events, properties, or style of an editable page element, such as its color, position, and size.
SEE ALSO: Site.com Page Elements Adding Site.com Page Elements Adding Content Blocks to Pages Laying Out Site.com Pages Using Panels About Editable Page Elements
Laying Out Site.com Pages Using Panels
A panel is a useful layout tool that defines the logical divisions of your page and lets you group EDITIONS page elements together for easy movement and positioning. Think of it as a container for other page elements, including other panels, or as a div that wraps around the content placed within Available in: Salesforce it. Panels are ideal for adding editable areas to page templates. Classic (not available in all When you create a page template or site page, you can use predefined page layouts that include orgs) headers, footers, and columns, which are created using panels. Once created, you can then further Available for purchase in: modify the layout to match your site's design. Enterprise, Performance, If you need to add more divisions to the page and you're not familiar with CSS, the easiest method and Unlimited Editions is to use row and column panels. This feature adds panels with predefined CSS positioning to ensure Available (with limitations) they align correctly on the page. in: Developer Edition Note: Predefined page layouts, and row and column panels use inline CSS to set their position. If you're familiar with CSS and are using CSS rules to style your site, you can remove the inline USER PERMISSIONS CSS by deleting it from the Code tab in the Style pane ( ) and clicking Apply. To build, edit, and manage To add row and column panels to a page: Site.com sites: • Site.com 1. Select the page (the top folder icon) in the Page Structure pane ( ). Publisher User 2. Click > Add Rows and Column Panels. field enabled on the user detail page 3. Select the number of row or column panels you require. If the page already contains content, it is placed in the first new panel. AND To add a row panel: Site administrator or designer role assigned • Above a panel, select the panel on the page or in the Page Structure pane and click > at the site level Add Rows and Column Panels > Insert Row Above • Below a panel, select the panel on the page or in the Page Structure pane and click > Add Rows and Column Panels > Insert Row Below To add row and column panels to another panel: 1. Select the panel on the page or in the Page Structure pane. 2. Click > Add Rows and Column Panels. 3. Select the number of row or column panels you require. If the page already contains content, it is placed in the first new panel.
To add a single panel, drag a Panel from the Page Elements pane ( ) onto the page.
555 Extend Salesforce with Clicks, Not Code Site.com
By default, the height of a panel automatically adjusts when you add content to it because its Auto Height property is enabled. You can disable the property to resize and reposition panels. If you hover over a panel on the page, an information popup appears that displays the width and height of the panel.
When you drag a page element onto a panel, the edges change color, indicating that the element is now grouped within it. To remove the element from the group, drag it outside the panel.
SEE ALSO: Adding Site.com Page Elements Positioning Panels Using CSS Changing a Page Element’s HTML Tag
Positioning Panels Using CSS
A panel is a useful layout tool that defines the logical divisions of your page. Using CSS, you can EDITIONS position panels and improve the layout of the page. Available in: Salesforce Adding Padding and Margins to Panels Classic (not available in all orgs) Two CSS properties—margins and padding—can help with your page layout by creating space between the rows and columns, and the content within. The margin property controls the space Available for purchase in: outside the panel between its border and outer edge, while the padding property controls the Enterprise, Performance, space between the panel's content and border. and Unlimited Editions To add margins and padding: Available (with limitations) in: Developer Edition 1. Select the panel. 2. Open the Dimensions section of the Style pane. USER PERMISSIONS 3. In the Margins section, either: • Set the margin width for all four sides by entering a value in the All text box and selecting To build, edit, and manage the unit of measurement. Site.com sites: • Site.com • Set the margin widths for the top, right, bottom, or left sides independently by entering a Publisher User value in the appropriate text box and selecting the unit of measurement. field enabled on the user detail page 4. Similarly, in the Padding section, set the padding widths as required. Adding padding increases the total width of the panel. For example, if you have a panel with a width of 500px and you AND add padding of 20px to all sides, the total width of the panel will be 540px. Site administrator or designer role assigned Tip: You can center a panel or block page element using the margin property. Enter 0 in at the site level the All text box and select Auto in the drop-down list.
Creating Column Panels Using the Float Property If you need to add more divisions to the page and you're not familiar with CSS, the easiest method is to use row and column panels. Alternatively, using the CSS float property, you can position panels to the left or right to create columns. (When you add panels using
556 Extend Salesforce with Clicks, Not Code Site.com
the row and column panels feature, they're automatically positioned using the float property.) For example, you could add two single panels to a container panel and set both panel's float and width properties to create a two-column page layout. To create a column panel: 1. Select the panel. 2. Open the Layout section of the Style pane. 3. Click to float the panel to the left, or click to float the panel to the right. If you're creating a two-column layout, for example, ensure you set the float property of both panels. 4. Adjust the width of the panel to ensure the panels align correctly by either setting the width in the Dimensions section or dragging the panel's border on the page. For example, if you're creating two columns of equal width, set the width of both panels to 50%.
Tip: When you use the float property, remember to set the overflow property of the container panel to “hidden.” This allows the container panel to grow as the height of the column panels increase. Select the container panel and in the Layout section of the Style pane, select Hidden in the Overflow drop-down list.
SEE ALSO: Cascading Style Sheets Overview Laying Out Site.com Pages Using Panels
Adding Images Directly to the Page
As a site administrator or designer, you can add images directly to your site pages and page templates EDITIONS or you can add images to content blocks. To add an image directly to the page: Available in: Salesforce Classic (not available in all 1. Open the site page or page template. orgs) 2. Drag an Image from the Page Elements pane onto the page. Available for purchase in: 3. In the Add an Image dialog box, either: Enterprise, Performance, • Find an existing image by typing its name in the Search Image text box and selecting and Unlimited Editions it from the list. Available (with limitations) • Upload an image from your computer in the Upload tab by browsing to the image, clicking in: Developer Edition Upload, and selecting it from the list.
4. Click Apply. The image is added to the page. USER PERMISSIONS 5. Enter a brief description of the image in the Alternative Text field in the Properties To build, edit, and manage pane. The description is used by screen reader users or as a substitute if the browser can’t display Site.com sites: the image. It can also help with search engine optimization (SEO). • Site.com Publisher User SEE ALSO: field enabled on the user detail page Adding Site.com Page Elements AND Editing and Working With Site.com Page Elements Site administrator or designer role assigned at the site level
557 Extend Salesforce with Clicks, Not Code Site.com
Adding Content Blocks to Pages
Content blocks contain the text of your website pages, and can also house images, videos, and EDITIONS hyperlinks. Designers and site administrators can add content blocks to pages when in Design Mode. Available in: Salesforce To add a content block when the page is open, either drag it from the Page Elements pane onto Classic (not available in all the page or target a container page element. orgs) To edit a content block, double-click it. For greater control over the text, you can edit the HTML Available for purchase in: directly by selecting the content block and clicking > Edit HTML. Enterprise, Performance, and Unlimited Editions If you make a content block in a page template editable, contributors can edit the content block in any page based on the template. To add a content block that only other site administrators or Available (with limitations) designers can edit, use custom code instead. in: Developer Edition
Understanding the Content Editing Toolbar USER PERMISSIONS Editing Content Blocks in Design Mode To build, edit, and manage Designers and site administrators can edit content blocks on the page. Content blocks contain Site.com sites: the text for site pages, and can also house images, videos, and hyperlinks. • Site.com Adding Images to Content Blocks in Design Mode Publisher User field enabled on the user Adding Video to Content Blocks in Design Mode detail page Attaching Hyperlinks to Text and Images in Design Mode AND Adding Anchors to Pages in Design Mode Site administrator or designer role assigned at the site level SEE ALSO: Adding Images to Content Blocks in Design Mode Attaching Hyperlinks to Text and Images in Design Mode
Understanding the Content Editing Toolbar
Designers and site administrators can edit content blocks when in Design mode. Content blocks EDITIONS contain the site page's text, along with images, videos, and hyperlinks. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
558 Extend Salesforce with Clicks, Not Code Site.com
When in Design Mode, you can use the content editing toolbar to: • Undo and redo your edits, and remove the formatting of text copied and pasted from Microsoft® Office, which can often include hidden formatting (1). • Cut, copy, and paste text (2). • Apply direct formatting (3), such as: – Font family and size – Bold, italic, underline, subscript, superscript, and strikethrough – Font and highlight color
• Control the text style and layout (4) by: – Applying paragraph and heading styles – Setting paragraph indentation – Left-aligning, centering, right-aligning, or justifying text – Inserting numbered or bulleted lists
• Insert a table, and add rows, columns, and spacing (5). • Add images, videos, and special characters (6). • Add and remove hyperlinks and anchors (7).
Tip: Avoid applying formatting, such as different fonts or highlighting, directly to text whenever possible. Instead, it’s best practice to use the paragraph and heading styles to quickly apply consistent formatting throughout the site. This also ensures that all page text is updated automatically if a site administrator or designer modifies the site's paragraph and heading styles.
559 Extend Salesforce with Clicks, Not Code Site.com
Editing Content Blocks in Design Mode
Designers and site administrators can edit content blocks on the page. Content blocks contain the EDITIONS text for site pages, and can also house images, videos, and hyperlinks. When the page is open in Design Mode: Available in: Salesforce Classic (not available in all 1. Double-click the content block on the page. orgs) 2. Add or edit text and format it using the content editing toolbar. Available for purchase in: Tip: Enterprise, Performance, and Unlimited Editions • If you copy and paste text from Microsoft® Office, highlight the text and click to remove any hidden formatting, which can adversely affect how the text appears on Available (with limitations) the page. in: Developer Edition • Avoid applying formatting, such as different fonts or highlighting, directly to text whenever possible. Instead, it’s best practice to use the paragraph and heading styles USER PERMISSIONS to quickly apply consistent formatting throughout the site. This also ensures that all page text is updated automatically if a site administrator or designer modifies the To build, edit, and manage site's paragraph and heading styles. Site.com sites: • Site.com 3. Add images, videos, hyperlinks, or anchors as required. Publisher User field enabled on the user 4. Click Save. detail page Note: The content of all editable page elements on a child page or template is linked to the AND content of the editable elements on its parent page template. When you update the content Site administrator or of an editable page element on the parent template, the changes are pushed down to any designer role assigned child pages or page templates. However, if you modify the content of an editable page at the site level element at the child page or template level, you break the link between the elements, and any subsequent changes made to the page element on the parent template won't trickle down to its children.
560 Extend Salesforce with Clicks, Not Code Site.com
Adding Images to Content Blocks in Design Mode
Designers and site administrators can add images to content blocks when viewing a page in Design EDITIONS Mode. When the page is open: Available in: Salesforce Classic (not available in all 1. Double-click the content block on the page. orgs) 2. Position your cursor where you want to insert the image and click . Available for purchase in: 3. In the Image Properties dialog box, either: Enterprise, Performance, • Enter a URL to an image in the Image URL field. and Unlimited Editions • Select an image from your website by clicking From Website and selecting the image in Available (with limitations) the list that appears. in: Developer Edition • Upload an image from your computer by opening the Upload tab, browsing to the image, and clicking Upload. USER PERMISSIONS
4. Enter a brief description of the image in the Alternative text field. The description is To build, edit, and manage used by screen reader users or as a substitute if the browser can’t display the image. It can also Site.com sites: help with search engine optimization (SEO). • Site.com Publisher User 5. Optionally, preview how the image appears in relation to the text on the page and set: field enabled on the user • The width and height of the image detail page • How much space surrounds the image (which is controlled by the HSpace and VSpace AND properties) Site administrator or • How it aligns with the text on the page designer role assigned at the site level • The image border (for example, to set a dotted green border that's 10 pixels wide, you enter 10px dotted green in the Border field) To edit only content in Site.com sites: 6. Click Apply. • Site.com 7. Click Save. Contributor User AND SEE ALSO: Contributor role Editing Content Blocks in Design Mode assigned at the site level Understanding the Content Editing Toolbar Importing and Managing Assets
561 Extend Salesforce with Clicks, Not Code Site.com
Adding Video to Content Blocks in Design Mode ® ® ® ® ® Designers and site administrators can add YouTube , Google , Adobe Flash , Windows Media , EDITIONS and Apple QuickTime® videos to content blocks when viewing a page in Design Mode. When the page is open: Available in: Salesforce Classic (not available in all 1. Double-click the content block on the page. orgs) 2. Position your cursor where you want to insert the video and click . Available for purchase in: 3. In the Video Properties dialog box, select the video type and either: Enterprise, Performance, • Enter the URL to the video in the Video URL text box—for example, and Unlimited Editions http://www.youtube.com/watch?v=123abc. Available (with limitations) • Select a video from your website by clicking From Website and selecting the video in the in: Developer Edition list that appears. • Upload a video from your computer by opening the Upload tab, browsing to the image, USER PERMISSIONS and clicking Upload. To build, edit, and manage Note: You can only select or upload Flash, Windows Media, and QuickTime videos. Site.com sites: • Site.com 4. To specify how the video is displayed on the page, you can set: Publisher User field enabled on the user • The width and height of the video detail page • How much space surrounds the video (which is controlled by the HSpace and VSpace AND properties) Site administrator or • How it aligns with the text on the page designer role assigned at the site level You can also preview the video. 5. Click Apply. The video appears as an icon in the content block. To edit only content in Site.com sites: 6. Click Save. • Site.com Note: You can view all video types, other than Windows Media videos, when you preview Contributor User a page. AND Contributor role SEE ALSO: assigned at the site level Editing Content Blocks in Design Mode Understanding the Content Editing Toolbar
562 Extend Salesforce with Clicks, Not Code Site.com
Attaching Hyperlinks to Text and Images in Design Mode
When viewing a page in Design Mode, designers and site administrators can create hyperlinks to: EDITIONS • External Web pages or websites • Pages and assets in the site Available in: Salesforce Classic (not available in all • Email messages orgs) • Anchors on the page Available for purchase in: When the page is open: Enterprise, Performance, 1. Double-click the content block on the page. and Unlimited Editions Available (with limitations) 2. Select the text or image that you want to attach a hyperlink to and click . in: Developer Edition 3. Select the link type in the Link to drop-down list. To link to: • A Web page: USER PERMISSIONS a. Select A URL. To build, edit, and manage b. Type the address in the URL field—for example, Site.com sites: http://www.externalsite.com. • Site.com c. Go to step 4. Publisher User field enabled on the user • A page or item in your site: detail page a. Select An item in your site. AND b. Select the item type, such as a page or image. Site administrator or designer role assigned URL c. Select the item. (If you can’t see the list of items, place your cursor in the field and at the site level press the DOWN key on your keyboard.) d. Go to step 4.
• An anchor that you previously added to the page: a. Select An anchor on the page. b. Select the anchor in the drop-down list. Alternatively, enter a new anchor name and create the anchor afterwards. c. Go to step 5.
• An email message: a. Select An email. b. Enter the recipient's email address and the message information. c. Go to step 5.
Note: For content blocks in a data repeater, you can use expressions to add a custom link, such as a URL query string, to an item in your site or to a Web page.
4. To select which window the item should open in, select an option in the Target drop-down list: • Popup window loads the item into a popup window. When you select this option, you can set the title for the popup and control its appearance and size with the options that appear. • New window (_blank) loads the item into a new, unnamed browser window. • Same window (_self) loads the item into the same frame or window as the link. This is the default setting. • Topmost window (_top) loads the item into the topmost parent frameset or window of the frame that contains the link.
563 Extend Salesforce with Clicks, Not Code Site.com
• Parent window (_parent) loads the item into the parent frameset or window of the frame that contains the link.
5. Optionally, enter a tooltip description for the link. The tooltip displays as a pop-up when the user hovers over the link. 6. Click Apply. 7. Click Save.
To delete a hyperlink, select it and click .
SEE ALSO: Editing Content Blocks in Design Mode Understanding the Content Editing Toolbar
Adding Anchors to Pages in Design Mode
An anchor is an invisible marker that identifies a particular location on a page. If you’re a designer EDITIONS or site administrator, you can add an anchor to the page and then create a hyperlink that jumps to that specific location. This can be useful if a page is particularly long; for example, if your page has Available in: Salesforce several sections, you could add links to each section at the top of the page to aid navigation. Classic (not available in all When the page is open in Design Mode: orgs) 1. Double-click the content block on the page. Available for purchase in: 2. Enterprise, Performance, Place your cursor at the beginning of the line where you want to link to and click . and Unlimited Editions 3. Enter a name for the anchor and click Apply. Ideally, use a name that helps identify the anchor’s Available (with limitations) location on the page—for example, top. in: Developer Edition 4. Now create a hyperlink that links to the anchor. USER PERMISSIONS SEE ALSO: Attaching Hyperlinks to Text and Images in Design Mode To build, edit, and manage Site.com sites: Editing Content Blocks in Design Mode • Site.com Understanding the Content Editing Toolbar Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
To edit only content in Site.com sites: • Site.com Contributor User AND Contributor role assigned at the site level
564 Extend Salesforce with Clicks, Not Code Site.com
Adding Custom Code to Pages
Custom code lets you customize your site using markup, such as HTML and JavaScript. EDITIONS • Add markup to a specific location on a page using the Custom Code page element. JavaScript added using the Custom Code page element loads when that part of the page loads. Available in: Salesforce • Add markup to the page head. JavaScript in the page head loads first. Classic (not available in all orgs) • Add JavaScript to the page body. JavaScript added to the page body is positioned at the end of the body tag and only loads when the DOM is ready. Available for purchase in: Enterprise, Performance, • Add a reference to a JavaScript file or library in the page head or body. and Unlimited Editions Tip: Available (with limitations) • Scripts can't execute while you're editing a page in Site.com Studio. To test your code, in: Developer Edition preview the page. • If you are building a Site.com site from an existing HTML site, avoid using the Custom USER PERMISSIONS Code page element to paste large chunks HTML from the original site. Instead, use the available page elements, such as panels, content blocks, and data tables. This will let you To build, edit, and manage make future updates and design changes much more easily. Site.com sites: • Site.com Publisher User Adding Markup Directly to the Page field enabled on the user detail page 1. Drag a Custom Code page element from the Page Element pane onto the page. AND 2. Enter the code in the Edit Code dialog box. Site administrator or 3. Click Save and Close to add the code directly to the page. designer role assigned at the site level Adding Markup to the Page Head 1. In the Scripts section of the Properties pane, click Configure in the Edit Head Markup section. 2. Enter the markup in the Edit HTML Code dialog box. 3. Click Save and Close to insert the markup into the page head.
Adding JavaScript to the Page Body 1. In the Scripts section of the Properties pane, click Configure in the Edit Body Scripts section. 2. Enter the code in the Edit JavaScript Code dialog box. Don't add
oncomplete="refreshFeed();"/> Account: Contact: Status: Priority: Case Origin:
Note: When you redirect to a URL internal to your org, the action dialog closes upon completion or programmatically navigating away. If you set up the redirect to point to an external URL, the behavior can vary because an external URL opens in a new browser tab.
732 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Requirements for Refreshing Host Pages If you want an object-specific or global custom action to refresh the feed on the page that hosts it, the Visualforce page you create to use as that action must: • Reference the publisher JavaScript file: . (Creating custom Visualforce actions doesn’t require the Canvas SDK.) • Include this JavaScript call: Sfdc.canvas.publisher.publish({name : 'publisher.refresh', payload : {feed:true}});.
Visualforce Pages as Global Custom Actions Visualforce pages used as global actions can be invoked in many different places and don’t have a specific record associated with them. They have complete “freedom of action,” which means it’s up to you to write the code. Hide the Action Header for Visualforce Custom Actions When creating a Visualforce page to use as a custom action, you can choose to hide the action’s header. Hiding the action header helps prevent user confusion, especially if you have your own buttons specified in the Visualforce page.
SEE ALSO: Visualforce Pages as Global Custom Actions Create Object-Specific Quick Actions Quick Actions
Visualforce Pages as Global Custom Actions
Visualforce pages used as global actions can be invoked in many different places and don’t have a EDITIONS specific record associated with them. They have complete “freedom of action,” which means it’s up to you to write the code. Available in: both Salesforce Visualforce pages you create to use as global actions can’t use a standard object controller. You Classic (not available in all must write a custom controller to handle the page. orgs) and Lightning Experience When a global action completes, the user should be either redirected to a parent record created as part of the action or returned to where they started. Available in: Group, Professional, Enterprise, This code sample shows a Visualforce page designed to be used as a custom action on any object Performance, Unlimited, that supports actions. This action lets users create cases from record detail pages, Chatter, Chatter Contact Manager, groups (except customer groups), or the home page. It has a different user interface from standard Database.com, and create actions. As with all global actions, the records created through this action aren’t associated Developer Editions with other records.
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();
733 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
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(); } } }
Subject: Account: Contact: 734 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
style="width:500px;height:92px;margin-top:4px;" />
Status: Priority: Case Origin: {!lastError}
Requirements for Refreshing Host Pages To have an object-specific or global custom action refresh the feed on the page that hosts it, the Visualforce page you create to use as that action must: • Reference the publisher JavaScript file: . (Creating custom Visualforce actions doesn’t require the Canvas SDK.) • Include this JavaScript call: Sfdc.canvas.publisher.publish({name : 'publisher.refresh', payload : {feed:true}});.
SEE ALSO: Visualforce Pages as Object-Specific Custom Actions Create Global Quick Actions Quick Actions
Hide the Action Header for Visualforce Custom Actions
When creating a Visualforce page to use as a custom action, you can choose to hide the action’s EDITIONS header. Hiding the action header helps prevent user confusion, especially if you have your own buttons specified in the Visualforce page. Available in: both Salesforce To hide the header, add showQuickActionVfHeader=“false” to the Classic (not available in all tag of the custom action’s Visualforce page. When the Visualforce custom action renders in the orgs) and Lightning Salesforce mobile app, the header and the Cancel and Save buttons are hidden. Using this attribute Experience doesn’t affect how the action displays in the full Salesforce site. Available in: Group, If you don’t specify showQuickActionVfHeader, its value defaults to true. Professional, Enterprise, Performance, Unlimited, Contact Manager, Database.com, and Developer Editions
735 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
The showQuickActionVfHeader attribute isn’t supported in Experience Cloud sites.
SEE ALSO: Visualforce Pages as Object-Specific Custom Actions Visualforce Pages as Global Custom Actions
Prerequisites for Using Canvas Apps as Custom Actions
Using canvas apps as custom actions makes it easy to give users access to the functionality of your EDITIONS apps in Chatter and elsewhere in Salesforce. You can use as a custom action any canvas app that uses Publisher as a location. For example, you Available in: both Salesforce might use an expense report app as a custom action to make it easy for salespeople to submit Classic (not available in all expense reports directly from feeds. A custom action that includes a video conferencing canvas orgs) and Lightning app could help support agents communicate with customers visually for easier troubleshooting of Experience technical issues. Quick actions available in: Before creating a custom action with a canvas app, be sure the app uses Publisher as a location, Group, Professional, and be sure to give the users you want to be able to use the action access to the app. Enterprise, Performance, Unlimited, Contact SEE ALSO: Manager, Database.com, and Developer Editions Visualforce Pages as Object-Specific Custom Actions Custom canvas actions Quick Actions available in: Professional (with Canvas enabled), Enterprise, Performance, Unlimited, and Developer Editions
Enable Actions in the Chatter Publisher
Enabling actions in the publisher lets you add actions that you’ve created to the Chatter publisher. USER PERMISSIONS Actions appear on the Home page, on the Chatter tab, in Chatter groups, and on record detail pages. To enable actions in the Chatter publisher: Available in: Salesforce Classic (not available in all orgs) • Customize Application
Available in: Group, Professional, Enterprise, Performance, Unlimited, Contact Manager, Database.com, and Developer Editions
By default, the Salesforce Classic Chatter publisher includes the standard actions Post, File, Link, Poll, Question, and Thanks. With the actions in the publisher setting enabled, you can include nonstandard actions in the Chatter publisher too. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. In organizations created after the Winter ‘14 release, actions in the publisher is enabled automatically. 1. From Setup, enter Chatter Settings in the Quick Find box, then select Chatter Settings. 2. Click Edit. 3. Select Enable Actions in the Publisher.
736 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Although the Enable Actions setting appears in Lightning Experience, it has no effect there.
4. Click Save.
Note: You aren’t required to enable actions in the publisher to use them in the Salesforce app or in third-party apps. See Actions With and Without Chatter for more information.
Set Up Actions with Chatter Enabled Global and object-specific actions enhance the Chatter experience for your users in Salesforce Classic and in the Salesforce app. Set Up Actions Without Chatter Enabled You can set up object-specific and global actions for the Salesforce mobile app or third-party apps, even if your org doesn’t have Chatter enabled. Actions With and Without Chatter Use actions regardless of whether Chatter or actions in the publisher are enabled.
Set Up Actions with Chatter Enabled
Global and object-specific actions enhance the Chatter experience for your users in Salesforce EDITIONS Classic and in the Salesforce app. Chatter must be enabled for your organization. Available in: both Salesforce Classic (not available in all By default, the Chatter publisher in Salesforce Classic includes the standard actions Post, File, Link, orgs) and Lightning Poll, Question, and Thanks. To set up more actions in Chatter: Experience 1. Enable feed tracking for the objects for which you want to make actions available. Available in: Group, 2. Enable actions in the publisher if you want to see both standard actions and non-standard Professional, Enterprise, actions in the Chatter publisher. Performance, Unlimited, 3. Optionally, enable feed updates for related records to display feed items on a record detail page Contact Manager, when related records are created. Database.com, and Developer Editions 4. Create object-specific actions or global actions. 5. Customize the action layout with the fields that you want users to see when they use the action. USER PERMISSIONS 6. Add the actions to page layouts or global publisher layouts. Salesforce automatically adds default actions to the page layouts for account, case, contact, To set up actions: • Customize Application lead, and opportunity, and to the global publisher layout in organizations that were created after Winter ‘14.
SEE ALSO: Enable Actions in the Chatter Publisher Create Object-Specific Quick Actions
737 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Set Up Actions Without Chatter Enabled
You can set up object-specific and global actions for the Salesforce mobile app or third-party apps, EDITIONS even if your org doesn’t have Chatter enabled. When Chatter is disabled in an org, only the nonstandard actions appear in the action bar in the Available in: both Salesforce Salesforce mobile app or in third-party apps that use action lists. Nonstandard actions include Classic (not available in all Create, Update, Log a Call, custom actions, and Mobile Smart Actions. orgs) and Lightning Experience Note: You can create actions in Salesforce Classic when Chatter is disabled. Those actions don’t appear in Salesforce Classic, but can appear in Lightning Experience and the Salesforce Available in: Group, mobile app if you don’t customize the Salesforce Mobile and Lightning Experience Actions Professional, Enterprise, section of the page layout editor. Performance, Unlimited, Contact Manager, Follow these steps to set up actions for use in the Salesforce mobile app or third-party apps. Database.com, and 1. Create object-specific actions or global actions. Developer Editions 2. Customize the action layout with the fields that you want users to see when they use the action. USER PERMISSIONS 3. Add the actions to page layouts or global publisher layouts. Salesforce automatically adds default actions to the page layouts for account, case, contact, To set up actions: lead, and opportunity, and to the global publisher layout in organizations that were created • Customize Application after Winter ‘14.
SEE ALSO: Create Object-Specific Quick Actions Create Global Quick Actions Customize Actions with the Enhanced Page Layout Editor
Actions With and Without Chatter
Use actions regardless of whether Chatter or actions in the publisher are enabled. EDITIONS The actions that are available in the full Salesforce site (Salesforce Classic and Lightning Experience) or in the Salesforce mobile app depend on your org’s settings. To enable or disable Chatter for your Available in: both Salesforce organization, from Setup, enter Chatter Settings in the Quick Find box, then select Classic (not available in all Chatter Settings. If Chatter is enabled, the Enable Actions in the Publisher option orgs) and Lightning controls whether the actions that you create display in the Chatter publisher. Experience
Chatter Off, Chatter On, Chatter On, Quick actions available in: Actions Off Actions Off Actions On Group, Professional, Enterprise, Performance, You can create global actions Yes Yes Yes Unlimited, Contact and customize global action Manager, Database.com, lists and Developer Editions
You can create Yes Yes Yes Custom canvas actions object-specific actions and available in: Professional (with Canvas enabled), customize object-specific Enterprise, Performance, action lists Unlimited, and Developer Actions appear on the Home No Yes1 Yes Editions page and Chatter home
738 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Chatter Off, Actions Off Chatter On, Actions Off Chatter On, Actions On page in the full Salesforce site
Actions appear in object feeds in the full No Yes1,2 Yes2 Salesforce site
The action bar is available in the No3 Yes4 Yes Salesforce mobile app feed
The action bar is available on the record Yes5 Yes6 Yes6 view in the Salesforce mobile app
The action bar is available on Lightning Yes5 Yes Yes pages in the Salesforce mobile app
Footnotes: 1. If actions in the publisher aren’t enabled, only standard Chatter actions (Post, File, Link, Poll, and Thanks) appear in the Chatter publisher in the full Salesforce site. 2. The Chatter feed appears on an object’s detail page in the full Salesforce site only for objects that have feed tracking enabled. 3. When Chatter is disabled, the Feed item isn’t available in the Salesforce mobile app. 4. When Chatter is enabled but actions in the publisher aren’t, standard Chatter actions and nonstandard actions appear in the Salesforce mobile app action bar and in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. 5. When Chatter and actions in the publisher are disabled, only nonstandard actions appear in the action bar in the Salesforce mobile app or in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. 6. If feed tracking isn’t enabled on an object, only nonstandard actions appear in the Salesforce mobile app action bar and in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions.
SEE ALSO: Set Up Actions with Chatter Enabled Set Up Actions Without Chatter Enabled Quick Actions
739 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Layout Editor
Just as object record pages have page layouts that can be customized, actions have action layouts EDITIONS that can be customized. When you create an action, Salesforce populates its layout with a default set of fields. You can add, remove, or reorder fields on the action layout to present only the essential Available in: both Salesforce items your users need when they’re taking the action. Classic (not available in all For example, a Post action needs just one large text area for user input. By contrast, an object-related orgs) and Lightning Create action must include multiple fields; otherwise, Salesforce can’t create the record. Experience The first time you view the layout for an action you’ve created, certain fields are prepopulated: Available in: Group, target object default fields, standard required fields, and any custom universally required fields. Professional, Enterprise, Default actions (available in organizations created after Winter ’14) have predefined sets of fields. Performance, Unlimited, Contact Manager, The upper part of the action layout editor is the palette, and below the palette is the action layout. Database.com, and The palette contains fields from the action’s target object that you can add to the action layout, Developer Editions except for the following unsupported field types: • Record type fields • Read-only field types such as roll-up summary, formula, and auto-number fields • Read-only system fields such as Created By or Last Modified By Inactive Fields Fields that are already on the action layout still appear on the palette but are inactive. When you select an inactive field on the palette, Salesforce highlights the field on the action layout. Field Type Conversion If you convert a field’s type from one that is supported for actions to a type that isn’t supported, Salesforce removes the field from the action layout. If you convert the field back to a supported type without changing the action layout, Salesforce automatically adds the field back to the layout. If you edit the layout, and then convert the field back to a supported type, add the field back to the layout manually. Layouts Used for Log a Call Actions A Log a Call action takes the active task page layout except under the following conditions: • Suppose that your organization has a custom Log a Call action for an object. The custom action takes the custom action layout defined for it. • Now suppose that your organization has a custom Log a Call global action. That action takes the custom layout defined for it, unless you also have a custom Log a Call action for an object. (A custom action on an object overrides a custom global action.) To display the simpler New Task form to Salesforce mobile app users, enable the form in Activity Settings and ensure that the layout used includes a subject field. Layout Auditing Salesforce tracks action layout customization in the setup audit trail history. To view and edit the layouts for global actions in Setup, enter Actions in the Quick Find box, then select Global Actions and then click Layout next to the action’s name. To view and edit the layouts for object-specific actions, find the object in Setup, then go to Buttons, Links, and Actions.
740 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Layout Editor Considerations When you create an action, Salesforce populates its layout with a default set of fields. You can add, remove, or reorder fields on the action layout to present only the essential items your users need when they’re taking the action.
SEE ALSO: Quick Actions
Action Layout Editor Considerations
When you create an action, Salesforce populates its layout with a default set of fields. You can add, EDITIONS remove, or reorder fields on the action layout to present only the essential items your users need when they’re taking the action. Available in: both Salesforce • There is no hard limit to the number of fields you can add to an action layout. However, for Classic (not available in all optimum usability, we recommend a maximum of 8 fields. Adding more than 20 fields can orgs) and Lightning severely impact user efficiency. To reduce the number of fields in your layout, you can create Experience predefined values for the required fields, and then remove those fields from your layout. You Available in: Group, can set predefined field values from the action detail page. Professional, Enterprise, • By default, the Call productivity action in the Salesforce mobile app action bar uses the global Performance, Unlimited, Log A Call action layout. If you create one Log a Call action on an object, users see that custom Contact Manager, Log a Call action’s layout when they tap Call from the action bar for that object. If you create Database.com, and more than one Log a Call action for the same object, the Call action on that object doesn’t know Developer Editions which layout to use, so it uses the global Log a Call action layout. • Mobile smart actions are populated with all your org’s required fields on the relevant object, regardless of how many fields there are. For example, the New Case action in the mobile smart action bundle includes all required case fields. You can’t edit the fields on mobile smart actions. The fields that appear change only if you change which fields on an object are required. • You can remove a required field from the action layout, but make sure that the field has a predefined value. Otherwise, users can’t create records. • Rich text area fields are supported only when you add them to one-column layouts, or as fields that span both columns in two-column layouts. If you add a rich text area field to only one column in a two-column layout, it appears as a plain text area, because there’s not enough space to display the full rich text editor.
Custom Success Messages for Quick Actions
For Create a Record, Update a Record, and Log a Call action types, you can create a custom message EDITIONS that displays when the action executes successfully. Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience
Available in: Group, Professional, Enterprise, Performance, Unlimited, Contact Manager, Database.com, and Developer Editions
741 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
In the Salesforce mobile app and Lightning Experience, when a create, update, or Log a Call action is completed, a default success message displays, regardless of whether the action created a feed item. If you add a custom success message to one of these actions, your custom success message displays instead of the default message. In Salesforce Classic, custom success messages have slightly different behavior. If you select Create Feed Item for a Create a Record or Log a Call action, no success message displays in Salesforce Classic. The feed item itself is the confirmation that the action executed successfully. You can configure translations for custom success messages through the Translation Workbench. From Setup, enter Translate in the Quick Find box, and then select Translate. Choose Action for the Setup Component, and choose Informational Message for the Aspect.
Note: If you have All Related Objects selected under feed tracking for a particular object, when a quick action creates related objects, a feed item is always created, regardless of the status of Create Feed Item.
SEE ALSO: Create Object-Specific Quick Actions Create Global Quick Actions
742 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Customize Actions with the Enhanced Page Layout Editor
Use the page layout editor to customize which actions show up in Salesforce and in the Salesforce EDITIONS mobile app.
Tip: To manage the actions for global pages, such as Home, Chatter Home, and Chatter Available in: both Salesforce groups, see Global Publisher Layouts. Classic (not available in all orgs) and Lightning From the management settings for the object whose actions you want to manage, go to Page Experience Layouts. Available in: Group, You can add actions to two sections on a page layout: Professional, Enterprise, Quick Actions in the Salesforce Classic Publisher Performance, Unlimited, This section can contain actions only from the Quick Actions category in the palette. Actions Contact Manager, in this section appear in the Chatter publisher in Salesforce Classic. Database.com, and Developer Editions Salesforce Mobile and Lightning Experience Actions This section can contain actions only from the Mobile & Lightning Actions category in the palette. On object page layouts, the Mobile & Lightning Actions category contains all available USER PERMISSIONS types of actions for the object, including quick actions, productivity actions, Lightning component actions, and standard and custom buttons. Actions in this section appear in the action bar and To create actions: action menu in the Salesforce mobile app and in various areas of Lightning Experience. • Customize Application To customize action layouts Tip: Hover over an action in the palette to see its label, API name, and action type. and page layouts: • Customize Application • To override the action defaults for an action section that you haven’t customized, either click the override text or hover over the section and click . To view page layouts: • View Setup If you haven’t customized the Quick Actions in the Salesforce Classic Publisher section of a page layout, the actions that appear in the publisher for that object default to the actions that are assigned to the global publisher layout. Upon overriding, the actions default to the standard actions—Post, File, Link, Poll, Question, and Thanks—regardless of what actions were assigned to the global publisher layout. If you haven’t customized the Salesforce Mobile and Lightning Experience Actions section of a page layout, the actions for that object default to a set of predefined actions. If you have customized actions in the Quick Actions in the Salesforce Classic Publisher section, and have saved the layout, the Salesforce Mobile and Lightning Experience Actions section inherits the actions from the Quick Actions in the Salesforce Classic Publisher section, plus any standard or custom buttons present on the layout, when you click to override.
• To revert the actions in either section to the defaults for that section, hover over the section and click .
SEE ALSO: Set Up Actions with Chatter Enabled Actions in Lightning Experience Send Email Action Considerations for Cases Mobile Smart Actions Customize Page Layouts with the Enhanced Page Layout Editor Find Object Management Settings
743 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Set Predefined Field Values for Quick Action Fields
When you create actions, use predefined field values to set a value for a field. Predefined values can EDITIONS help ensure consistency and make it faster and easier for users to create records. When you configure action layouts, it’s better to use fewer fields. Most users, especially mobile Available in: both Salesforce users, don’t like to fill in a lot of required fields. They want to get things done and move on to their Classic (not available in all next task. A good way to use fewer fields in action layouts is to set predefined values for as many orgs) and Lightning fields as possible. The more fields you can set predefined values for, the more you can remove from Experience the layout and make the action easier and quicker to use. Balance ease of use with the need for Available in: Group, required information. However, don’t remove required fields from an action layout without setting Professional, Enterprise, a predefined value for those fields, or when a user applies that action, the record won’t save properly. Performance, Unlimited, If you set predefined values for fields on object records created through an action, you don’t need Contact Manager, to add those fields to the action layout. For example, when you configure an action that lets users Database.com, and create opportunities, set Prospecting as the predefined value for the Stage field. All new opportunities Developer Editions users create through that action are automatically assigned to the prospecting stage. You can remove the Stage field from the action’s layout, because the field is going to be assigned a value USER PERMISSIONS automatically. To set predefined field Tip: Predefined values for fields on actions are different from default values that you can set values: for fields on records. If a field is included in an action, it can have both a predefined value set • Customize Applications for the action and a default value set. 1. Click the name of an action in the Buttons, Links, and Actions list or the Global Actions list. 2. On the action detail page, click New in the Predefined Field Values list. 3. Select the field you want to predefine a value for. 4. Specify the value for the field. For single-select picklists, you can specify both a specific value and a formula value. If you set both, the formula value takes precedence over the specific value.
5. Click Save.
Tip: On object-specific actions, the predefined value can include references to the source object and its related objects.
Notes on Predefined Field Values for Quick Actions
SEE ALSO: Notes on Predefined Field Values for Quick Actions
744 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Notes on Predefined Field Values for Quick Actions
Setting predefined field values for quick actions is especially important if you remove required or EDITIONS Always on Layout fields from the action layout. • You can set predefined values for any field available in the action layout editor, with these Available in: both Salesforce exceptions. Classic (not available in all orgs) and Lightning – Dependent picklists Experience – Multi-select picklists Available in: Group, – Read-only field types like auto-number, formula, and roll-up summary fields Professional, Enterprise, – Lookup fields Performance, Unlimited, Contact Manager, • You can’t use a dependent picklist to set a predefined value. Database.com, and • If a field on an action has both a predefined value and a default value set, the action uses the Developer Editions predefined value, not the default value. • If a picklist field on a quick action has both a predefined specific value and predefined formula value, the formula value takes precedence over the specific value. • If you set a predefined value for a field and leave it on the action layout, that value displays as the default value for the field. • If you use a rich text field as a predefined field value, any text formatting that was applied in the rich text field is removed in the new field. • When you have a required field with a predefined value and remove the field from the action layout, you must add the required field back to the action layout if you later delete the field’s predefined value. Otherwise, users can’t save the record. • Formulas can’t reference fields on external objects, so you can’t reference an external object field to set a predefined field value for a quick action. • You can use a TEXT(picklist) value in a predefined value field. • To set the value for an email action’s recipient, predefine the To, CC, or BCC fields. You can use ID fields, such as Contact.Id, or string fields, such as Contact.custom_email_field to predefine the value. – Contact, lead, and person account IDs are supported. – Use an ID field if you want to log the email on the recipient’s record. – Use a string field to predefine an email recipient for a custom object or custom field. – If you use a string field, the email isn’t logged on the recipient’s record.
SEE ALSO: Set Predefined Field Values for Quick Action Fields
745 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Global Publisher Layouts
Global publisher layouts determine the global actions that appear in the various Salesforce interfaces. EDITIONS In Salesforce Classic and Lightning Experience, these layouts customize the actions on global pages (like the Home page) and on the Chatter page. Lightning Experience also uses these layouts to Available in: both Salesforce populate the Global Actions menu. And in the Salesforce mobile app, these layouts drive the actions Classic (not available in all that appear in the action bar on the Feed and People pages. Global publisher layouts can include orgs) and Lightning global actions only. Experience
In Salesforce for Outlook, global publisher layouts drive the actions that Group, Contact Manager, Available in: Group, and Professional Edition users see when they click the Salesforce Side Panel Publisher. Professional, Enterprise, Salesforce for Outlook users working in all other editions can set up their side panel publishers using Performance, Unlimited, Outlook Side Panel Publisher Layouts. Contact Manager, Database.com, and Note: Chatter groups without customers display the global publisher layout by default, Developer Editions unless you override it with a customized group publisher layout. In Chatter groups that allow customers, the publisher displays standard actions only, such as Post, File, Link, and Poll. You can assign different global publisher layouts to different user profiles to customize which actions USER PERMISSIONS users see by default on global pages. To create actions: Note: Changes to user layouts override the global publisher layout on user profile pages • Customize Application and the Chatter home page. To customize action layouts and page layouts: These are the steps involved in working with global publisher layouts. • Customize Application To view page layouts: 1. Create Global Publisher Layouts • View Setup Global publisher layouts determine the global actions that appear in the various Salesforce interfaces. In Salesforce Classic and Lightning Experience, these layouts customize the actions on global pages (like the Home page) and on the Chatter page. Lightning Experience also uses these layouts to populate the Global Actions menu. And in the Salesforce mobile app, these layouts drive the actions that appear in the action bar on the Feed and People pages. Global publisher layouts can include global actions only. 2. Add Actions to Global Publisher Layouts Actions you add to the global publisher layouts appear on pages such as the Home and Chatter pages. They also appear on the action bar and action menu on the Feed and People pages in the Salesforce mobile app. 3. Assign Global Publisher Layouts to User Profiles Once you finish creating a global publisher layout, you can assign it to different user profiles. For example, a Marketing User and a Standard User might need different actions in the Chatter publisher or in the Salesforce mobile app. Create multiple global publisher layouts and assign them to different user profiles to customize the actions for each profile.
SEE ALSO: Create Global Quick Actions
746 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Create Global Publisher Layouts
Global publisher layouts determine the global actions that appear in the various Salesforce interfaces. EDITIONS In Salesforce Classic and Lightning Experience, these layouts customize the actions on global pages (like the Home page) and on the Chatter page. Lightning Experience also uses these layouts to Available in: both Salesforce populate the Global Actions menu. And in the Salesforce mobile app, these layouts drive the actions Classic and Lightning that appear in the action bar on the Feed and People pages. Global publisher layouts can include Experience global actions only. Available in: Enterprise, Publisher Layouts Quick Find 1. From Setup, enter in the box, then select Publisher Performance, Unlimited, Layouts. Database.com, and 2. To create a new global publisher layout, click New. Developer Editions 3. To clone a publisher layout, select one from the Existing Global Publisher Layout drop-down list. USER PERMISSIONS
4. Enter a name for the new global publisher layout. To create actions: 5. Click Save. • Customize Application To customize action layouts SEE ALSO: and page layouts: • Customize Application Assign Global Publisher Layouts to User Profiles To view page layouts: Global Publisher Layouts • View Setup
Add Actions to Global Publisher Layouts
Actions you add to the global publisher layouts appear on pages such as the Home and Chatter EDITIONS pages. They also appear on the action bar and action menu on the Feed and People pages in the Salesforce mobile app. Available in: both Salesforce Arrange the actions so that the frequently used actions appear first in each list. Classic (not available in all orgs) and Lightning You can add actions to two sections on a page layout: Experience Quick Actions in the Salesforce Classic Publisher This section can contain actions only from the Quick Actions category in the palette. Actions Available in: Group, Professional, Enterprise, in this section appear in the Chatter publisher in Salesforce Classic. Performance, Unlimited, Salesforce Mobile and Lightning Experience Actions Contact Manager, This section can contain actions only from the Mobile & Lightning Actions category in the Database.com, and palette. On object page layouts, the Mobile & Lightning Actions category contains all available Developer Editions types of actions for the object, including quick actions, productivity actions, Lightning component actions, and standard and custom buttons. Actions in this section appear in the action bar and USER PERMISSIONS action menu in the Salesforce mobile app and in various areas of Lightning Experience.
Note: Changes to user layouts override the global publisher layout on user profile pages To create actions: and the Chatter home page. Actions on the user profile page come from the Quick Actions • Customize Application in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter To customize action layouts actions appear on the user profile page, regardless of which actions are present in the User and page layouts: Page Layout or the global publisher layout. • Customize Application 1. From Setup, enter Publisher Layouts in the Quick Find box, then select Publisher To view page layouts: Layouts. • View Setup
747 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
2. To add or remove actions, drag them to and from the palette. To reorder actions, select an action and drag it to a new position. 3. Click Save when you’re done, or click Quick Save to save your changes and continue working on the layout. If you navigate away without saving, you lose your changes.
Note: Before using the personal email setting When you click an email address to compose an email, which email editor do you want to use?, confirm that the Global Publisher Layout has the email action in the Salesforce Mobile and Lightning Experience Action section.
Example: Let’s add the New Account action to the publisher on the Home and Chatter pages in Salesforce Classic. The New Account action lets users create an account directly from the publisher. Drag the New Account action to the Quick Actions in the Salesforce Classic Publisher section and save your changes.
Go to the Chatter tab in Salesforce Classic. Now the New Account action shows up in the publisher.
Note: The Chatter page in Lightning Experience supports only the standard Chatter actions Post, Poll, and Question, and if you have Groups, the Announcement action.
SEE ALSO: Actions in Lightning Experience Send Email Action Considerations for Cases Assign Global Publisher Layouts to User Profiles Email Application Publisher Layouts
748 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Assign Global Publisher Layouts to User Profiles
Once you finish creating a global publisher layout, you can assign it to different user profiles. For EDITIONS example, a Marketing User and a Standard User might need different actions in the Chatter publisher or in the Salesforce mobile app. Create multiple global publisher layouts and assign them to different Available in: both Salesforce user profiles to customize the actions for each profile. Classic (not available in all 1. From Setup, enter Publisher Layouts in the Quick Find box, then select Publisher orgs) and Lightning Layouts. Experience 2. Click Publisher Layout Assignment. Available in: Group, Professional, Enterprise, 3. Click Edit Assignment. Performance, Unlimited, 4. Select a user profile by clicking anywhere on its row in the table. Contact Manager, 5. From the Publisher Layout to Use drop-down, select the global publisher layout that you want Database.com, and to assign to the highlighted profile. Developer Editions 6. Save the layout. USER PERMISSIONS
SEE ALSO: To create actions: Add Actions to Global Publisher Layouts • Customize Application Global Publisher Layouts To customize action layouts and page layouts: • Customize Application To view page layouts: • View Setup
Quick Actions and Record Types
Using record types in your organization can affect the availability of quick actions for your users. EDITIONS If users don’t have access to a particular record type, actions that are assigned to that record type aren’t available to them. For example, let’s say that you have a page layout that contains a mix of Available in: both Salesforce actions—some have no record type assigned and some are assigned to Record Type A. Users Classic (not available in all without access to Record Type A see only the nonassigned actions when they visit the page. orgs) and Lightning Experience Important: Don’t assign actions to the Master record type. The Master record type is a placeholder record type that’s assigned when your organization is created. Quick actions available in: Group, Professional, Enterprise, Performance, Default Global Actions: A Special Case Unlimited, Contact If you have default global actions in your organization and you’re using record types, your users Manager, Database.com, might not be able to see all the default actions that are assigned to a page layout. and Developer Editions Default global actions are assigned to the Master record type, which isn’t accessible to most profiles. Custom canvas actions As a result, default global actions with the Master record type that are associated with target objects available in: Professional that have record types configured aren’t available for most users. To fix this issue, edit the default (with Canvas enabled), global actions associated with those objects and reassign them to a different record type. Enterprise, Performance, Unlimited, and Developer For example, the New Contact default global action has Contact as its target object. Let’s say you Editions have record types set up for the Contact object, and you add the New Contact default global object to a page layout. Users who visit records based on that page layout don’t see the New Contact action because the action is assigned to the Master record type by default. Editing the New Contact
749 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
default global action and assigning it to a record type other than Master makes it available for all users who have access to its assigned record type.
Actions Best Practices
Use these tips as you set up actions. EDITIONS
Tips for Creating Actions Actions available in: both Salesforce Classic and • Action labels longer than approximately 12–14 characters are shortened when they’re displayed Lightning Experience in the Chatter publisher. Keep names short and descriptive. • Give your actions task-oriented names that tell your users what they do. Use terms such as New, Publisher available in: Create, Share, Update, or Import. Salesforce Classic • Use the Description field to create notes for yourself about each action. Notes are especially Available in: Essentials, useful if you’re creating several similar actions for different record types, for example. The Group, Professional, description appears in the list of buttons, links, and actions for object-specific actions, or in the Enterprise, Performance, list of global actions, as well as on the detail page for the action. Your notes aren’t visible to Unlimited, Contact users. Manager, Database.com, and Developer Editions • 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.
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 necessary for them and for whomever handles 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, when you configure an action that lets users create opportunities, set Prospecting as the predefined value for the Stage field. All new opportunities users create through that action are automatically assigned to the prospecting stage. You can remove the Stage field from the action’s layout, because the field is going to be assigned a value automatically. If you set 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 appears to different user profiles.
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 Salesforce Classic, if you include five or more actions in the actions section of a page layout, 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 the Salesforce mobile app, the first three actions show up in the action bar, and the full set of actions are accessed by tapping .
SEE ALSO: Quick Action Considerations Troubleshooting Actions Set Up Actions with Chatter Enabled
750 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Quick Action Considerations
Keep these considerations in mind when working with quick actions. EDITIONS • If you’re using record types in your org, sometimes quick actions aren't visible to your users. For more information, see Quick Actions and Record Types on page 749. Actions available in: both • To see an object-specific action on a page layout, a user must have both Read and Edit Salesforce Classic and permissions on the action’s relationship field. The relationship field is the field that’s automatically Lightning Experience populated on the target object when a user creates a record using an action. For example, for Available in: Essentials, an action on a case that lets users create child cases, the default relationship field is Parent Group, Professional, Case. To be sure that users can see the Create Child Case action, check that they have both Enterprise, Performance, Read and Edit permissions on the Parent Case field. Unlimited, Contact Manager, Database.com, Field-level security sets the Account parent field on the Case object to read-only by default, and Developer Editions which means it’s not visible to non-system administrator users. Therefore, actions on accounts that have Case as the target object are also not visible to users without the System Administrator profile. To let users see actions on accounts that have Case as the target object, remove the Read Only setting.
• In quick action layouts: – A blank space inserted on the same line as another field in the quick action layout causes that field to stretch to the full page width. The field is left justified on the page, regardless of its position in the quick action layout editor. – Two blank spaces inserted on the same row in the quick action layout editor don't create a blank line on the page. The two blank spaces are ignored. – If there's an uneven number of fields on the quick action layout, the final field stretches to the full page width and is left justified. The behavior is the same if a blank space is inserted on the same row as the final field.
• Custom actions can be defined for person accounts but with these exceptions. – Person account-specific fields, including Email and Mobile, aren’t available in action layouts when using object-specific custom actions to update accounts. – To set up object-specific custom quick actions that create person account records, define a custom lookup field for Account on the Account or Contact object. Global custom quick actions can be used without defining this field. – Actions that create business account records from a person account detail page must be global, not object-specific.
• If you delete an action, the action is removed from all layouts that it’s assigned to. • Automatic triggers that change record ownership can affect what object details are visible to users. In some cases, a user can enter information that is then immediately hidden from them if an automatic trigger changes the object's owner. For example, if you use a global create quick action to create an object and an automatic trigger changes the object ownership, some information about the object isn't visible to you. • My Domain must be deployed in your org for Lightning component actions to work properly. • Chatter groups without customers display the global publisher layout by default, unless you override it with a customized group publisher layout. In Chatter groups that allow customers, the publisher displays standard actions only, such as Post, File, Link, and Poll.
Actions and Master-Detail Object Relationships • Actions to create records for an object that is the detail object in a master-detail relationship must be object-specific, not global. • If you create an action on a detail object in a master-detail relationship, the action’s target object can’t be a different detail object of the same master.
751 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
For example, master object A has two detail objects, B and C. You can create actions on object A with B or C as the target object. However, when creating an action on object B, the target object can’t be object C because B and C have the same master. To create an action on B with C as the target, you can do one of the following: – Change the relationship between B and C to master-detail so that A is the master of B, and B is the master of C. – Change the relationship between C and A to a lookup relationship. Note that A is still the master of B with this option, so you can’t create a quick action on B with a target object of A.
Troubleshooting Actions
EDITIONS I don’t see feeds on record detail pages for a certain object. Feeds appear only for objects for which you’ve enabled feed tracking. Available in: both Salesforce Classic (not available in all orgs) and Lightning I see the feed on a record detail page, but I don’t see a publisher. Experience
If there are no actions in the Quick Actions in the Salesforce Classic Publisher section on a page Available in: Group, layout, the publisher in Salesforce Classic doesn't appear. Add at least one action to the page layout Professional, Enterprise, for the publisher to appear. Performance, Unlimited, Contact Manager, I can create actions, but I can’t add them to publishers. Database.com, and Developer Editions Enable actions in the publisher to add nonstandard actions to publishers in Salesforce Classic.
I’m using Internet Explorer 10 and all the actions I’ve created appear in the publisher with the same icon, even though the actions are for different types of objects. Internet Explorer version 10 doesn’t support the techniques Salesforce uses to show icons that correspond to the type of object an action is associated with. Consider using Chrome, Firefox, Safari, or an earlier version of Internet Explorer.
I’ve added an action to a page layout, but a user assigned to the profile that uses that page layout can’t see the action. Be sure that the user has both Read and Edit permissions on the action’s relationship field. The relationship field is the field that’s automatically populated on the target object when a user creates a record using an action. For example, for an action on a case that lets users create child cases, the default relationship field is Parent Case. To be sure that users can see the Create Child Case action, check that they have both Read and Edit permissions on the Parent Case field.
I don’t see a relationship field on my global create actions. Relationship fields apply only to object-specific create actions, not to global actions.
I don’t see some of the actions in my Chatter groups. Which actions you see depends on your role in the group, the type of group, and how your administrator has configured the publisher layout for groups. Chatter groups without customers display the global publisher layout by default, unless you override it with a customized group publisher layout. In Chatter groups that allow customers, the publisher displays standard actions only, such as Post, File, Link, and Poll.
752 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
I see an error when I select a custom create account action from a person account. Although your administrator can add the custom create account action to the page layout, this action isn’t supported for person accounts.
SEE ALSO: Actions Best Practices Set Up Actions with Chatter Enabled
Action Limits and Limitations
Actions can work differently than you expect in certain situations and for different objects. Keep EDITIONS these limits and limitations in mind when working with actions. • Custom actions aren’t available in Experience Builder sites. Available in: Essentials, • You can display up to 10 actions in Lightning view. Group, Professional, Enterprise, Performance, • Custom images used for action icons must be less than 1 MB in size. Unlimited, Contact • Custom actions can be defined for person accounts but with these exceptions. Manager, Database.com, – Person account-specific fields, including Email and Mobile, aren’t available in action and Developer Editions layouts when using object-specific custom actions to update accounts. – To set up object-specific custom quick actions that create person account records, define a custom lookup field for Account on the Account or Contact object. Global custom quick actions can be used without defining this field. – Actions that create business account records from a person account detail page must be global, not object-specific.
• Actions associated with objects that aren’t supported in Lightning Experience don’t appear in the Global Actions menu. Also, the Global Actions menu doesn’t support standard Chatter actions. • Mobile smart actions don’t appear in the full Salesforce site, regardless of which page layouts you add them to. They appear only to users in the Salesforce mobile app. • The Chatter page in Lightning Experience supports only the standard Chatter actions Post, Poll, and Question, and if you have Groups, the Announcement action. • The palette in the action layout editor doesn’t support: – Record type fields – Read-only field types such as roll-up summary, formula, and auto-number fields – Read-only system fields such as Created By or Last Modified By
• Actions on the user profile page come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on the user profile page, regardless of which actions are assigned to the User Page Layout or the global publisher layout. • Actions on reports come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on reports, regardless of which other actions are assigned to the global publisher layout. • Chatter groups with customers don’t support global create, log a call, or custom actions and display only standard Chatter actions, such as Post, File, Link, and Poll. • External objects support quick actions, except when the actions involve features or functionality that are incompatible with external objects. For example: – Formulas can’t reference fields on external objects, so you can’t reference an external object field to set a predefined field value for a quick action. – Log a Call actions create tasks, which aren’t available for external objects.
753 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• When you create an object-specific action, you can choose as a target object an event, a task, or any object that has a parent-child or lookup relationship to the host object. You can’t choose Quote as a target object from Opportunity. However, you can still create quotes from an opportunity by going to the opportunity’s Quotes related list and clicking New. • The Account Contact Relationship object supports custom actions, but with limitations. – Custom actions must be specific to the Account Contact Relationship object. Global actions aren’t supported. – You can create actions that update records or invoke Lightning components or Visualforce pages. But you can’t create actions that create records. – You can’t create actions that send emails or log calls because you can't associate activities to the Account Contact Relationship object. – You can’t override the default actions on the Account Contact Relationship object. – Only custom actions that are created on the Contact object can use the Account Contact Relationship object as a target object. – Chatter standard actions aren’t supported because the Account Contact Relationship object doesn’t have a Chatter feed.
Actions in Lightning Experience
In Lightning Experience, actions appear in the Global Actions menu in the header, on related lists, EDITIONS and on list view items. Actions also appear on a record page, in one of several places depending on the action’s type. Available in: both Salesforce Note: Quick actions aren’t the only action type covered here. Standard and custom buttons Classic (not available in all are also considered actions. orgs) and Lightning Experience
Actions in the Global Actions Menu Quick actions available in: Group, Professional, The Global Actions menu displays a subset of global actions from the Salesforce Mobile and Lightning Enterprise, Performance, Experience Actions section of the global publisher layout. Unlimited, Contact Manager, Database.com, and Developer Editions Custom canvas actions available in: Professional (with Canvas enabled), Enterprise, Performance, Unlimited, and Developer Editions
The items in the menu appear in the order that they’re listed in the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout. Actions associated with objects that aren’t supported in Lightning Experience don’t appear in the Global Actions menu. Also, the Global Actions menu doesn’t support standard Chatter actions.
754 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Actions on List Views and List View Items Custom buttons, list view actions, and certain standard buttons are supported on all list views, except Recently Viewed. To have a custom button appear on a list view, add the button to the object’s List View search layout. In the Kanban view, only the standard New action is supported. List view items support only specific standard actions, like Edit, Delete, or Change Owner.
For Tasks, table format list views and the Kanban view support only standard buttons. Tasks list view items in table view and the task item detail pane in split view contain the complete list of available actions for tasks.
Actions on the Home Page On the Home page, you can find actions on recommendations in the Assistant. For example, imagine that a sales rep receives an update that an opportunity doesn’t have any open activity. The rep can create a task or event directly from the recommendation.
The actions that appear depend on the type of recommendation. To appear in the Assistant, actions must be added to the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout. Supported actions include: • New Task • New Event • Edit • Email After you complete an action, the related recommendation disappears from the Assistant.
755 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Actions on the Chatter Page The Chatter page, like the Chatter tab on record pages, contains only standard Chatter actions. By default, only the Post, Poll, and Question actions are supported, and if you have Groups, the Announcement action. You can add, remove, or reorder the actions on the Chatter page from the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout.
Actions on Record Pages Here’s a sample contact page in Lightning Experience.
Note: The opportunity and leads workspaces have different structures, but actions appear in the same way on those pages.
The page-level action menu in the record’s highlights panel (1) contains: • Productivity actions • Global and object-specific quick actions, except for those actions related to creating tasks, creating events, and logging calls • Standard buttons • Custom object-specific Lightning component quick actions • Custom flow actions • Custom Visualforce quick actions • Custom Visualforce buttons
756 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• Canvas actions The actions that appear in the page-level action menu are listed in the order that they appear in the Salesforce Mobile and Lightning Experience Actions section of the page layout.
Note: You can enable dynamic actions in the highlights panel on an object’s record page using the Lightning App Builder. Dynamic actions for custom objects on desktop and mobile and for the standard objects Account, Case, Contact, Lead, and Opportunity on desktop are generally available. Dynamic actions for other standard objects on desktop are beta. Add, remove, and reorder actions directly in the Lightning App Builder and control action visibility based on filters that you apply. When you enable dynamic actions in the Lightning App Builder, highlights panel actions for the record page no longer come from the object’s page layout. The Activity tab (2) contains Create a Record quick actions that point to the Event and Task objects. It also contains Log A Call and Send Email actions. The Chatter tab (3) contains standard Chatter actions. By default, only the Post, Poll, and Question actions are supported, and if you have Groups, the Announcement action. Some objects support other standard Chatter actions predefined by Salesforce.
Note: Actions on user profiles, cases, and work orders can appear in a different way than on other records. • Actions on the user profile page come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on the user profile page, regardless of which actions are assigned to the User Page Layout or the global publisher layout. • When feed tracking is enabled for cases or work orders, the page-level action menu on those records contains only custom buttons and supported standard buttons. Quick actions appear on the Chatter tab. On Experience Builder sites, quick actions for work orders appear on the page-level action menu.
Actions on Related Lists Related lists in Lightning Experience (4) show custom list buttons and supported standard buttons assigned to the related list. Not all related list standard buttons are supported in Lightning Experience.
Actions on Reports Actions on reports come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on reports, regardless of which other actions are assigned to the global publisher layout.
Example: Let’s say you have these actions on your Contact page layout in the Salesforce Mobile and Lightning Experience Actions section.
You have quick actions (New Account, New Event, New Task), a productivity action (Call), standard buttons (Edit, Delete, Clone, Send an Email), and Chatter actions (Poll, Post). Here’s how those actions appear on a contact record page in Lightning Experience. • The actions in the page-level action menu are a combination of the quick actions, productivity actions, and standard buttons. These actions appear in the order that they’re listed on the page layout. Although they’re quick actions, New Event and New Task don’t show up here.
757 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• The Chatter actions from the front of the action list are on the Chatter tab.
• The Activities-related actions—Email, New Event, New Task—display on the Activity tab.
How Actions Are Ordered in Lightning Experience In Lightning Experience, the actions on record pages are derived from the list of actions in the Salesforce Mobile and Lightning Experience Actions section of the page layout for that object. The same section on global publisher layouts determines the global actions that appear in the Global Actions menu.
SEE ALSO: Quick Actions Quick Action Considerations Set Up Cases for Lightning Experience
758 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
How Actions Are Ordered in Lightning Experience
In Lightning Experience, the actions on record pages are derived from the list of actions in the EDITIONS Salesforce Mobile and Lightning Experience Actions section of the page layout for that object. The same section on global publisher layouts determines the global actions that appear in the Global Available in: both Salesforce Actions menu. Classic (not available in all If you haven’t customized the Salesforce Mobile and Lightning Experience Actions section of an orgs) and Lightning object’s page layout, the quick actions that appear on the object’s record pages are derived from: Experience
• The actions on the global publisher layout Quick actions available in: • Standard and custom buttons in the buttons section of the object page layout Group, Professional, However, the order of the actions from the global page layout aren’t respected on those record Enterprise, Performance, Unlimited, Contact pages. Manager, Database.com, When you click to override the predefined actions in the Salesforce Mobile and Lightning Experience and Developer Editions Actions section, the custom buttons in the buttons section of the page layout aren’t automatically Custom canvas actions included in the action list. You must add the custom buttons as actions from the Mobile & Lightning available in: Professional Actions category in the palette. (with Canvas enabled), After you customize the Salesforce Mobile and Lightning Experience Actions section of an object’s Enterprise, Performance, page layout, the actions in each section of the record page respect the ordering of its types of Unlimited, and Developer actions on the page layout. For example, actions in the page-level actions menu appear in the order Editions that you configure them in the Salesforce Mobile and Lightning Experience Actions section on the page layout. And actions in the Chatter and Activity tabs reflect the order of the actions supported for those tabs on the page layout.
The Global Actions menu ( ) in the Lightning Experience header displays all global quick actions from the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout, except the standard Chatter actions Post, File, Poll, Link, Question, and Thanks.
SEE ALSO: Actions in Lightning Experience Send Email Action Considerations for Cases Quick Actions
Salesforce Mobile App Action Bar Salesforce mobile app users have a one-stop place to find actions, so there’s no confusion about where to go to do something. The action bar and its associated action menu collect actions from different places in the app into a single, unified home. The productivity actions, standard and custom record buttons, and quick actions appear in the action bar and the action menu ( ). The action bar and action menu show all the available actions for a given page.
759 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Salesforce Mobile App Actions in the Action Bar and Action Menu
The action bar appears in most places in the mobile app, including the feed, groups, user profiles, dashboards and reports, standard and custom object record views, related lists, and search results. The actions that are available depend on where a user is in the app and on how you’ve configured page layouts and publisher layouts for your organization. Users may see some or all of these kinds of actions in the action bar (including the action menu). • Productivity actions—The Send Email, Call, Map, View Website, and Read News actions are available on accounts, contacts, leads, and person accounts. The Quick Message, Join Conference Call, and Map actions are available on mobile calendar events in Salesforce Today.
Tip: In most cases, a productivity action displays only if a record includes the information that the action is keyed to. For example, the Send Email action depends on the record including an email address. The View Website action requires the record to include a website URL.
• Custom and standard buttons—Buttons (such as Edit, Delete, or Clone) that are included in the Buttons section on an object’s page layout are available in the mobile app as actions in the action bar on record pages. If you haven’t customized the action order, the button order in the button section of the page layout is used. However, the Edit button is in a fixed position.
Note: Custom links, custom buttons that are added to list views, and custom buttons that define the content source as OnClick JavaScript aren’t supported and don’t appear in the Salesforce mobile app.
• Quick actions—If you add, remove, or reorder actions in the action bar in the global publisher layout or an object’s page layout, the changes are reflected in the Salesforce mobile app. • Standard Chatter actions—Actions unique to Chatter, such as Post, File, Link, or Poll.
What are the exceptions? • On accounts, the Call action appears even when there isn’t a phone number on the record. • On record feeds, the Follow/Unfollow button remain in the highlights area on the page.
760 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• On public and private group feeds, the Join Group and Ask to Join buttons remain in the highlights area, but the Leave Group button is in the action bar.
What does this mean for custom branding? There can be only one version of a custom icon. Custom action icons that you created before Winter ’15 are still supported, but they are truncated in the action bar. To optimize your custom action icons for display in the action bar, use these guidelines. • The icon should be 72 x 72 pixels. Use the full pixel area for the image—don’t leave spacing around the image like before. • Make the image a PNG with a transparent background, with a file size that is less than 10k. • Have a resolution of 72 dpi. • Make the icon graphic white or lighter than the background color. • Avoid heavy inner or outer shadows. • Use simple and flat styling resembling the Salesforce mobile app icon family.
How Actions Are Ordered in the Salesforce Mobile App Action Bar The Salesforce Mobile and Lightning Experience Actions section of a page layout and global publisher layout drives which actions appear in the Salesforce mobile app action bar. It also enables you to customize the order of quick actions, productivity actions, and standard and custom buttons that are available as actions. List Item Actions in the Salesforce Mobile App List item actions give you access to your actions in list views, task lists, and related record lists. You can use list item actions to update records directly from lists. How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions Your org’s page layouts and publisher layouts control the order in which actions appear in the Salesforce mobile app action bar and list item actions. If you don’t customize the actions in the action bar on a page layout or global publisher layout, Salesforce predefines the location of key actions. Considerations for Actions in the Salesforce Mobile App
How Actions Are Ordered in the Salesforce Mobile App Action Bar
The Salesforce Mobile and Lightning Experience Actions section of a page layout and global publisher EDITIONS layout drives which actions appear in the Salesforce mobile app action bar. It also enables you to customize the order of quick actions, productivity actions, and standard and custom buttons that Available in: both Salesforce are available as actions. Classic (not available in all If you customize the Salesforce Mobile and Lightning Experience Actions section of a layout, the orgs) and Lightning mobile app reflects your customizations. Experience If you customize the Quick Actions in the Salesforce Classic Publisher section but not the Salesforce Available in: Group, mobile app section, the actions in the mobile app action bar are a combination of those in the Professional, Enterprise, Quick Actions in the Salesforce Classic Publisher section plus any standard or custom buttons present Performance, Unlimited, on the page layout. Contact Manager, Database.com, and When you click to override the predefined actions in the Salesforce Mobile and Lightning Experience Developer Editions Actions section, the custom buttons in the buttons section of the page layout aren’t automatically included in the action list. You must add the custom buttons as actions from the Mobile & Lightning Actions category in the palette. If neither section is customized, the action bar inherits a default set of actions predefined by Salesforce. The sets of actions differ between objects based on the most common or typical activities required for each object.
761 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: You can enable dynamic actions for custom object record pages for the Salesforce mobile app. When you enable dynamic actions, you assign actions in the Lightning App Builder instead of the page layout and apply filters to control when and where actions appear for users. You can assign the same dynamic actions for desktop and mobile, or assign a different set of dynamic actions for mobile.
SEE ALSO: How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions Salesforce Mobile App Action Bar Considerations for Actions in the Salesforce Mobile App
List Item Actions in the Salesforce Mobile App List item actions give you access to your actions in list views, task lists, and related record lists. You can use list item actions to update records directly from lists. To access list item actions, navigate to a list view or task list or open a related list from an object’s related information page. Then swipe left on the desired record. Hide list item actions by swiping the list item back to the right or by tapping another item in the list.
List Views List item actions in list views don’t have the same actions that are available in the action bar when viewing an object’s record. For example, when a user visits an opportunity record in the Salesforce mobile app, the actions in its action bar reflect the actions in the Salesforce Mobile and Lightning Experience Actions section of the Opportunity page layout. However, when the user swipes left on an opportunity from a list view, as you can see below, the actions that display come from the list of predefined actions for opportunities. See How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions for the breakdown of predefined actions for each object.
Swipe a list item to the left to reveal list item Tap to show the action menu, with the Here’s the All Opportunities list view. actions. full list of actions available for the list item.
762 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Related Lists List item actions on related lists in the app reflect the same actions as the related list in Lightning Experience. Usually, these are the standard actions Edit and Delete, but can vary by object. For example, in Lightning Experience, the actions available in the dropdown menu on an Opportunity related list item are the same set of actions that Salesforce mobile app users see when swiping left on the same record in the related list.
Note: Even if your org doesn’t have Lightning Experience enabled, the actions on related lists that you see in the Salesforce mobile app still match the actions that would appear on the related list items in Lightning Experience if it was enabled.
763 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: Task and event list items are different than other objects when they display in related lists. In the mobile app, when you tap the Tasks item from the menu, you can swipe left on an item in the My Tasks list view and see the predefined actions for tasks. However, tasks and events in the Open Activities or Activity History related lists in the mobile app have no actions and aren’t swipe-able.
How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions Your org’s page layouts and publisher layouts control the order in which actions appear in the Salesforce mobile app action bar and list item actions. If you don’t customize the actions in the action bar on a page layout or global publisher layout, Salesforce predefines the location of key actions.
Important: Predefined actions apply to the Salesforce mobile app action bar only if you haven’t customized the Salesforce Mobile and Lightning Experience Actions section of an object’s page layout or a global publisher layout. Predefined actions are derived from the Quick Actions in the Salesforce Classic Publisher section of the object page layout or global publisher layout. On object page layouts, when the Salesforce mobile app section isn’t customized: If you customized the Quick Actions in the Salesforce Classic Publisher section, the quick actions in the action bar reflect those customizations. If you didn’t customize either section, the quick actions in the action bar come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
764 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
On global publisher layouts, when the Salesforce mobile app section isn’t customized: If you customized the Quick Actions in the Salesforce Classic Publisher section, the quick actions in the action bar reflect those customizations. If you didn’t customize either section, the quick actions in the action bar for global pages default to a Salesforce predefined set. Here’s the breakdown of which actions are contained in each group for each object or page. Keep in mind these considerations: • The predefined actions in the action bar, list item actions, and associated action menus are divided into groups. The arrangement of these groups is fixed. • Unless they’re in an ordered list, the order of actions within the groups can vary based on the object and the actions present on the global publisher layout or on an object’s page layout. • Some actions are in fixed positions. For actions in a numbered list, this is the fixed order that they appear in the action bar, list item actions, and in the respective action menus. – For example, for the Account object, the standard Chatter Post action is in the fourth position. This position is fixed. Regardless of where you put the Post action in the account page layout, Post always displays in the fourth position. – However, deletion of actions is respected. So in our example, if you delete the Post action from the account page layout, the remaining actions move up and you see Edit in the fourth position.
• Some action groups aren’t supported for every object or page.
Note: Actions on list view items reflect only the predefined set of actions for that object. For example, let’s say you’re viewing the All Accounts list in the Salesforce mobile app. If you swipe left on an account item in the list, you see a set of actions. Those actions come from the predefined list of actions for accounts in this chart. You always see Call, Edit, and Delete. The other actions on the list view item follow the order and rules defined for the action groups in the chart.
Table 2: Account Object Action Predefined Actions Group 1 1. Call, 2. New Task, 3. New Event, 4. Post
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Account page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Send Text (if the Phone field is populated), View Website (if the Website field is populated)
Table 3: Case Object Action Predefined Actions Group 1 Actions from the Quick Actions in the Salesforce Classic Publisher section of the Case page layout. If that section isn’t customized, quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout
765 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Predefined Actions Group
2 Edit
3 Action group 3 isn’t supported for the Case object.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Productivity actions aren’t supported for this object.
Table 4: Contact Object Action Predefined Actions Group 1 1. Call, 2. Send Email, 3. New Task, 4. New Event
2 Edit
3 Remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Contact page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.*
5 Remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Send Text
Table 5: Custom Objects Action Predefined Actions Group 1 The first four actions in the order defined on the page layout. If the Quick Actions in the Salesforce Classic Publisher section of the page layout isn’t customized, then the first four actions in the order defined on the global publisher layout.
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the page layout. If that section isn’t customized, remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.*
5 Remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Action group 6 isn’t supported for custom objects.
766 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Table 6: Event Object Action Predefined Actions Group 1 Quick actions in the order defined on the layout. Standard Chatter actions aren’t supported.
2 Edit, Delete
3–6 Action groups 3 to 6 aren’t supported for the Event object.
Table 7: Feed Object Action Predefined Actions Group 1 Quick actions in the order defined on the global publisher layout
2–6 Action groups 2 to 6 aren’t supported for the Feed object.
Table 8: Group Object Action Predefined Actions Group 1 Actions from the Quick Actions in the Salesforce Classic Publisher section of the Group page layout. If that section isn’t customized, quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
2–4 Action groups 2 to 4 aren’t supported for the Group object.
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Action group 6 isn’t supported for the Group object.
Table 9: Lead Object Action Predefined Actions Group 1 1. Log a Call, 2. New Task, 3. Convert (if enabled), 4. Post
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Lead page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Lead page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the Lead page layout.
6 In order: Call, Send Text, Send Email
767 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Table 10: “App Page” Lightning Page Action Predefined Actions Group 1 Global actions in the order defined in the Lightning page.
2–6 Action groups 2 to 6 aren’t supported for “App Page” Lightning pages.
Table 11: List View Action Predefined Actions Group 1 New
2–6 Action groups 2 to 6 aren’t supported for list views.
Table 12: Object Home Page (Tablet Only) Action Predefined Actions Group 1 1. New, 2. Sort
2–6 Action groups 2 to 6 aren’t supported for object home pages.
Table 13: Opportunity Object Action Predefined Actions Group 1 1. Log a Call, 2. New Task, 3. New Event, 4. Post
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Opportunity page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Opportunity page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the Opportunity page layout.
6 Action group 6 isn’t supported for the Opportunity object.
Table 14: Person Object Action Predefined Actions Group 1 1. Call, 2. Send Email, 3. Post
2 Action group 2 isn’t supported for the Person object.
768 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Predefined Actions Group 3 The remaining actions in the order defined on the global publisher layout
4–6 Action groups 4 to 6 aren’t supported for the Person object.
Table 15: Person Account Object Action Predefined Actions Group 1 1. Call, 2. Send Email, 3. New Task, 4. New Event
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Person Account page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Person Account page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Read News, Send Text, View Website
Table 16: Related List (for Standard Objects) Action Predefined Actions Group 1 New
2–6 Action groups 2 to 6 aren’t supported for related lists.
Table 17: Salesforce Today—Main Page Action Predefined Actions Group 1 Quick actions in the order defined on the global publisher layout
2–6 Action groups 2 to 6 aren’t supported for the Salesforce Today main page.
Table 18: Salesforce Today—Mobile Calendar Event Action Predefined Actions Group 1 1. Quick Message, 2. Join Conference Call, 3. Map
2 Action group 2 isn’t supported for Salesforce Today mobile calendar events.
769 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Predefined Actions Group 3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Event page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4–6 Action groups 4 to 6 aren’t supported for Salesforce Today mobile calendar events.
Table 19: Task Object Action Predefined Actions Group 1 1. Edit Comments, 2. Change Date, 3. Change Status, 4. Change Priority
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Task page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Standard Chatter actions aren’t supported.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Task page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the Task page layout.
6 Action group 6 isn’t supported for the Task object.
* Custom buttons that are added to the Button section of a page layout and that define the content source as URL or Visualforce are supported in the Salesforce mobile app. Remember that Visualforce pages must be enabled for use in the Salesforce mobile app. Custom links, custom buttons that are added to list views, and custom buttons that define the content source as OnClick JavaScript aren’t available in the Salesforce mobile app.
SEE ALSO: How Actions Are Ordered in the Salesforce Mobile App Action Bar Salesforce Mobile App Action Bar Considerations for Actions in the Salesforce Mobile App
770 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Considerations for Actions in the Salesforce Mobile App
• Most actions, including quick actions, productivity actions, and standard and custom buttons, EDITIONS are displayed in the action bar in the Salesforce mobile app. • The Save & New action button isn’t available in the Salesforce mobile app. Available in: both Salesforce • The Delete action is available on record pages only, not record detail pages. Classic (not available in all orgs) and Lightning • In most cases, a productivity action appears only if a record includes the information that the Experience action is keyed to. For example, the Send Email action depends on the record including an email address. The View Website action requires the record to include a website URL. On Available in: Group, accounts, the Call action appears even when there isn’t a phone number on the record. Professional, Enterprise, • By default, the Call productivity action in the mobile app action bar uses the global Log A Call Performance, Unlimited, Contact Manager, action layout. If you create one Log a Call action on an object, users see that custom Log a Call Database.com, and action’s layout when they tap Call from the object's action bar. If you create more than one Developer Editions Log a Call action for the same object, the Call action on that object uses the global Log a Call action layout. • There are a few differences between the Send Email quick action in Salesforce and the standard Email action in Case Feed: – Users can’t switch between the rich text editor and the plain text editor in a Send Email action. – Templates aren’t supported in the Send Email action. – Quick Text isn’t available in the Send Email action. – The Send Email action doesn’t support attachments. – Users can’t save messages as drafts when using the Send Email action. – Users can’t edit or view the From field in the Send Email action.
• If feed tracking isn’t enabled on an object, only nonstandard actions appear in the Salesforce mobile app action bar and in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. • If you’re using record types in your org, sometimes quick actions aren't visible to your users. For more information, see Quick Actions and Record Types on page 749. • The Mobile Smart Actions element appears as a single action element in the page layout editor, but it expands to several actions when it appears in the Salesforce mobile app. If the Mobile Smart Actions element is in Quick Actions in the Salesforce Classic Publisher section when you customize the action bar section, the actions in the app use your action bar customizations. In this case, the Mobile Smart Actions element in the Quick Actions in the Salesforce Classic Publisher section becomes irrelevant. • To customize the actions in the Salesforce mobile app action bar for standard and custom objects, first override the predefined actions. You can then add or remove actions from the Salesforce Mobile and Lightning Experience Actions section. For instance, to move the Join Group, Edit Group, or Leave Group actions on groups in the Salesforce mobile app, override the predefined actions in the Groups page layout.
• Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. • If you add a custom button to the Salesforce Mobile and Lightning Experience Actions section of a page layout, it has a lightning bolt icon in the Salesforce mobile app action bar. If the Salesforce Mobile and Lightning Experience Actions section isn't customized, the icon in the app action bar is a wrench.
SEE ALSO: How Actions Are Ordered in the Salesforce Mobile App Action Bar How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions
771 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Set Up a Mass Quick Action
A mass quick action is a quick action that gets added to an object’s search layout. After a mass quick EDITIONS action is set up, you can select up to 100 records in a list view and perform mass updates. You can use a mass quick action with cases, leads, accounts, campaigns, contacts, opportunities, work orders, Available in: Lightning and custom objects that support quick actions and have a search layout in Lightning Experience. Experience You can’t perform mass quick actions on a Recently Viewed list. Available in: Essentials, Important: You can perform a mass quick action on only the following quick action types: Group, Professional, • Create a Record Enterprise, Performance, Unlimited, and Developer • Update a Record Editions Before setting up a mass quick action: • Set up quick actions for your objects. These actions are the ones that you want users to perform USER PERMISSIONS on multiple records in a list view. To set up mass quick actions • Review Mass Quick Action Considerations. for Lightning Experience: To set up mass quick actions, customize an object’s search layout. • Customize Application 1. From Setup, click the Object Manager tab. 2. Select the object you want to allow mass quick actions on. 3. Select Search Layout. 4. Edit the List View layout. 5. In the List View Actions in Lightning Experience section, add the actions that you want your users to be able to perform on list views for multiple records. Here’s an example of the List View Actions for the case object.
6. Click Save. The list view for the object you updated now displays buttons for the actions you added. Users can select multiple records in the list view and use the mass quick action button to perform bulk updates. To help users understand the changes they’re making, a “Fields to update” section is included in the quick action layout.
772 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Mass Quick Action Considerations Review these guidelines and considerations before setting up and using mass quick actions in list views.
SEE ALSO: Mass Quick Action Considerations
Mass Quick Action Considerations
Review these guidelines and considerations before setting up and using mass quick actions in list EDITIONS views. Setting Up a Mass Quick Action Available in: Lightning Experience • Mass quick actions are available only in Lightning Experience apps, including apps with standard and console navigation. Available in: Essentials, • You can’t perform mass quick actions in Experience Cloud sites, or on notes or users. Personal, Group, Enterprise, Performance, • You can’t use the Tooling API, AppExchange, and Changesets to add mass quick actions to Unlimited, Developer, and an object’s search layout. Professional Editions • If you want to set up predefined field values for a quick action, we recommend not including those fields on the quick action’s layout. If a predefined field value is included in the quick action’s layout, it’s only updated if the user manually selects it. If a predefined field value isn’t included in the quick action’s layout, the predefined value is updated, but the user isn't notified of the change. The “Fields to update” section includes only predefined field values that are specified in the layout.
Using a Mass Quick Action • When using a mass quick action, only the fields you manually modify are changed. Some fields show a default value, but changes aren’t made unless you manually select them. The “Fields to update” section shows the changes you’re making. • You can’t perform a mass quick action on a Recently Viewed list view. • You can’t undo changes performed by a mass quick action—so be careful when making your changes. • Mass actions in split view use the same logic as mass actions in table view. • If you use a mass quick action on only one record, the “Fields to update” section isn’t displayed.
Example: This mass quick action updates the owner on cases. The Case Owner field displays Awesome Admin because the user modified this field. The Status field displays New because that was the value of all the selected records. The changes to make are listed in the “Fields to update” section.
773 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: If the selected records had different statuses, such as one was set to New and one was set to Escalated, the Status field would display None.
SEE ALSO: Set Up a Mass Quick Action
Custom Buttons and Links
Custom buttons and links help you integrate Salesforce data with external URLs, applications, your EDITIONS company’s intranet, or other back-end office systems. Salesforce supports these custom links and custom buttons. Available in: Salesforce Classic Type of Custom Link or Custom Button Setup Page Where It’s Configured Available in: All Editions Bookmark-style links defined in the standard Home Page Components except Database.com custom links home page component
Full-featured custom links included in custom Custom Links USER PERMISSIONS home page components To create or change custom Full-featured custom links or custom buttons Buttons, Links, and Actions (in the object’s buttons or links: on objects management settings) • Customize Application
Custom links can link to an external URL, such as www.google.com, a Visualforce page, or your company’s intranet. Custom links can also link to a custom s-control in the custom s-control library, such as a Java applet or Active-X control. Custom buttons can: • Connect users to external applications, such as a web page that displays a map to a contact’s address. • Run an s-control from the s-control library, such as an s-control that escalates a case from the case detail page. • Launch custom links. You can choose the display window properties that determine how the target of a link or button is displayed to your users. Custom links and s-controls can include Salesforce fields as tokens within the URL or custom s-control. For example, you can include an account name in a URL that searches Yahoo: http://search.yahoo.com/bin/search?p={!Account_Name}. You can override the default action of some standard buttons and customize the behavior of tab home pages to suit your org’s needs.
Define Custom Buttons and Links Define the action that occurs when a user clicks a custom button or link. Custom buttons and links can streamline actions within Salesforce or integrate Salesforce data with external URLs, applications, or systems. Override Standard Buttons and Tab Home Pages You can override the behavior of standard buttons—like New, View, or Edit—in Salesforce Classic, Lightning Experience, and mobile independently. You can also override the tab home page that displays when a user clicks a standard, custom, or external object tab. Custom Button and Link Samples Use samples of custom Salesforce buttons and links to determine whether they can work for you. Custom Button and Link Considerations Keep these considerations in mind when working with custom buttons and links.
774 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Viewing References to Salesforce Components
SEE ALSO: Define Custom Buttons and Links Adding Default Custom Links Customize Salesforce Classic Home Tab Page Layouts
Define Custom Buttons and Links
Define the action that occurs when a user clicks a custom button or link. Custom buttons and links EDITIONS can streamline actions within Salesforce or integrate Salesforce data with external URLs, applications, or systems. Available in: Salesforce Watch a Demo (English only) Classic (not available in all orgs) If you want the button or link to launch a custom page or other code, consider a Visualforce page. 1. From the management settings for the object that you want to edit, go to Buttons, Links, and Custom buttons and links are available in: All Editions Actions. Visualforce pages and Note: Custom buttons aren’t available on the User object or custom home pages. Custom s-controls are available in: buttons and links are available for activities under the individual object management Contact Manager, Group, settings for tasks and events. To override a standard button that applies to both tasks and Professional, Enterprise, events, go to the object management settings for activities. Performance, Unlimited, and Developer Editions 2. Click New Button or Link. Alternatively, click Default Custom Links to add a predefined custom link. 3. For Display Type, select Detail Page Link, Detail Page Button, or List Button. USER PERMISSIONS
Note: If you select List Button, and your list button requires users to select individual To create or change custom records in a list, then select Display Checkboxes (for Multi-Record Selection). When buttons or links: you select this option, a checkbox appears next to each list item to let users select records, • Customize Application and the list button action is applied to those records. Don’t select Display Checkboxes (for Multi-Record Selection) if your list button doesn’t require users to select individual records in the list. For example, your list button links to a URL that doesn’t support POST operations, such as a URL that links to a Lightning component. In Lightning Experience, when you select Display Checkboxes (for Multi-Record Selection), the related list type must be set to Enhanced List. You can set the related list type for a related list on a record page in the Lightning App Builder.
4. Enter the button or link attributes. Here’s an example of the attributes for a button that performs a web search for an account’s name.
775 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
5. To validate all Salesforce merge fields and functions, click Check Syntax. 6. Click Save when you’re finished, or click Quick Save to save and continue editing. Saving validates the URL you defined if you set the content source to URL. 7. To open a button or link using settings other than the user’s default browser settings, click Window Open Properties on the button or link’s detail page. 8. To view all references to the new button or link, click Where is this used? on its detail page. Custom links for users are automatically added to the Custom Links section of the user detail page. You can add page buttons only to the Button section of a page layout.
Note: A link URL can be up to 2,048 bytes. When data is substituted for the tokens in the URL, the link can exceed 3,000 bytes. Some browsers enforce limits on the maximum URL length. Before you can use your custom buttons and links, add them to an object’s page layout. You can then see and use the button or link on a record detail page.
Custom Button and Link Fields This table defines the fields that are available when you create a custom button or link. Constructing Effective Custom URL Buttons and Links Use these methods to construct effective custom URL buttons and links. Editing Window Open Properties
776 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Merge Fields for Custom Buttons and Links Adding Default Custom Links Custom Link Best Practices Custom buttons and links can streamline actions within Salesforce, or integrate Salesforce data with external URLs, applications, or systems. Use these best practices to get the most out of your custom links.
SEE ALSO: Find Object Management Settings Custom Button and Link Considerations Custom Button and Link Samples
Custom Button and Link Fields
This table defines the fields that are available when you create a custom button or link. EDITIONS
Attribute Name Description Available in: Salesforce Label Enter the text that displays in the user interface for the custom button or Classic link. Custom buttons and links are available in: All Editions Name Accept or enter the unique name to use for the button or link when it’s except Database.com referenced from a merge field. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must Visualforce pages and begin with a letter, not include spaces, not end with an underscore, and s-controls are available in: not contain two consecutive underscores. Contact Manager, Group, Professional, Enterprise, Namespace Enter the prefix that uniquely identifies your package. In a packaging Performance, Unlimited, Prefix context, a namespace prefix is a one to 15-character alphanumeric identifier and Developer Editions that distinguishes your package and its contents from packages of other developers on AppExchange. Namespace prefixes are case-insensitive. For example, ABC and abc are not recognized as unique. Your namespace prefix must be globally unique across all Salesforce organizations. It keeps your managed package under your control exclusively.
Protected Optionally limit use in a subscriber org. Protected components can’t be Component linked to or referenced by components created in a subscriber org. A developer can delete a protected component in a future release without worrying about failing installations. However, once a component is marked as unprotected and is released globally, the developer can’t delete it.
Description Enter text that distinguishes the button or link from others. This text displays only to administrators when setting up buttons and links.
Display Type Determine where the button or link appears on page layouts. Detail Page Link Adds the link to the Custom Links section of your page layouts. Detail Page Button Adds the custom button to a record’s detail page. You can add detail page buttons to the Button section of a page layout.
777 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Attribute Name Description
List Button Adds the custom button to a list view, search result layout, or related list. You can add list buttons to the Related List section of a page layout or the List View and Search Result layouts. For list buttons, Salesforce selects the Display Checkboxes (for Multi-Record Selection) option to include a checkbox next to each record in the list. Users can select the records they want applied to the action on the list button. If your custom button doesn’t require the user to select records, deselect this option.
Behavior Choose the outcome of clicking the button or link. When applicable, some settings have default values. For example, if you choose Display in new window, the default height of a new window is 600 pixels. See Editing Window Open Properties.
Note: Custom button links open in a new tab in Experience Builder sites, even if any of the Display in existing window options is selected.
Content Source Choose whether to use a URL, s-control, JavaScript action, or Visualforce page as the content of the button or link. Salesforce checks the correctness of URLs in custom links and custom buttons. When you create or edit custom links or buttons that contain invalid URL markup, such as scripts, Salesforce blocks the links from rendering. Instead, an error message is shown on hover. Reconfigure the URLs to be valid and well formed. The URL can be a relative URL or an absolute http://, https://, file://, ftp://, or mailto:// address. Invalid URLs in custom links or custom buttons created before Spring ’13 aren’t checked for correctness until you edit them.
Content Enter the content of the button or link for buttons and links of type URL or OnClick JavaScript. • To insert a field, choose the field type from Select Field Type and choose a field from Insert Field. • To insert activity merge fields, select Event or Task from Select Field Type. • To insert an operator, choose the appropriate operator icon from the Insert Operator drop-down list. • To insert a function, double-click its name in the list, or select it and click Insert Selected Function. To filter the list of functions, choose a category from the Functions drop-down list. Select a function and click Help on this function to view a description and examples of formulas using that function.
Tip: Internet standards require special encoding for URLs. Salesforce encodes the text from any merge field you insert into a link. Encode extra text in your link manually. For example, to generate the following URL:
http://www.google.com/search?q={!user.name} Steve Mark 50%
Use this content:
http://www.google.com/search?q={!user.name}+Steve+Mark+50%25
Salesforce strips double quotes from URLs when the content source is a URL. If you must use double quotes, encode them manually. For example, to generate the URL http://www.google.com/search?q="salesforce+foundation", use this
778 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Attribute Name Description
content: http://www.google.com/search?q=%22salesforce+foundation%22
Link Encoding Choose the encoding setting. Encoding defaults to Unicode (UTF-8). Change the default encoding setting if the target of a link requires data in a different format. Encoding is available if your Content Source is URL.
Constructing Effective Custom URL Buttons and Links
Use these methods to construct effective custom URL buttons and links. EDITIONS Use merge fields to pass Salesforce data. You can add merge fields to a custom link to pass data from your Salesforce records, user Available in: Salesforce information, or company information to another website or application. Classic (not available in all orgs) For example, you can create custom links that search Google for an account name or look up an address on a map. Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
http://google.com/search?q={!Account.Name}
http://maps.google.com?q={!Account.ShippingStreet} {!Account.ShippingCity} {!Account.ShippingState} {!Account.ShippingPostalCode}
Note: Custom links don’t support data type conversion. When creating custom links to pass data from one Salesforce field to another, the data must match the data type of the fields in which you are placing it. For example, if you have numeric data, you must pass it to a numeric field. Substitute symbols for certain characters or use URLENCODE(). Due to URL encoding standards set forth by the World Wide Web Consortium (W3C), certain “unsafe” characters, such as spaces and punctuation marks, can’t be passed through a URL. Custom buttons and links escape these characters, so you don’t have to URL-encode them. If you need to encode your URL, use the URLENCODE() function in the merge field like so: {!URLENCODE(text)} and replace text with the merge field or text string that you want to encode. For example: If the merge field foo__c contains Mark's page, {!URLENCODE(foo_c)} results in: %3CB%3EMark%27s%20page%3C%2Fb%3E.
779 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Use URLFOR() to link to Visualforce pages. To link to a Visualforce page, use URLFOR() with the relative path to the page, which is /apex/PageName. For example, to link to a Visualforce page called MissionList that isn’t associated with a record, use the following syntax.
{! URLFOR( “/apex/MissionList” ) }
When you use URLFOR() with a Visualforce page, and you want to pass a record ID into the page, you must pass the ID in as a parameter.
{! URLFOR( “/apex/Mission”, null, [id=Mission__c.Id] ) }
Use the $Action global variable and URLFOR() to point to Salesforce pages. When creating a custom button or link that points to a page in Salesforce, use the $Action global variable to construct the link, instead of pasting in the path to the page. Then, if your organization is moved to another server or the URL to the page changes, the link still points to the right place. To construct the link, use the URLFOR() formula function with the $Action variable.
{!URLFOR( $Action.Case.NewCase, Account.Id )}
This custom link on the Account object opens the New Case form, creating the case as a child of the account record. You can use this process for any object that has a lookup to the Account object. To create a record that isn’t a child of another record, or if two objects have no relationship, you can use $ObjectType.ObjectName as the second argument. For example:
{!URLFOR( $Action.Case.NewCase, $ObjectType.Case )}
$Action global variables expect either a record ID or the $ObjectType. For example, these formulas create links to the tab and detail page for an account, respectively.
{!URLFOR( $Action.Account.Tab, $ObjectType.Account )}
{!URLFOR( $Action.Account.View, Some_Account_Lookup__c.Id )}
The URLFOR() function takes additional optional arguments that get passed into the destination as query string parameters. You can use these arguments when overriding a standard action with a Visualforce page to pass in the additional parameters needed by the Visualforce page or its controller. For example, if when closing a case you want to change the value of a custom field on the case called Actual Delivery Date to today, you could use:
{!URLFOR($Action.Case.CloseCase, Case.Id, [ actualDeliveryDate=TODAY()] )}
You can then override the Close Case action with a Visualforce page and handle setting the value of the Actual Delivery Date field either in that Visualforce page or its controller. See Using Query String Parameters in a Visualforce Page for more information. Use these Lightning-friendly URL button and link methods to point to other pages in Lightning Experience.
Custom URL Button or Link Lightning Experience Behavior External URL URL opens in new tab
www.google.com
Relative Salesforce URL, View Record home page opens in existing tab
/{!Account.Id}
Relative Salesforce URL, Edit Edit overlay pops up on the existing page
780 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Custom URL Button or Link Lightning Experience Behavior
/{!Account.Id}/e
Relative Salesforce URL, List Object home page opens in existing tab
/001/o
$Action URL, View Record home page opens in existing tab
{!URLFOR($Action.Account.View, Account.Id)}
$Action URL, Edit Edit overlay pops up on the existing page
{!URLFOR($Action.Account.Edit, Account.Id)}
Note: Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app.
SEE ALSO: Custom Link Example: Link to Documents Custom Link Example: Link to Files in Chatter Custom Link Example: Link to Reports
Editing Window Open Properties
Custom buttons and links can open in different types of windows. If you have selected a custom EDITIONS button or link to open in a popup window, set the window properties. If you leave the window properties blank, the custom button or link will use the default settings of the user’s browser. Available in: Salesforce To edit the window open properties: Classic 1. From the management settings for the object whose button or link you want to edit, go to Available in: All Editions Buttons, Links, and Actions, and then click the button or link name. Custom buttons are not except Database.com available on the user object. S-controls are available in: 2. Click Window Open Properties. Contact Manager, Group, Professional, Enterprise, 3. Edit the following properties. Performance, Unlimited, and Developer Editions Window Property Description Width The width (in pixels) of the popup. USER PERMISSIONS Height The height (in pixels) of the popup. To edit custom button or link Window Position The location on the screen where the popup properties: should open. • Customize Application Resizeable Allow users to resize the popup window.
781 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Window Property Description Show Address Bar Show the browser’s address bar which contains the URL.
Show Scrollbars Show browser scrollbars for the popup.
Show Toolbars Show the browser toolbars. Toolbars normally contain navigation buttons like Back, Forward, and Print.
Show Menu Bar Show the browser menus. The menus typically contain option like File and Edit.
Show Status Bar Show the status bar at the bottom of the browser.
Note: Some properties may not be available depending on the behavior of the custom button or link. For example, if you chose Execute JavaScript, no window open properties are available.
4. Save your changes.
SEE ALSO: Define Custom Buttons and Links
Merge Fields for Custom Buttons and Links
A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. Available in: Salesforce Syntax and Formatting Classic When you insert a merge field in a custom button or link, the syntax consists of an open curly brace Custom buttons and links and exclamation point, followed by the object name, a period, the field name, and a closing curly are available in: All Editions brace. except Database.com Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
{!Object_Name.Field_Name}
To ensure that you’re using the correct syntax, select merge fields from the dropdown list in the editor for custom buttons and links.
Note: Custom objects named “Org”, can’t be used in a merge field. Objects named “org’ are explicitly filtered from the Select Field Type list for a custom button.
Tips • To insert activity merge fields, select Event or Task from the Select Field Type dropdown list.
782 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• You can add links quickly to the sidebar by using the standard home page’s Custom Links component.
Warning: The standard home page’s Custom Links component doesn’t support – Merge fields – Functions, such as URLFOR – JavaScript execution – Customizable window opening properties
SEE ALSO: Generate Emails From Records Custom Button and Link Considerations
Adding Default Custom Links
1. From the management settings for the appropriate object, go to Buttons, Links, and Actions EDITIONS or to Buttons and Links. 2. Click Default Custom Links. Available in: Salesforce Classic 3. Next to a sample link you want to add, click Add Now!. 4. Change the default data for the link, as necessary. Available in: All Editions except Database.com 5. Choose Save. 6. Edit the page layout for the appropriate tab to display the new link. USER PERMISSIONS
SEE ALSO: To create or change custom links: Define Custom Buttons and Links • Customize Application
Custom Link Best Practices
Custom buttons and links can streamline actions within Salesforce, or integrate Salesforce data with EDITIONS external URLs, applications, or systems. Use these best practices to get the most out of your custom links. Available in: Salesforce Note: Salesforce checks the correctness of URLs in custom links and custom buttons. When Classic (not available in all you create or edit custom links or buttons that contain invalid URL markup, such as scripts, orgs) Salesforce blocks the links from rendering. Instead, an error message is shown on hover. Custom buttons and links Reconfigure the URLs to be valid and well formed. The URL can be a relative URL or an absolute are available in: All Editions http://, https://, file://, ftp://, or mailto:// address. Invalid URLs in Visualforce pages and custom links or custom buttons created before Spring ’13 aren’t checked for correctness until s-controls are available in: you edit them. Contact Manager, Group, Professional, Enterprise, Best Practices for Advanced Users Performance, Unlimited, and Developer Editions Salesforce has no plans to change field names; however, that doesn’t guarantee that field names won’t change in the future. Therefore, custom links that include Salesforce fields may change how they are mapped.
783 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Pass Session IDs with SSL Never pass session IDs to an “http” URL. Instead, pass session IDs with a secure sockets layer (SSL) “https” URL. Any data that is passed to other applications hosted on the Internet should always use SSL since the URL may contain sensitive customer information. Single Sign-On Use custom links to pass a session ID to support Single Sign-On (SSO), so users can avoid multiple logins to web applications that your organization hosts to manage Salesforce data. Construct your custom link to pass the {!User_Session_ID} merge field, which allows users to access all authorized resources during a single authentication. External systems can access Salesforce resources using a web service, which allows organizations to communicate data without intimate knowledge of each other's IT systems behind a firewall. Send the Server Date in the URL Some integration projects need custom links to include a server date to know the Salesforce initiation date. The Salesforce server date can be passed to external systems using custom links. For example, http://someurl.com/somepath?current_date={!Today}. Dates use the Pacific time zone. Avoid Double Sets of Tabs in a Browser Unlimited Edition and Enterprise Edition users can build a custom link to perform an action that keeps users in the same browser window and doesn’t display a double set of tabs. Create a Visualforce page that contains the following code, replacing with your regular or existing custom link.
784 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Override Standard Buttons and Tab Home Pages
You can override the behavior of standard buttons—like New, View, or Edit—in Salesforce Classic, EDITIONS Lightning Experience, and mobile independently. You can also override the tab home page that displays when a user clicks a standard, custom, or external object tab. Available in: Salesforce Button overrides are global. For example, if you override the New button on opportunities, your Classic (not available in all replacement action takes effect wherever that action is available, such as: orgs) and Lightning Experience • Opportunities home page • Any opportunities related lists on other objects, such as accounts Available in: Enterprise, Performance, Unlimited, • Create New dropdown list in the Salesforce Classic sidebar and Developer Editions • Any browser bookmarks for this Salesforce page Visualforce overrides also 1. From the object management settings for the object you want to set an override for, go to available in: Contact Buttons, Links, and Actions. Manager, Group, and 2. Click Edit next to the button or tab home page you want to override. Professional Editions Record types available in: 3. For each experience—Salesforce Classic, Lightning Experience, or mobile—click the type of Professional, Enterprise, override you want associated with the action. Performance, Unlimited, • No override (use default)—Use a custom override provided by an installed package. If and Developer Editions there isn't one installed, the standard Salesforce behavior is used. • Standard page—This option is available only for subscribers who are overriding the actions on an installed custom object. If selected, the standard Salesforce behavior is used. USER PERMISSIONS • Custom s-control—Use the behavior from an s-control. This option isn’t supported for To override standard buttons mobile. and tab home pages: • Customize Application Important: Visualforce pages supersede s-controls. Organizations that haven’t previously used s-controls can’t create them. Existing s-controls are unaffected, and To reset button and tab home page overrides: can still be edited. • Customize Application • Lightning component—Use the behavior from a Lightning component. Supported only for the Edit, New, New Event, Tab and View actions. This option isn’t supported for Salesforce Classic. • Lightning page—Use the behavior from the Lightning record page assigned as the org default for the object. This option is available only for the View action in Lightning Experience. • Visualforce page—Use the behavior from a Visualforce page. • Use the Salesforce Classic override—Inherits the behavior from the Salesforce Classic Override setting.
Important: Before you override a standard button with a Lightning component or Visualforce page, review implementation details in the respective developer guides.
4. Select the name of the s-control, Lightning component, Lightning page, or Visualforce page you want to run when users click the button or tab. When overriding the New button with a Visualforce page, you can choose to skip the record type selection page. If you do, new records you create aren’t forwarded to the record type selection page. Salesforce assumes that your Visualforce page is already handling record types.
Important: When a Salesforce mobile app user clicks New to create a product, the user must select a record type even if the Skip record type selection page option is selected in Setup.
5. Click Save.
785 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: A standard button (New, Edit, View, Delete, and Clone) overridden with a Visualforce page doesn’t show up in the Salesforce mobile app unless the Visualforce page is enabled for Salesforce mobile apps. Overriding standard list and tab controls isn’t supported in mobile.
Standard Action Overrides For standard actions, such as Delete, Edit, List, New, Tab, and View, you can provide a custom user interface for the action, called an action override. Use action overrides when your business model requires a more customized user experience than the Salesforce standard page provides. Considerations for Overriding Standard Buttons Before you override a standard button, review these considerations. Remove Overrides for Standard Buttons and Tab Home Pages
SEE ALSO: Considerations for Overriding Standard Buttons Remove Overrides for Standard Buttons and Tab Home Pages Visualforce Developer Guide : Overriding Buttons, Links, and Tabs with Visualforce Lightning Aura Components Developer Guide : Standard Actions and Overrides Basics
Standard Action Overrides
For standard actions, such as Delete, Edit, List, New, Tab, and View, you can provide a custom user EDITIONS interface for the action, called an action override. Use action overrides when your business model requires a more customized user experience than the Salesforce standard page provides. Available in: Salesforce You can specify a different override for each user experience, with the following guidelines. Classic (not available in all orgs) and Lightning • Salesforce Classic—Use a Visualforce page as the action override. Experience • Lightning Experience and the Salesforce mobile app —You can override the Edit, New, Tab, and View standard actions on most standard and all custom objects. Available in: Enterprise, Performance, Unlimited, • Lightning Experience—Use a Lightning component as the action override for the Edit, New, and Developer Editions and Tab actions. Use a Lightning page or a Lightning component as the action override for the View action. Visualforce overrides also available in: Contact • Experience Builder sites—Use a custom Lightning component to replace standard forms when Manager, Group, and users click the New or Edit button. The action you choose in Lightning Experience is the same Professional Editions action that you use to override actions in Experience Builder sites. Record types available in: • Salesforce app—Use a Lightning component as the action override. Professional, Enterprise, • Managed packages—Developers can include action overrides as package defaults, and managed Performance, Unlimited, package subscribers can specify local overrides as alternatives to the default overrides. and Developer Editions
Note: For Salesforce Classic, usually a Visualforce page is the only supported override option. Under certain conditions, you can use existing s-controls as overrides for Salesforce Classic. USER PERMISSIONS However, s-controls have been deprecated since the Spring ’09 release. We recommend using Visualforce pages instead. To override standard buttons: • Customize Application
786 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Assign Action Overrides To assign a Visualforce page or Lightning component as an override, first create the page or component (or use one created by a Salesforce developer in your org). It’s important to understand the action override options for each user experience and how your selections for each one can affect the others. Assign a Lightning Record Page Override for the View Action When you create an override for the View action for Lightning Experience, you can use either a Lightning record page or a Lightning component. To use a Lightning record page as an override, you must activate the page as the org default in the Lightning App Builder. Action Overrides in Managed Packages In a managed package, overrides specified by the package developer are included as default overrides. The package subscriber can specify local overrides for each user experience to use instead of the package default overrides. Package default overrides impact the options and behaviors of local overrides. Action Overrides in Experience Builder Sites Personalize your Experience Builder site users’ experience by adding a custom Lightning component to replace standard forms when users click the New or Edit button. Use action overrides when your site and portal users require a more customized user experience than the Salesforce standard page provides.
SEE ALSO: Trailhead: Introduction to Creating Visualforce Pages Trailhead: Build a Lightning Component to Override a Standard Action
Assign Action Overrides
To assign a Visualforce page or Lightning component as an override, first create the page or EDITIONS component (or use one created by a Salesforce developer in your org). It’s important to understand the action override options for each user experience and how your selections for each one can Available in: Salesforce affect the others. Classic (not available in all When assigning overrides, keep in mind the following requirements. orgs) and Lightning Experience • Salesforce Classic—To use a Visualforce page to override an action, the Visualforce page must use the standard controller for the object on which the action appears. To use a Visualforce Available in: Enterprise, page to override a tab, the Visualforce page must use the standard list controller for that tab’s Performance, Unlimited, associated object. and Developer Editions • Lightning Experience and the Salesforce mobile app—To make a Visualforce page available Visualforce overrides also for use as an override, select Available for Lightning Experience, Experience Builder sites, available in: Contact and the mobile app in the Visualforce Pages setup panel. Manager, Group, and Professional Editions 1. Click Setup, select Object Manager, and select the object that you want to modify. Record types available in: 2. In the Object Manager settings list, select Buttons, Links, and Actions. Professional, Enterprise, 3. In the row for the action you want to modify, select Edit from the dropdown menu. Performance, Unlimited, and Developer Editions 4. Specify the override option for each user experience.
USER PERMISSIONS
To override standard buttons: • Customize Application
787 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Example: This Override Properties panel specifies a Visualforce page for Salesforce Classic and a Lightning component for Lightning Experience. The mobile override specifies the Salesforce Classic override, so mobile users see the Visualforce page.
SEE ALSO: Trailhead: Introduction to Creating Visualforce Pages Trailhead: Build a Lightning Component to Override a Standard Action
Assign a Lightning Record Page Override for the View Action
When you create an override for the View action for Lightning Experience, you can use either a EDITIONS Lightning record page or a Lightning component. To use a Lightning record page as an override, you must activate the page as the org default in the Lightning App Builder. Available in: Salesforce 1. Click Setup, enter Lightning App in the Quick Find box, and select Lightning App Classic (not available in all Builder. orgs) and Lightning Experience 2. In the Setup panel for the Lightning App Builder, click Edit next to the Lightning page that you want to use as an override. Available in: Enterprise, Performance, Unlimited, 3. In the Lightning App Builder, click Activation. and Developer Editions 4. On the Activation page, select Org Default and click Close. After you activate the Lightning Visualforce overrides also page as the org default, the page is selected as the Lightning Experience override for the View available in: Contact action in the Override Properties panel. Manager, Group, and 5. To remove the Lightning page as the override, return to the Activation page in the Lightning Professional Editions App Builder, click Remove as Org Default, and click Close.. Record types available in: Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To override standard buttons: • Customize Application
788 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Example: In this Override Properties panel, the Lightning page Account_Lightning_Page_Test is the specified Lightning Experience override for the View action.
SEE ALSO: Create and Configure Lightning Experience Record Pages
Action Overrides in Managed Packages
In a managed package, overrides specified by the package developer are included as default EDITIONS overrides. The package subscriber can specify local overrides for each user experience to use instead of the package default overrides. Package default overrides impact the options and behaviors of Available in: Salesforce local overrides. Classic (not available in all Several rules determine local override behaviors in a managed package. orgs) and Lightning Experience • For each user experience—When a package subscriber specifies a local override, the local override takes precedence over the package default override. If no local override is specified Available in: Enterprise, for a user experience, the package default override for that user experience is used. Performance, Unlimited, • For Lightning Experience and the Salesforce mobile app—If no local override is specified and and Developer Editions no package default override is specified, the local override inherits from Salesforce Classic. Either Visualforce overrides also the Salesforce Classic local override (if it is specified) is used, or the Salesforce Classic package available in: Contact default override (if no Salesforce Classic local override is specified) is used. Manager, Group, and Professional Editions • A package developer can remove or replace the default overrides when updating a managed package. The new default overrides are available for package subscribers when they install the Record types available in: updated package. Professional, Enterprise, Performance, Unlimited, Example: The Override Properties panel for a managed package identifies the override and Developer Editions defaults and the local override options for each user experience. The available local override options vary based on the override defaults. • No override (use default)—Uses either the override default Visualforce page or the USER PERMISSIONS Salesforce standard page if no Visualforce page is specified. To override standard • Standard page—Available for package subscribers only if the package default override buttons: for the given user experience is a Visualforce page or Lightning component. • Customize Application • Lightning component—The specified component takes precedence over the package default override for the given user experience.
789 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• Use the package default override—Available for package subscribers only if the package default override for the given user experience is a Lightning component. • Use the Salesforce Classic override—Available for package subscribers only if the package default override for the given user experience is the Salesforce standard page. Option inherits from the local Salesforce Classic override.
Action Overrides in Experience Builder Sites
Personalize your Experience Builder site users’ experience by adding a custom Lightning component EDITIONS to replace standard forms when users click the New or Edit button. Use action overrides when your site and portal users require a more customized user experience than the Salesforce standard page Available in: Salesforce provides. Classic (not available in all To override actions in an Experience Builder site: orgs) and Lightning Experience 1. In Salesforce Setup, enter Digital Experiences in the Quick Find box and select All Sites. Available in: Essentials,Enterprise, 2. Next to the site that you want to override, click Workspaces. Performance, Unlimited, 3. Click Administration. and Developer Editions 4. Select Override standard actions with the Lightning component. 5. Click Save. USER PERMISSIONS
Note: The action you choose in Lightning Experience is the same action that you use to To override standard override actions in Experience Builder sites. buttons: • Customize Application
790 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Considerations for Overriding Standard Buttons
Before you override a standard button, review these considerations. EDITIONS
Implementation Tips Available in: Salesforce Classic (not available in all Important: Before you override a standard button with a Lightning component or Visualforce orgs) and Lightning page, review implementation details in the respective developer guides. Experience
• If you override a standard button in Salesforce, that button is still available in Connect Offline, Available in: Enterprise, but it retains its original behavior. Performance, Unlimited, • The View standard button refers to all links in Salesforce that display the detail page for a record. and Developer Editions Overriding the View standard button reroutes all these links. Visualforce overrides also • The View action is the only one that supports overrides with a Lightning record page. To make available in: Contact a Lightning record page available for a View action override, assign the page as the org default Manager, Group, and for its associated object by activating it in the Lightning App Builder. Professional Editions • If you have the View action overridden with a Visualforce page in Salesforce Classic, the Setup Record types available in: menu on that object record page in Lightning Experience displays the Edit Page option. Selecting Professional, Enterprise, Edit Page in Lightning Experience on an object page that’s overridden with a Visualforce page Performance, Unlimited, in Salesforce Classic lets you create a custom Lightning Experience record page for that object and Developer Editions in the Lightning App Builder. • If a button isn’t available for overrides, you can still hide it on the page layout. USER PERMISSIONS • Button overrides affect everywhere that action or behavior is available. For example, overriding the New button on an account also overrides the account option in the Create New drop-down To override standard list in the Salesforce Classic sidebar. buttons: • Customize Application • Person Account records use any standard button overrides you make for accounts. Person Account records also use any overrides for the View Self-Service and Enable Self-Service buttons you make for contacts. • If your organization uses the Console tab, overrides for the Edit and View buttons for an object don’t affect the Edit and View buttons in the mini page layouts. Pages that display due to overrides display in the console without the header or sidebar. • To replace a standard button with a custom button, first define the custom button, then customize the page layout to hide the standard button and display the custom one in its place. • When you override the Edit button with a Visualforce page, you’re also overriding default logic that checks whether the record has been locked for approval. However, you can perform the same check by implementing the Approval.lock Apex method.
Limitations • You can override buttons on the detail page but not the edit page of a record. • You can only override these standard buttons: New, View, Edit, and Delete. • For tasks and events in Salesforce Classic, you can only override standard buttons and links, with the exception of the New Event button. Overrides for that button aren’t supported in Salesforce Classic. In Lightning Experience, you can override the New Event button on the Calendar page with a Lightning component for a custom object, but clicking a timeslot always creates a standard event. • You can’t change buttons on lookup dialogs, reports, or tabs. However, you can change the buttons on list view and search result layouts under search layouts. • Action overrides on the New standard button don't work on New Object links in lookup searches.
791 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• Action overrides on the New standard button for objects with multiple record types aren’t supported in the Outlook and Gmail integrations unless you choose to skip the record type selection page. • You can’t relabel or relocate standard buttons on a record detail page. • When overriding tabs or buttons with a Lightning component, you can select only Lightning components that implement the lightning:actionOverride interface. • A standard button (New, Edit, View, Delete, and Clone) overridden with a Visualforce page doesn’t show up in the Salesforce mobile app unless the Visualforce page is enabled for Salesforce mobile apps. Overriding standard list and tab controls isn’t supported in mobile. • When overriding tabs with a Visualforce page, you can select only Visualforce pages that use the standard list controller for that tab’s associated object, pages with a custom controller, or pages with no controller. • When overriding lists with a Visualforce page, you can select only Visualforce pages that use a standard list controller. • When overriding buttons with a Visualforce page, you can select only Visualforce pages that use the standard controller for the object on which the button appears. For example, if you want to use a page to override the Edit button on accounts, the page markup must include the standardController="Account" attribute on the tag:
... page content here ...
SEE ALSO: Override Standard Buttons and Tab Home Pages Visualforce Developer Guide : Overriding Buttons, Links, and Tabs with Visualforce Lightning Aura Components Developer Guide : Standard Actions and Overrides Basics
792 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Remove Overrides for Standard Buttons and Tab Home Pages
To remove overrides for actions that support overrides for Classic, Lightning, and mobile web: EDITIONS 1. From the management settings for the object whose button you want to edit, go to Buttons, Links, and Actions. Available in: Salesforce Classic (not available in all 2. Click Edit next to the overridden button or tab link. orgs) and Lightning 3. Select No override (use default) for the Salesforce Classic override Experience
4. To also remove overrides for Lightning Experience or Mobile, select Use the Salesforce Classic Available in: Enterprise, override. Performance, Unlimited, 5. Click Save and Developer Editions Visualforce overrides also available in: Contact Manager, Group, and Professional Editions Record types available in: Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To override standard buttons and tab home pages: • Customize Application To reset button and tab home page overrides: • Customize Application
To remove overrides for actions that support only Classic: 1. From the management settings for the object whose button you want to edit, go to Buttons, Links, and Actions. 2. Click Edit next to the overridden button or tab link. 3. Select No override (use default) for Salesforce Classic Override. 4. Click Save
793 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Custom Button and Link Samples
Use samples of custom Salesforce buttons and links to determine whether they can work for you. USER PERMISSIONS
Custom Link Example: Link to Documents To create or change custom buttons or links: Use custom links to reference documents from a Salesforce record detail page. • Customize Application Custom Link Example: Link to Files in Chatter Use custom links to reference files from Chatter. EDITIONS Custom Link Example: Link to Reports Use custom links to run reports with filtered results from a Salesforce record detail page. For Available in: Salesforce example, let’s say you frequently run a mailing list report for the contacts related to an account. Classic (not available in all You can create a custom link for accounts that links directly to a report that is automatically orgs) filtered to the account you are viewing. In this case, your custom link must pass the account’s Custom buttons and links unique record ID to the report. are available in: All Editions Create a Custom Button for Performing Mass Deletes Visualforce pages and This example creates a JavaScript custom button for Salesforce Classic that can be added to s-controls are available in: activity-related lists and list views and allows users to delete selected records at the same time. Contact Manager, Group, Displaying Alerts Professional, Enterprise, Performance, Unlimited, This example creates a button that opens a popup dialog with a welcome message containing and Developer Editions the user's first name. Getting Record IDs This example creates a button that opens a popup window listing record IDs for user selected records. This is useful when testing to ensure you have the correct record IDs before processing them further. Passing Record IDs to an External System You can use Salesforce record IDs as unique identifiers for integrating with an external system. This example creates a button that calls a Visualforce page to determine the record IDs of selected records and passes them in a URL query parameter to an external Web page called “www.yourwebsitehere.com.” Launching Record Create Page with Default Field Values Construct custom buttons and links that pass default field values to a record create page. This feature applies to Lightning Experience in all editions. This feature doesn’t apply to Lightning Out, Experience Builder sites, or the Salesforce mobile app. Reopening Cases This example creates a button that can be added to cases related lists so users can reopen several cases on an opportunity at once.
794 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
International Maps This example creates a link that displays a country-specific Google map.
SEE ALSO: Define Custom Buttons and Links
Custom Link Example: Link to Documents
Use custom links to reference documents from a Salesforce record detail page. EDITIONS 1. Create a folder on the Documents tab to which all users have access. 2. Upload the document to that folder. Available in: Salesforce Classic (not available in all 3. From the Documents tab, choose the folder and click Go. orgs)
4. Click View next to the document. Custom buttons and links 5. Copy the document’s URL from the browser. For example, are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create or change custom buttons or links: • Customize Application
https://MyDomainName.my.salesforce.com/servlet/servlet.FileDownload?file=015300000000xvU. 6. Use everything after the domain portion of the URL to create your custom link. Using the example in the previous step, your link would point to /servlet/servlet.FileDownload?file=015300000000xvU.
SEE ALSO: Constructing Effective Custom URL Buttons and Links Custom Link Example: Link to Files in Chatter Custom Link Example: Link to Reports
795 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Custom Link Example: Link to Files in Chatter
Use custom links to reference files from Chatter. EDITIONS 1. Upload a file to the Files tab. 2. When the upload is finished, from the Upload dialog box, click Share settings. Available in: Salesforce Classic (not available in all 3. Click Anyone with link. orgs)
4. Copy the document’s URL from the Share via Link dialog box. For example, Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create or change custom buttons or links: • Customize Application
https://MyDomainName.my.salesforce.com/sfc/p/D0000000JsES/a/D000000001dd/aiq8UPJ5q5i6Fs4Sz.IQLKUERsWYdbAm320cjqWnkfk=. 5. Use everything after the domain portion of the URL to create your custom link. Using the example in the previous step, your link would point to /sfc/p/D0000000JsES/a/D000000001dd/aiq8UPJ5q5i6Fs4Sz.IQLKUERsWYdbAm320cjqWnkfk=.
SEE ALSO: Constructing Effective Custom URL Buttons and Links Custom Link Example: Link to Documents Custom Link Example: Link to Reports
796 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Custom Link Example: Link to Reports
Use custom links to run reports with filtered results from a Salesforce record detail page. For example, EDITIONS let’s say you frequently run a mailing list report for the contacts related to an account. You can create a custom link for accounts that links directly to a report that is automatically filtered to the Available in: Salesforce account you are viewing. In this case, your custom link must pass the account’s unique record ID Classic (not available in all to the report. orgs) 1. Copy the ID for the type of record by which you want to filter your report (in this example, an Custom buttons and links account). To do so, view the record and copy the 15-character ID from the last part of the URL. are available in: All Editions For example, https://MyDomainName.my.salesforce.com/001200030012j3J. Visualforce pages and s-controls are available in: 2. From the Reports tab, create the report you want by either customizing a standard report or Contact Manager, Group, creating a custom report. Professional, Enterprise, 3. Filter the report by the record ID you copied. For example, “Account ID equals 001200030012j3J”. Performance, Unlimited, and Developer Editions 4. Run the report to verify that it contains the data you expect. 5. Click Customize. USER PERMISSIONS 6. Click Save or Save As to save the report to a public folder accessible by the appropriate users. Save doesn’t create a custom report, whereas Save As does. To create or change custom 7. Run the report and copy the report’s URL from the browser. buttons or links: • Customize Application 8. Begin creating your custom link. Set the Content Source field to URL. In the large formula text area, paste the report URL you copied. Remember to omit the domain portion https://MyDomainName.my.salesforce.com. 9. Add the custom link to the appropriate page layouts. 10. Verify that the new custom link works correctly.
Tip: When creating a report for use in a custom link, set date ranges and report options generically so that report results include data that can be useful for multiple users. For example, if you set a date range using the “Created Date” of a record, set the Start Date far enough in the past to not exclude any relevant records and leave the End Date blank. If you scope the report to just “My” records, the report might not include all records that a user can see. Try setting the report options to “All visible” records.
SEE ALSO: Constructing Effective Custom URL Buttons and Links Custom Link Example: Link to Documents Custom Link Example: Link to Files in Chatter
797 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Create a Custom Button for Performing Mass Deletes
This example creates a JavaScript custom button for Salesforce Classic that can be added to USER PERMISSIONS activity-related lists and list views and allows users to delete selected records at the same time. To create or change custom Note: JavaScript custom buttons are supported in all editions, in Salesforce Classic only. The buttons or links: mass delete function described here doesn’t work in editions where the API isn’t enabled. • Customize Application 1. Define a button for events with the following attributes. • Display Type List Button EDITIONS Note: Select Display Checkboxes (for Multi-Record Selection) so users can select Available in: Salesforce multiple records in the list before clicking the button. Classic (not available in all • Behavior Execute JavaScript orgs) • Content Source OnClick JavaScript Custom buttons and links • Use the following sample code. are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
{!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")}
var records = {!GETRECORDIDS( $ObjectType.Event )}; var taskRecords = {!GETRECORDIDS( $ObjectType.Task)}; records = records.concat(taskRecords);
if (records[0] == null) { alert("Please select at least one record.") } else {
var errors = []; var result = sforce.connection.deleteIds(records); if (result && result.length){ var numFailed = 0; var numSucceeded = 0; for (var i = 0; i < result.length; i++){ var res = result[i]; if (res && res.success == 'true'){ numSucceeded++; } else { var es = res.getArray("errors"); if (es.length > 0) { errors.push(es[0].message); } numFailed++; } }
798 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
if (numFailed > 0){ alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n")); } else { alert("Number of records deleted: " + numSucceeded); } } window.location.reload(); }
2. Add the button to your activity list views. 3. Add the button to any page layout that contains an activity-related list. The button deletes any selected task or event in the list. You can install custom buttons from the Mass Delete app at http://sites.force.com/appexchange.
SEE ALSO: Custom Button and Link Samples
Displaying Alerts
This example creates a button that opens a popup dialog with a welcome message containing the USER PERMISSIONS user's first name. 1. Define a button with the following attributes. To create or change custom buttons or links: • Display Type Detail Page Button • Customize Application • Behavior Execute JavaScript • Content Source OnClick JavaScript EDITIONS • Use the following sample code. Available in: Salesforce Classic (not available in all orgs)
Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
alert ("Hello {!$User.FirstName}");
2. Add the button to the appropriate page layout.
SEE ALSO: Custom Button and Link Samples
799 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Getting Record IDs
This example creates a button that opens a popup window listing record IDs for user selected USER PERMISSIONS records. This is useful when testing to ensure you have the correct record IDs before processing them further. To create or change custom 1. Define a button with the following attributes. buttons or links: • Customize Application • Display Type List Button
Note: Select Display Checkboxes (for Multi-Record Selection) so users can select EDITIONS multiple records in the list before clicking the button. Available in: Salesforce • Behavior Execute JavaScript Classic (not available in all • Content Source OnClick JavaScript orgs) • Use the following sample code. Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
idArray = {!GETRECORDIDS($ObjectType.Contact)}; alert("The Ids you have selected are: "+idArray);
Note: This example is for contacts. Change the object type for a different type of record.
2. Add the button to the appropriate related list on a page layout or list view layout.
SEE ALSO: Custom Button and Link Samples
800 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Passing Record IDs to an External System
You can use Salesforce record IDs as unique identifiers for integrating with an external system. This USER PERMISSIONS example creates a button that calls a Visualforce page to determine the record IDs of selected records and passes them in a URL query parameter to an external Web page called To create or change custom “www.yourwebsitehere.com.” buttons or links: • Customize Application 1. Create a Visualforce page that uses the GETRECORDIDS function to retrieve a list of selected records: EDITIONS
Available in: Salesforce Classic (not available in all orgs)
Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
idArray = {!GETRECORDIDS($ObjectType.Account)};
window.location.href="http://www.yourwebsitehere.com?array="+idArray;
Note: Replace www.yourwebsitehere.com with your own URL.
2. Define a button for accounts with the following attributes. • Display Type List Button
Note: Select Display Checkboxes (for Multi-Record Selection) so users can select multiple records in the list before clicking the button.
• Behavior Display in existing window with sidebar • Content Source Visualforce Page • Select the Visualforce page you created in the first step.
3. Add the button to the appropriate page layout or list view layout.
SEE ALSO: Custom Button and Link Samples
801 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Launching Record Create Page with Default Field Values Construct custom buttons and links that pass default field values to a record create page. This feature applies to Lightning Experience in all editions. This feature doesn’t apply to Lightning Out, Experience Builder sites, or the Salesforce mobile app. To construct a custom button or link, encode any field that is read from a record and contains special characters, like commas. Use this sample formula:
/lightning/o/Account/new?defaultFieldValues= Name={!URLENCODE(Account.Name)}, OwnerId={!Account.OwnerId}, AccountNumber={!URLENCODE(Account.AccountNumber)}, NumberOfEmployees=35000, CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)}
Important: The URLENCODE function works only when creating custom buttons and links. You can’t use it for custom fields. The TEXT function is supported for custom number fields, but it returns only the numbers without any separators, like commas.
Note: Passing the RecordTypeId to defaultFieldValues isn’t yet supported. The recordTypeId influences routing behavior, layout assignment, and page assignment, so you can see unexpected results if you try to use it.
Reopening Cases
This example creates a button that can be added to cases related lists so users can reopen several USER PERMISSIONS cases on an opportunity at once. 1. Define a button for cases with the following attributes. To create or change custom buttons or links: • Display Type List Button • Customize Application Note: Select Display Checkboxes (for Multi-Record Selection) so users can select multiple records in the list before clicking the button. EDITIONS • Behavior Execute JavaScript Available in: Salesforce • Content Source OnClick JavaScript Classic (not available in all • Use the following sample code. orgs) Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
{!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")} var records = {!GETRECORDIDS($ObjectType.Sample)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one row") } else { for (var n=0; n802 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: This example references the AJAX Toolkit, which is available if API access is enabled. See https://developer.salesforce.com/page/Integration.
2. Add the button to your opportunity page layouts by editing the Cases related list.
Tip: Use this button on any page layout that contains the cases related list, such as account or contact page layouts.
Note: Notice the check for records[0] == null, which displays a message to users when they don’t select at least one record in the list.
SEE ALSO: Custom Button and Link Samples
International Maps
This example creates a link that displays a country-specific Google map. USER PERMISSIONS 1. Define a link for accounts with the following attributes. To create or change custom • Display Type Detail Page Link buttons or links: • Behavior Display in new window • Customize Application • Content Source URL • Use the following sample code. EDITIONS
Available in: Salesforce Classic (not available in all orgs)
Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
{! IF(Sample.BillingCountry = "US", "http://maps.google.com/maps?q="&Sample.BillingStreet& "+"&Sample.BillingCity&"+"&Sample.BillingState&"+"&Sample.BillingCountry, (IF(Sample.BillingCountry = "UK", "http://maps.google.co.uk/maps?q="&Sample.BillingStreet &"+"&Sample.BillingCity&"+"&Sample.BillingCountry, "http://maps.google.com"))) }
803 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
2. Add the link to your account page layout.
SEE ALSO: Custom Button and Link Samples
Custom Button and Link Considerations
Keep these considerations in mind when working with custom buttons and links. EDITIONS
Implementation Tips Available in: Salesforce Classic (not available in all • Custom buttons display at the top and bottom of the detail page to the right of all standard orgs) buttons. • Custom buttons aren't distinguished from standard buttons in any graphical way. However, Custom buttons and links you can recognize them by their location on the right of all standard buttons. are available in: All Editions • If the button bar gets too wide on the detail page layout, the browser displays a horizontal Visualforce pages and scroll bar. If the button bar gets too wide on the list view, search result, tagging result, or related s-controls are available in: Contact Manager, Group, list layouts, the buttons wrap. Professional, Enterprise, • Custom buttons are available for activities under the individual setup links for tasks and events. Performance, Unlimited, To add a custom button to an activity list view or search layout, first create a custom list button and Developer Editions in tasks or events. Next, add it to your activity list view or search result layouts. You can override a button that applies to both tasks and events. • Person Account records use the custom buttons and links you have made for accounts. USER PERMISSIONS
• If your organization uses the Console tab, list buttons are available in Mass Action. List To create or change custom buttons don’t display in the mini page layouts. Pages that display due to custom buttons and buttons or links: links display in the console without the header or sidebar. • Customize Application • If you get an error message when overriding a button that appears in a list, try calling the s-control using the URLFOR function. • When creating custom buttons, be aware of any validation rules your organization has for records on that object. For example, some custom list buttons that change case status conflict with a case validation rule. In this scenario, Salesforce displays the error message for the validation rule when users click the custom button. • To replace a standard button with a custom button, first define the custom button, then customize the page layout to hide the standard button and display the custom one in its place. • Visualforce pages used as custom links on the home page can’t specify a controller. • Visualforce pages used as custom buttons or links on detail pages must specify a standard controller of the same object. • Visualforce pages used as custom list buttons must use a standard list controller of the same object. • A Web tab or custom link could display a blank page if the embedded site: – Has been set to deny the loading of its content in a frame. – Has been set to allow the loading of its content in a frame only if the same site is delivering the content. – Contains a mix of secure and unsecure content, and the user’s browser has been configured to block mixed active content. To resolve this issue, try these workarounds. – Set your custom link to either open in a new window or display in the existing window without the sidebar or header. – Move the URL from a Web tab into a custom link instead, and set the URL to either open in a new window or display in the existing window without the sidebar or header.
804 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
– If the site you’re embedding has an HTTP prefix and mixed active content, try changing the prefix to HTTPS. If the embedded site has a valid security certificate and it hasn’t blocked itself from being displayed in frames, using HTTPS as the prefix allows the site to display.
Best Practices • Use formula functions in custom buttons with caution. Because functions run on the server before your HTML or JavaScript is passed to the browser, they can only evaluate information that exists at that time. Don't use functions like IF to evaluate conditions that only exist when the code reaches the browser, such as the value of a JavaScript variable that your code returns. • To prevent a user from performing a particular action, such as creating or editing, change the user's permissions rather than hiding the standard button. Hiding a standard button removes it from a page layout, but the link is still available and users can navigate to the new or edit page manually. • Use global variables to access special merge fields for components like custom buttons, links, and s-controls. For example, the $Request global variable allows you to access query parameters inside a snippet, s-control, or custom button. • When you create a custom list button, select Display Checkboxes (for Multi-Record Selection) only if your list button requires users to select individual records in a list. If your list button doesn’t require users to select individual records, don’t select this option. Don’t select Display Checkboxes (for Multi-Record Selection) if your list button links to a URL that doesn’t support POST operations, such as a URL that links to a Lightning component. • In Lightning Experience, when you select Display Checkboxes (for Multi-Record Selection), the related list type must be set to Enhanced List. You can set the related list type for a related list on a record page in the Lightning App Builder. • If you create multiple custom list buttons on a list and select Display Checkboxes (for Multi-Record Selection) for at least one of the list buttons, checkboxes appear next to records in the list. But those checkboxes aren’t activated for custom list buttons without Display Checkboxes (for Multi-Record Selection) selected.
Limitations • A custom link's label can't exceed 1,024 characters. • A link URL can be up to 2,048 bytes. When data is substituted for the tokens in the URL, the link can exceed 3,000 bytes. Some browsers enforce limits on the maximum URL length. • Custom buttons that call JavaScript aren’t supported in Lightning Experience. • Custom buttons with a content source of OnClick JavaScript aren’t supported in the Salesforce app. • Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. • On record detail pages for external objects that are associated with high-data-volume external data sources, custom buttons, and links that call JavaScript aren’t supported. • Custom buttons aren’t available for Web-to-Lead, Web-to-Case, the Case Teams related list, or the user object. • Custom buttons on search results pages aren’t supported in Lightning Experience. • When you redirect to an external website with merge fields, use the Text Field data type field. If you use the URL data type field, the link breaks because symbols in the link are converted to hexadecimal code.
Considerations for the Salesforce Mobile App • Custom buttons that are added to the Button section of a page layout and that define the content source as URL or Visualforce are supported in the Salesforce mobile app. Remember that Visualforce pages must be enabled for use in the Salesforce mobile app. Custom links, custom buttons that are added to list views, and custom buttons that define the content source as OnClick JavaScript aren’t available in the Salesforce mobile app.
805 Extend Salesforce with Clicks, Not Code External Services
• Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. • Custom images used for action icons must be less than 1 MB in size.
SEE ALSO: Define Custom Buttons and Links Custom Button and Link Samples
Viewing References to Salesforce Components
You can view a list of all the areas in Salesforce that reference a component. For example, view the EDITIONS custom links, custom buttons, or page layouts that reference another component, such as a Visualforce page or static resource. To do this, click Where is this used? from the detail page of Available in: Salesforce the component. Salesforce lists the type of component that references the component and the Classic label for that component. Click any item in the list to view it directly. Custom buttons and links are available in: All Editions SEE ALSO: Visualforce pages and Define Custom Buttons and Links custom components available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create or change custom buttons or links: • Customize Application To create, edit, and delete Visualforce pages and custom components: • Customize Application To clone, edit, or delete static resources: • Customize Application
External Services Connect your Salesforce org to an external API using zero lines of code. Use declarative tools and OpenAPI specifications to describe the external API functionality, and External Services creates invocable actions within Salesforce. Use the invocable actions to create a flow that interacts with the external API source.
What Can I Do with External Services? To illustrate how External Services work, let’s say you want to connect Salesforce to an external credit service that determines if credit is extended to a Salesforce account. You also want to know the payment terms.
806 Extend Salesforce with Clicks, Not Code External Services
Current and Legacy Versions The current version of External Services became generally available in Spring ’20 release and has replaced the legacy version. Compared to the legacy version, this version provides significant improvements and adds a broader feature set, including support for larger and more complex schemas, and offers better error messaging and error recovery. External Services Registration To register and use External Services, provide an API spec that describes the services and methods for tools such as Flow Builder or Einstein Bots to consume. The API spec’s schema generates the External Service flow actions with corresponding input and output parameters. Import MuleSoft APIs Import your MuleSoft Anypoint Platform APIs in a few clicks with External Services for MuleSoft. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. Create a Flow with External Services Design and test the automation that sends a user’s information from Salesforce to the external employee banking system. Create the variables for user phone numbers, and combine different phone numbers into one piece of data. Then use the external service action to create the user. Add Actions to an Einstein Bot Integrating your Einstein bot with a registered external service is now as easy as adding an action to a dialog. You can add an external service action to your bot from Einstein’s Bot Builder. Edit, Delete, Save As, and View an External Service Find services that you already registered, view actions for a previously defined service, edit, clone, and delete a service. You can’t edit or delete an external service that is in use by a flow. Recreate an External Service Recreate your external service, and update the related flows. External Services and Packaging You can install or create packages containing an external service. Read these tips before you begin. Testing External Service Actions in Flow Test the example flow MyAtmFlow with a flow external service action MyAtmExternalService by implementing the HttpCalloutMock interface that provides a test response without performing the callout to the external service endpoint.
What Can I Do with External Services?
To illustrate how External Services work, let’s say you want to connect Salesforce to an external EDITIONS credit service that determines if credit is extended to a Salesforce account. You also want to know the payment terms. Available in: Lightning Example: First, you create a Named Credential by supplying a URL and authentication Experience settings for the credit service. Salesforce uses these items to make callouts to the external Available in: Enterprise, service. With the External Services wizard, you then select whether you will get your API spec Performance, Unlimited, from Mulesoft Anypoint Platform, or from an API spec provided elsewhere. To register an API and Developer Editions spec: 1. Enter a URL (or endpoint) to the location of the hosted OpenAPI specification (”API spec”) for the external service, or provide (paste in) the complete schema from the API spec. For Mulesoft, provide your credentials and select the ASPI spec. 2. Select the operations from the schema you want to make available in Salesforce as invocable actions, and complete the registration.
807 Extend Salesforce with Clicks, Not Code External Services
The External Services wizard walks you through it so that you don’t directly touch the API. You can also skip writing Apex code to make the callout. Once you have registered your new external service, use a Salesforce point-and-click automation tool, such as Flow Builder or Einstein Bots. Create a flow using the External Service type for flow actions automatically generated from your External Services registration. When the flow runs, the output contains the credit decision and, if applicable, payment terms.
Example: Another use case involves saving time when you add new users to an org. For instance, you want new users to automatically become collaborators for all external org-related applications. Create a flow using inputs such as user ID, which you can define in your API spec’s schema. Then you add triggers in your flow. When a user is created, the triggers engage and add the new user as a collaborator to your other applications.
Current and Legacy Versions
The current version of External Services became generally available in Spring ’20 release and has EDITIONS replaced the legacy version. Compared to the legacy version, this version provides significant improvements and adds a broader feature set, including support for larger and more complex Available in: Lightning schemas, and offers better error messaging and error recovery. Experience External Services (Current version) Available in: Enterprise, Here are some of the key enhancements and additions for OpenAPI support: Performance, Unlimited, • More complex OpenAPI 2.0 schema. and Developer Editions – Nested parameters - rendered as Dynamic Apex-defined data type in Flow Builder – Header parameters in HTTP request.
• Named arrays, anonymous arrays, or inline arrays, supported as collection type in Flow Builder • Access to the latest product enhancements. • Normal packaging support. • Shows up as External Service type for flow actions. • External Services operations show up as External Service action type in Flow builder.
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
SEE ALSO: Register an External Service Edit, Delete, Save As, and View an External Service External Services Considerations
808 Extend Salesforce with Clicks, Not Code External Services
External Services Registration
To register and use External Services, provide an API spec that describes the services and methods EDITIONS for tools such as Flow Builder or Einstein Bots to consume. The API spec’s schema generates the External Service flow actions with corresponding input and output parameters. Available in: Lightning When you create your API spec, keep the following in mind. Experience • An API spec can include up to 4,000,000 characters (4.0MB). Available in: Enterprise, • You can use the GET, PATCH, PUT, POST, and DELETE methods in a schema. Performance, Unlimited, and Developer Editions • A property must include a value. • Each parameter must have a name. • Request headers are supported. • Response headers aren’t supported. • Form parameters are supported. • Security settings defined in the API spec are ignored and defer to security settings in the Named Credential. Supported data types: • boolean • date • datetime • double • float • integer • long • string • any type (as Apex Object) • object: top level named and nested anonymous objects • anonymous and top level named lists (can nest both named and anonymous arrays) • additionalProperties as maps • allOf as an object composition
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
Register an External Service Registering an external service takes only a few steps and no code. External Services Considerations Here are the semantic, service, and usage constraints to keep in mind when integrating your services into External Services. Examples: External Services Schema These API spec examples highlight various scenarios with JSON schemas supported by External Services and can help you avoid common mistakes with syntax and code placement. The API spec examples also cover schema elements like HTTP header as input parameters.
809 Extend Salesforce with Clicks, Not Code External Services
MIME Type Mapping in External Service Registrations You can register OpenAPI specifications with non-permitted consumes or produces MIME types directives by mapping the MIME types to permitted MIME types.
SEE ALSO: Register an External Service External Services Named Credentials
Register an External Service
Registering an external service takes only a few steps and no code. EDITIONS Before you begin, ensure that you have the OpenAPI version 2.0 endpoint information for the service that you’re registering. Then set up a named credential. A named credential specifies the URL of a Available in: Lightning callout endpoint (the service you want to access) and its authentication parameters. For example, Experience https://my_endpoint.example.com. Available in: Enterprise, Note: If you use OpenAPI 2.0, your endpoint is relative to the base URL. So if your named Performance, Unlimited, credential URL is https://my_endpoint.example.com and the basePath is and Developer Editions /basepath, they combine as the final endpoint of https://my_endpoint.example.com/basepath. USER PERMISSIONS External Services supports all named credential authoring schemes. To manage connections: Note: OpenAPI 2.0 security schemes are ignored. • Customize Application
1. From Setup in Lightning Experience, enter External Services in the Quick Find box, and select External Services. 2. Click New External Service. 3. On the Select an API Source screen, select whether you are importing an API spec From Mulesoft Anypoint Platform, or From API Specification. 4. Enter a service name and an optional description. 5. Choose a named credential. 6. If your schema includes operations that are not supported, you can filter them out by toggling on Only include supported operations (default). To learn why operations can't be included, disable this toggle. If you aren’t sure, leave this toggle on. 7. Enter a schema URL path (or endpoint), or provide a complete schema. If you enter a schema URL path, it must begin with “/” and be a relative path. For example, /accountSchema.json. If you provide a schema, it must be complete, valid OpenAPI 2.0, and JSON-compliant. 8. Click Save & Next. 9. Select the operations you want to import into your external service registration. Note that you can select up to 625 operations per org, and up to 625 active objects per org. If you exceed either of these limits, divide the operations in your schema across separate registrations. For information about limits, see External Services Considerations on page 811. For information about “objects” in Open API schemas, see https://swagger.io/docs/specification/2-0/basic-structure/ 10. Click Next.
810 Extend Salesforce with Clicks, Not Code External Services
11. Click Done.
SEE ALSO: External Services Define a Named Credential Choose an Authentication Protocol
External Services Considerations Here are the semantic, service, and usage constraints to keep in mind when integrating your services into External Services.
OpenAPI 2.0 Support • The following MIME types are permitted: – application/json — Structured data in JSON format – application/x-www-form-urlencoded -- URL encoded form – text/plain -- Unstructured data as plain text
• Non-permitted MIME types can be mapped to permitted MIME types for request and response content serialization. To do this, see MIME Type Mapping in External Service Registrations. • Form data parameters are supported. • Supports all Java runtime supported character set encodings. UTF-8 is the default encoding. • Server and operation level consumes and produces directives.
Supported Schema Format • OpenAPI 2.0, JSON schema format • UTF-8, with full character set for names and identifiers
Unsupported Schema Formats • Interagent hyper-schema format • OpenAPI 2.0 schema, YAML format • OpenAPI 3.0
Unsupported OpenAPI 2.0 Schema Constructs • The combined schema keywords: oneOf, anyOf, not • Media types such as xml, png, and pdf
OpenAPI 2.0 Schema Definitions • A schema can have up to 4,000,000 characters (4.0 MB). • You can use up to 25 External Services registrations per org. • You can have up to 625 active operations per org. The sum of active (selected) and inactive operations can’t exceed 5,000 per org.
811 Extend Salesforce with Clicks, Not Code External Services
• You can have up to 625 active, unique, Apex-defined objects per org. Apex-defined objects are derived from the object schemas in the OAS. The sum of active and inactive objects can’t exceed 5,000 per org. • You can have up to 200,000 properties per org. • You can use the GET, PATCH, PUT, POST, and DELETE methods in a schema. • The following MIME types are permitted: – application/json — Structured data in JSON format. – text/plain -- Unstructured data as plain text. – application/x-www-form-urlencoded -- URL encoded form.
• The following OpenAPI schema components are ignored: – security requirement objects and security definitions – tag objects – external documentation objects – For allOf, the schema object property discriminator is ignored. The discriminator property determines the schema referenced by its type name. The discriminator property must be set in your flow to the appropriate schema property name. Only properties from the base schema are accessible, not the composition properties from the schema designated by the discriminator schema type value. For more information, see the Swagger 2.0 Specification OpenAPI Specification.
• The operation name is derived from the schema's path operationId. If missing, it's derived from the HTTP method and resource path. • Use case consistently for object name definitions, property names, parameter names, and field names in a schema. • The derived Apex class name for an OpenAPI schema input or output parameter object can be a maximum of 255 characters. Ensure that class names are the correct length by choosing a short service name, or edit the schema object name definition to create a shorter name if errors are encountered during registration. The operation or object developer name is derived from the registered API specification. The name must fit within a maximum of 80 characters. If the individual objects or operations in the nested data structure don't themselves exceed 80 characters, then nested data structures can go up to 255 characters. • The derived Apex class name and Apex object property names require valid Apex identifier characters. Ensure that the object name in the schema object definition section matches the naming convention and the object property names. • External Services can handle up to 1,333 characters for any optional description string used to describe operations and parameters in your JSON schema definition. If the description string exceeds this limit, External Services stores only the first 1,333 characters of the description. Truncating the operation or parameter description doesn’t affect the integrity of your schema definition. • consumes/produces directives: – Unsupported consumes/produces directives invalidate the API spec registration. – consumes/produces directives that are incompatible with a request body or response entity schema declaration cause errors during callout. – Missing consumes/produces directives are defaulted to: • application/json—if the request body or the response body schema is either an object or an array • text/plain—if the request or response schema body is a primitive type such as a string or an integer number
– If no request body parameter is defined for methods POST, PUT, and PATCH, form data request parameters are sent in the request body as application/x-www-form-urlencoded. – The applicable media type in the produces list or a default (json or text/plain) is set as the HTTP Accept header.
• Character set encodings:
812 Extend Salesforce with Clicks, Not Code External Services
– The request body is encoded by the character set in the operation’s resolved consumes directive. For example, application/json; charset=ISO-8859-1 encodes the HTTP request in Latin-1 before sending it to the server – The response body is encoded by the character set in the operation’s resolved produces directive. For example, application/x-www-form-urlencoded; charset=SHIFT_JIS decodes the percent URL encoded form with the Shift JIS character set. – The default character set for encoding request bodies is UTF-8 – The default character set for decoding server response entities is defined by the server response’s Content-Type header or UTF-8 if it’s missing. – Reserved HTTP request header characters aren’t escaped and are encoded by the request body’s character set – The supported encoding set is as defined by the Java JDK. For example, for version 11, supported encoding is documented here (replace the “11” in this URL with your Java SE Platform version number): https://docs.oracle.com/en/java/javase/11/intl/supported-encodings.html - and it’s recommended to use the standard character set encoding name as described by the IANA Charset Registry.
• Considerations for properties and additionalProperties – In OpenAPI 2.0, the named properties are accessible as Apex properties with matching property type. additionalProperties allow for free form map or dictionary properties with a common property value type that are accessible in Apex as a Map property. – properties and additionalProperties under an OpenAPI 2 schema directive show as formal object properties and as a dictionary property. If declared under a property or additionalProperties type, then the OpenAPI 2 parser ignores one or the other. The registration process doesn't throw an error – OpenAPI 2.0 named properties are properties in Apex with the same name and property type. – OpenAPI 2.0 additionalProperties are grouped in the Apex property with name properties and type Map, where Type is the declared additionalProperties type. – OpenAPI 2.0 additionalProperties are always declared as an Apex object map property, even if it could be declared as a standalone Apex Map type. The result is consistently handled named object properties defined together with additionalProperties. – OpenAPI 2.0 properties and additionalProperties can both be declared under an OpenAPI parameter schema or schema in the definitions section. The OpenAPI 2.0 parser ignores either properties or additionalProperties if declared as an object property type. An object property type must only define named properties or additionalProperties, but not both. To work around, place the object property definition as a named schema under definitions and reference it by name. – The OpenAPI 2.0 parser doesn't differentiate between literal declarations or untyped schemas. Declarations like additionalProperties: true, additionalProperties: false or additionalProperties: {} are interpreted as untyped. Untyped additionalProperties are ignored. There isn't a workaround to define additionalProperties that can be of any type. – Flow doesn't allow access or manipulation of Apex object types with Map properties, but transparently preserves the content when assigned to variables of the same Apex object type. To manipulate map data structure in flow, call an Apex invocable action that can access the map data structure. For an example with External Service maps in action, see the “External Services Schema Example 9” section of Examples: External Services Schema.
External Service support for Apex reserved keywords Although not a best practice, External Services doesn’t prohibit schema entities with the same name as the Apex reserved keywords. If your schema name conflicts with an Apex reserved keyword, External Services creates a unique name by encoding it to be compatible with Apex identifier rules.
813 Extend Salesforce with Clicks, Not Code External Services
For example, you have an account object with property name type. Because the property name type conflicts with the Apex reserved keyword type, External Services encodes the property name type as z0type to make it Apex compliant. During callout, the property name type is used according to the original OpenAPI schema. Special characters that aren’t valid Apex identifiers are UTF-8 encoded. For example, 5getOpen-bankingV2.2Atms is encoded as x35getOpenx2dbankingV2x2e2Atms for a valid Apex identifier. Flow • You can’t edit an external service used in a flow. • External service callouts aren’t allowed when there are pending, uncommitted transactions. Close your transaction, and resume Flow using the flow element Pause. Array definition in OpenAPI 2.0 External Services supports inline array definitions and referenceable named arrays. List types in External Services are identified by their object element type. Supported Inline Array Definition with Reference to Array Items Definition
{ "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "type": "array", "items": { "$ref": "#definitions/MyObject" } } ... "definitions": { "MyObject": { "type": "object", "properties": {...} } } }
In Flow Builder, declare a variable for the myObjects parameter by marking the variable as a collection and picking its Apex element type ExternalService__RegistrationName_MyObject. Inline Array Definition with Inline Array Items Definition
{ "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "type": "array", "items": { "type": "object", "properties": {...} } }
814 Extend Salesforce with Clicks, Not Code External Services
... "definitions": { ... } }
In Flow Builder, declare a collection variable for the myObjects parameter and Apex element type ExternalService__RegistrationName_OperationName_IN_myObjects. Referenceable Array Definition with Reference to Array Item Definitions
{ "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "$ref": "#definitions/MyObjectList" } ... "definitions": { "MyObjectList": { "type": "array", "items": { "$ref": "#definitions/MyObject" } } "MyObject": { "type": "object", "properties": {...} } } }
In Flow Builder, declare a collection variable for the myObjects parameter and Apex element type ExternalService__RegistrationName_MyObject. Referenceable Array Definition with Inline Array Items Definition
{ "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "$ref": "#definitions/MyObjectList" } ... "definitions": { "MyObjectList": { "type": "array", "items": { "type": "object", "properties": {...} } }
815 Extend Salesforce with Clicks, Not Code External Services
} }
In Flow Builder, declare a collection variable for the myObjects parameter and Apex element type ExternalService__RegistrationName_MyObjectList.
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
Examples: External Services Schema
These API spec examples highlight various scenarios with JSON schemas supported by External EDITIONS Services and can help you avoid common mistakes with syntax and code placement. The API spec examples also cover schema elements like HTTP header as input parameters. Available in: Lightning External Services API Spec Example 1 Experience Here’s an example of a an API spec that contains a supported JSON schema for OpenAPI 2.0. The Available in: Enterprise, parameters (in bold) contain the definition for the accountId input. The responses (also in bold) Performance, Unlimited, contain the definition for the output, which is creditRating. Parameters and responses and Developer Editions translate to inputs and outputs, respectively, for your flow actions.
{ "swagger":"2.0", "info":{ "description":"A service for checking credit for an account.", "version":"1.0.0", "title":"Credit Decision", "termsOfService":"http://swagger.io/terms/", "contact":{ "email":"[email protected]" }, "license":{ "name":"Apache 2.0", "url":"http://www.apache.org/licenses/LICENSE-2.0.html" } }, "host":"", "paths":{ "/account/lastCreditRating":{ "get":{ "summary":"Evaluates credit rating and decides what payment terms to offer.",
"description":"", "consumes":[ "application/json", "application/xml" ], "produces":[ "application/xml", "application/json" ], "parameters":[{ "in":"body",
816 Extend Salesforce with Clicks, Not Code External Services
"name":"body", "description":"Specifies input parameters to calculate payment term", "required":true, "schema":{ "$ref":"#/definitions/accountId" } }], "responses":{ "200":{ "description":"success", "schema":{ "$ref":"#/definitions/creditRating" } }, "405":{ "description":"Invalid input" } } } } }, "definitions":{ "accountId":{ "type":"object", "properties":{ "accountIdString":{ "type":"string" } }, "xml":{ "name":"accountId" } }, "creditRating":{ "type":"object", "properties":{ "creditRatingString":{ "type":"string" } }, "xml":{ "name":"creditRating" } } } }
External Services API Spec Example 2 Basic Setup • For the named credential that your org uses to access the banking system, assign the Bank label and the https://api.example.com URL. The named credential URL corresponds to the declared host of the JSON schema and one of its schemes or URL protocols. The URL can point to a different endpoint as long as it hosts the same external service. The base path is added to the named credential URL on callout.
817 Extend Salesforce with Clicks, Not Code External Services
• Register the employee banking system’s external service. Use the Bank name and the Bank named credential, and then copy one of the following schemas provided. • The banking system's external service shows two ways to define parameters with object types: a named object type under a “definitions” block or an anonymously declared object type inline.
Note: The defined or derived parameter object type name, or a property with an object type, must be fewer than 255 characters to be used in Flow Builder.
Here’s a schema with the named object type defined under the “definitions” block. The phone object type's name is ExternalService__Bank_Phone in Flow Builder.
{ "swagger": "2.0", "info": { "title": "bankService", "description": "API description in Markdown.", "version": "1.0.0" }, "host": "api.example.com", "basePath": "/v1", "schemes": [ "https" ], "definitions": { "User": { "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones":{ "type":"array", "items":{ "type": "object", "$ref": "#/definitions/Phone" } } } }, "Phone":{ "properties":{ "typeofphone":{ "type":"string" }, "phone":{ "type":"string" } } } }, "paths": { "/users/{userId}": {
818 Extend Salesforce with Clicks, Not Code External Services
"get": { "summary": "Returns a user by ID.", "parameters": [{ "in": "path", "name": "userId", "required": true, "type": "integer" }], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/User" } } } } }, "/users": { "post": { "summary": "Creates a new user.", "parameters": [{ "in": "body", "name": "user", "schema": { "$ref": "#/definitions/User" } }], "responses": { "200": { "description": "OK" } } } } } }
External Services API Spec Example 3 Here’s an API spec with a JSON schema with anonymous object types defined inline. The derived phone object type's name is ExternalService__Bank_getUsers_OUT_200_phones.
Note: For anonymous object types, Salesforce automatically derives object type names based on the external service, parent operation, operation parameter, parent object, and object property names. The derived name must be fewer than 255 characters. Object types with names longer than 40 characters and object types that reference through their properties’ object types with names longer than 40 characters can't be used in Flow Builder.
{ "swagger": "2.0", "info": { "title": "bankService", "description": "API description in Markdown.", "version": "1.0.0" },
819 Extend Salesforce with Clicks, Not Code External Services
"host": "api.example.com", "basePath": "/v1", "schemes": [ "https" ], "paths": { "/users/{userId}": { "get": { "summary": "Returns a user by ID.", "parameters": [{ "in": "path", "name": "userId", "required": true, "type": "integer" }], "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones": { "type":"array", "items": { "type": "object", "properties": { "typeofphone": { "type":"string" }, "phone": { "type":"string" } } } } } } } } } }, "/users": { "post": { "summary": "Creates a new user.", "parameters": [{ "in": "body", "name": "user", "schema": {
820 Extend Salesforce with Clicks, Not Code External Services
"type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones": { "type":"array", "items": { "type": "object", "properties": { "typeofphone": { "type":"string" }, "phone": { "type":"string" } } } } } } }], "responses": { "200": { "description": "OK" } } } } } }
External Services API Spec Example 4 Here's an API spec registered with external service name BankingAutomaticTellerMachine. However, the derived object names: • ExternalService__BankingAutomaticTellerMachine_VeryImportantCustomer_phone • ExternalService__BankingAutomaticTellerMachine_getBalanceAccountTypeChecking_OUT_200 Must be no longer than 255 characters. To use Flow Builder, you must shorten the external service schema name and the schema (shown in Example 5).
Tip: If the derived object name is longer than 255 characters, try one of the following methods to resolve the issue. • Shorten the external service name. • If the object is declared inline under an operation parameter, shorten the operation name by adding an operationId to the schema. • If the object is declared inline under a parent object property, shorten the parent object name in the schema. • Declare the nested object as a top-level object under schema “definitions”.
{ "swagger": "2.0",
821 Extend Salesforce with Clicks, Not Code External Services
... "paths": { "/balance/account/{accountId}/type/checking": { "get": { "parameters": [{ "in": "path", "name": "accountId", "required": true, "type": "integer" }], "responses": { "200": { "schema": { "type": "object", "properties": { "balance": { "type": "integer" }, "owner": { "$ref": "#/definitions/VeryImportantCustomer" } } } } } } } }, "definitions": { "VeryImportantCustomer": { "type": "object", "properties": { "name": { "type": "string" }, "phone": { "type": "object", "properties": { "number": { "type": "string" } } } } } } }
External Services API Spec Example 5 Here's an example of an API spec with a schema that results in shortened names. It's registered with the shortened name BankAtm. Shorten the external service schema name to BankAtm, the schema object name to VIP and add operationId as getBalance: • ExternalService__BankAtm_VIP_phone
822 Extend Salesforce with Clicks, Not Code External Services
• ExternalService__BankAtm_getBalance_200
{ "swagger": "2.0", ... "paths": { "/balance/account/{accountId}/type/checking": { "get": { "operationId": "getBalance", "parameters": [{ "in": "path", "name": "accountId", "required": true, "type": "integer" }], "responses": { "200": { "schema": { "type": "object", "properties": { "balance": { "type": "integer" }, "owner": { "$ref": "#/definitions/VIP" } } } } } } } }, "definitions": { "VIP": { "type": "object", "properties": { "name": { "type": "string" }, "phone": { "type": "object", "properties": { "number": { "type": "string" } } } } } } }
External Services API Spec Example 6
823 Extend Salesforce with Clicks, Not Code External Services
Here's an example with an inline array definition.
{ "swagger": "2.0", "host": "Employees.org", "basePath": "/", ... "paths": { "/employees/{employeeId}": { "get": { "operationId": "getEmployee", "parameters": [{ "in": "path", "name": "employeeId", "required": true, "type": "string" }], "responses": { "200": { "schema": { "type": "object", "properties": { "employee": {"$ref": "#/definitions/Employee"}, "manager": {"$ref": "#/definitions/Employee"}, "team": { "type": "array", "items": {"$ref": "#/definitions/Employee"} } } } } } } } }, "definitions": { "Employee" : { "type": "object", "properties": { "employeeId": {"type": "string"}, "firstName": {"type": "string"}, "middleName": {"type": "string"}, "lastName": {"type": "string"}, "dateOfHire": {"type": "date"} } } } }
External Services API Spec Example 7 Here’s how a header parameter is declared in an OpenAPI schema. In Flow, the name “apiKey” shows up as a string parameter. Now when you set any string value in a flow to apiKey, it functions as an HTTP parameter when making a callout request.
{ "swagger": "2.0",
824 Extend Salesforce with Clicks, Not Code External Services
"info": { "description": "A service for checking credit for an account.", "version": "1.0.0", "title": "Credit Decision", "termsOfService": "http://swagger.io/terms/", "contact": { "email": "[email protected]" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, "host": "", "paths": { "/account/lastCreditRating": { "get": { "summary": "Evaluates credit rating and decides what payment terms to offer.", "description": "", "consumes": [ "application/json", "application/xml" ], "produces": [ "application/xml", "application/json" ], "parameters": [{ "name": "body", "description": "Specifies input parameters to calculate payment term", "in": "body", "required": true, "schema": { "$ref": "#/definitions/accountId" } },{ "name": "apiKey", "description": "Your API Key for calling the credit rating service", "in": "header", "type": "string" }], "responses": { "200": { "description": "success", "schema": { "$ref": "#/definitions/creditRating" } }, "405": { "description": "Invalid input" } } } }
825 Extend Salesforce with Clicks, Not Code External Services
}, "definitions": { "accountId": { "type": "object", "properties": { "accountIdString": { "type": "string" } }, "xml": { "name": "accountId" } }, "creditRating": { "type": "object", "properties": { "creditRatingString": { "type": "string" } }, "xml": { "name": "creditRating" } } } }
External Services API Spec Example 8 Request and response form data is declared alongside the matching consumes and produces directives.
{ "swagger": "2.0", "info": { "description": "Apply here for your next mortgage", "version": "1.0.0", "title": "My Mortgage Buddy", "contact": { "email": "[email protected]" }, }, "host": "MyMortgageBuddy.org", "basePath": "/mortgages", "paths": { "/apply": { "post": { "operationId": "applyMortgage", "consumes": [ "application/x-www-form-urlencoded; charset=utf-8" ], "produces": [ "application/x-www-form-urlencoded; charset=utf-8" ], "parameters": [{ "description": "Desired mortgage terms",
826 Extend Salesforce with Clicks, Not Code External Services
"name": "terms", "in": "formData", "type": "array", "items": { "type": "integer" }, "collectionFormat": "multi", "required": true },{ "description": "Full Name", "name": "fullName", "in": "formData", "type": "string", "required": true },{ "description": "Loan amount", "name": "loanAmount", "in": "formData", "type": "number", "required": true }], "responses": { "200": { "description": "200", "schema": { "type": "object", "properties": { "formApplicationId": { "type": "string" }, "loanOfficerFullName": { "type": "string" } } } } } } } }
External Services API Spec Example 9 This JSON schema definition highlights the constructs allOf for schema object composition and additionalProperties for dictionary values. The sample schema is registered as external service MyBank with named credential MyBank. The registration is invoked by a sample flow that accesses the dictionary properties with an Apex invocable action. A flow Apex unit test ties it all together. The schema defines a banking service that gets customer details for a customer ID. • The Customer schema object has dictionary properties of type schema object CreditRating. In Apex, the class ExternalService.MyBank_Customer has property properties of type Map with the customer’s credit ratings.
827 Extend Salesforce with Clicks, Not Code External Services
• Phones and Emails compose their own properties together with the common allOf properties from the schema object Contact.
{ "swagger": "2.0",
"info": { "title": "myBank", "description": "Sample Banking Service with allOf and additionalProperties schema constructs", "version": "1.0.0" },
"host": "api.mybank.com", "basePath": "/v1", "schemes": [ "https" ],
"definitions": { "Customer": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones": { "type":"array", "items": { "$ref": "#/definitions/Phone" } }, "emails": { "type": "array", "items": { "$ref": "#/definitions/Email" } } }, "additionalProperties": { "$ref": "#/definitions/CreditRating" }, "required": [ "id", "name" ] },
"Contact": { "type": "object", "properties": { "primary": { "type": "boolean"
828 Extend Salesforce with Clicks, Not Code External Services
}, "timeOfDay": { "type": "string" } }, "required": [ "primary" ] }, "Phone": { "allOf": [ { "$ref": "#/definitions/Contact" }, { "type": "object", "properties": { "typeOfPhone": { "type":"string" }, "phoneNumber":{ "type":"string" } } } ] }, "Email": { "allOf": [ { "$ref": "#/definitions/Contact" }, { "type": "object", "properties": { "email": { "type":"string" } } } ] },
"CreditRating": { "type": "object", "properties": { "rating": { "type": "string" }, "score": { "type": "number", "format": "double" } }
829 Extend Salesforce with Clicks, Not Code External Services
} },
"paths": { "/customers/{customerId}": { "get": { "summary": "Get the customer by ID.", "parameters": [{ "in": "path", "name": "customerId", "required": true, "type": "integer" }], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/Customer" } } } } } } }
Here is the Apex invokable action that gets the customer credit ratings as a list demonstrating how to work with map data types from flow:
public class MyBankGetCreditRatings { @InvocableMethod( label='Get Credit Ratings' description='A list of credit ratings for a customer' category='MyBank' ) public static List getCreditRatings(List inCustomers) {
List outCreditRatingsList = new List(); for (Customer inCustomer: inCustomers) { ExternalService.MyBank_Customer customer = inCustomer.customer; CustomerCreditRatings outCreditRatings = new CustomerCreditRatings(); outCreditRatings.customerId = customer.id; outCreditRatings.creditRatings = new List();
Map creditRatings = customer.properties; for (String ratingProperty: creditRatings.keySet()) { ExternalService.MyBank_CreditRating creditRating = creditRatings.get(ratingProperty); outCreditRatings.creditRatings.add(creditRating); }
830 Extend Salesforce with Clicks, Not Code External Services
outCreditRatingsList.add(outCreditRatings); }
return outCreditRatingsList; }
public class Customer { @InvocableVariable( label='Customer' description='Banking customer' required=true ) public ExternalService.MyBank_Customer customer; }
public class CustomerCreditRatings { @InvocableVariable( label='Customer ID' description='Bank customer ID' required=true ) public Integer customerId;
@InvocableVariable( label='Credit Ratings' description='Credit ratings for a customer' required=true ) public List creditRatings; } }
The flow starts by calling the external MyBank service action getCustomerById to get the customer details given a customer ID. The Apex invokable flow action getCreditRatings gets the list of credit ratings from the customer details. Phone and email contact details are formatted as a list of customer contacts by looping through the phones and emails properties and assigning the formatted value to the contacts list.
831 Extend Salesforce with Clicks, Not Code External Services
The HTTP callout mock asserts an expected request and responds with a sample customer as application/json:
public class MyBankGetCustomerCalloutMock implements HttpCalloutMock { public HTTPResponse respond(HTTPRequest request) { // Assert expected request test data: customer ID in the request path System.assertEquals('GET', request.getMethod()); System.assertEquals('callout:MyBank/v1/customers/42', request.getEndpoint());
// Send response test data: customer details with sample ratings // as additional properties and sample contacts HttpResponse response = new HttpResponse(); response.setHeader('Content-Type', 'application/json'); response.setBody('{' + '"id": 42, "name": "Foo Bar", "phones": [' + ' {"primary": true, "timeOfDay": "Daytime", ' + ' "typeOfPhone": "Mobile", "phoneNumber": "555-5555"},' + ' {"primary": false, "timeOfDay": "Evening", ' + ' "typeOfPhone": "Landline", "phoneNumber": "222-5555"}' + '], "emails": [' + ' {"primary": true, "timeOfDay": "AllDay", "email": "[email protected]"}' + '],' + '"rating1": {"rating": "Rating 1", "score": 0.95}, ' + '"rating2": {"rating": "Rating 2", "score": 0.78}' + '}'); response.setStatusCode(200); return response; } }
Tip: You can also use JSON to serialize a sample response matching the external service response type if the HTTP response mime type is application/json and the JSON properties are compliant with Apex identifier characters:
ExternalService.MyBank_Customer customer = new ExternalService.MyBank_Customer(); customer.id = 42; ... customer.properties = new Map(); ExternalService.MyBank_CreditRating creditRating = new ExternalService.MyBank_CreditRating(); creditRating.rating = 'Rarging 1'; creditRating.score = 0.95; customer.properties.put('rating1', creditRating); ... response.setBody(System.JSON.serialize(customer)); ....
The Apex unit test sets up the HTTP callout mock and asserts the expected credit ratings and customer contacts:
@IsTest public class MyBankFlowTest { @IsTest static public void testGetCustomer() { // Set HTTP callout mock to match flow's external service action invocation Test.setMock(HttpCalloutMock.class, new MyBankGetCustomerCalloutMock());
// Set flow input variables and create the flow interview Map inputVariables = new Map(); inputVariables.put('customerId', 42);
832 Extend Salesforce with Clicks, Not Code External Services
Flow.Interview myBankFlow = Flow.Interview.createInterview('MyBank', inputVariables);
// Start flow interview with set input variables myBankFlow.start();
// Assert customer's expected credit ratings List creditRatings = (List)myBankFlow. getVariableValue('creditRatings'); System.assertEquals(2, creditRatings == null ? 0 : creditRatings.size()); ExternalService.MyBank_CreditRating actualRating = creditRatings.get(1); ExternalService.MyBank_CreditRating expectedRating = new ExternalService.MyBank_CreditRating(); expectedRating.rating = 'Rating 2'; expectedRating.score = 0.78; System.assertEquals(expectedRating.toString(), actualRating.toString());
// Assert customer's contacts: List contacts = (List)myBankFlow.getVariableValue('*contacts*'); System.assertEquals(3, contacts == null ? 0 : contacts.size()); System.assertEquals('Phone Number: 555-5555', contacts.get(0)); System.assertEquals('Phone Number: 222-5555', contacts.get(1)); System.assertEquals('Email: [email protected]', contacts.get(2)); } }
For another example of a flow Apex unit test, see Testing External Service Actions in Flow on page 850.
MIME Type Mapping in External Service Registrations You can register OpenAPI specifications with non-permitted consumes or produces MIME types directives by mapping the MIME types to permitted MIME types. OpenAPI consumes MIME types: • The Content-Type header is the specified consumes MIME type. • The request body is serialized with the mapped permitted media type. OpenAPI produces MIME types: • The request Accept header is the specified produces MIME type. • The response Content-Type header, if present, is mapped to the permitted MIME type to deserialize the response body. Non-permitted MIME types must be mapped to permitted MIME types as mappings in the field serviceBinding of the ExternalServiceRegistration metadata file.
MIME Type Mapping Example Acme bank specifies an OpenAPI 2.0 service for their credit rating service. It defines its own MIME type for handling the JSON compatible payload: application/x-acme-json:
{ "swagger":"2.0", "info":{
833 Extend Salesforce with Clicks, Not Code External Services
"description":"A service for checking credit for an account.", "version":"1.0.0", "title":"Credit Decision" }, "host":"", "paths":{ "/account/credit-rating":{ "get":{ "operationId":"getCreditRating", "summary":"Evaluates credit rating for offered payment terms.", "consumes":[ "application/x-acme-json" ], "produces":[ "application/x-acme-json" ], "parameters":[{ "description":"Account", "in":"body", "name":"body", "required":true, "schema":{ "$ref":"#/definitions/Account" } }], "responses":{ "200":{ "description": "Credit rating", "schema":{ "$ref":"#/definitions/CreditRating" } } } } } }, "definitions":{ "Account":{ "type":"object", "properties":{ "accountId":{ "type":"string" }, "accountHolder":{ "type":"string" } } }, "CreditRating":{ "type":"object", "properties":{ "creditRating":{ "type":"string" }
834 Extend Salesforce with Clicks, Not Code External Services
} } } }
To map the BankService MIME type to the permitted MIME type application/json, open a command-line terminal. Create a directory in which to retrieve the external service’s metadata.
> mkdir BankService > cd BankService
Create the manifest package.xml for the external service metadata for your BankService to retrieve from your organization:
> touch package.xml
Edit the package.xml:
BankService ExternalServiceRegistration 53.0
Retrieve the metadata for the external service with the Salesforce CLI command after successful authentication to your organization:
> sfdx force:mdapi:retrieve -r . -k package.xml
Unzip the package zip with the metadata and navigate to the directory with the external service:
> unzip unpackaged.zip > cd unpackaged/externalServiceRegistrations
Edit service bindings in the external service registration metadata file BankService.externalServiceRegistration:
BankServiceEndpoint true getcreditrating Custom { ... } OpenApi {"compatibleMediaTypes" :{"application/x-acme-json" :"application/x-acme-json"}} Complete
Note that the section (in bold, above) should not be broken by line breaks as it may break deserialization.
835 Extend Salesforce with Clicks, Not Code External Services
The service binding specifies in JSON format the non-permitted MIME types defined by this external service registration:
{"compatibleMediaTypes":{ "application/x-acme-json":"application/x-acme-json" }}
Map the non-permitted MIME type to the permitted MIME type for the external service payload serialization:
{"compatibleMediaTypes":{ "application/x-acme-json":"application/json" }}
The updated metadata for the bank rating external service sample registration respects the MIME type mapping to the permitted MIME type when deployed in a package:
BankService true getcreditrating Custom { ... } OpenApi {"compatibleMediaTypes" :{"application/x-acme-json" :"application/json"}} Complete
Note that the section should not be broken by line breaks as it may break deserialization. Save the edited external service registration metadata file and deploy it:
> cd ../.. > sfdx force:mdapi:deploy -d unpackaged
For more information see Salesforce DX Developer Guide.
Import MuleSoft APIs Import your MuleSoft Anypoint Platform APIs in a few clicks with External Services for MuleSoft. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account.
Configure a Connected App and Named Credentials To use External Services for MuleSoft, complete these setup steps. Register a MuleSoft-Hosted External Service Registering an external service for MuleSoft Anypoint Platform takes only a few steps and no code.
836 Extend Salesforce with Clicks, Not Code External Services
Configure a Connected App and Named Credentials To use External Services for MuleSoft, complete these setup steps.
Create a Connected App in MuleSoft Anypoint Platform Set up a connected app in MuleSoft Anypoint Platform that allows Salesforce to call MuleSoft APIs. Create an Authentication Provider Use the ID and the secret from your MuleSoft Anypoint Platform connected app to create an authentication provider. Update Your MuleSoft Anypoint Platform Connected App Use the Salesforce authentication provider callback URL to update your MuleSoft Anypoint Platform connected app. Create a Named Credential Create a named credential to access your MuleSoft Anypoint Platform connected app from Salesforce.
Create a Connected App in MuleSoft Anypoint Platform Set up a connected app in MuleSoft Anypoint Platform that allows Salesforce to call MuleSoft APIs. To use the External Services for MuleSoft wizard, you need a valid MuleSoft license or demo account. The MuleSoft user account must have full permissions for the API Manager and Exchange in your MuleSoft Anypoint Platform org. Complete these steps in MuleSoft Anypoint Platform. 1. Log in to MuleSoft Anypoint Platform. 2. Under Management Center, click Access Management. 3. In the Access Management menu, select Connected Apps. 4. Click Create app. 5. Enter a name for your app. 6. Ensure that App acts on behalf of a user is selected for Type. 7. Under Grant types, select Authorization Code, and then select Refresh Token. 8. In Website URL, enter https://www.salesforce.com. 9. In Redirect URIs, enter https://www.salesforce.com, and click Add.
Note: This redirect URI is a temporary value that is updated after you create an authentication provider in your Salesforce org.
10. For Who can use this application? select Members of this organization only. 11. Under Scopes, click Add Scopes. 12. In Add scopes, enable Background Access and Read-Only Access, and click Add scopes. 13. Save your changes. 14. On the Connected Apps page, click Copy Id, and paste the id into a text file. 15. Click Copy Secret, and paste it into the same text file. Create an authentication provider.
837 Extend Salesforce with Clicks, Not Code External Services
Create an Authentication Provider
Use the ID and the secret from your MuleSoft Anypoint Platform connected app to create an EDITIONS authentication provider. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. Available in: Lightning Experience This setup requires the ID and secret that can be copied when you created your connected app in MuleSoft Anypoint Platform. Available in: Enterprise, Complete these steps. Performance, Unlimited, and Developer Editions 1. From Setup, in the Quick Find box, enter Auth. Providers, and then select Auth. Providers. 2. Click New. 3. For Provider Type, select Open ID Connect. 4. Specify a name like MuleSoft Anypoint Platform. 5. For Consumer Key, enter the ID that you copied when you created your connected app in MuleSoft Anypoint Platform. 6. For Consumer Secret, enter the secret that you copied when you created your connected app in MuleSoft Anypoint Platform. 7. For Authorize Endpoint URL, enter https://anypoint.mulesoft.com/accounts/api/v2/oauth2/authorize. 8. For Token Endpoint URL, enter https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token. 9. Save your changes. 10. On the Auth. Provider Detail page, under Salesforce Configuration, copy the Callback URL. Update the connected app in MuleSoft Anypoint Platform.
Update Your MuleSoft Anypoint Platform Connected App Use the Salesforce authentication provider callback URL to update your MuleSoft Anypoint Platform connected app. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. This setup requires the callback URL that can be copied when you created your authentication provider in Salesforce. Complete these steps in MuleSoft Anypoint Platform. 1. In Access Management, on the Connected Apps page, click the name of the connected app you created in MuleSoft Anypoint Platform. 2. On the Update App page, in Redirect URIs, enter the callback URL that you copied when you created an authentication provider in Salesforce, and click Add. 3. Delete the Redirect URI for https://www.salesforce.com. 4. Save your changes. Create a named credential.
838 Extend Salesforce with Clicks, Not Code External Services
Create a Named Credential
Create a named credential to access your MuleSoft Anypoint Platform connected app from Salesforce. EDITIONS To use the External Services for MuleSoft wizard, you need a valid MuleSoft license or demo account. 1. From Setup, in the Quick Find box, enter Named Credentials, and then select Named Available in: Lightning Experience Credentials. 2. Click New Named Credential. Available in: Enterprise, Performance, Unlimited, 3. Enter a label for your named credential. The label can contain no spaces or special characters. and Developer Editions 4. (Optional) Enter a name for your named credentials, or use the name that the system generated based on the label you entered. 5. For URL, enter https://anypoint.mulesoft.com. 6. Select an Identity Type. a. To require that each Salesforce user log into MuleSoft Anypoint Platform from within their personal settings to get a token for their own use, select Per User. b. To allow one named credential to be shared by all users in your org, select Named Principal.
7. For Authentication Protocol, select OAuth 2.0. 8. Select an Authentications Provider. For Authentication Provider, click the magnifying glass and select the name of the auth provider that you created. 9. For Scope, enter read:full offline_access. 10. Ensure that Start Authentication Flow on Save is enabled. 11. Save your changes.
Note: If you receive the “No_Oauth_State: State was not sent back” error when saving the named credential, ensure that the selected scopes for your MuleSoft Anypoint Platform connected app are Read-Only Access and Background Access. You can also receive the error if the read:full offline_access scope you specified has a period at the end of it.
12. (Optional) If you’re not already logged into MuleSoft Anypoint platform, log in now. 13. Grant read-only access and background access to your Salesforce user. 14. On the Named Credential Setup page, Authentication Status is now set to Authenticated. Import MuleSoft Anypoint Platform APIs.
Register a MuleSoft-Hosted External Service
Registering an external service for MuleSoft Anypoint Platform takes only a few steps and no code. EDITIONS To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. 1. From Setup, in the Quick Find box, enter External Services, and then select External Available in: Lightning Experience Services. 2. Select New External Service, and click Next. Available in: Enterprise, Performance, Unlimited, 3. In the Select an API Source window, select From MuleSoft Anypoint Platform, and click and Developer Editions Next.
Note: If you’re in an operationally isolated environment (OIE), the MuleSoft Anypoint Platform tile can’t be selected.
839 Extend Salesforce with Clicks, Not Code External Services
4. In the Select a MuleSoft Anypoint Platform Account window, select the named credential with the most access to MuleSoft.
Important: External Services for MuleSoft use this credential to log in to MuleSoft Anypoint Platform and list MuleSoft APIs available for import. In a later step, you can specify a different named credential with more targeted access to MuleSoft to run the external service in the next step.
5. In the Configure Your MuleSoft Anypoint Platform Service window, set up the details for your external service. a. Select a MuleSoft API. b. Enter a name for your external service. The name must start with a letter, can’t contain spaces or special characters, and be no longer than 80 characters. c. (Optional) Enter a description of your external service. If you don’t enter a description, the system-generated description is used. d. Select a named credential to use to run the external service. e. Ensure that Only include supported operations is enabled.
Important: External Services for MuleSoft use this credential to run a MuleSoft API operation when the external service is called from a flow. You can select a named credential with more targeted access than the one you chose in the previous step.
f. Click Save & Next.
Note: Clicking Save & Next creates an external service record in Salesforce. After this step, you can’t change the MuleSoft API name or version associated with the external service. You can only change the external service name, description, named credential, and included MuleSoft API operations.
6. In the Select Operations window, select up to 625 operations to include in your external service.
Note: For limits, including the maximum number of operations allowed in your org, see External Services Considerations.
7. Click Next. 8. Review your changes, and click Done. Use your external service in a flow.
Create a Flow with External Services Design and test the automation that sends a user’s information from Salesforce to the external employee banking system. Create the variables for user phone numbers, and combine different phone numbers into one piece of data. Then use the external service action to create the user. 1. Define a named credential For the named credential that your org uses to access the banking system, assign the Bank label and the https://api.example.com URL. The named credential URL corresponds to the declared host of the API spec and one of its transfer protocol schemes or URL protocols. The URL can point to a different endpoint as long as it hosts the same external service. The base path is added to the named credential URL on callout.
2. Register the employee banking system’s external service, using the steps described in Register an External Service on page 810 as a guide. Use the BankService name and the Bank named credential, and then copy the schema from one of the API spec examples. 3. Create a flow.
840 Extend Salesforce with Clicks, Not Code External Services
This example uses static values for simplicity. In contrast, a production flow with user data includes elements to get user records, store values to variables, and communicate these values to the external service.
4. To handle the multiple phone numbers nested below the BankService_Phone value, add the two variable resources. a. Click Manager, and then click New Resource. b. For the resource type, select Variable. c. For the API name, enter WorkPhone. d. For the data type, select Apex-Defined. e. For the Apex class, select ExternalService__BankService_Phone.
f. Click Done. g. Repeat these steps using the API name CellPhone.
5. Add the variable resource that acts as the array for the phone number values. a. Click New Resource. b. For the resource type, select Variable. c. For the API name, enter Phones. d. For the data type, select Apex-Defined, and select the Allow multiple values (collection) option. e. For the Apex class, select ExternalService__BankService_Phone.
841 Extend Salesforce with Clicks, Not Code External Services
f. Click Done.
6. Add the variable resource that stores the user’s name. a. Click New Resource. b. For the resource type, select Variable. c. For the API name, enter User. d. For the data type, select Apex-Defined. e. For the Apex class, select ExternalService__BankService_User. f. Click Done.
7. Assign values to the work phone variable. a. From the Toolbox, click Elements. b. Drag an Assignment element to the canvas. c. For Label, enter Assign Work Phone, and let the API name autopopulate. d. Click Search variables, select WorkPhone, then select phone. The variable {!WorkPhone.phone} appears. e. For Value, enter 1234567890. f. Click Add Assignment.
842 Extend Salesforce with Clicks, Not Code External Services
g. Click Search variables, select WorkPhone, then select typeofphone. The variable {!WorkPhone.typeofphone} appears. h. For Value, enter Work.
i. Click Done. j. Connect the Start element to this assignment element.
8. Assign values to the cell phone variable. a. Drag an Assignment element to the canvas. b. For Label, enter Assign Cell Phone, and let the API name autopopulate. c. Click Search variables, select CellPhone, then select phone. The variable {!CellPhone.phone} appears. d. For Value, enter 0987654321 e. Click Add Assignment. f. Click Search variables, select CellPhone, then select typeofphone. The variable {!CellPhone.typeofphone} appears. g. For Value enter Cell. h. Click Done. i. Connect the last element to this one.
843 Extend Salesforce with Clicks, Not Code External Services
9. Assign multiple phone values to the single phone array variable. a. Drag an Assignment element to the canvas. b. For Label, enter Assign Phones, and let the API name autopopulate. c. Click Search variables then select Phones. The variable {!Phones} appears. d. Change the Operator to Add. e. For Value, select Workphone. f. Click Add Assignment. g. Click Search variables then select Phones again. h. Change the Operator to Add. i. For Value select Cellphone.
j. Click Done. k. Connect the last element to this one.
10. Assign the user values. a. Drag an Assignment element to the canvas.
844 Extend Salesforce with Clicks, Not Code External Services
b. For Label, enter Assign User, and let the API name autopopulate. c. Click Search variables, select User, then id. The variable {!User.id} appears. d. For Value, enter 1234. e. Click Add Assignment. f. Click Search variables, select User, then name. The variable {!User.name} appears. g. For Value, enter Maria. h. Click Add Assignment. i. Click Search variables, select User, then phones. The variable {!User.phones} appears. j. For Value, select Phones.
k. Click Done. l. Connect the last element to this one.
11. To create users on the external bank system, add the action generated by your external service schema.
845 Extend Salesforce with Clicks, Not Code External Services
a. Drag an Action element to the canvas. b. Filter the actions by type, and select External Service. c. Select postUser. d. For Label, enter Create a new user, and let the API name autopopulate. e. Next to >_user, click the toggle to include input values. f. From the lookup, select User.
g. Click Done. h. Connect the last element to this one. Your canvas includes these elements.
12. Save and debug the flow. A successful debug includes the assignment and External Service callout.
846 Extend Salesforce with Clicks, Not Code External Services
SEE ALSO: External Services Build a Flow
Add Actions to an Einstein Bot Integrating your Einstein bot with a registered external service is now as easy as adding an action to a dialog. You can add an external service action to your bot from Einstein’s Bot Builder. Sometimes the data that your Einstein bot needs to personalize customer requests is stored outside of Salesforce. For example, a banking customer wants to update their account password and billing address in a single bot conversation. Or a retail customer starts a return process for a purchase and expects the bot to return a unique tracking number. Now you can automate these multi-platform requests directly from the Bot Builder, without writing a single line of code.
SEE ALSO: Add an External Service Action
847 Extend Salesforce with Clicks, Not Code External Services
Edit, Delete, Save As, and View an External Service
Find services that you already registered, view actions for a previously defined service, edit, clone, EDITIONS and delete a service. You can’t edit or delete an external service that is in use by a flow. Available in: Lightning Locate Registered External Services Experience To find your registered services, go to Setup, in the Quick Find box enter External Services, Available in: Enterprise, and then select External Services. Performance, Unlimited, and Developer Editions 1. Actions that you can select for your external service registration: View Actions, Edit, Save As, and Delete. 2. Service recreated with Save As and has the provided prefix of CopyOf in front of the name. Remember to change the name to something more descriptive of the service.
View Actions To view actions available for a service that you defined with your schema, click the arrow in the service’s Actions column, and select View Actions.
Edit To edit an external service, click the arrow in the service’s Actions column, and select Edit. You can modify these service settings: • Named Credential • Description • Service Schema (URL or JSON) • Operations
Save As Save As allows you to recreate your external service registration. Use this action to clone an existing service without changing anything except the name of the new service. 1. To save settings to a new external service, click the arrow in the service’s Actions column, and select Save As. 2. On the Save External Service As page, enter a unique External Service Name
Note: By default, External Services automatically adds the prefix CopyOf in front of the existing external service name. Modify the default name so that it’s unique and descriptive of the external service.
3. Optionally change: • Named Credential • Description • Service Schema Relative URL or Complete JSON • Operations
4. Click Next, then click Done from the External Service Actions page.
848 Extend Salesforce with Clicks, Not Code External Services
Delete To delete an external service, click the arrow in the service’s Actions column, and select Delete.
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
Recreate an External Service
Recreate your external service, and update the related flows. EDITIONS 1. From Setup in Lightning Experience, enter External Services in the Quick Find box, and select External Services. Available in: Lightning Experience 2. Under Actions, next to the name of the external service that you want to recreate, click Save As. Available in: Enterprise, Performance, Unlimited, 3. Note: External Services fills in most of the necessary information, including a modified and Developer Editions external service’s name, named credential used, description, and schema URL or JSON. Modify the external service name so that it’s different from the original registration. If you don’t USER PERMISSIONS provide a name, External Services automatically adds the prefix CopyOf in front of the existing external service name. To manage connections: 4. Verify or change the named credential used, description, schema URL, or JSON. • Customize Application 5. Click Save & Next. 6. If needed, modify the selected operations. 7. Click Next. 8. Click Done. 9. Update the flows that use the actions from the original external service. To locate actions for External Services registrations, filter the actions by type, and select External Service. To find actions that aren’t from External Services registrations, filter by type, and select Apex Action. 10. Return to External Services in Setup. 11. Under Actions, for the original external service that you recreated, click Delete.
SEE ALSO: Register an External Service
External Services and Packaging
You can install or create packages containing an external service. Read these tips before you begin. EDITIONS Consuming an External Services Package Any flow within the package or newly added flows outside the package can reference external Available in: Lightning Experience service actions. Creating an External Services Package Available in: Enterprise, Performance, Unlimited, To ensure that subscriber orgs that install a package can use the External Service actions from the and Developer Editions External Services registration: Add named credential components to the external services registration
849 Extend Salesforce with Clicks, Not Code External Services
package. Alternatively, a subscriber can create a named credential in the subscriber org using the same name as the one specified in the external services registration that references it.
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
SEE ALSO: External Services Components Available in Managed Packages
Testing External Service Actions in Flow Test the example flow MyAtmFlow with a flow external service action MyAtmExternalService by implementing the HttpCalloutMock interface that provides a test response without performing the callout to the external service endpoint. MyAtmExternalService is registered with a Named Credential MyAtmNamedCredential, has operation getBalance with String accountId as path parameter and Integer pin as header parameter. Its output is a JSON data structure with the account ID, account holder, balance and account type. The HTTP callout mock implementation reacts to an expected test request by responding with the appropriate HTTP response output:
global class MyAtmHttpCalloutMock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest request) { // Assert expected request test data System.assertEquals('GET', request.getMethod()); System.assertEquals('callout:MyAtmNamedCredential/A123-456', request.getEndpoint());
System.assertEquals('1234', request.getHeader('pin'));
// Send response test data HttpResponse response = new HttpResponse(); response.setHeader('Content-Type', 'application/json'); response.setBody('{"availableBal": 0, "name": "Account Holder", ' + '"type": "Checking", "accountId": "A123-456"}'); response.setStatusCode(200); return response; } }
The flow test class sets up the HTTP callout mock for the external service action it’s calling. It creates a flow interview with input parameter values to test, runs the flow interview and then asserts the actual flow output parameters with expected test values:
@IsTest public class MyAtmFlowTest { @IsTest static public void testMyAtmFlow() { // Set HTTP callout mock to match flow's external service action invocation Test.setMock(HttpCalloutMock.class, new MyAtmHttpCalloutMock());
// Set flow input variables and create the flow interview Map inputVariables = new Map(); Flow.Interview myAtmFlow = Flow.Interview.createInterview('MyAtmFlow', inputVariables);
850 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
// Start flow interview with set input variables myAtmFlow.start();
// Assert flow output variables System.assertEquals('expected', (String)myAtmFlow.getVariableValue('myFlowOutput')); } }
Access External Data With Salesforce Connect Salesforce Connect lets your users view, search, and modify data that’s stored outside your Salesforce org. Instead of copying the data into standard or custom objects, use external objects to access the data in real time via web service callouts.
Salesforce Connect Salesforce Connect provides seamless integration of data across system boundaries by letting your users view, search, and modify data that’s stored outside your Salesforce org. For example, perhaps you have data that’s stored on premises in an enterprise resource planning (ERP) system. Instead of copying the data into your org, you can use external objects to access the data in real time via web service callouts. External Data Sources With Salesforce Connect Salesforce Connect uses external data sources to access data that's stored outside your Salesforce org. You must configure an external data source and synchronize it to map its tables with external objects in Salesforce. Salesforce Platform Features Supported by Salesforce Connect Salesforce Connect provides seamless integration with the Salesforce Platform and enables users to view, search, and modify external object data. Access Data in Another Salesforce Org with the Cross-Org Adapter for Salesforce Connect Connect your users to data that's stored in another Salesforce org. Access External Data with the OData 2.0 or 4.0 Adapter for Salesforce Connect Connect your users to data that's exposed via the Open Data Protocol. Access External Data with a Custom Adapter for Salesforce Connect Connect your users to any data anywhere by developing your own custom adapter with the Apex Connector Framework.
851 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Connect
Salesforce Connect provides seamless integration of data across system boundaries by letting your EDITIONS users view, search, and modify data that’s stored outside your Salesforce org. For example, perhaps you have data that’s stored on premises in an enterprise resource planning (ERP) system. Instead Available in: both Salesforce of copying the data into your org, you can use external objects to access the data in real time via Classic (not available in all web service callouts. orgs) and Lightning Traditionally, we’ve recommended importing or copying data into your Salesforce org to let your Experience (not for users access that data. For example, extract, transform, and load (ETL) tools can integrate third-party high-data-volume external systems with Salesforce. However, doing so copies data into your org that you don’t need or that objects) quickly becomes stale. Available in: Developer In contrast, Salesforce Connect maps Salesforce external objects to data tables in external systems. Edition Instead of copying the data into your org, Salesforce Connect accesses the data on demand and in Available for an extra cost real time. The data is never stale, and we access only what you need. We recommend that you use in: Enterprise, Performance, Salesforce Connect when: and Unlimited Editions • You have a large amount of data that you don’t want to copy into your Salesforce org. • You need small amounts of data at any one time. • You want real-time access to the latest data. Even though the data is stored outside your org, Salesforce Connect provides seamless integration with the Lightning Platform. External objects are available to Salesforce tools, such as global search, lookup relationships, record feeds, and the Salesforce mobile app. External objects are also available to Apex, SOSL, SOQL queries, Salesforce APIs, and deployment via the Metadata API, change sets, and packages. For example, you store product order information in a back-office ERP system. You want to view those orders as a related list on each customer record in your Salesforce org. Salesforce Connect enables you to set up a lookup relationship between the customer object (parent) and the external object (child) for orders. Then you can set up the page layouts for the parent object to include a related list that displays child records. Going a step further, you can update the orders directly from the related list on the customer record. By default, external object records are read only. But you can define the external data source to enable writable external objects. For information about using Apex DML write operations on external object records, see the Apex Developer Guide.
Note: If transmitting potentially sensitive information, including sensitive or regulated data such as personal health data or financial data, Salesforce recommends that customers encrypt their external data sources at rest. Transmissions through the Salesforce Connect service are already encrypted using mTLS.
Example: This screenshot shows how Salesforce Connect can provide a seamless view of data across system boundaries. A record detail page for the Business_Partner external object includes two related lists of child objects. The external lookup relationships and page layouts enable users to view related data from inside and from outside the Salesforce org on a single page. • Account standard object (1) • Sales_Order external object (2)
852 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Connect Adapters Salesforce Connect uses a protocol-specific adapter to connect to an external system and access its data. When you define an external data source in your organization, you specify the adapter in the Type field. Salesforce Connect Adapters Included per Add-On License Using Salesforce Connect to access external data in an org requires one or more Salesforce Connect add-on licenses. General Limits for Salesforce Connect Understand the limits that are applicable to all Salesforce Connect adapters.
SEE ALSO: External Data Sources With Salesforce Connect External Object Relationships Salesforce Platform Features Supported by Salesforce Connect Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Set Up Salesforce Connect to Access External Data with a Custom Adapter
853 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Connect Adapters
Salesforce Connect uses a protocol-specific adapter to connect to an external system and access EDITIONS its data. When you define an external data source in your organization, you specify the adapter in the Type field. Available in: both Salesforce These adapters are available for Salesforce Connect. Classic (not available in all orgs) and Lightning Salesforce Description When to Use Experience (not for Connect high-data-volume external Adapter objects) Cross-org Uses the Lightning Platform REST API to To seamlessly connect data between Available in: Developer access data that’s stored in other your Salesforce orgs. For example, Edition Salesforce orgs. provide your service representatives a Available for an extra cost unified view of customer transactions by in: Enterprise, Performance, integrating data from different Salesforce and Unlimited Editions orgs.
OData 2.0 Uses Open Data Protocol to access data To integrate external data sources into OData 4.0 that’s stored outside Salesforce. The your org that support the ODATA external data must be exposed via OData protocol and publish an OData provider. producers. For example, give your account executives a unified data view by pulling data from legacy systems such as SAP, Microsoft, and Oracle in real time.
Custom You use the Apex Connector Framework To develop your own adapter with the adapter to develop your own custom adapter Apex Connector Framework when the created via when the other available adapters aren’t other available adapters aren’t suitable Apex suitable for your needs. for your needs. For example, when you A custom adapter can obtain data from want to retrieve data via callouts from a anywhere. For example, some data can REST API. be retrieved from anywhere in the Internet via callouts, while other data can be manipulated or even generated programmatically.
SEE ALSO: Salesforce Connect OData 2.0 or 4.0 Adapter for Salesforce Connect Cross-Org Adapter for Salesforce Connect Custom Adapter for Salesforce Connect Salesforce Connect Adapters Included per Add-On License
854 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Connect Adapters Included per Add-On License
Using Salesforce Connect to access external data in an org requires one or more Salesforce Connect EDITIONS add-on licenses. Each Salesforce Connect add-on license includes a set number of connections per adapter type. A Available in: both Salesforce Salesforce Connect add-on license is associated with a single Salesforce org. Classic (not available in all orgs) and Lightning Salesforce Connect Adapter Number of Connections per License Experience (not for high-data-volume external Cross-org 5 objects)
OData 2.0, OData 4.0, or a custom adapter 1 Available in: Developer Edition Available for an extra cost The number of Salesforce Connect add-on licenses you need depends on where the data is stored in: Enterprise, Performance, and which type of connections are required. These are some common data integration scenarios and Unlimited Editions and the number of licenses required. • Your primary Salesforce org accesses data stored in six other Salesforce orgs. You need two Salesforce Connect add-on licenses. Both Salesforce Connect add-on licenses are assigned to the primary org. • Your primary Salesforce org accesses data stored in one secondary Salesforce org. The secondary org accesses the primary org data. You need two Salesforce Connect add-on licenses, one for each org. • Your primary Salesforce org accesses data stored in five other Salesforce orgs and one external data source. You need one Salesforce Connect add-on license, which is assigned to the primary org.
SEE ALSO: Salesforce Connect Salesforce Connect Adapters OData 2.0 or 4.0 Adapter for Salesforce Connect Cross-Org Adapter for Salesforce Connect Custom Adapter for Salesforce Connect
General Limits for Salesforce Connect
Understand the limits that are applicable to all Salesforce Connect adapters. EDITIONS The assigned user license determines the maximum number of custom objects that each user can access. You can also grant object permissions up to that same number of external objects. External Available in: both Salesforce objects don’t count toward the amount for custom objects. Classic (not available in all orgs) and Lightning Maximum external objects per org1 200 Experience (not for high-data-volume external Note: If the default value for external objects in your org is 100, create objects) a support case to increase your org limit to 200. Available in: Developer Maximum joins per query across external objects and other types of objects 4 Edition Available for an extra cost Maximum length of the OAuth token that’s issued by the external system 4,000 characters in: Enterprise, Performance, Maximum new rows retrieved by SOSL and Salesforce searches per hour. 100,000 and Unlimited Editions
855 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
This limit doesn’t apply to high-data-volume external data sources.
Maximum new rows retrieved or created per hour. 100,000 This limit doesn’t apply to: • High-data-volume external data sources • Rows that are retrieved only as search results and aren’t opened or edited • Other rows that have already been retrieved
Maximum page size for server-driven paging 2,000 rows
1 The amount of 200 external objects applies regardless of how many Salesforce Connect add-ons you purchase for your org. External objects don’t count toward the amount for custom objects.
Callout Limits for Salesforce Connect Adapters Salesforce Connect accesses the external data in real time via Web service callouts to external data sources. • Cross-org adapter: No callout limits. However, each callout counts toward the API usage limits of the provider org. See API Request Limits and Allocations. • OData 2.0 and OData 4.0 adapter – 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require higher limits, create a support case. – 1,000 OData callouts per hour for Developer Edition.
• Custom adapter: See Callout Limits and Limitations and Execution Governors and Limits in the Apex Developer Guide.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect
External Data Sources With Salesforce Connect
Salesforce Connect uses external data sources to access data that's stored outside your Salesforce EDITIONS org. You must configure an external data source and synchronize it to map its tables with external objects in Salesforce. Available in: both Salesforce Classic (not available in all Identity Type for External Data Sources orgs) and Lightning On the external data source configured for Salesforce Connect, the Identity Type field Experience (not for high-data-volume external specifies whether your organization uses one set or multiple sets of credentials to access the objects) external system. Each set of credentials corresponds to a login account on the external system. Sync an External Data Source for Salesforce Connect Available in: Developer Edition When you validate and sync an external data source, it creates or overwrites Salesforce external objects that map to the external system’s schema. Syncing doesn’t copy any data into your Available for an extra cost Salesforce org or write data from your org to the external system. in: Enterprise, Performance, and Unlimited Editions
856 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
External Objects in Salesforce Connect External objects behave similar to custom objects except that they map to data stored outside Salesforce in an external data source. Each external object maps to a data table, and the object fields map to accessible table columns. Record IDs for Salesforce Connect External Objects The first time a data row is retrieved from an external system, the external object record is assigned a Salesforce ID. Each record ID remains associated with the same external data row, unless the external object is deleted from the org. Writable External Objects in Salesforce Connect Select Writable External Objects when you define an external data source and use Salesforce Connect external objects to create, update, and delete data. External objects are read only by default.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Work with External Data Sources
Identity Type for External Data Sources
On the external data source configured for Salesforce Connect, the Identity Type field EDITIONS specifies whether your organization uses one set or multiple sets of credentials to access the external system. Each set of credentials corresponds to a login account on the external system. Available in: both Salesforce If you select Named Principal, your organization uses only one login account on the external Classic (not available in all system. orgs) and Lightning Experience (not for If you select Per User, your organization uses multiple login accounts on the external system. Each high-data-volume external of your users can have a unique set of credentials, or you can group your users—for example, by objects) function or business unit—and have each group share a set of credentials. After you grant user access to the external data source through permission sets or profiles, users can set up and manage Available in: Developer their own authentication settings for the external system. Edition Available for an extra cost Note: For an external data source with Per User Identity Type, site members in Experience in: Enterprise, Performance, Cloud can’t set up their own credentials. However, as an admin you can set up and manage and Unlimited Editions each user’s authentication settings for external systems from Lightning Experience or Salesforce Classic.
Identity Type is Named Principal Identity Type is Per User To access the external system’s... The system uses the credentials that are defined in the... Data External data source definition User’s personal authentication settings for (search or view external objects) the external system
Metadata External data source definition External data source definition (sync to create external objects)
857 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for each external system. If you’re using OAuth 2.0, test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes.
SEE ALSO: Define an External Data Source for Salesforce Connect—Cross-Org Adapter Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Define an External Data Source for Salesforce Connect—Custom Adapter Grant Access to Authentication Settings for External Data Sources Store Authentication Settings for External Systems
Sync an External Data Source for Salesforce Connect
When you validate and sync an external data source, it creates or overwrites Salesforce external EDITIONS objects that map to the external system’s schema. Syncing doesn’t copy any data into your Salesforce org or write data from your org to the external system. Available in: both Salesforce Syncing fails if it causes your org to exceed 200 external objects. Syncing also fails if it tries to create Classic (not available in all an external object with an API name that conflicts with an existing object in the org. In such cases, orgs) and Lightning determine whether the existing object is needed. Experience (not for high-data-volume external • If the object isn’t needed, delete that object, and sync again. objects) • If the object is needed, change the API name of the existing object to no longer conflict with the table that you're trying to sync. However, if the existing object is an external object that Available in: Developer Edition was previously synced, you can’t resync it. Manually update the external object and its fields as needed for schema changes on the external system. Available for an extra cost in: Enterprise, Performance, Tip: We recommend that you create your external data sources and external objects in a and Unlimited Editions Developer Edition org. Then use managed packages to deploy the external data sources and external objects to your other orgs. Doing so prevents your external object names from conflicting with other objects in your org by applying a namespace prefix. When an external object is created via syncing, its Deployment Status is set to In Development. When you’re ready to expose the external object to users, set the status to Deployed. If the external system’s schema changes, the modifications aren’t automatically synced to your Salesforce org. To reflect the changes in the external system, resync the objects. After resyncing, all users who have the same profile as the user who initiated the resync are granted field-level access to the external objects. When you resync an external object: • The Display URL Reference Field is set to None. • If a custom field has the Is Name Field attribute, the attribute is removed. The External ID standard field is used as the name field of the external object. • The Deployment Status doesn’t change.
858 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
To understand how syncing affects relationship fields on external objects, see Relationships on External Objects on page 173.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Deployment Status for Custom Objects and External Objects Validate and Sync an External Data Source
External Objects in Salesforce Connect
External objects behave similar to custom objects except that they map to data stored outside EDITIONS Salesforce in an external data source. Each external object maps to a data table, and the object fields map to accessible table columns. Available in: both Salesforce As with custom objects, you must create custom tabs to display external object data in Salesforce. Classic (not available in all When you add a custom tab to an app in Salesforce Classic, it appears as a tab. When you add a orgs) and Lightning custom tab to an app in Lightning Experience, it appears as an item in the app’s navigation bar and Experience (not for in the App Launcher. See Create a Custom Object Tab. high-data-volume external objects) To know the field types that you can create for external objects, see Custom Field Types. Some special behavior for text and number fields on external objects. Available in: Developer Edition • Text fields: Ensure that the field length matches the length of the associated field on the external object to avoid any display or edit issues. Available for an extra cost in: Enterprise, Performance, • Number fields: Ensure that the specified length can contain all digits to the left of the decimal and Unlimited Editions point in external values. If the numeric value from an external system doesn’t fit within the length of the associated number field on the external object, the value is blank in your Salesforce org. If you notice blank numeric field values, adjust Length and Decimal Places for the number field on the external object to accommodate more digits to the left of the decimal point. If the digits to the right of the decimal point in the external values don’t fit within the specified decimal places, the value is truncated. When a custom field on an external object record is displayed, leading and trailing spaces are removed from the field value. Keep this behavior in mind when you filter by a field that contains leading or trailing spaces. For example, include the leading and trailing spaces in the following SOQL query to match the values that are stored in the external system. However, the spaces aren’t displayed in the query results.
SELECT FirstName__c FROM Buyers__x WHERE FirstName__c = ' Test '
Note: Formulas and Roll-up Summary fields can’t reference fields on external objects.
Features Not Supported • Set up Data with External Objects – Merge Fields – Schema Builder – Validation Rules – Custom fields • Field types not supported – Auto-Number (available only with the cross-org adapter for Salesforce Connect)
859 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
– Currency (available only with the cross-org adapter for Salesforce Connect) – Formula – Geolocation – Master-Detail Relationship – Picklist and Picklist (Multi-select) (available only with the cross-org adapter for Salesforce Connect) – Roll-up Summary – Text (Encrypted) – Text Area (Rich)
• Lookup filter on relationship fields • Default field values
• Record-level security to manage data access for external objects • Record types to customize external data • Productivity Tools – Activities, Events, and Tasks – Attachments – Notes
SEE ALSO: External Object Relationships Considerations for Relationships External Data Sources With Salesforce Connect Manage Custom Objects
Record IDs for Salesforce Connect External Objects
The first time a data row is retrieved from an external system, the external object record is assigned EDITIONS a Salesforce ID. Each record ID remains associated with the same external data row, unless the external object is deleted from the org. Available in: both Salesforce Note: Classic (not available in all orgs) and Lightning • Salesforce IDs aren’t assigned to external object records that are associated with Experience high-data-volume external data sources. Available in: Developer • In a near future release, temporary Salesforce record IDs will be assigned to external object Edition records that are retrieved by SOSL and Salesforce searches, rather than permanent IDs. To prepare for this change, don’t create code or use third-party integrations that require Available for an extra cost these record IDs to remain associated with the same external data rows. For existing code in: Enterprise, Performance, and Unlimited Editions
860 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
and integrations, we recommend removing dependencies on external object record IDs to avoid issues when this change is rolled out.
SEE ALSO: Record IDs and External IDs for External Objects in Salesforce Connect—Cross-Org Adapter Salesforce Connect External Data Sources With Salesforce Connect
Writable External Objects in Salesforce Connect
Select Writable External Objects when you define an external data source and use Salesforce EDITIONS Connect external objects to create, update, and delete data. External objects are read only by default. External systems execute write operations initiated from Salesforce and also handle write conflicts, Available in: both Salesforce if any. Classic (not available in all orgs) and Lightning • It can take some time for changes to external object records to take effect. If you don’t see Experience (not for recent changes when you view or query an external object record, try again later. high-data-volume external • It can’t be guaranteed that all write operations that are initiated from Salesforce are applied in objects) case of write conflicts. Available in: Developer If Salesforce attempts to save changes to an external object and a standard or custom object in the Edition same transaction, an error occurs. As a best practice, we recommend you use a separate transaction Available for an extra cost to access or modify data in an external system. in: Enterprise, Performance, Write operations on external object records initiated from different contexts can occur in varying and Unlimited Editions order. When you create, update, or delete external object records via the user interface, processes or flows, operations occur synchronously. When Apex is used to perform external records operations, operations occur asynchronously and an active background queue minimizes potential save conflicts. To monitor an asynchronous job progress, use BackgroundOperation.
Note: When a custom field on an external object record is edited, leading and trailing spaces are removed from the field value.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect External Data Sources With Salesforce Connect Apex Developer Guide: Writable External Objects
861 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Platform Features Supported by Salesforce Connect
Salesforce Connect provides seamless integration with the Salesforce Platform and enables users EDITIONS to view, search, and modify external object data. Available in: both Salesforce Reports Classic (not available in all Depending on network latency and the availability of the external system, reports that include orgs) and Lightning an external object can take a long time to run. Experience (not for high-data-volume external Record Feed objects) View the Chatter feed associated with external object records you follow to see updates about the record. Following records helps keep you up to date on important changes to the external Available in: Developer Edition objects. Available for an extra cost Quick Actions in: Enterprise, Performance, External objects support quick actions, except when the actions involve features or functionality and Unlimited Editions that are incompatible with external objects. Flows and Processes You can build flows and processes that include external objects and automate your organization’s repetitive business tasks. Salesforce App You can view and search external objects from the Salesforce mobile app, Salesforce on the go! Salesforce Console You can access external objects from the Salesforce console only in Salesforce Classic. Other consoles, such as the Salesforce console in Lightning Experience, aren’t supported. More Features Supported by Salesforce Connect External objects are available to Salesforce APIs, SOQL queries, SOSL and Salesforce searches, SOQL queries, packages, Metadata API, change sets, and Lightning Experience app.
SEE ALSO: Salesforce Connect External Data Sources With Salesforce Connect Cross-Org Adapter for Salesforce Connect OData 2.0 or 4.0 Adapter for Salesforce Connect Custom Adapter for Salesforce Connect
862 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Reports
Depending on network latency and the availability of the external system, reports that include an EDITIONS external object can take a long time to run. When you run a report that includes external objects, your org performs a request callout for each Available in: both Salesforce external object in the report. And if it’s a joined report, your org performs separate request callouts Classic (not available in all for each block. If the URL of a report callout approaches or exceeds 2 KB, the request is split into orgs) and Lightning multiple HTTP calls, with each URL being less than 2 KB Experience (not for high-data-volume external A report that includes an external object fetches up to 20,000 records for the primary object. If the objects) report is customized to include child objects, the total number of rows can be greater or less than 10,000, depending on how many child records are fetched. To obtain more relevant external object Available in: Developer rows, try customizing the report. Edition For custom reports that include external objects as the primary object Available for an extra cost in: Enterprise, Performance, • If the deployment status of the external object changes, custom report type’s Deployment and Unlimited Editions Status changes similarly from Deployed to In Development. See Deployment Status for Custom Objects and External Objects. • If the external object is deleted, custom report type and reports created from it are deleted. For large external data sets, report callouts typically access only a subset of the external data. If the report includes summary fields and formulas, those aggregate values likely reflect only a subset of your data. To improve the accuracy of the aggregate values and obtain more relevant data, try customizing the report. As is true for all callouts for external objects, report callouts are limited by the Salesforce Connect adapters in use. • Cross-org adapter: No callout limits. However, each callout counts toward the API usage limits of the provider org. See API Request Limits and Allocations. • OData 2.0 and OData 4.0 adapter – 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require higher limits, create a support case. – 1,000 OData callouts per hour for Developer Edition.
• Custom adapter: See Callout Limits and Limitations and Execution Governors and Limits in the Apex Developer Guide.
Features Not Supported • Converted currency fields • Cross filters • Buckets and bucket fields • Historical trend reporting
SEE ALSO: Reports and Dashboards Limits, Limitations, and Allocations Troubleshoot Reports External Object Relationships Salesforce Platform Features Supported by Salesforce Connect
863 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Record Feed
View the Chatter feed associated with external object records you follow to see updates about the EDITIONS record. Following records helps keep you up to date on important changes to the external objects. Available in: both Salesforce Features Not Supported Classic (not available in all orgs) and Lightning • Field history tracking. Experience (not for • External objects that map to high-data-volume external data sources. high-data-volume external objects)
SEE ALSO: Available in: Developer Records and List Views Edition Salesforce Connect Available for an extra cost Salesforce Platform Features Supported by Salesforce Connect in: Enterprise, Performance, and Unlimited Editions
Quick Actions
External objects support quick actions, except when the actions involve features or functionality EDITIONS that are incompatible with external objects. With custom quick actions, you can make your users’ navigation and workflow as smooth as possible Available in: both Salesforce by giving them convenient access to information that’s most important. For example, you can let Classic (not available in all users quickly create or update records, send emails, and more in the context of the external object. orgs) and Lightning Experience (not for high-data-volume external Features Not Supported objects) • Log a Call action: Creating tasks isn’t available for external objects. Available in: Developer • Predefined Field Values for Quick Action Fields: Formulas can’t reference external object fields. Edition Available for an extra cost SEE ALSO: in: Enterprise, Performance, Action Types and Unlimited Editions Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect
864 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Flows and Processes
You can build flows and processes that include external objects and automate your organization’s EDITIONS repetitive business tasks. If a flow or a process accesses standard or custom objects along with external objects, you must Available in: both Salesforce commit the changes to the standard or custom object before accessing the external objects. We Classic (not available in all recommend using a separate transaction to access data from the external system. orgs) and Lightning Experience (not for • In Flow Builder, add a screen, local action, or Pause element that pauses until a flow-based time high-data-volume external occurs. See Flow Elements. objects) • In Process Builder, add a scheduled action. See Add Actions to Your Process. Available in: Developer To understand how processes interact with external objects, see Compatibility Considerations for Edition Processes. Available for an extra cost To know the limits while building flows with external objects, see External Object Considerations in: Enterprise, Performance, for Flows. and Unlimited Editions
Features Not Supported These are the automation tool features that aren’t available for external objects in Salesforce Connect. • Approval Processes • Workflow Rules
SEE ALSO: Flow Builder Process Builder Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect
Salesforce App
You can view and search external objects from the Salesforce mobile app, Salesforce on the go! EDITIONS As with custom objects, external objects must be assigned to tabs that users can access, and object permissions must be granted via profiles or permission sets. When you search for an external object, Available in: both Salesforce click More in the Recent section to view the search results. Classic (not available in all orgs) and Lightning When external objects are used with Salesforce for iOS and Salesforce mobile web on iOS devices, Experience (not for you must select Enable Search in the associated external data sources. Only then external objects high-data-volume external appear in these apps. This requirement doesn’t apply to custom adapters for Salesforce Connect. objects)
Available in: Developer SEE ALSO: Edition Salesforce Mobile App Available for an extra cost Salesforce Connect in: Enterprise, Performance, Salesforce Platform Features Supported by Salesforce Connect and Unlimited Editions
865 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Console
You can access external objects from the Salesforce console only in Salesforce Classic. Other consoles, EDITIONS such as the Salesforce console in Lightning Experience, aren’t supported. External objects haven’t been fully adapted to a console and can cause unexpected behaviors. Available in: both Salesforce Unlike other objects that haven’t been fully adapted to a console, external objects aren’t marked Classic (not available in all with asterisks in the console setup area. orgs) and Lightning Experience (not for high-data-volume external SEE ALSO: objects) Salesforce Console in Salesforce Classic Available in: Developer Salesforce Classic Console Limitations Edition Salesforce Connect Available for an extra cost Salesforce Platform Features Supported by Salesforce Connect in: Enterprise, Performance, and Unlimited Editions
More Features Supported by Salesforce Connect
External objects are available to Salesforce APIs, SOQL queries, SOSL and Salesforce searches, SOQL EDITIONS queries, packages, Metadata API, change sets, and Lightning Experience app. • API Query Available in: both Salesforce Classic (not available in all – To know how Salesforce Connect accesses the external data in real time via Web service orgs) and Lightning callouts, see query(), queryAll(), and queryMore(). Experience (not for – To understand the limitations that apply to queryAll() and queryMore() calls high-data-volume external on external data, see External Objects in the SOAP API Developer Guide. objects) – To implement server-driven or client-driven paging for external object data that’s obtained Available in: Developer by a custom adapter, see Paging with the Apex Connector Framework. Edition • SOQL Available for an extra cost – To know about the specific limits SOQL applies to external objects, see External objects in in: Enterprise, Performance, SOQL Limits on Objects. and Unlimited Editions – To understand the limitations for external objects when you design SOQL relationship queries, see Understanding Relationship Query Limitations.
• SOSL and Salesforce searches – To know about the specific limits SOSL applies to external objects in search results, see SOSL Limits on External Object Search Results. – To learn about how to add RETURNING clause to a SOSL query with external objects, see RETURNING FieldSpec. – To understand how search works with external objects, look for external objects in Searchable Fields by Object in Lightning Experience and Searchable Fields by Object in Salesforce Classic. – (Salesforce Classic only) Search results for external object display only the top 25 rows.
• Packaging – To understand how packaging affects external data sources and external objects, see Special Behavior of Components in Packages. – To know what components are automatically included in the package when you add external data sources and external objects, see Components Automatically Added to Packages.
866 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
– To learn about the behavior of external data sources and external objects with permission sets or profile settings, see About Permission Sets and Profile Settings.
• Deployment via the Metadata API: In Metadata API, external objects are represented as CustomObject. • Change Sets: External objects are included in the Custom Object component. See Components Available in Change Sets. • Lightning Experience app: When you access external objects from the Lightning Experience app, the associated external data sources must have the High Data Volume option deselected. This requirement doesn’t apply to the cross-org adapter for Salesforce Connect.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Writable External Objects in Salesforce Connect
Access Data in Another Salesforce Org with the Cross-Org Adapter for Salesforce Connect Connect your users to data that's stored in another Salesforce org.
Cross-Org Adapter for Salesforce Connect Collaborate more effectively and improve processes by connecting the data across your Salesforce orgs. With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access records in other Salesforce orgs. Nevertheless, setup is quick and easy with point-and-click tools. Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Provide users with seamless access to data in your other Salesforce orgs so that they have a complete view of the business. Setting up the cross-org adapter for Salesforce Connect is quick and easy with point-and-click tools. Considerations for Salesforce Connect—Cross-Org Adapter Understand the special behaviors, limits, and recommendations for using the cross-org adapter for Salesforce Connect.
Cross-Org Adapter for Salesforce Connect
Collaborate more effectively and improve processes by connecting the data across your Salesforce EDITIONS orgs. With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access records in other Salesforce orgs. Nevertheless, setup is quick and easy with point-and-click tools. Available in: both Salesforce Your users and the Lightning Platform interact with other orgs’ data via external objects. The Classic (not available in all cross-org adapter for Salesforce Connect converts each of those interactions into a Lightning orgs) and Lightning Platform REST API call. Experience (not for high-data-volume external Suppose that you store your inventory of products in one Salesforce org. You want your regional objects) and local branch offices, who have their own orgs, to see the latest information about your stock. With the cross-org adapter for Salesforce Connect, those other organizations can easily access your Available in: Developer data while respecting access restrictions that you control. Edition The cross-org adapter makes a Lightning Platform REST API call each time that: Available for an extra cost in: Enterprise, Performance, • A user clicks an external object tab for a list view. and Unlimited Editions • A user views a record detail page of an external object.
867 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• A user views a record detail page of a parent object that displays a related list of child external object records. • A user performs a Salesforce global search. • A user creates, edits, or deletes an external object record. • A user runs a report. • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. To set up Salesforce Connect with the cross-org adapter, you use only point-and-click tools.
Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter The provider org stores the data that the subscriber org accesses. API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter If external objects and custom fields are created in the subscriber org via syncing, their API names are derived from the corresponding API names in the provider org. Record IDs and External IDs for External Objects in Salesforce Connect—Cross-Org Adapter External object record IDs are derived from the corresponding record IDs in the provider organization. External ID values in external object records match the record IDs in the provider organization. User Access to External Data in Salesforce Connect—Cross-Org Adapter A user’s access to external data is determined by settings on both subscriber and provider orgs.
SEE ALSO: Salesforce Connect Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Considerations for Salesforce Connect—Cross-Org Adapter
Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter
The provider org stores the data that the subscriber org accesses. EDITIONS You define the external data source and external objects in the subscriber org. Manually create the external objects and their fields, or automatically create them by syncing the provider org’s metadata. Available in: both Salesforce When users view or search those external objects in the subscriber org, the data is obtained from Classic (not available in all the provider org and displayed in the subscriber org. When users create or edit external object orgs) and Lightning records in the subscriber org, the data is saved in the provider org. Experience (not for high-data-volume external • An org can serve as both a subscriber and a provider. objects) • A subscriber org can access data from multiple provider orgs. Available in: Developer • A provider org can let multiple subscriber orgs access its data. Edition Available for an extra cost SEE ALSO: in: Enterprise, Performance, Cross-Org Adapter for Salesforce Connect and Unlimited Editions
868 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter
If external objects and custom fields are created in the subscriber org via syncing, their API names EDITIONS are derived from the corresponding API names in the provider org. Each external object’s API name ends with __x. Custom fields on external objects use the traditional Available in: both Salesforce __c suffix in the API name. Specifically for objects and custom fields that are synced with the Classic (not available in all cross-org adapter for Salesforce Connect: orgs) and Lightning Experience • For an API name with no suffix in the provider org, the API name is reused in the subscriber org, but with an applied __x suffix for an object or __c suffix for a field. Available in: Developer • For an API name with a suffix in the provider org, the API name is reused in the subscriber org. Edition But one of the underscores (_) from the original suffix is removed, and a new __x or __c Available for an extra cost suffix is applied. in: Enterprise, Performance, and Unlimited Editions Example: If you sync the provider org’s Account object, the subscriber org creates: • An external object with the API name Account__x • Custom fields including one with the API name Account__x.Name__c If you sync the provider org’s CustObj__c object, the subscriber org creates: • An external object with the API name CustObj_c__x • Custom fields including one with the API name CustObj_c__x.Name__c If the provider org’s object has a custom field, the subscriber org creates the custom field on the equivalent external object, for example: • Account__x.MyCustField_c__c • CustObj_c__x.MyOtherCustField_c__c If you sync the provider org’s Account__x external object, the subscriber org creates: • An external object with the API name Account_x__x • Custom fields including one with API name Account_x__x.Name_c__c
SEE ALSO: Cross-Org Adapter for Salesforce Connect
Record IDs and External IDs for External Objects in Salesforce Connect—Cross-Org Adapter
External object record IDs are derived from the corresponding record IDs in the provider organization. EDITIONS External ID values in external object records match the record IDs in the provider organization. Each object in Salesforce has an object ID with a key prefix as the first three characters. When an Available in: both Salesforce external object is created, it’s assigned a unique key prefix. Classic and Lightning Experience Each external object record has a record ID that uses the same key prefix as the external object ID. The rest of the external object record ID matches the original record ID that’s in the provider Available in: Developer organization, excluding its original key prefix. Edition Each record ID that comes from the provider organization becomes a case-insensitive 18-character Available for an extra cost alphanumeric string in the subscriber organization. in: Enterprise, Performance, and Unlimited Editions The original record ID is available in the subscriber organization as the value of the External ID standard field on the external object record.
869 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Each external object has an External ID standard field. Its values uniquely identify each external object record in your org. When the external object is the parent in an external lookup relationship, the External ID standard field is used to identify the child records.
Example: You sync the provider organization’s Account object, and the subscriber organization’s Account__x object is assigned the key prefix x00. An account in the provider organization with the ID 001B0000003SVC7IAO appears in the subscriber organization with the ID x00B0000003SVC7IAO and the external ID 001B0000003SVC7IAO.
SEE ALSO: Cross-Org Adapter for Salesforce Connect
User Access to External Data in Salesforce Connect—Cross-Org Adapter
A user’s access to external data is determined by settings on both subscriber and provider orgs. EDITIONS The credentials that are used by the subscriber org to connect to the provider org are associated with a user in the provider org. We refer to this user as the connected user. Available in: both Salesforce Classic (not available in all A user in the subscriber org can access only data that the connected user can access within the orgs) and Lightning provider org. In other words, the subscriber org’s user access respects the connected user’s access Experience (not for restrictions, which are determined by these settings in the provider org. high-data-volume external • Object-level security—permission sets and profiles objects)
• Field-level security—permission sets and profiles Available in: Developer • Record-level security—organization-wide sharing settings, role hierarchies, and sharing rules Edition In the subscriber org, grant users access to external objects via permission sets and profiles. Available for an extra cost in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Cross-Org Adapter for Salesforce Connect Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter
Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter
USER PERMISSIONS EDITIONS
To create and edit external data sources: Customize Application Available in: both Salesforce Classic and Lightning To create and edit external objects: Customize Application Experience To define or change object-level help: Customize Application Available in: Developer To create and edit custom fields: Customize Application Edition Available for an extra cost To edit permission sets and user profiles: Manage Profiles and Permission Sets in: Enterprise, Performance, To edit another user’s authentication settings Manage Users and Unlimited Editions for external systems:
Provide users with seamless access to data in your other Salesforce orgs so that they have a complete view of the business. Setting up the cross-org adapter for Salesforce Connect is quick and easy with point-and-click tools. Setting up Salesforce Connect with the cross-org adapter involves these high-level steps.
870 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
1. Define an external data source of type Salesforce Connect: Cross-Org. Create an external data source for each provider org.
2. Create the external objects. Perform this task only if you don’t sync to automatically create the external objects. In the subscriber org, create an external object for each object in the provider org that you want to access.
3. Create help content for the external objects. Help your users distinguish between external objects and the other objects in the subscriber org, which can have similar names and types of data. On the subscriber org, create Visualforce pages to describe the external objects. When your users click Help for this Page on an external object, they read your custom help content.
4. Add custom fields and relationships to the external objects. Create relationships between objects. If you didn’t sync to automatically create the external objects and their fields on the subscriber org, create a custom field for each of the provider org’s fields that you want to access.
5. Enable user access to external objects. Grant object permissions through permission sets or profiles.
6. Enable user access to the fields on the external objects. Grant field permissions through permission sets or profiles.
7. If the external data source uses per-user authentication: a. Let users authenticate to the external system. Grant users access to authentication settings for the external data source through permission sets or profiles.
b. Set up each user’s authentication settings. You or your users can perform this task.
Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for the provider org. If you’re using OAuth 2.0, the OAuth flow displays the Salesforce login page twice: first to log in to the provider org to obtain an access token, and then to log back in to the subscriber org. Test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes.
SEE ALSO: Cross-Org Adapter for Salesforce Connect Considerations for Salesforce Connect—Cross-Org Adapter Developer Guide: Visualforce Developer Guide External Object Relationships Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter
871 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Define an External Data Source for Salesforce Connect—Cross-Org Adapter
Give your users seamless access to data across your Salesforce orgs. EDITIONS 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. Available in: both Salesforce Classic and Lightning 2. Click New External Data Source, or click Edit to modify an existing external data source. Experience 3. Complete the fields. Available in: Developer Edition Field Description Available for an extra cost Label A user-friendly name for the external data source. The label is displayed in: Enterprise, Performance, in the Salesforce user interface, such as in list views. and Unlimited Editions If you set Identity Type to Per User, this label appears when your users view or edit their authentication settings for external systems. USER PERMISSIONS To create and edit external Name A unique identifier that’s used to refer to this external data source data sources: definition through the API. • Customize Application The name can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
Type Select Salesforce Connect: Cross-Org.
Connect to Determines which URL is used to connect to the provider org.
URL If you selected Connect to Custom URL, enter the login URL for the provider org.
API Version Select an API version that the provider org supports. The API version determines which of the provider org’s objects, fields, and types you can access from the subscriber org.
Connection Number of seconds to wait for a response from the provider org before Timeout timing out. By default, the value is set to the maximum of 120 seconds.
Writable Lets the Lightning platform and users in this org create, update, and External delete records for external objects associated with the external data Objects source. The external object data is stored outside the org. By default, external objects are read only.
Enable Search Determines whether global searches in the subscriber org also search the external objects’ data, which is stored in the provider org. When selected, you can control which external objects are searchable by selecting or deselecting Allow Search on each external object. Only text, text area, and long text area fields on external objects can be searched. If an external object has no searchable fields, searches on that object return no records.
872 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description Identity Type Determines whether the subscriber org uses one set or multiple sets of credentials to access the provider org. See Identity Type for External Data Sources on page 857.
4. Select the authentication protocol. • If you select Password Authentication, enter the username and password for accessing the external system. • If you select OAuth 2.0, complete the following fields.
Field Description Authentication Select a Salesforce authentication provider. See “Configure a Salesforce Authentication Provider” Provider in the Salesforce Help.
Note: On a production org, an external data source can’t use an authentication provider that directs authorization or token requests to a sandbox org. Similarly, on a sandbox org, an external data source can’t use an authentication provider that directs authorization or token requests to a production org.
Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter.
Note: – The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider. – Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen. – We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system.
Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status.
5. Click Save. 6. Click Validate and Sync, and confirm that the connection is successful. If you instead receive an error message, refer to the following documents. • “Status Codes and Error Responses” in the REST API Developer Guide • The “API Fault Element,” “ExceptionCode,” “Error,” and “StatusCode” sections of “Core Data Types Used in API Calls” in the SOAP API Developer Guide
873 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
7. Optionally, select tables and click Sync to do the following for each selected table. • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type.
Note: Before you sync, make sure that you understand the considerations that are described in these topics. • Sync an External Data Source for Salesforce Connect on page 858 • Sync Considerations for Salesforce Connect—Cross-Org Adapter on page 875
You can instead choose to manually create the external objects and custom fields that map to the external data. Doing so lets you customize the external object names, decide which table columns to create custom fields for, and customize the custom field names. However, this approach takes longer and requires manual maintenance.
SEE ALSO: Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Store Authentication Settings for External Systems API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Developer Guide: REST API Developer Guide
Considerations for Salesforce Connect—Cross-Org Adapter
Understand the special behaviors, limits, and recommendations for using the cross-org adapter for EDITIONS Salesforce Connect. Also review the considerations that apply to all Salesforce Connect adapters. Available in: both Salesforce Classic (not available in all orgs) and Lightning Salesforce Compatibility Considerations for Salesforce Connect—Cross-Org Adapter Experience (not for Some Salesforce features and functionality have special behaviors or aren’t available for external high-data-volume external objects that are associated with an external data source of type Salesforce Connect: objects) Cross-Org. Available in: Developer Sync Considerations for Salesforce Connect—Cross-Org Adapter Edition When you validate and sync an external data source of type Salesforce Connect: Available for an extra cost Cross-Org, some special behaviors and limitations apply. in: Enterprise, Performance, Writable External Objects Considerations for Salesforce Connect—Cross-Org Adapter and Unlimited Editions Some behaviors and limitations affect writable external objects that are associated with the cross-org adapter for Salesforce Connect. API Usage Considerations for Salesforce Connect—Cross-Org Adapter With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access records in other Salesforce orgs. Depending on how the external object is accessed, each call counts toward the API usage limits of only the provider org or of both provider and subscriber orgs. Picklist Considerations for Salesforce Connect—Cross-Org Adapter Special behaviors and limitations apply to picklist and multi-select picklist fields on external objects.
874 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Currency Considerations for Salesforce Connect—Cross-Org Adapter Special behaviors and limitations apply to currency fields on external objects.
SEE ALSO: Salesforce Platform Features Supported by Salesforce Connect
Salesforce Compatibility Considerations for Salesforce Connect—Cross-Org Adapter
Some Salesforce features and functionality have special behaviors or aren’t available for external EDITIONS objects that are associated with an external data source of type Salesforce Connect: Cross-Org. Available in: both Salesforce • The cross-org adapter for Salesforce Connect can access only queryable objects in the provider Classic and Lightning org. If you define an external object whose table name specifies an object that can’t be queried, Experience your users and the Lightning Platform can’t access that external object. Available in: Developer • You can’t use Salesforce Connect external objects to access big objects in another org. Edition • When you deploy an external data source that uses OAuth 2.0 from a sandbox org to a Available for an extra cost production org, you must update the authentication provider. On a production org, an external in: Enterprise, Performance, data source can’t use an authentication provider that directs authorization or token requests and Unlimited Editions to a sandbox org. Similarly, on a sandbox org, an external data source can’t use an authentication provider that directs authorization or token requests to a production org. Also review the considerations that apply to all Salesforce Connect adapters.
Sync Considerations for Salesforce Connect—Cross-Org Adapter
When you validate and sync an external data source of type Salesforce Connect: EDITIONS Cross-Org, some special behaviors and limitations apply. • Which objects and fields can be synced is determined by the object permissions and field Available in: both Salesforce permissions of the provider org’s user whose credentials are defined in the external data source Classic (not available in all definition. See User Access to External Data in Salesforce Connect—Cross-Org Adapter on page orgs) and Lightning 870. Experience (not for high-data-volume external • Only queryable objects can be synced. objects) • You can’t sync an object whose API name contains 38 or more characters. An external object’s name can’t exceed 40 characters, including the automatically appended __x suffix. See API Available in: Developer Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter on Edition page 869. Available for an extra cost • These field types aren’t synced. in: Enterprise, Performance, and Unlimited Editions – Encrypted text – Rich text area
• Global picklist value sets aren’t synced. If a provider org’s picklist field uses a global picklist value set, syncing creates a local picklist field on the subscriber org. A local picklist field has its own set of values. • Inactive picklist values aren’t synced. If the subscriber org accesses an external object record that contains an inactive picklist value, the inactive value is added to the picklist field on the external object.
• Syncing converts restricted picklists on the provider org into unrestricted picklists on the subscriber org’s external objects.
875 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
We recommend having only unrestricted picklists on external objects, even when they’re associated with restricted picklists on the provider org. Restricted picklists on the provider org block unapproved values from the subscriber org, eliminating the need to restrict picklists on external objects.
• To enable users to change the currency when editing an external object record, add the Currency field to the page layouts. All other synced fields are automatically added to the default page layout. • Syncing always enables search on the external object when search is enabled on the external data source, and vice versa. • Hierarchical, lookup, and master-detail relationship fields are synced. However, they become text fields in the subscriber org, and their values appear as IDs, not as record names. For example, suppose that we sync the Account object. When we view the Acme Wireless account in the provider org, the value of the Account Owner (Account.OwnerId) field appears as John Smith. When we view the equivalent account in the subscriber org, the value for the (Account__x.OwnerId__c) field appears as 005B00000019eapIAA.
• You can use external lookup relationships in the subscriber org to mirror lookup relationships in the provider org. For each lookup relationship that you want to bring into the subscriber org, sync the parent and child objects. Each lookup relationship field becomes a text field on the subscriber org. Change the field type of the sync-created text field to External Lookup Relationship. When specifying the parent of the external lookup relationship, select the external object that corresponds to the parent object in the provider org. • The names and labels of synced fields on the subscriber org are derived from the API names—not the labels—of the fields on the provider org. For example, the Account object in the provider org has the Account Owner (OwnerId) standard field. If we sync the Account object, the Account__x.OwnerId__c field in the subscriber org has the label “Owner ID” and the name “OwnerId.”
Important: When you select the provider org objects to sync, determine whether check marks appear in the Synced column. If a Synced check mark appears, the subscriber org has an external object whose object name (for example, Account__x) associates it with the object in the provider org (for example, Account). If you select the object and click Sync: • The external object is overwritten. • Any custom field on the external object is overwritten if its API name (for example, Email_c__c) associates it with a field on the provider org (for example, Email__c). • Any other custom fields on the external object remain as they are, including: – Previously synced custom fields whose API names were changed by editing their Field Name values. – Manually added custom fields whose API names aren’t associated with fields on the provider org’s object.
If no Synced check mark appears, and you sync the object, a new external object is created in the subscriber org. For example, the object name is changed on the provider org to no longer be associated with the object name of the external object on the subscriber org. Syncing that object creates a new external object on the subscriber org. We recommend that you change the object name of the existing external object to match the updated object name on the provider org before you sync.
Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Sync an External Data Source for Salesforce Connect Cross-Org Adapter for Salesforce Connect
876 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Writable External Objects Considerations for Salesforce Connect—Cross-Org Adapter
Some behaviors and limitations affect writable external objects that are associated with the cross-org EDITIONS adapter for Salesforce Connect. • Some fields remain read only on writable external objects, such as fields that are creatable but Available in: both Salesforce not editable and fields that have derived or calculated values. For example: Classic (not available in all orgs) and Lightning – Address fields such as Billing Address and Shipping Address, which are Experience (not for derived from writable fields, such as Street Address, State, and Zip) high-data-volume external – Auto-number fields objects) – Created by fields Available in: Developer – Formula fields Edition – Last Modified fields Available for an extra cost – Roll-up summaries in: Enterprise, Performance, and Unlimited Editions • Picklist values on external objects can get out of sync with picklist values on the provider org. If picklist values are changed on the provider org, resync or manually delete and recreate the associated picklist fields on the subscriber org. • Enable multiple currencies in the subscriber org, and make sure that the subscriber org has all the currencies that the provider orgs use. If a currency is later added to the provider org, add the currency to the subscriber org. If you can’t enable multiple currencies in the subscriber org, make sure that all provider orgs are single-currency and use the same currency as the subscriber org.
• To enable users to change the currency when editing an external object record, add the Currency field to the page layouts. • If a user tries to change the currency in an external object record, the list of currency options isn’t limited to active currencies in the provider org. If the user selects a currency that’s inactive or unavailable in the provider org, the user gets an error and can’t save the record. • You can use external lookup relationships in the subscriber org to mirror lookup relationships in the provider org. For each lookup relationship that you want to bring into the subscriber org, sync the parent and child objects. Each lookup relationship field becomes a text field on the subscriber org. Change the field type of the sync-created text field to External Lookup Relationship. When specifying the parent of the external lookup relationship, select the external object that corresponds to the parent object in the provider org. Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: Writable External Objects in Salesforce Connect Sync an External Data Source for Salesforce Connect Cross-Org Adapter for Salesforce Connect
877 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
API Usage Considerations for Salesforce Connect—Cross-Org Adapter
With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access EDITIONS records in other Salesforce orgs. Depending on how the external object is accessed, each call counts toward the API usage limits of only the provider org or of both provider and subscriber orgs. Available in: both Salesforce When a user accesses an external object in one of the following ways, the Lightning Platform REST Classic (not available in all API call counts toward the API usage limits of the provider org. orgs) and Lightning Experience (not for • Opening a list view of external object records high-data-volume external • Viewing an external object record detail page objects) • Viewing a parent object record that contains an external object related list Available in: Developer • Viewing a child object record that contains an external lookup field Edition • Executing a search that also searches external objects Available for an extra cost • Accessing an external object from a flow, Visualforce page, Apex class, or Apex trigger in: Enterprise, Performance, • Creating, editing, or deleting an external object record and Unlimited Editions • Running a report • Editing a report and causing the preview to load in report builder If a user or system accesses an external object through the SOAP API, Bulk API, or Lightning Platform REST API, that access counts toward the API usage limits of both the subscriber org and the provider org.
SEE ALSO: Salesforce Limits Quick Reference Guide: API Request Limits and Allocations Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter
Picklist Considerations for Salesforce Connect—Cross-Org Adapter
Special behaviors and limitations apply to picklist and multi-select picklist fields on external objects. EDITIONS • You can edit picklist values on external objects, but changes to fields on the provider org aren’t automatically reflected in the subscriber org. To reflect changes on the subscriber org, resync Available in: both Salesforce the external object or manually update the picklist values on the external object. Classic (not available in all orgs) and Lightning If you don’t resync or update the picklist values on the external object: Experience (not for – When an active picklist value is added to the provider org, the subscriber org doesn’t display high-data-volume external it as an available picklist value on external object records. objects)
– When an active picklist value is deleted from or made inactive on a restricted picklist on Available in: Developer the provider org, the subscriber org can’t create or edit external object records with that Edition value. Available for an extra cost • Global picklist value sets aren’t synced. If a provider org’s picklist field uses a global picklist value in: Enterprise, Performance, set, syncing creates a local picklist field on the subscriber org. A local picklist field has its own and Unlimited Editions set of values. • Inactive picklist values aren’t synced. If the subscriber org accesses an external object record that contains an inactive picklist value, the inactive value is added to the picklist field on the external object.
• Syncing converts restricted picklists on the provider org into unrestricted picklists on the subscriber org’s external objects.
878 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• We recommend having only unrestricted picklists on external objects, even when they’re associated with restricted picklists on the provider org. Restricted picklists on the provider org block unapproved values from the subscriber org, eliminating the need to restrict picklists on external objects.
SEE ALSO: Sync Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Considerations for Salesforce Connect—Cross-Org Adapter Picklist Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter
Currency Considerations for Salesforce Connect—Cross-Org Adapter
Special behaviors and limitations apply to currency fields on external objects. EDITIONS • Enable multiple currencies in the subscriber org, and make sure that the subscriber org has all the currencies that the provider orgs use. If a currency is later added to the provider org, add Available in: both Salesforce the currency to the subscriber org. Classic (not available in all orgs) and Lightning If you can’t enable multiple currencies in the subscriber org, make sure that all provider orgs Experience (not for are single-currency and use the same currency as the subscriber org. high-data-volume external • To enable users to change the currency when editing an external object record, add the objects) Currency field to the page layouts. Available in: Developer • If a user tries to change the currency in an external object record, the list of currency options Edition isn’t limited to active currencies in the provider org. If the user selects a currency that’s inactive Available for an extra cost or unavailable in the provider org, the user gets an error and can’t save the record. in: Enterprise, Performance, • The convertCurrency() function is ignored in SOQL queries of external objects. and Unlimited Editions
SEE ALSO: Considerations for Enabling Multiple Currencies Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter
Access External Data with the OData 2.0 or 4.0 Adapter for Salesforce Connect Connect your users to data that's exposed via the Open Data Protocol.
OData 2.0 or 4.0 Adapter for Salesforce Connect Connect to your back office for a complete view of your business. With the OData 2.0 or 4.0 adapter, Salesforce Connect uses Open Data Protocol Version 2.0 or Version 4.0 to access data that’s stored outside Salesforce. Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Let users view and search data that’s stored outside your Salesforce org, such as data in an enterprise resource planning (ERP) system. Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the special behaviors, limits, and recommendations for using the OData 2.0 or 4.0 adapter for Salesforce Connect. Picklist Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter Special behaviors and limitations apply to picklist fields on external objects.
879 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Get to know the Salesforce implementation of the Open Data Protocol (OData) for accessing external systems with Salesforce Connect. Use External Change Data Capture to Track Data Changes on External Objects With External Change Data Capture, you can track changes to data that is stored outside your Salesforce org when using the Odata 4.0 adapter. You can then build automation in response to the changes to increase productivity or provide a better customer experience.
OData 2.0 or 4.0 Adapter for Salesforce Connect
Connect to your back office for a complete view of your business. With the OData 2.0 or 4.0 adapter, EDITIONS Salesforce Connect uses Open Data Protocol Version 2.0 or Version 4.0 to access data that’s stored outside Salesforce. Available in: both Salesforce Your users and the Lightning Platform interact with the external data via external objects. Salesforce Classic (not available in all Connect converts each of those interactions into an OData query that contains the relevant orgs) and Lightning parameters to filter the results. Salesforce performs an OData callout each time that: Experience (not for high-data-volume external • A user clicks an external object tab for a list view. objects) • A user views a record detail page of an external object. Available in: Developer • A user views a record detail page of a parent object that displays a related list of child external Edition object records. Available for an extra cost • A user performs a Salesforce global search. in: Enterprise, Performance, • A user creates, edits, or deletes an external object record. and Unlimited Editions • A user runs a report. • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. The OData 2.0 adapter for Salesforce Connect can access external data that’s exposed via services called OData producers. Learn more about OData producers at www.odata.org. To understand the limitations on Apex code accessing external objects via the OData adapters, see Apex Considerations for Salesforce Connect External Objects.
External IDs and OData Entity Keys When you access external data with the OData 2.0 or 4.0 adapter for Salesforce Connect, the values of the External ID standard field on an external object are derived according to the entity key that’s defined in the OData service metadata document. Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters It's common for Salesforce Connect queries of external data to have a large result set that's broken into smaller batches or pages. You decide whether to have the paging behavior controlled by the external system (server-driven) or by the OData 2.0 or 4.0 adapter for Salesforce Connect (client-driven).
880 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
General Limits for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the limits for the OData adapters for Salesforce Connect.
SEE ALSO: Salesforce Connect Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters
External IDs and OData Entity Keys
When you access external data with the OData 2.0 or 4.0 adapter for Salesforce Connect, the values EDITIONS of the External ID standard field on an external object are derived according to the entity key that’s defined in the OData service metadata document. Available in: both Salesforce Each external object has an External ID standard field. Its values uniquely identify each Classic (not available in all external object record in your org. When the external object is the parent in an external lookup orgs) and Lightning relationship, the External ID standard field is used to identify the child records. Experience (not for high-data-volume external Important: Don’t use sensitive data as the values of the External ID standard field or fields objects) designated as name fields, because Salesforce sometimes stores those values. Available in: Developer • External lookup relationship fields on child records store and display the External ID values Edition of the parent records. Available for an extra cost • For internal use only, Salesforce stores the External ID value of each row that’s retrieved in: Enterprise, Performance, from the external system. This behavior doesn’t apply to external objects that are associated and Unlimited Editions with high-data-volume external data sources.
This list view for the Order_Detail external object displays External ID values.
Each External ID value is derived according to the entity key that’s defined in the OData service metadata document of the remote data service (OData producer). The entity key is formed from a subset of the entity type’s properties. This excerpt from an OData service metadata document shows that the External ID values for the Order_Detail external object are derived from the OrderID and ProductID properties.
881 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
...
This record detail page displays the OrderID and ProductID fields. Their values are combined to create the value of the External ID standard field.
If you enable writable external objects, determine whether the external system requires write operations to specify values for the entity keys. For example, many external systems generate values for entity keys when new external object records are created in Salesforce. If your external system requires write operations to specify values for entity keys, ensure that External ID standard field values and entity key values don’t contradict each other. For each write operation, include either the External ID standard field value or the custom field values that form the entity key, but never both.
SEE ALSO: OData 2.0 or 4.0 Adapter for Salesforce Connect Writable External Objects in Salesforce Connect
Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters
It's common for Salesforce Connect queries of external data to have a large result set that's broken EDITIONS into smaller batches or pages. You decide whether to have the paging behavior controlled by the external system (server-driven) or by the OData 2.0 or 4.0 adapter for Salesforce Connect Available in: both Salesforce (client-driven). Classic (not available in all By default, the OData 2.0 and 4.0 adapters for Salesforce Connect use client-driven paging. orgs) and Lightning Specifically, the OData requests use the $top and $skip system query options to page through Experience (not for the result set. high-data-volume external objects) With server-driven paging, the external system determines the page sizes and batch boundaries. The external system’s paging settings can optimize the external system’s performance and improve Available in: Developer the load times for external objects in your org. Also, the external data set can change while your Edition users or the Lightning Platform are paging through the result set. Typically, server-driven paging Available for an extra cost adjusts batch boundaries to accommodate changing data sets more effectively than client-driven in: Enterprise, Performance, paging. and Unlimited Editions
882 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
The Server Driven Pagination field on the external data source specifies whether to use client-driven or server-driven paging. If you enable server-driven paging on an external data source, Salesforce ignores the requested page sizes, including the default queryMore() batch size of 500 rows. The pages returned by the external system determine the batches, but each page can’t exceed 2,000 rows. However, the limits for the OData adapters for Salesforce Connect still apply.
SEE ALSO: Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter General Limits for Salesforce Connect—OData 2.0 and 4.0 Adapters OData Query String Options
General Limits for Salesforce Connect—OData 2.0 and 4.0 Adapters
Understand the limits for the OData adapters for Salesforce Connect. EDITIONS An org is limited to: • 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require Available in: both Salesforce Classic (not available in all higher limits, create a support case. orgs) and Lightning • 1,000 OData callouts per hour for Developer Edition. Experience (not for • 100k new external object record IDs per hour for long-term ID mapping high-data-volume external • 100k new external object record IDs per hour for short-term ID mapping objects) Available in: Developer Note: To view external object records in Lightning Experience, Salesforce Connect maps the Edition external IDs of the record to Salesforce IDs. Mappings classified as short-term refer to records retrieved via Search results only. Mappings classified as long-term refer to records retrieved Available for an extra cost by all other Lightning Experience components, such as List Views. Record IDs not viewed in in: Enterprise, Performance, 365 days are subject to deletion unless the mappings have customer data attached to them. and Unlimited Editions
Maximum HTTP request size for OData 8 MB
Maximum HTTP response size for OData 8 MB
Maximum result set size for an OData query 16 MB
Maximum result set size for an OData subquery 1,000 rows
SEE ALSO: General Limits for Salesforce Connect OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData 2.0 or 4.0 Adapter for Salesforce Connect Record IDs for Salesforce Connect External Objects
883 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter
USER PERMISSIONS EDITIONS
To create and edit external data sources: Customize Application Available in: both Salesforce Classic (not available in all To create and edit external objects: Customize Application orgs) and Lightning To define or change object-level help: Customize Application Experience (not for high-data-volume external To create and edit custom fields: Customize Application objects)
To edit permission sets and user profiles: Manage Profiles and Permission Sets Available in: Developer To edit another user’s authentication settings Manage Users Edition for external systems: Available for an extra cost in: Enterprise, Performance, and Unlimited Editions Let users view and search data that’s stored outside your Salesforce org, such as data in an enterprise resource planning (ERP) system. Setting up Salesforce Connect with anOData 2.0 or 4.0 adapter involves these high-level steps. 1. Define an external data source of type Salesforce Connect: OData 2.0 or Salesforce Connect: OData 4.0. If your external system hosts multiple services, create an external data source for each service endpoint. Each service endpoint points to an OData service root URL and can expose collections of entities. For example, you’d create a separate external data source for each of these service endpoints. • http://services.example.org/Warehouse.svc • https://services.example.org/Payroll.svc
2. Create the external objects. Perform this task only if you don’t sync to automatically create the external objects. Create an external object for each external data table that you want to access from your Salesforce org.
3. Create help content for the external objects. Create Visualforce pages that describe the external data. When your users click Help for this Page on an external object, they read your custom help content. Remember, your users can’t find information about the external data in Salesforce Help.
4. Add custom fields and relationships to the external objects. Create relationships between objects. If you didn’t sync to automatically create the external objects and their fields, create a custom field for each external table column that you want to access from your Salesforce org.
5. Verify access to external object data. Check that expected user and code interactions with the external objects work, including sorting and filtering search and query results.
Tip: After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results.
6. Enable user access to external objects. Grant object permissions through permission sets or profiles.
7. Enable user access to the fields on the external objects.
884 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Grant field permissions through permission sets or profiles.
8. If the external data source uses per-user authentication: a. Let users authenticate to the external system. Grant users access to authentication settings for the external data source through permission sets or profiles.
b. Set up each user’s authentication settings. You or your users can perform this task.
Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for each external system. If you’re using OAuth 2.0, test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes.
SEE ALSO: OData 2.0 or 4.0 Adapter for Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Developer Guide: Visualforce Developer Guide External Object Relationships
Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter ® Connect your Salesforce org to data that’s stored in an external system, such as SAP NetWeaver EDITIONS Gateway, Microsoft Dynamics® NAV, or IBM WebSphere®.
Note: Available in: both Salesforce Classic (not available in all • The external data must be exposed by a service that uses Open Data Protocol (OData) orgs) and Lightning Version 2.0 or 4.0. Such a service is called an OData producer. Experience (not for • The URL for reaching the OData producer must be accessible by Salesforce application high-data-volume external servers through the Internet. You can allow access by white-listing Salesforce server IP objects) addresses on your corporate network firewall or by setting up a reverse-proxy XML Available in: Developer Gateway. Edition • The extent to which you can customize data visibility depends on the external system. Available for an extra cost To determine the optimal settings for integration with Salesforce, consult the external in: Enterprise, Performance, system’s documentation. and Unlimited Editions 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. USER PERMISSIONS 2. Click New External Data Source, or click Edit to modify an existing external data source. To create and edit external 3. Complete the fields. data sources: • Customize Application
885 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description Label A user-friendly name for the external data source. The label is displayed in the Salesforce user interface, such as in list views. If you set Identity Type to Per User, this label appears when your users view or edit their authentication settings for external systems.
Name A unique identifier that’s used to refer to this external data source definition through the API. The name can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
Type Select Salesforce Connect: OData 2.0 or Salesforce Connect: OData 4.0.
URL The OData service root URL. Make sure that you escape all special characters. Each service endpoint requires its own external data source definition, but you can have multiple entities under one service root URL. For more information about the service root URL and other URL conventions, go to www.odata.org. Examples: • http://services.example.org/Warehouse.svc • https://services.example.org/Payroll.svc If the endpoint is defined in a named credential, enter the named credential URL. A named credential URL contains the scheme callout:, the name of the named credential, and an optional path. For example: callout:My_Named_Credential/some_path. You can append a query string to a named credential URL. Use a question mark (?) as the separator between the named credential URL and the query string. For example: callout:My_Named_Credential/some_path?format=json. If you enter a named credential URL, skip the Authentication section for the external data source. To access the external system, Salesforce Connect uses the authentication settings that are defined in the named credential.
Connection Timeout Number of seconds to wait for a response from the external system before timing out. By default, the value is set to the maximum of 120 seconds. Depending on the availability of and the connection to the external system, it can take a long time to retrieve external data. Use this field to limit how long to wait for external data to load into your org.
Writable External Lets the Lightning platform and users in this org create, update, and delete records for external Objects objects associated with the external data source. The external object data is stored outside the org. By default, external objects are read only.
High Data Volume Salesforce enforces rate limits for retrieving and viewing data from external systems. If your org hits rate limits when accessing external objects, consider selecting the High Data Volume option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. See High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 897.
886 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description High-data-volume external data sources are still limited to 20,000 OData queries per hour for Enterprise, Performance, and Unlimited Editions. If you require higher limits, create a support case. See OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 896.
Server Driven It's common for Salesforce Connect queries of external data to have a large result set that's broken Pagination into smaller batches or pages. Select this option to have the external system control the paging behavior. See Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 882.
Request Row Counts Includes one of the following system query options in each OData query so that the response includes the total row count of the result set. • $inlinecount=allpages for the OData 2.0 adapter • $count=true for the OData 4.0 adapter Some external systems don’t support these system query options. If you receive errors or notice long load times when you try to access their data, deselect Request Row Counts on the external data source. If you do so, however, the external data source and its associated external objects can’t support the following functionality, which requires the total row count. • SOQL COUNT() aggregate function • Batch Apex with Database.QueryLocator
Compress Requests When selected, Salesforce sends compressed HTTP requests to the external system. Make sure that the external system is set up to receive gzip-compressed data. Salesforce automatically accepts gzip-compressed responses.
Enable Search Determines whether SOSL and Salesforce global searches also query the external objects that are associated with this external data source. When selected, you can control which external objects are searchable by selecting or deselecting Allow Search on each external object. Only text, text area, and long text area fields on external objects can be searched. If an external object has no searchable fields, searches on that object return no records. Select this option to allow the external data source’s associated external objects to appear in Salesforce for iOS and Salesforce mobile web when used on iOS devices.
Custom Query Option Available only for the OData 2.0 adapter for Salesforce Connect. If the OData producer has for Salesforce implemented and exposed a free-text-search custom query option, enter the name of that query Search string parameter. Learn more about OData custom query options and other URI conventions at www.odata.org. This field has no effect when Enable Search is deselected or when the OData producer isn’t set up to correctly handle the custom query option. See OData 2.0 Query Options.
Use Free-Text Search Available only for the OData 4.0 adapter for Salesforce Connect. Select this option to use the Expressions $search system query option instead of $filter in search requests that are sent to the
887 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description external system. Make sure that the OData producer is set up to support the $search system query option. This field has no effect when Enable Search is deselected. See OData 4.0 Query Options.
Format The format that the OData producer uses to represent resources, such as collections of data. Make sure that the OData producer is set up to support the selected format. Learn more about representation formats and operations at www.odata.org. If your external data source uses the OData 4.0 adapter and JSON format, make sure that the OData producer accepts headers that contain the odata.metadata=full format parameter. Other variations, including odata.metadata=minimal, aren’t supported.
Special Select Socrata only if the URL specifies a Socrata open data endpoint. See Socrata™ Considerations Compatibility for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 898.
CSRF Protection If the external system requires Cross-Site Request Forgery (CSRF) protection in requests to create, edit or delete its data, select this option. If you do so, your org obtains an anti-CSRF token and cookie from the external system and includes them in each create, edit, and delete request. See CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 898. Available only when Writable External Objects is selected.
Anti-CSRF Token Name HTTP header field that contains the anti-CSRF token. The external system determines the field name. Default: X-CSRF-Token Available only when CSRF Protection is selected.
Certificate If you specify a certificate, your Salesforce org supplies it when establishing each two-way SSL connection with the external system. The certificate is used for digital signatures, which verify that requests are coming from your Salesforce org.
Identity Type Determines whether you're using one set or multiple sets of credentials to access the external system. See Identity Type for External Data Sources on page 857. Select Anonymous only if the external system doesn’t require authentication.
4. Select the authentication protocol. • If you select Password Authentication, enter the username and password for accessing the external system. • If you select OAuth 2.0, complete the following fields.
Field Description Authentication Choose the provider. See Authentication Providers. Provider
888 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter.
Note: – The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider. – Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen. – We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system.
Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status.
5. Click Save. 6. Click Validate and Sync, and confirm that the connection is successful. 7. Optionally, select tables and click Sync to do the following for each selected table. • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type.
Note: Before you sync, make sure that you understand the considerations that are described in these topics. • Sync an External Data Source for Salesforce Connect on page 858 • Sync Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter on page 894
You can instead choose to manually create the external objects and custom fields that map to the external data. Doing so lets you customize the external object names, decide which table columns to create custom fields for, and customize the custom field names. However, this approach takes longer and requires manual maintenance.
Optionally, you can associate custom HTTP headers to the external data source to retrieve or request additional data.
SEE ALSO: Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Store Authentication Settings for External Systems OData Query String Options OData Type Mapping Named Credentials
889 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Define Custom HTTP Headers for OData Connectors
Define and activate custom HTTP headers to pass more request information to the external data EDITIONS source for processing. Custom HTTP headers provide context information from Salesforce such as region, org details, or Available in: both Salesforce the role of the person viewing the external object. For each OData external data source, define up Classic (not available in all 10 HTTP headers to request or data. For example, to see who’s making a callout to the external data orgs) and Lightning source, use a formula that resolves to the name of the user. Experience When naming the custom HTTP header, don’t override the following existing standard header Available with Salesforce names. Connect, which is available in: Developer Edition and for • Content-Type an extra cost in: Enterprise, • Accept Performance, and • maxVersionHeader Unlimited Editions • versionHeader • X-HTTP-METHOD USER PERMISSIONS • Content-Length To create and edit external • X-CSRF-Token (when CSRF-enabled) data sources: • Prefer (when a trigger on the external object is enabled) • Customize Application • Cookie 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. 2. Click the name of an OData 2.0 or 4.0 data source. 3. In the External Custom HTTP Headers related list, click New to create a custom HTTP header or Edit to change an existing one. 4. Complete the fields.
Field Description Header Field Name Enter a name that contains at least one alphanumeric character or underscore. It can also include: ! # $ % & ' * + - . ^ _ ` | ~
Header Field Value Create a formula for the Header Field Value using the formula editor. The values in the formula must evaluate to a string. If the formula resolves to null and an empty string, the header isn’t sent.
Active To start using the header field right away, select the Active checkbox.
Description A text description of the header field’s purpose.
Parent The name of the entity that the custom HTTP header is related to.
Note: A named credential as the parent entity for the custom HTTP header isn’t supported.
5. Click Save.
Note: You can’t add or delete Custom HTTP headers that are included in a managed package. However, you can edit custom HTTP headers that are part of a managed package. The Header Name and Description fields are developer editable. The Active and Header Field Value fields are both subscriber and developer editable.
890 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Named Credential as Callouts for Salesforce Connect OData 2.0 or 4.0 Adapters This example shows how Salesforce Connect OData 2.0 or 4.0 adapters can make callouts using the authentication settings defined in a named credential. Define a named credential that specifies the endpoint URL and the JWT authentication settings.
When you’re defining an external data source with an Odata 2.0 or Odata 4.0 adapter, specify the named credential you defined as the OData service root URL. In this example, the URL is callout:Test_named_credential. And skip the Authentication section for the external data source. To access the external system, Salesforce Connect uses the authentication settings defined in the named credential.
SEE ALSO: Define a Named Credential Store Authentication Settings for External Systems Grant Access to Authentication Settings for Named Credentials
891 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Understand the special behaviors, limits, and recommendations for using the OData 2.0 or 4.0 EDITIONS adapter for Salesforce Connect. Also review the considerations that apply to all Salesforce Connect adapters. Available in: both Salesforce Classic (not available in all orgs) and Lightning Lightning Experience Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Experience (not for Users can access external objects from the Lightning Experience app. But some requirements high-data-volume external and special behaviors apply when the external data is accessed via the OData 2.0 or 4.0 adapter objects) for Salesforce Connect. Available in: Developer Writable External Objects Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Edition Some special behaviors and limitations affect writable external objects that are associated with Available for an extra cost OData adapters for Salesforce Connect. in: Enterprise, Performance, Sync Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter and Unlimited Editions When you validate and sync an external data source of type Salesforce Connect: OData 2.0 or Salesforce Connect: OData 4.0, some special behaviors and limitations apply. OData Producer Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the limits and recommendations for the remote data service that exposes the external data to your Salesforce org. OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters An external object references data that’s stored outside Salesforce. Access to an external object involves a callout to its associated external system. Salesforce enforces rate limits for these callouts. High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters If your org hits rate limits when accessing external objects, consider selecting the High Data Volume option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. Socrata™ Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Socrata Open Data Protocol™ is commonly used for health data and for collaboration between governments and their citizens. Salesforce Connect can access data from endpoints that are backed by Socrata Open Data Portal. To accommodate Socrata-specific requirements, set the Special Compatibility field on the external data source to Socrata. CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the special behaviors, limitations, and recommendations for Cross-Site Request Forgery (CSRF) on OData external data sources.
SEE ALSO: Salesforce Platform Features Supported by Salesforce Connect
892 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Lightning Experience Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Users can access external objects from the Lightning Experience app. But some requirements and EDITIONS special behaviors apply when the external data is accessed via the OData 2.0 or 4.0 adapter for Salesforce Connect. Available in: both Salesforce • If external object records don’t appear in your org, make sure that the OData producer doesn’t Classic and Lightning change the values specified in the OData query filters. When your org sends OData queries that Experience specify field values with the $filter equals (eq) operator, the OData producer must return Available in: Developer those same field values in the resulting data rows. Edition • If external object records don’t appear in relationship fields or related lists, check for case-sensitive Available for an extra cost values. For example, suppose that you set up an indirect lookup relationship. If the external in: Enterprise, Performance, system uses case-sensitive values in the specified External Column Name, make sure that the and Unlimited Editions parent object field is also case-sensitive. When you define the parent object’s custom field, select External ID, Unique, and Treat "ABC" and "abc" as different values (case sensitive).
SEE ALSO: External Object Relationships OData Query String Options OData 2.0 or 4.0 Adapter for Salesforce Connect Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter
Writable External Objects Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Some special behaviors and limitations affect writable external objects that are associated with EDITIONS OData adapters for Salesforce Connect. • An external object custom field associated with an OData complex type on the external system Available in: both Salesforce is always read only, even if the external object is writable. Classic (not available in all • Writable external objects aren’t available for high-data-volume external data sources. orgs) and Lightning Experience (not for • If your external system requires write operations to specify values for entity keys, ensure that high-data-volume external External ID standard field values and entity key values don’t contradict each other. For objects) each write operation, include either the External ID standard field value or the custom field values that form the entity key, but never both. Available in: Developer Edition • When an external object record is edited, Salesforce Connect sends an HTTP request to the external system. Available for an extra cost in: Enterprise, Performance, – If the record is edited from the Salesforce user interface, the HTTP request includes all fields, and Unlimited Editions including the fields that weren’t changed. – If the record is edited from the API, only the specified fields are included in the HTTP request.
• Make sure that the OData producer supports the HTTP methods that are used by your Salesforce Connect adapter.
To Do This OData 4.0 Adapter Uses This HTTP Method OData 2.0 Adapter Uses This HTTP Method Create record POST POST
Edit record POST with X-HTTP-METHOD header set to PATCH POST with X-HTTP-METHOD header set to MERGE
Delete record DELETE DELETE
893 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
To Do This OData 4.0 Adapter Uses This HTTP Method OData 2.0 Adapter Uses This HTTP Method View record GET GET
Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: Writable External Objects in Salesforce Connect External IDs and OData Entity Keys OData 2.0 or 4.0 Adapter for Salesforce Connect
Sync Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter
When you validate and sync an external data source of type Salesforce Connect: OData EDITIONS 2.0 or Salesforce Connect: OData 4.0, some special behaviors and limitations apply. Available in: both Salesforce • Syncing always enables search on the external object when search is enabled on the external Classic (not available in all data source, and vice versa. orgs) and Lightning Experience (not for • For a list of supported OData types, see “OData Type Mapping” in Salesforce Help. high-data-volume external Important: When you select the tables to sync, determine whether check marks appear in objects) the Synced column. Available in: Developer If a Synced check mark appears, your org has an external object whose object name matches Edition the table name. If you select the table and click Sync: Available for an extra cost • The external object is overwritten. in: Enterprise, Performance, and Unlimited Editions • Any custom field on the external object is overwritten if its API name (for example, Email__c) associates it with a table column name (for example, Email). • Any other custom fields on the external object remain as they are, including: – Previously synced custom fields whose API names were changed by editing their Field Name values. – Manually added custom fields whose API names aren’t associated with table column names.
If no Synced check mark appears, and you sync the table, a new external object is created in your org. The new external object’s object name matches the table name. For example, if the table name is changed on the external system to no longer match the object name of the external object, syncing that table creates a new external object in Salesforce. We recommend that you change the object name of the existing external object to match the new table name on the external system before you sync that table.
894 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: Sync an External Data Source for Salesforce Connect Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter OData 2.0 or 4.0 Adapter for Salesforce Connect OData Type Mapping
OData Producer Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Understand the limits and recommendations for the remote data service that exposes the external EDITIONS data to your Salesforce org. • Validate your OData producer by using the Open Data Protocol Service Validation Tool at Available in: both Salesforce services.odata.org/validation. Doing so checks your implementation against Classic and Lightning the OData specification and identifies potential issues. Experience • To improve performance over low-bandwidth connections, set up your OData producer to Available in: Developer receive gzip-compressed data. Then, in the external data source definition in Salesforce, select Edition Compress Requests. You can also set up the OData producer to send gzip-compressed data Available for an extra cost to Salesforce, which automatically accepts gzip-compressed responses. in: Enterprise, Performance, • By default, Salesforce sends each OData request with one of the following system query options and Unlimited Editions so that the response includes the total row count of the result set. – $inlinecount=allpages for the OData 2.0 adapter – $count=true for the OData 4.0 adapter Some external systems don’t support these system query options. If you receive errors or notice long load times when you try to access their data, deselect Request Row Counts on the external data source. If you do so, however, the external data source and its associated external objects can’t support the following functionality, which requires the total row count. – SOQL COUNT() aggregate function – Batch Apex with Database.QueryLocator For details about OData URI conventions, go to www.odata.org.
• Configure your OData producer to use a page size that’s large enough to avoid excessive round trips. Querying a large set of data with a small page size can take a long time because of network latency. Salesforce pages that display external data can take a long time to load. For example, if the query results include 100 records, and the page size holds only 5 records, it takes 20 round trips to retrieve the results. If the network latency is 100 ms per round trip, it takes 2 seconds (20 × 100 ms) to retrieve the results. In contrast, if the page size holds 20 records, it takes only five round trips to retrieve the 100 records. With the same network latency of 100 ms per round trip, it takes 0.5 seconds (5 × 100 ms) to retrieve the results.
• For a list of supported OData types, see “OData Type Mapping” in Salesforce Help. • If your external data source uses the OData 4.0 adapter and JSON format, make sure that the OData producer accepts headers that contain the odata.metadata=full format parameter. Other variations, including odata.metadata=minimal, aren’t supported.
895 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• If external object records don’t appear in your org, make sure that the OData producer doesn’t change the values specified in the OData query filters. When your org sends OData queries that specify field values with the $filter equals (eq) operator, the OData producer must return those same field values in the resulting data rows.
SEE ALSO: OData 2.0 or 4.0 Adapter for Salesforce Connect OData Query String Options OData Type Mapping
OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
An external object references data that’s stored outside Salesforce. Access to an external object EDITIONS involves a callout to its associated external system. Salesforce enforces rate limits for these callouts. An org is limited to: Available in: both Salesforce Classic (not available in all • 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require orgs) and Lightning higher limits, create a support case. Experience (not for • 1,000 OData callouts per hour for Developer Edition. high-data-volume external • 100k new external object record IDs per hour for long-term ID mapping objects) • 100k new external object record IDs per hour for short-term ID mapping Available in: Developer Edition Note: To view external object records in Lightning Experience, Salesforce Connect maps the external IDs of the record to Salesforce IDs. Mappings classified as short-term refer to records Available for an extra cost retrieved via Search results only. Mappings classified as long-term refer to records retrieved in: Enterprise, Performance, by all other Lightning Experience components, such as List Views. Record IDs not viewed in and Unlimited Editions 365 days are subject to deletion unless the mappings have customer data attached to them. To obtain your org’s limits and current usage against those limits, use the Limits resource in the Lightning Platform REST API. Salesforce performs an OData callout each time that: • A user clicks an external object tab for a list view. • A user views a record detail page of an external object. • A user views a record detail page of a parent object that displays a related list of child external object records. • A user performs a Salesforce global search. • A user creates, edits, or deletes an external object record. • A user runs a report. • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. If your users or applications encounter rate limit errors for OData callouts, try one or more of the following. • Select High Data Volume in the external data source definition. Doing so bypasses most rate limits, but some special behaviors and limitations apply. • Run fewer SOQL and SOSL queries. • If you have Apex code that invokes the external system, modify that code to cache frequently accessed external data that seldom changes.
896 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• Contact Salesforce to request a higher limit.
SEE ALSO: REST API Developer Guide : List Organization Limits High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData 2.0 or 4.0 Adapter for Salesforce Connect Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
If your org hits rate limits when accessing external objects, consider selecting the High Data Volume EDITIONS option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. Available in: both Salesforce • The following features aren’t available for external objects that are associated with Classic (not available in all high-data-volume external data sources. orgs) and Lightning Experience (not for – Access via Lightning Experience high-data-volume external – Access via the Salesforce mobile app objects) – Appearance in Recent Items lists Available in: Developer – Record feeds Edition – Reports and dashboards Available for an extra cost – Writable external objects in: Enterprise, Performance, and Unlimited Editions • Salesforce IDs aren’t assigned to external object records that are associated with high-data-volume external data sources. • On record detail pages for external objects that are associated with high-data-volume external data sources, custom buttons, and links that call JavaScript aren’t supported. • Salesforce Console in Salesforce Classic doesn’t support external objects that are associated with high-data-volume external data sources. • CSRF protection for writable external objects isn’t available for high-data-volume external data sources.
SEE ALSO: REST API Developer Guide : List Organization Limits OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter
897 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Socrata™ Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters ™ Socrata Open Data Protocol is commonly used for health data and for collaboration between EDITIONS governments and their citizens. Salesforce Connect can access data from endpoints that are backed by Socrata Open Data Portal. To accommodate Socrata-specific requirements, set the Special Available in: both Salesforce Compatibility field on the external data source to Socrata. Classic (not available in all Socrata doesn’t support the row identifier (_id) column in $select or $orderby clauses in orgs) and Lightning OData queries. When Socrata is selected in the Special Compatibility field: Experience (not for high-data-volume external • OData queries don’t include the _id column in $select clauses. objects) • If an _id column is synced from a Socrata endpoint, the resulting custom field on the external Available in: Developer object isn’t sortable. Edition • If you manually define an external object’s custom field with _id as the External Column Available for an extra cost Name, make sure that you select the Sorting Disabled attribute for that custom field. in: Enterprise, Performance, If you modify the Special Compatibility field on an external data source, we recommend and Unlimited Editions that you resync its external objects. Or instead, you can test whether queries or user access to the external objects result in errors, and resync only the problematic external objects.
SEE ALSO: Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Understand the special behaviors, limitations, and recommendations for Cross-Site Request Forgery EDITIONS (CSRF) on OData external data sources. • CSRF protection isn’t available for high-data-volume external data sources. Available in: both Salesforce • Make sure that the URL of the external data source starts with https:// so that secure HTTP Classic (not available in all can prevent unauthorized access to the anti-CSRF token and cookie. orgs) and Lightning Experience (not for • In addition to enabling CSRF protection on the external data source, we recommend keeping high-data-volume external CSRF protection enabled in your org’s session security settings. These session settings are objects) enabled by default, and keeping them enabled protects your Salesforce data and your external data from CSRF attacks. Available in: Developer Edition – Enable CSRF protection on GET requests on non-setup pages Available for an extra cost Enable CSRF protection on POST requests on non-setup pages – in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Modify Session Security Settings
898 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Picklist Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter
Special behaviors and limitations apply to picklist fields on external objects. EDITIONS • Global and local single-select picklists are supported. • You must manually update picklist values to stay in sync between your org and the external Available in: both Salesforce system. If values are not in sync, your users could see an error message when viewing the field. Classic (not available in all orgs) and Lightning – Add values to the picklist as you would a picklist on a custom object. Experience (not for – Remove a value from a picklist by deactivating the value rather than deleting it. high-data-volume external – Replace a value by deactivating it and then adding the new value. Update the external objects) system’s record values to the new value on the external system. Available in: Developer Edition • Convert existing external object text fields to picklists by deleting and recreating. Delete the text field and create a picklist pointing to the text field’s existing External Column Name. Available for an extra cost in: Enterprise, Performance, • If you select to delete, you might be prompted to replace the value with another value. No and Unlimited Editions replace occurs for external object record values. You must manually change the values on the external system. • We recommend having only unrestricted picklists on external objects, even when they’re associated with restricted picklists on the provider org. Restricted picklists on the provider org block unapproved values from the subscriber org, eliminating the need to restrict picklists on external objects.
SEE ALSO: Picklist Considerations for Salesforce Connect—Cross-Org Adapter
OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters
Get to know the Salesforce implementation of the Open Data Protocol (OData) for accessing external EDITIONS systems with Salesforce Connect. Available in: both Salesforce OData Type Mapping Classic (not available in all Salesforce Connect maps OData types to Salesforce metadata field types when syncing metadata orgs) and Lightning and converting values between Salesforce and external systems. Experience (not for high-data-volume external OData Query String Options objects) The OData adapters for Salesforce Connect use a subset of the OData 2.0 and 4.0 system functions and filter expression constructs to query external systems. Available in: Developer Edition Available for an extra cost SEE ALSO: in: Enterprise, Performance, OData 2.0 or 4.0 Adapter for Salesforce Connect and Unlimited Editions
899 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData Type Mapping
Salesforce Connect maps OData types to Salesforce metadata field types when syncing metadata EDITIONS and converting values between Salesforce and external systems. Available in: both Salesforce OData 2.0 Type Mapping Classic (not available in all Understand how the OData 2.0 adapter for Salesforce Connect maps OData types to Salesforce orgs) and Lightning metadata field types. Experience (not for high-data-volume external OData 4.0 Type Mapping objects) Understand how the OData 4.0 adapter for Salesforce Connect maps OData types to Salesforce metadata field types. Available in: Developer Edition Available for an extra cost in: Enterprise, Performance, and Unlimited Editions
OData 2.0 Type Mapping
Understand how the OData 2.0 adapter for Salesforce Connect maps OData types to Salesforce EDITIONS metadata field types. Salesforce Connect supports only the following types when syncing metadata and converting Available in: both Salesforce values between Salesforce and an external system. Classic (not available in all orgs) and Lightning Experience (not for OData 2.0 Primitive Types high-data-volume external objects) OData 2.0 Type Salesforce Metadata Field Type Available in: Developer Binary TextArea Edition Boolean Checkbox Available for an extra cost in: Enterprise, Performance, Byte Number and Unlimited Editions DateTime DateTime
DateTimeOffset DateTime
Decimal Number
Double Number
Guid Text
Int16 Number
Int32 Number
Int64 Number
SByte Number
Single Number
900 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 2.0 Type Salesforce Metadata Field Type String Depends on the declared maximum length of the OData string column.
OData Declared Maximum Salesforce Field Type Salesforce Field Length Length Attribute Not declared Text 128 characters
255 or fewer characters Text Same as declared
More than 255 characters LongTextArea Same as declared
Time Text
Tip: A binary value from an external system is represented in Salesforce as a base64-encoded string. You can convert it to a value of type Blob by using the EncodingUtil.base64Decode(inputString) Apex method.
OData 2.0 Complex Types Salesforce Connect supports OData complex types as follows. • External data of complex type is flattened into a string that contains field names and values. For example, an address is flattened into the following string.
Street: 55 East 5th Street, City: New York, State: NY, Zip: 10003
• An external object custom field associated with an OData complex type on the external system is always read only, even if the external object is writable.
SEE ALSO: Sync an External Data Source for Salesforce Connect Custom Field Types Custom Field Attributes OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Apex Developer Guide : EncodingUtil Class: base64Decode(inputString)
901 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 4.0 Type Mapping
Understand how the OData 4.0 adapter for Salesforce Connect maps OData types to Salesforce EDITIONS metadata field types. Salesforce Connect supports only the following types when syncing metadata and converting Available in: both Salesforce values between Salesforce and an external system. Classic (not available in all orgs) and Lightning Experience (not for OData 4.0 Primitive Types high-data-volume external objects) OData 4.0 Type Salesforce Metadata Field Type Available in: Developer Binary TextArea Edition Boolean Checkbox Available for an extra cost in: Enterprise, Performance, Byte Number and Unlimited Editions Date DateTime with time properties set to 0
DateTimeOffset DateTime
Decimal Number
Double Number
Guid Text
Int16 Number
Int32 Number
Int64 Number
SByte Number
Single Number
String Depends on the declared maximum length of the OData string column.
OData Declared Salesforce Field Salesforce Field Maximum Length Type Length Attribute Not declared Text 128 characters
255 or fewer Text Same as declared characters
More than 255 LongTextArea Same as declared characters
Tip: A binary value from an external system is represented in Salesforce as a base64-encoded string. You can convert it to a value of type Blob by using the EncodingUtil.base64Decode(inputString) Apex method.
902 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 4.0 Complex Types Salesforce Connect supports OData complex types as follows. • External data of complex type is flattened into a string that contains field names and values. For example, an address is flattened into the following string.
Street: 55 East 5th Street, City: New York, State: NY, Zip: 10003
• An external object custom field associated with an OData complex type on the external system is always read only, even if the external object is writable.
SEE ALSO: Sync an External Data Source for Salesforce Connect Custom Field Types Custom Field Attributes OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Apex Developer Guide : EncodingUtil Class: base64Decode(inputString)
OData Query String Options
The OData adapters for Salesforce Connect use a subset of the OData 2.0 and 4.0 system functions EDITIONS and filter expression constructs to query external systems. When your users or the Lightning Platform interact with external objects, the OData 2.0 or 4.0 Available in: both Salesforce adapter for Salesforce Connect converts those actions into OData queries. Salesforce performs an Classic (not available in all OData callout each time that: orgs) and Lightning Experience (not for • A user clicks an external object tab for a list view. high-data-volume external • A user views a record detail page of an external object. objects) • A user views a record detail page of a parent object that displays a related list of child external Available in: Developer object records. Edition • A user performs a Salesforce global search. Available for an extra cost • A user creates, edits, or deletes an external object record. in: Enterprise, Performance, • A user runs a report. and Unlimited Editions • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. The following sections describe the Salesforce Connect implementation as a consumer of OData services. Salesforce automatically creates the OData queries so that you, as an administrator or developer, don’t have to. However, understanding how OData queries are generated—or even attempting manual OData queries—can help you troubleshoot issues with the external system’s OData producer. For details about each system query option, go to www.odata.org. Salesforce Connect supports only the following OData system query options. All other options in the OData 2.0 and 4.0 specifications are unused. • $count (OData 4.0 only) on page 904 • $filter on page 904 • $inlinecount (OData 2.0 only) on page 904
903 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• $orderby on page 905 • $search (OData 4.0 only) on page 905 • $select on page 905 • $skip on page 906 • $top on page 906 A query search string to an external system is sent as a case-sensitive single phrase after removing all ASCII punctuation characters except hyphens (-). For example, if the search string is Sales & Marketing, the external system receives Sales Marketing.
$count (OData 4.0 only) Specifies that the response must include the number of rows that the URI identifies after $filter system query options are applied, but before $top and $skip system query options are applied. When Request Row Counts is enabled on the external data source, Salesforce includes $count=true in all OData 4.0 queries of that external data source to determine the total number of items in each result set. The total items in the result set is the same as the LIMIT value in the query for values less than 202. If the LIMIT value is greater than 202, then 202 items are returned to indicate that more records exist in the next batch. If Request Row Counts is disabled, Salesforce includes $count=false in all OData 4.0 queries of the external data source, and 2000 items are returned in each result set.
Examples User action in View or access an external object. Salesforce
SOQL query Any SOQL query of an external object
Resulting OData http://services.example.org/my.svc/Suppliers?$select=SupplierID& query $count=true&$top=26
$filter Filters the collection of resources that’s addressed by a request URL. The response contains the results that evaluate to true.
Examples User action in Open a list view of cities from supplier records that are filtered so that the country is USA. Salesforce
SOQL query SELECT City__c FROM Suppliers__x WHERE Country__c = 'USA' ORDER BY City__c ASC LIMIT 26
Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=City& query $select=City,SupplierID&$inlinecount=allpages&$filter=Country+eq+'USA'& $top=26
$inlinecount (OData 2.0 only) Specifies that the response must include a count of the number of rows that the URI identifies after $filter system query options are applied but before $top and $skip system query options are applied.
904 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
When Request Row Counts is enabled on the external data source, Salesforce uses $inlinecount in all OData 2.0 queries of that external data source to determine the total number of items in each result set. If Request Row Counts is disabled, $inlinecount is excluded from all OData 2.0 queries of the external data source.
Examples User action in View or access an external object. Salesforce
SOQL query Any SOQL query of an external object.
Resulting OData http://services.example.org/my.svc/Suppliers?$select=SupplierID& query $inlinecount=allpages&$top=26
$orderby Sorts the result set in ascending or descending order. The fields in the ORDER BY clause of the SOQL query don't always match the properties used by the $orderby option in the resulting OData query. If you use the OFFSET clause in the SOQL query, the entity key property is added in the resulting OData query.
Examples User action in Open a list view of supplier records that are ordered by company name. Salesforce
SOQL query SELECT CompanyName__c,ContactName__c FROM Suppliers__x ORDER BY CompanyName__c ASC LIMIT 26
Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=CompanyName& query $select=CompanyName,ContactName,SupplierID&$inlinecount=allpages&$top=26
$search (OData 4.0 only) Requests entities that match the search query string as a free-text search expression. Enable this option by selecting Use Free-Text Search Expressions on the external data source. By default, Use Free-Text Search Expressions is not enabled. The search query string is used as the contains value in the $filter system query option.
Examples User action in View or access an external object. Salesforce
SOQL query Any SOQL query of an external object
Resulting OData http://services.example.org/my.svc/Shippers? query $select=CompanyName,Phone,ShipperID&$count=true&$search=Acme&$top=25
$select Requests a limited set of properties for each entity.
905 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Examples User action in Open a list view of supplier records where the page layout displays the company name and contact name. Salesforce
SOQL query SELECT CompanyName__c,ContactName__c FROM Suppliers__x ORDER BY CompanyName__c ASC LIMIT 26
Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=CompanyName& query $select=CompanyName,ContactName,SupplierID&$inlinecount=allpages&$top=26
$skip Specifies the number of items in the queried collection to skip in the result set.
Examples User action in Click to view the second page of a list view of supplier records that are ordered by city. Salesforce
SOQL query SELECT City__c,CompanyName__c FROM Suppliers__x ORDER BY City__c ASC OFFSET 25
Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=City& query $select=City,CompanyName,SupplierID&$inlinecount=allpages&$top=25& $skip=25
$top Specifies the number of items in the queried collection to include in the result. The value in the LIMIT clause of a SOQL query doesn’t always match the requested $top value, because the latter is modified as needed for client-driven paging and queryMore() calls.
Examples User action in Open a list view of the top 25 supplier records. Salesforce
SOQL query SELECT SupplierID__c FROM Suppliers__x LIMIT 25
Resulting OData http://services.example.org/my.svc/Suppliers?$select=SupplierID& query $inlinecount=allpages&$top=25
OData 2.0 Query Options By default, the search query string is used as the substringof value in the $filter system query option.
906 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 4.0 Query Options By default, the search query string is used as the contains value in the $filter system query option.
SEE ALSO: OData Producer Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters
OData 2.0 Query Options
By default, the search query string is used as the substringof value in the $filter system EDITIONS query option. In this example, the search query string is Acme. Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience (not for high-data-volume external objects)
Available in: Developer Edition Available for an extra cost in: Enterprise, Performance, and Unlimited Editions
http://services.example.org/my.svc/Shippers? $select=CompanyName,Phone,ShipperID&$inlinecount=allpages& $filter=substringof('Acme',CompanyName)+eq+true+ or+substringof('Acme',Phone)+eq+true&$top=25
OData 2.0 Custom Query Option We recommend that you set up the OData producer to support free text search expressions with the custom query option. You can then specify the name of the query string parameter in the Custom Query Option for Salesforce Search field on the external data source. In this example, the custom query parameter is doSearch and the search query string is Acme.
http://services.example.org/my.svc/Shippers? $select=CompanyName,Phone,ShipperID& $inlinecount=allpages&doSearch=Acme&$top=25
Learn more about OData URI conventions at www.odata.org.
907 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 4.0 Query Options
By default, the search query string is used as the contains value in the $filter system query EDITIONS option. In the following example, the search query string is Acme. Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience (not for high-data-volume external objects)
Available in: Developer Edition Available for an extra cost in: Enterprise, Performance, and Unlimited Editions
http://services.example.org/v4.svc/Shippers? $select=CompanyName,Phone,ShipperID&$count=true& $filter=contains(CompanyName,'Acme') eq true or contains(Phone,'Acme') eq true$top=25&
OData 4.0 Custom Query Option We recommend that you set up the OData producer to support free text search expressions with the $search system query option. You can then select Use Free-Text Search Expressions on the external data source.
http://services.example.org/v4.svc/Shippers? $select=CompanyName,Phone,ShipperID&$count=true& $search=Acme&$top=25
Learn more about OData URI conventions at www.odata.org.
Use External Change Data Capture to Track Data Changes on External Objects With External Change Data Capture, you can track changes to data that is stored outside your Salesforce org when using the Odata 4.0 adapter. You can then build automation in response to the changes to increase productivity or provide a better customer experience. The external data change tracking feature polls the external system at configurable intervals (5–30 minutes) for tracked changes. For each external object that has the feature enabled, a topic channel and an associate change event entity are created where change event notifications are published. You add a subscriber to each topic channel and then process the data changes through Streaming API. You can also add an Apex trigger that is called when change event notifications are published.
External Change Data Capture Considerations Keep these considerations in mind when working with External Change Data Capture. Enable External Change Data Capture and Tracking Enable external change data capture for the data source and each external object that you want to monitor.
908 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Subscribe to Change Events You can use Apex triggers to subscribe to change events. Or you can use a Bayeux client to subscribe to Streaming API on the publication channel. Check the External Change Data Capture Status for an External Object You can quickly check the change-tracking status from an external object’s detail page. More detailed monitoring is also available. Change the Polling Interval for External Change Data Capture By default, the external change data capture feature polls the external system every 30 minutes for tracked changes. You can change the interval to poll the external system as frequently as every 5 minutes. Monitor and Troubleshoot External Change Data Capture Check these tips when troubleshooting change tracking on external objects. Example: How Codey Outfitters Uses External Change Data Capture The fictitious company, Codey Outfitters, distributes outdoor equipment from local small businesses to outdoor enthusiasts around the world. The company handles all logistics, such as complying with import laws for each state and country.
External Change Data Capture Considerations Keep these considerations in mind when working with External Change Data Capture. • Each polling request counts toward your Salesforce org’s OData callout rate allocation. • OData doesn’t differentiate between created and updated change events. Both events are published with update change type. • When you enable change tracking, a $top=0 query for zero rows is sent to the external data source to tell it to track changes, and a delta link is returned. • If an error occurs, Salesforce stops sending polling requests. You can check for an error status by querying the BackgroundOperation object or viewing the latest error on the object’s setup page. • If you create an Apex trigger to respond to change events, these requirements and behaviors apply. – Create the Apex trigger with development tools, such as the Developer Console or Metadata API or Salesforce UI. You can’t create the trigger from the Salesforce UI. – Because the Apex trigger runs after an event occurs, only the after-insert trigger event is supported. – The trigger passes the associated change event, not the object that caused the change. – Changed records can be committed in the same transaction that started the trigger. However, keep in mind that this transaction is separate from the transaction that created the original event.
Enable External Change Data Capture and Tracking
Enable external change data capture for the data source and each external object that you want USER PERMISSIONS to monitor. 1. From Setup, enter External Data Sources in the Quick Find box, then select External To create or edit external Data Sources. objects: • Customize Application 2. Click Edit, and select Eligible for External Change Data Capture. 3. Click Save. 4. From the External Objects list , select the external object that you want to track. 5. Click Edit, and select Track Data Changes. 6. Click Save.
909 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
After you enable change tracking, a publication channel is created under the topic for the external object. For example, /data/Object Name__ChangeEvents appears as /data/Products__ChangeEvents, where Product is the object name.
Subscribe to Change Events You can use Apex triggers to subscribe to change events. Or you can use a Bayeux client to subscribe to Streaming API on the publication channel. After subscribing, you can observe change event notifications when you perform a DML operation on an external object. You can also see change events on the tracked data stored on the external system.
Check the External Change Data Capture Status for an External Object
You can quickly check the change-tracking status from an external object’s detail page. More USER PERMISSIONS detailed monitoring is also available. 1. From Setup, enter External Objects in the Quick Find box, then select External Objects. To create or edit external objects: 2. Click the label of the external object. • Customize Application The External Change Data Capture Status field shows one of the following statuses. • Disabled—Either the data source or the external object doesn’t have external change data capture enabled. • Error—External change data capture encountered an error in the last poll for changes and stopped. After resolving the error, restart external change data capture. • Running—External change data capture is running and polls the external system in the configured time interval for changes. • Stopped—External change data capture is not scheduled to poll for changes.
Change the Polling Interval for External Change Data Capture By default, the external change data capture feature polls the external system every 30 minutes for tracked changes. You can change the interval to poll the external system as frequently as every 5 minutes. 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. 2. Next to the name of the external data source, click Edit. 3. In the Polling Interval for External Change Data Capture field, enter the number of seconds between polling. 4. Click Save.
Monitor and Troubleshoot External Change Data Capture Check these tips when troubleshooting change tracking on external objects. • To check the status of external data change tracking, query the BackgroundOperation object. • Each BackgroundOperation record is available for inspection for one day. You can include the ExpiresAt field in your SOQL query of the BackgroundOperation object to check when the record expires. • Set up and view debug logs.
Example: How Codey Outfitters Uses External Change Data Capture The fictitious company, Codey Outfitters, distributes outdoor equipment from local small businesses to outdoor enthusiasts around the world. The company handles all logistics, such as complying with import laws for each state and country.
910 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Over the years, Codey Outfitters has acquired different IT systems to manage orders, shipments, inventory, and billing. It uses Salesforce CRM to manage its customer base and the suppliers whose items it sells. Codey Outfitters wants to provide customers with a one-stop shopping portal where they can see price changes on the gear. When the inventory is updated, Codey Outfitters wants the change notifications sent to its Salesforce org. Salesforce then performs business logic to determine whether the updates include price changes that are valuable to customers based on their order history. Customers can see or be notified about relevant deals on their Codey Outfitters portal. Let’s see how Codey Outfitters sets up and uses external change data capture to accomplish these goals.
Set Up the External Data Source and the External Object Codey Outfitters has an OData 4.0 service for its inventory. The company connects its Salesforce org to the inventory by creating an external data source called Gear Inventory and creating an external object called Products. Monitor External Change Data Capture With external change data capture enabled, Codey Outfitters’ org polls the external system every 30 minutes. To monitor the tracking status, it queries the BackgroundOperation object. Codey Outfitters prefers to run SOQL queries in the Query Editor of the Developer Console, but you can use your preferred tool. Subscribe to Changes with Streaming API When Codey Outfitters runs its Bayeux client, the client subscribes to Streaming API on the products publication channel. React to Changes with Apex Triggers To automate your business with external change events, use Apex triggers.
Set Up the External Data Source and the External Object Codey Outfitters has an OData 4.0 service for its inventory. The company connects its Salesforce org to the inventory by creating an external data source called Gear Inventory and creating an external object called Products. The Products external object provides the following data. • Name (product name) • UnitPrice (current price) • Stock (number of items in stock) • OrderLimit (limit for each order) To track changes, Codey Outfitters selects Eligible for External Change Data Capture for the Gear Inventory external data source. It then enables Track Data Changes on the Products external object.
Monitor External Change Data Capture With external change data capture enabled, Codey Outfitters’ org polls the external system every 30 minutes. To monitor the tracking status, it queries the BackgroundOperation object. Codey Outfitters prefers to run SOQL queries in the Query Editor of the Developer Console, but you can use your preferred tool. Here’s the SOQL query that Codey Outfitters uses to monitor the tracking status.
SELECT Id,Name,SubmittedAt,StartedAt,FinishedAt,ProcessAfter,Status FROM BackgroundOperation WHERE WorkerUri='v45.0/xds/data-changes'
In the query results, the first row shows the initial callout to the external system. The initial request tells the OData producer to start tracking changes on the Products__x object. In the second row, the org schedules the next callout to request the tracked changes. Notice that the callout is scheduled to occur after 30 minutes have passed.
911 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
ID Name Submitted Started Finished Process After Status
08Pxx0000000019EAA Products__x 2017-10-06T01:11:04.000Z 2017-10-06T01:11:08.000Z 2017-10-06T01:11:08.000Z Complete
08Pxx000000000qEAA Products__x 2017-10-06T01:11:08.000Z 2017-10-06T01:41:08.000Z Waiting
After waiting 30 minutes, querying the BackgroundOperation object shows that the second callout finishes, and the status is Complete. In the third row, a new change request is scheduled to run after 30 more minutes have passed.
ID Name Submitted Started Finished Process After Status 08Pxx0000000019EAA Products__x 2017-10-06T01:11:04.000Z 2017-10-06T01:11:08.000Z 2017-10-06T01:11:08.000Z Complete
08Pxx000000000qEAA Products__x 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:08.000Z Complete
08Pxx000000002MEAQ Products__x 2017-10-06T01:41:09.000Z 2017-10-06T02:11:09.000Z Waiting
Suppose that the Codey Outfitters inventory has a service outage, preventing the scheduled poll request from succeeding. Errors cause change tracking to stop, so querying the BackgroundOperation object shows the error status and no new rows.
ID Name Submitted Started Finished Process After Status 08Pxx0000000019EAA Products__x 2017-10-06T01:11:04.000Z 2017-10-06T01:11:08.000Z 2017-10-06T01:11:08.000Z Complete
08Pxx000000000qEAA Products__x 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z Complete
08Pxx000000002MEAQ Products__x 2017-10-06T01:41:09.000Z 2017-10-06T02:12:07.000Z 2017-10-06T02:12:07.000Z 2017-10-06T02:11:09.000Z Error
When query results show no rows in Waiting status, external change data capture is disabled. When the query results show an error, you can get error details by including the Error field in your SOQL query of the BackgroundOperation object. Here’s how Codey Outfitters investigates the error.
SELECT Error FROM BackgroundOperation WHERE Id=’08Pxx000000002MEAQ’
Because a service outage caused the problem, the error message says:
The external system is unreachable. Try again later, or contact your admin, who can verify the external data source settings and the external system's availability. Attempted to reach this URL: https://codey-outfitters.example.com/inventory/Products
Codey Outfitters fixes the service outage and restarts change tracking on the Products__x object.
Subscribe to Changes with Streaming API When Codey Outfitters runs its Bayeux client, the client subscribes to Streaming API on the products publication channel. Codey Outfitters uses a Visualforce page to show its customers updates to prices and inventory and new and discontinued outdoor gear. This sample source code for the Visualforce page is on Github, and you can modify it to work with your OData 4.0 producer. The heart of the subscription mechanism is in the _subscribeChannels method in src/js/channel/ServerConnection.js.
cometd.subscribe(channelName, function(event) { if (event && event.data && event.data.payload &&
912 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
event.data.payload.ChangeEventHeader) { var header = event.data.payload.ChangeEventHeader; var entityName = header.entityName; var recordId = header.recordIds[0]; var timestamp = header.commitTimestamp; var changeType = header.changeType;
switch (changeType) { case "UPDATE": // Update logic ... break; case "CREATE": // Create logic break; case "DELETE": // Delete logic break; } } }
The channelName for Codey Outfitters’ products is /data/Products__ChangeEvent. Each change event notification that’s published on the channel is in the Bayeux format and represents an updated record in the product inventory. The data.payload contains the change event data and includes a header that describes the nature of the change event. This sample event notification describes a change to a Codey Outfitters product record.
{ schema=”lswW55LyUCYeU7raSrmZ5A”, payload={ ChangeEventHeader={ commitUser=”005xx000001SvAn”, sequenceNumber=15, entityName=”Products__x”, changeType=”UPDATE”, changeOrigin=”Products?$deltaToken=3779”, transactionKey=”f158f145-a...”, commitTimestamp=1507759119826, recordIds=[“x03xx0000000008”] }, Name__c=”Camping Stove”, ExternalId=7801, UnitPrice__c=10.0, Stock__c=1500.0, OrderLimit__c=12.0, ProductId__c=7801.0 }, event={replayId=15} }
Each change event notification has this structure.
Field Description schema Versioned schema reference that defines the change event.
913 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description
payload Details about the change event. • ChangeEventHeader—Describes the nature of the data change event. • Record fields and values—The OData producer can also include fields that have no changed values. To see the current values, query the external object using the record ID in the change event header.
event The replay ID that refers to the position of the event notification in the event stream on a channel.
Each change event header contains these fields.
Field Description commitUser User who publishes the event.
sequenceNumber Change event sequence number. Each change occurs in the order in which it’s received.
entityName API name of the external object.
changeType Specifies whether a record was updated, created, or deleted.
changeOrigin Delta link that’s used to request the change. The OData producer calculates the delta token while executing the previous change request.
transactionKey Unique identifier for the transaction.
commitTimestamp Specifies when the change event notification is published in milliseconds since January 1, 1970.
recordIds Salesforce ID of the external object record that’s updated, created, or deleted. To see the current values of the record’s fields, query the external object using this record ID.
nulledFields List of fields set to null.
React to Changes with Apex Triggers To automate your business with external change events, use Apex triggers. Codey Outfitters can customize Salesforce to send email or SMS notifications on items that are low on stock or have been updated to an attractive price. Gear and other items that are in high demand can be monitored for low stock and automatically ordered. Before customizing Salesforce, make sure that you’re tracking data changes on the external object that you want to track. To track items that are running low on stock, Codey Outfitters creates an Apex trigger named LowOnStock. Next, the company selects the trigger’s sObject and the change event that publishes changes for the external object Products__x: Products__ChangeEvent.
914 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Here’s an example of a simple rule that sends a notification when an item is low on stock.
trigger LowOnStock on Products__ChangeEvent (after insert) { // Get the change event’s product ID for added and updated products Set productIds = new Set(); for (Products__ChangeEvent event: Trigger.new) { if (event.ChangeEventHeader.getChangeType() != 'DELETE') { String productId = event.ChangeEventHeader.getRecordIds()[0]; productIds.add(productId); } } if (productIds.size() > 0) { ProductNotifications.notifyOnLowOnStockProductUpdates(productIds); } }
The product notifications class queries the external Product objects for the given changed product IDs and LowOnStock threshold value. Looking up the current Product records on the external system for qualifying products is a callout and is scheduled as an Apex future.
public class ProductNotifications { // Notify subscribers on product updates that are low on stock. // This method is run asynchronously as it is performing a callout to the external // system to get the latest product details @future (callout=true) public static void notifyOnLowOnStockProductUpdates(Set productIds) { // Look up the current stock threshold to filter the products with Integer productStockThreshold = ...; List lowOnStockProducts = getProductsLowOnStock(productIds, productStockThreshold); // Notify subscribers notifySubscribers(lowOnStockProducts, ‘These items are running out of stock. Act soon!’); }
// Get the external Product objects for each Product ID public static List getProductsLowOnStock(Set productIds, Integer productStockThreshold) { return [SELECT Id, ExternalId, Name__c, ProductId__c, Stock__c, UnitPrice__c FROM Products__x WHERE Stock__c < :productStockThreshold AND Stock__c > 0 AND Id IN :productIds]; }
// Notify subscribers by sending an email or SMS public static void notifySubscribers(String message, List products) { ... } }
You can discover the metadata for change events through the sObject describe API. For example, the sObject describe for Products__ChangeEvent shows the following standard change event fields.
915 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Type Description
Id String The change event’s Salesforce ID. This ID isn’t the Salesforce ID of the record that changed, but the event that carries the record’s changes.
ReplayId String The position of the event notification in the event stream on a channel.
ChangeEventHeader Complex Type The type of data change event.
Each change event object defines fields that hold the updated value at the time the record was updated. The OData producer can also include fields that haven’t changed. To see the current values, query the external object using the record ID in the change event header. The following table shows sample Products__x fields. Event change objects are tailored to their tracked external object. For a change event, not all fields are necessarily present.
Field Type Description Id String Product record’s Salesforce ID in your org
ExternalId String Product record’s external ID
DisplayUrl String URL representing the record in the external system
CreatedOn__c DateTime When the record was created in the external system
UpdatedOn__c DateTime When the record was last updated on the external system
Name__c String Product name in Product__x
OrderLimit__c Integer Number of items that can be ordered at a time
Stock__c Integer Number of items in stock
UnitPrice__c Decimal(8,2) Item’s unit price
The following fields are change event header complex type fields. To access ChangeEventHeader fields from Apex, use its getter method. For example, to access the field ChangeType, use eventObject.ChangeEventHeader.getChangeType().
Field Type Description commitUser String User who published the event.
sequenceNumber Integer Change event sequence number. Each change is listed in the order in which it’s received.
entityName String API name of the external object.
916 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Type Description
changeType ChangeType enum Specifies whether a record was updated, created, or deleted. The enum values for external change events are Create, Update, and Delete.
changeOrigin String Delta link that’s used to request the changes made since the previous or initial change request. The OData producer calculates the delta token while executing the previous change request.
transactionKey String Unique identifier for the transaction.
commitTimestamp Long Specifies when the change event notification is published in milliseconds since January 1, 1970.
recordIds Array of type String Salesforce ID of the external object record that is updated, created, or deleted. To see the current values of the record fields, query the external object using this record ID. This array always has exactly one Salesforce ID.
nulledFields Array of type String List of field names set to null.
Access External Data with a Custom Adapter for Salesforce Connect Connect your users to any data anywhere by developing your own custom adapter with the Apex Connector Framework.
Custom Adapter for Salesforce Connect Connect to any data anywhere for a complete view of your business. Use the Apex Connector Framework to develop a custom adapter for Salesforce Connect. Set Up Salesforce Connect to Access External Data with a Custom Adapter Let users view, search, and modify any data anywhere from within their Salesforce org. Considerations for Salesforce Connect—Custom Adapter Understand the special behaviors, limits, and recommendations for using a custom adapter for Salesforce Connect.
917 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Custom Adapter for Salesforce Connect
Connect to any data anywhere for a complete view of your business. Use the Apex Connector EDITIONS Framework to develop a custom adapter for Salesforce Connect. Your users and the Lightning Platform interact with the external data via external objects. For each Available in: both Salesforce of those interactions, Salesforce Connect invokes methods in the Apex classes that compose the Classic (not available in all custom adapter. Salesforce invokes the custom adapter’s Apex code each time that: orgs) and Lightning Experience (not for • A user clicks an external object tab for a list view. high-data-volume external • A user views a record detail page of an external object. objects) • A user views a record detail page of a parent object that displays a related list of child external Available in: Developer object records. Edition • A user performs a Salesforce global search. Available for an extra cost • A user creates, edits, or deletes an external object record. in: Enterprise, Performance, • A user runs a report. and Unlimited Editions • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. Apex code can access external objects, but some limitations and requirements apply. • To understand the limitations on Apex code accessing external objects, see Apex Considerations for Salesforce Connect External Objects. • To know how to use a custom adapter for Salesforce Connect, see Get Started with the Apex Connector Framework.
External IDs for External Objects in Salesforce Connect—Custom Adapter When you access external data with a custom adapter for Salesforce Connect, the values of the External ID standard field on an external object come from the DataSource.Column named ExternalId.
SEE ALSO: Salesforce Connect Set Up Salesforce Connect to Access External Data with a Custom Adapter Considerations for Salesforce Connect—Custom Adapter
918 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
External IDs for External Objects in Salesforce Connect—Custom Adapter
When you access external data with a custom adapter for Salesforce Connect, the values of the EDITIONS External ID standard field on an external object come from the DataSource.Column named ExternalId. Available in: both Salesforce Each external object has an External ID standard field. Its values uniquely identify each Classic (not available in all external object record in your org. When the external object is the parent in an external lookup orgs) and Lightning relationship, the External ID standard field is used to identify the child records. Experience (not for high-data-volume external Important: objects)
• The custom adapter’s Apex code must declare the DataSource.Column named Available in: Developer ExternalId and provide its values. Edition • Don’t use sensitive data as the values of the External ID standard field or fields designated Available for an extra cost as name fields, because Salesforce sometimes stores those values. in: Enterprise, Performance, – External lookup relationship fields on child records store and display the External ID and Unlimited Editions values of the parent records. – For internal use only, Salesforce stores the External ID value of each row that’s retrieved from the external system. This behavior doesn’t apply to external objects that are associated with high-data-volume external data sources.
Example: This excerpt from a sample DataSource.Connection class shows the DataSource.Column named ExternalId.
override global List sync() { List tables = new List(); List columns; columns = new List(); columns.add(DataSource.Column.text('title', 255)); columns.add(DataSource.Column.text('description',255)); columns.add(DataSource.Column.text('createdDate',255)); columns.add(DataSource.Column.text('modifiedDate',255)); columns.add(DataSource.Column.url('selfLink')); columns.add(DataSource.Column.url('DisplayUrl')); columns.add(DataSource.Column.text('ExternalId',255)); tables.add(DataSource.Table.get('googleDrive','title', columns)); return tables; }
SEE ALSO: Custom Adapter for Salesforce Connect Apex Developer Guide
919 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Set Up Salesforce Connect to Access External Data with a Custom Adapter
USER PERMISSIONS EDITIONS
To create Apex classes: Author Apex Available in: both Salesforce Classic (not available in all To configure remote settings: Modify All Data orgs) and Lightning To create and edit external data sources: Customize Application Experience (not for high-data-volume external To create and edit external objects: Customize Application objects)
To define or change object-level help: Customize Application Available in: Developer To create and edit custom fields: Customize Application Edition Available for an extra cost To edit permission sets and user profiles: Manage Profiles and Permission Sets in: Enterprise, Performance, To edit another user’s authentication settings Manage Users and Unlimited Editions for external systems:
Let users view, search, and modify any data anywhere from within their Salesforce org. Setting up Salesforce Connect with a custom adapter involves these high-level steps. 1. Develop the custom adapter for Salesforce Connect. Using the Apex Connector Framework, create the DataSource.Connection and DataSource.Provider classes that comprise the custom adapter.
2. Define remote sites for Apex callouts. If the custom adapter involves any Apex callouts, define each callout endpoint as a remote site in your organization. However, you don’t need to define a remote site for a callout whose endpoint is specified as a named credential instead of a URL.
3. Define an external data source of type Salesforce Connect: Custom. If you created multiple custom adapters, make sure that the external data source’s Type field specifies the correct DataSource.Provider class.
4. Create the external objects. Perform this task only if you don’t sync to automatically create the external objects. Create an external object for each external data table that you want to access from your Salesforce org.
5. Create help content for the external objects. Create Visualforce pages that describe the external data. When your users click Help for this Page on an external object, they read your custom help content. Remember, your users can’t find information about the external data in Salesforce Help.
6. Add custom fields and relationships to the external objects. Create relationships between objects. If you didn’t sync to automatically create the external objects and their fields, create a custom field for each external table column that you want to access from your Salesforce org.
7. Verify access to external object data. Check that expected user and code interactions with the external objects work, including sorting and filtering search and query results.
920 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Tip: After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results.
8. Enable user access to external objects. Grant object permissions through permission sets or profiles.
9. Enable user access to the fields on the external objects. Grant field permissions through permission sets or profiles.
10. If the external data source uses per-user authentication: a. Let users authenticate to the external system. Grant users access to authentication settings for the external data source through permission sets or profiles.
b. Set up each user’s authentication settings. You or your users can perform this task.
Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for each external system. If you’re using OAuth 2.0, test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes.
SEE ALSO: Custom Adapter for Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Developer Guide: Visualforce Developer's Guide External Object Relationships
Define an External Data Source for Salesforce Connect—Custom Adapter
Connect your Salesforce org to any data anywhere via a Salesforce Connect custom adapter that EDITIONS you create with the Apex Connector Framework. Before you begin, develop the custom adapter for Salesforce Connect. If the custom adapter uses Available in: both Salesforce Apex callouts, also define remote sites for the callout endpoints. See Set Up Salesforce Connect to Classic and Lightning Access External Data with a Custom Adapter on page 920. Experience 1. From Setup, enter External Data Sources in the Quick Find box, then select Available in: Developer External Data Sources. Edition 2. Click New External Data Source, or click Edit to modify an existing external data source. Available for an extra cost in: Enterprise, Performance, 3. Complete the fields. and Unlimited Editions
Field Description Label A user-friendly name for the external data source. The label is displayed USER PERMISSIONS in the Salesforce user interface, such as in list views. To create and edit external If you set Identity Type to Per User, this label appears when data sources: your users view or edit their authentication settings for external • Customize Application systems.
921 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description Name A unique identifier that’s used to refer to this external data source definition through the API. The name can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
Type Select Salesforce Connect: Custom—. If you change and save a DataSource.Connection class, resave the corresponding DataSource.Provider class. Otherwise, when you define the external data source, the custom adapter doesn’t appear as an option for the Type field.
URL URL of the external system. Available only when the DataSource.Provider class declares the REQUIRE_ENDPOINT capability. If the class also declares the REQUIRE_HTTPS capability, the URL must begin with https://. If the endpoint is defined in a named credential, enter the named credential URL. A named credential URL contains the scheme callout:, the name of the named credential, and an optional path. For example: callout:My_Named_Credential/some_path. You can append a query string to a named credential URL. Use a question mark (?) as the separator between the named credential URL and the query string. For example: callout:My_Named_Credential/some_path?format=json.
Writable External Lets the Lightning platform and users in this org create, update, and delete records for external Objects objects associated with the external data source. The external object data is stored outside the org. By default, external objects are read only.
High Data Volume Salesforce enforces rate limits for retrieving and viewing data from external systems. If your org hits rate limits when accessing external objects, consider selecting the High Data Volume option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. See High Data Volume Considerations for Salesforce Connect—Custom Adapters on page 926.
Certificate If you specify a certificate, your Salesforce org supplies it when establishing each two-way SSL connection with the external system. The certificate is used for digital signatures, which verify that requests are coming from your Salesforce org. Available only when the DataSource.Provider class declares the CERTIFICATE authentication capability.
Identity Type Determines whether you're using one set or multiple sets of credentials to access the external system. See Identity Type for External Data Sources on page 857. Available only when the DataSource.Provider class declares the BASIC or OAUTH authentication capability.
4. Select the authentication protocol. • If you select Password Authentication, enter the username and password for accessing the external system.
922 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Password authentication is available only when the DataSource.Provider class declares the BASIC authentication capability.
• If you select OAuth 2.0, complete the following fields. OAuth 2.0 is available only when the DataSource.Provider class declares the OAUTH authentication capability.
Field Description Authentication Choose the provider. See Authentication Providers. Provider
Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter.
Note: – The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider. – Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen. – We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system.
Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status.
5. Click Save. 6. Click Validate and Sync, and confirm that the connection is successful. This step also invokes the sync() method on the DataSource.Connection class to obtain the list of tables that you can sync to create external objects and their fields.
7. Optionally, select tables and click Sync to do the following for each selected table. • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type.
Note: Before you sync, make sure that you understand the considerations that are described in these topics. • Sync an External Data Source for Salesforce Connect on page 858 • Sync Considerations for Salesforce Connect—Custom Adapter on page 927
923 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
You can instead choose to manually create the external objects and custom fields that map to the external data. Doing so lets you customize the external object names, decide which table columns to create custom fields for, and customize the custom field names. However, this approach takes longer and requires manual maintenance.
SEE ALSO: Set Up Salesforce Connect to Access External Data with a Custom Adapter Store Authentication Settings for External Systems Named Credentials
Considerations for Salesforce Connect—Custom Adapter
Understand the special behaviors, limits, and recommendations for using a custom adapter for EDITIONS Salesforce Connect. Also review the considerations that apply to all Salesforce Connect adapters. Available in: both Salesforce Classic (not available in all orgs) and Lightning Apex Connector Framework Considerations for Salesforce Connect—Custom Adapter Experience (not for Understand the limits and considerations for creating Salesforce Connect custom adapters with high-data-volume external the Apex Connector Framework. objects) High Data Volume Considerations for Salesforce Connect—Custom Adapters Available in: Developer If your org hits rate limits when accessing external objects, consider selecting the High Data Edition Volume option on the associated external data sources. Doing so bypasses most rate limits, Available for an extra cost but some special behaviors and limitations apply. in: Enterprise, Performance, Writable External Objects Considerations for Salesforce Connect—Custom Adapters and Unlimited Editions Some special behaviors and limitations affect writable external objects that are associated with custom adapters for Salesforce Connect. Sync Considerations for Salesforce Connect—Custom Adapter When you validate and sync an external data source of type Salesforce Connect: Custom, some special behaviors and limitations apply.
SEE ALSO: Salesforce Platform Features Supported by Salesforce Connect
924 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Apex Connector Framework Considerations for Salesforce Connect—Custom Adapter
Understand the limits and considerations for creating Salesforce Connect custom adapters with EDITIONS the Apex Connector Framework. • If you change and save a DataSource.Connection class, resave the corresponding Available in: both Salesforce DataSource.Provider class. Otherwise, when you define the external data source, the Classic (not available in all custom adapter doesn’t appear as an option for the Type field. Also, the associated external orgs) and Lightning objects’ custom tabs no longer appear in the Salesforce UI. Experience (not for high-data-volume external • DML operations aren’t allowed in the Apex code that comprises the custom adapter. objects) • Make sure that you understand the limits of the external system’s APIs. For example, some external systems accept only requests for up to 40 rows. Available in: Developer Edition • Apex data type limitations: Available for an extra cost – Double—The value loses precision beyond 18 significant digits. For higher precision, use in: Enterprise, Performance, decimals instead of doubles. and Unlimited Editions – String—If the length is greater than 255 characters, the string is mapped to a long text area field in Salesforce.
• Custom adapters for Salesforce Connect are subject to the same limitations as any other Apex code. For example: – All Apex governor limits apply. – Test methods don’t support web service callouts. Tests that perform web service callouts fail. For an example that shows how to avoid these failing tests by returning mock responses, see Google Drive™ Custom Adapter for Salesforce Connect.
• In Apex tests, use dynamic SOQL to query external objects. Tests that perform static SOQL queries of external objects fail.
SEE ALSO: Custom Adapter for Salesforce Connect External Objects in Salesforce Connect Apex Developer Guide: Primitive Data Types Apex Developer Guide: Execution Governors and Limits Apex Developer Guide: Callout Limits and Limitations Apex Developer Guide: Google Drive™ Custom Adapter for Salesforce Connect Apex Developer Guide: Dymamic SOQL
925 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
High Data Volume Considerations for Salesforce Connect—Custom Adapters
If your org hits rate limits when accessing external objects, consider selecting the High Data Volume EDITIONS option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. Available in: both Salesforce • The following features aren’t available for external objects that are associated with Classic (not available in all high-data-volume external data sources. orgs) and Lightning Experience (not for – Access via Lightning Experience high-data-volume external – Access via the Salesforce mobile app objects) – Appearance in Recent Items lists Available in: Developer – Record feeds Edition – Reports and dashboards Available for an extra cost – Writable external objects in: Enterprise, Performance, and Unlimited Editions • Salesforce IDs aren’t assigned to external object records that are associated with high-data-volume external data sources. • On record detail pages for external objects that are associated with high-data-volume external data sources, custom buttons, and links that call JavaScript aren’t supported. • Salesforce Console in Salesforce Classic doesn’t support external objects that are associated with high-data-volume external data sources.
SEE ALSO: Custom Adapter for Salesforce Connect Considerations for Salesforce Connect—Custom Adapter
Writable External Objects Considerations for Salesforce Connect—Custom Adapters
Some special behaviors and limitations affect writable external objects that are associated with EDITIONS custom adapters for Salesforce Connect. • Writable external objects aren’t available for high-data-volume external data sources. Available in: both Salesforce • Queued changes to the external data execute over time, so external object records that are Classic (not available in all read successively can contain different data. orgs) and Lightning Experience (not for Also review the considerations that apply to all Salesforce Connect adapters. high-data-volume external objects)
SEE ALSO: Available in: Developer Writable External Objects in Salesforce Connect Edition Custom Adapter for Salesforce Connect Available for an extra cost Apex Developer Guide : Writable External Objects in: Enterprise, Performance, and Unlimited Editions
926 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Sync Considerations for Salesforce Connect—Custom Adapter
When you validate and sync an external data source of type Salesforce Connect: Custom, EDITIONS some special behaviors and limitations apply. • Syncing always enables search on the external object when search is enabled on the external Available in: both Salesforce data source, and vice versa. For an external data source of type Salesforce Connect: Custom, Classic (not available in all search is enabled when the custom adapter’s DataSource.Provider class declares the orgs) and Lightning DataSource.Capability.SEARCH capability. Experience (not for high-data-volume external Important: When you select the tables to sync, determine whether check marks appear in objects) the Synced column. Available in: Developer If a Synced check mark appears, your org has an external object whose object name matches Edition the table name. If you select the table and click Sync: Available for an extra cost • The external object is overwritten. in: Enterprise, Performance, • Any custom field on the external object is overwritten if its API name (for example, and Unlimited Editions Email__c) associates it with a table column name (for example, Email). • Any other custom fields on the external object remain as they are, including: – Previously synced custom fields whose API names were changed by editing their Field Name values. – Manually added custom fields whose API names aren’t associated with table column names.
• Syncing always enables search on the external object when search is enabled on the external data source, and vice versa. For an external data source of type Salesforce Connect: Custom, search is enabled when the custom adapter’s DataSource.Provider class declares the DataSource.Capability.SEARCH capability. If no Synced check mark appears, and you sync the table, a new external object is created in your org. The new external object’s object name matches the table name. For example, suppose you change the table name in the custom adapter’s DataSource.Connection class to no longer match the object name of the external object. Syncing that table creates a new external object in Salesforce. We recommend that you change the object name of the existing external object to match the new table name in the DataSource.Connection class before you sync that table.
Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: Sync an External Data Source for Salesforce Connect Define an External Data Source for Salesforce Connect—Custom Adapter Custom Adapter for Salesforce Connect
Work with External Data Sources An external data source specifies how to access an external system. Salesforce Connect uses external data sources to access data that's stored outside your Salesforce organization. Files Connect uses external data sources to access third-party content systems. External data sources have associated external objects, which your users and the Lightning platform use to interact with the external data and content.
927 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Define External Data Sources Create external data sources to connect to content and data that is stored outside your Salesforce org. Validate and Sync an External Data Source After you configure an external data source, synchronize it to map its tables with external objects in your Salesforce org. The content and data of external objects appear in federated search, together with your Salesforce content and data. Define External Objects Tables in external systems map to external objects in Salesforce, combining all your data and content for users in your org. Validate External Object Connections After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results. Validator is available for external objects from Apex and Odata data sources. Grant Access to Authentication Settings for External Data Sources For external data sources that use per-user authentication, grant users access through permission sets and profiles. Doing so lets users set up and manage their own authentication settings for accessing the external system. Store Authentication Settings for External Systems You or your administrator can set up and manage your authentication settings for external systems. With valid authentication settings, you can access external systems from within your Salesforce org. External Object Relationships External objects support standard lookup relationships, which use the 18-character Salesforce record IDs to associate related records with each other. However, data that’s stored outside your Salesforce org often doesn’t contain those record IDs. Therefore, two special types of lookup relationships are available for external objects: external lookups and indirect lookups.
928 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Define External Data Sources
Create external data sources to connect to content and data that is stored outside your Salesforce EDITIONS org. 1. From Setup, enter External Data Sources in the Quick Find box, then select External Available in: both Salesforce Data Sources. Classic (not available in all orgs) and Lightning 2. Click New External Data Source. To modify an existing external data source, click Edit. Experience 3. Complete the steps for your type of external data source. Salesforce Connect is • Files Connect: Google Drive available in: Developer • Files Connect: SharePoint 2010 or 2013 Edition and for an extra cost • Files Connect: SharePoint Online or OneDrive for Business in: Enterprise, Performance, and Unlimited Editions • Files Connect: Box Files Connect for • Simple URL: Data from Another Web Domain cloud-based external data • Salesforce Connect: OData 2.0 sources is available in: • Salesforce Connect: OData 4.0 Professional, Enterprise, Performance, Unlimited, • Salesforce Connect: Cross-Org and Developer Editions • Salesforce Connect: Custom Federated Search is • Federated Search available in: Enterprise, Professional, Unlimited, and Developer Editions SEE ALSO: Salesforce Connect USER PERMISSIONS
To create and edit an external data source: • Customize Application
929 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Validate and Sync an External Data Source
After you configure an external data source, synchronize it to map its tables with external objects EDITIONS in your Salesforce org. The content and data of external objects appear in federated search, together with your Salesforce content and data. Available in: both Salesforce When you sync a large number of tables, you can select to execute the sync operation asynchronously Classic (not available in all as a background job and avoid connection timeout. You can view the list of sync operations orgs) and Lightning performed as background jobs in the corresponding External Data Source page. Experience
Note: Salesforce Connect is available in: Developer • Syncing creates or overwrites Salesforce external objects that map to the external system’s Edition and for an extra cost schema. Syncing doesn’t copy any data into your Salesforce org or write data from your in: Enterprise, Performance, org to the external system. and Unlimited Editions • Syncing is a one-time process. If the external system’s schema changes, the modifications Files Connect for aren’t automatically synced to your Salesforce org. To reflect the changes in the external cloud-based external data system, resync the objects. After resyncing, full field-level security to the external objects sources is available in: is granted to all users who have the same profile as the user who initiated the resync. Professional, Enterprise, • Each org can have up to 200 external objects. External objects don’t count toward the Performance, Unlimited, amount for custom objects. Syncing fails if it causes your org to exceed 200 external and Developer Editions objects. Federated Search is • For Salesforce Connect external data sources, make sure that you read and understand available in: Enterprise, the sync considerations. See Sync an External Data Source for Salesforce Connect on page Professional, Unlimited, 858. and Developer Editions
1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. USER PERMISSIONS
2. Click the name of the external data source. To create an external object 3. Click Validate and Sync, and confirm that the connection is successful. from an external data source: 4. Select tables and click Sync to do the following for each selected table. • Customize Application • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type.
Example: The resulting external data source detail page will include a list of related external objects like this.
930 Extend Salesforce with Clicks, Not Code Work with External Data Sources
SEE ALSO: Salesforce Connect
Define External Objects
Tables in external systems map to external objects in Salesforce, combining all your data and content EDITIONS for users in your org. External objects are similar to custom objects, except that they map to data that’s stored outside Available in: both Salesforce your Salesforce org. Each external object relies on an external data source definition to connect Classic (not available in all with the external system’s data. Each external object definition maps to a data table on the external orgs) and Lightning system. Each of the external object’s fields maps to a table column on the external system. External Experience objects enable your users and the Lightning Platform to search and interact with the external data. Salesforce Connect is Note: available in: Developer Edition and for an extra cost • Each org can have up to 200 external objects. External objects don’t count toward the in: Enterprise, Performance, amount for custom objects. and Unlimited Editions • If the external system allows it, we recommend that you sync the external data source to Files Connect for automatically create related external objects. You can instead choose to manually define cloud-based external data external objects to customize the external object names and manually create the custom sources is available in: fields. Professional, Enterprise, Performance, Unlimited, To create or modify an external object: and Developer Editions 1. From Setup, enter External Objects in the Quick Find box, then select External Objects. Federated Search is 2. Click New External Object, or click Edit to modify an existing external object. available in: Enterprise, Professional, Unlimited, 3. Enter the following: and Developer Editions
Field Description Label A user-friendly name for the external object. The label is displayed in USER PERMISSIONS the Salesforce user interface, such as in list views. To create or edit external We recommend that you make object labels unique across all objects: standard, custom, and external objects in the org. • Customize Application
Plural Label The plural name of the external object. If you create a tab for this object, this name is used for the tab.
Starts with If it’s appropriate for your org’s default language, select to precede vowel sound your label with “an” instead of “a” for any automated messages.
Object Name A unique identifier used to refer to this external object definition when using the API. Object names must be unique across all standard, custom, and external objects in the org. The Object Name field can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
931 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Field Description Description An optional description of the external object. A meaningful description helps you distinguish among your external objects when you view them in a list.
Context-Sensitive Defines what appears when users click Help for this Page from the external object record home Help Setting (overview) and detail pages, as well as list views and related lists. We recommend that you select Open a window using a Visualforce page to display custom help that you create for your users. See Object-Level Help in Salesforce Classic on page 94. If you instead keep the default value, your users only see Salesforce Help, which doesn’t provide any information about your external data. This setting doesn’t affect the Help & Training link at the top of each page, which always opens Salesforce Help.
Content Name Select the Visualforce page that best describes the data that’s provided by this external object. This field is available only when you select Open a window using a Visualforce page.
External Data Source The external data source definition that contains the connection details you want to use for this external object.
Table Name Table in the external system that the external object maps to. For SharePoint, the table name must match the related scope name.
Display URL Available only for Salesforce Connect. The external object’s Display URL standard field values Reference Field are automatically generated from the external system. For example, with the OData 2.0 adapter for Salesforce Connect, the value is based on the link href that’s defined on the OData producer. You can override the default values with the values of a custom field on the same external object. Select the field name, and make sure that the custom field’s values are valid URLs.
Allow Reports Available only for Salesforce Connect.
Deployment Status Indicates whether the external object is visible to other users.
Launch New Custom If selected, the custom tab wizard starts after you save the external object. Tab Wizard after saving this external object
Allow Search If search is also enabled on the external data source, selecting this option lets users find the external object’s records via SOSL and Salesforce global searches. By default, search is disabled for new external objects. However, you can validate and sync an external data source to automatically create external objects. Syncing always enables search on the external object when search is enabled on the external data source, and vice versa.
4. Click Save.
932 Extend Salesforce with Clicks, Not Code Work with External Data Sources
5. On the external object detail page, view and modify the external object’s custom fields and relationships, page layouts, field sets, search layouts, and buttons and links. • To create field mappings or add fields to an external object, click New on the Custom Fields & Relationships related list. • To assign different page layouts by user profile, click Page Layout Assignments.
Tip: After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results.
SEE ALSO: Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Set Up Salesforce Connect to Access External Data with a Custom Adapter Deployment Status for Custom Objects and External Objects
Validate External Object Connections
After you configure an external data source, run the validator tool on each external object to test EDITIONS and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results. Validator is available for external objects from Apex and Odata data sources. Available in: both Salesforce 1. From Setup, enter External Data Source in the Quick Find box, then select External Classic (not available in all Data Source. orgs) and Lightning Experience 2. Select the external data source that contains the external object you want to validate. 3. Next to the external object’s name, click Validate. Salesforce Connect is available in: Developer 4. Select each query type you want validator to run. Edition and for an extra cost 5. Click Run Queries. in: Enterprise, Performance, and Unlimited Editions The validator results are displayed. Queries that ran successfully are listed in the Passed Queries table. The Failed Queries table lists the unsuccessful queries with information to help with Files Connect for troubleshooting. Queries that weren’t run because a prerequisite query was unsuccessful are in the cloud-based external data sources is available in: Skipped Queries table. Professional, Enterprise, Performance, Unlimited, SEE ALSO: and Developer Editions Define External Objects Federated Search is available in: Enterprise, Professional, Unlimited, and Developer Editions
USER PERMISSIONS
To create or edit external objects: • Customize Application
933 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Grant Access to Authentication Settings for External Data Sources
For external data sources that use per-user authentication, grant users access through permission EDITIONS sets and profiles. Doing so lets users set up and manage their own authentication settings for accessing the external system. Available in: both Salesforce 1. From Setup, enter Permission Sets in the Quick Find box, then select Permission Sets Classic (not available in all or Profiles. orgs) and Lightning Experience 2. Click the name of the permission set or profile that you want to modify. 3. Do one of the following. Salesforce Connect is available in: Developer • For a permission set, or for a profile in the enhanced profile user interface, click External Edition and for an extra cost Data Source Access in the Apps section. Then click Edit. in: Enterprise, Performance, • For a profile in the original profile user interface, click Edit in the Enabled External Data and Unlimited Editions Source Access section. Files Connect for cloud-based external data 4. Add the data sources that you want to enable. sources is available in: 5. Click Save. Professional, Enterprise, Performance, Unlimited, and Developer Editions SEE ALSO: Federated Search is Store Authentication Settings for External Systems available in: Enterprise, Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Professional, Unlimited, Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter and Developer Editions Set Up Salesforce Connect to Access External Data with a Custom Adapter USER PERMISSIONS
To edit permission sets and user profiles: • Manage Profiles and Permission Sets
934 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Store Authentication Settings for External Systems
You or your administrator can set up and manage your authentication settings for external systems. EDITIONS With valid authentication settings, you can access external systems from within your Salesforce org.
Note: All credentials stored within the NamedCredential, ExternalDataSource, and Available in: both Salesforce ExternalDataUserAuth entities are encrypted under a framework that is consistent with other Classic and Lightning encryption frameworks on the platform. Salesforce encrypts your credentials by auto-creating Experience org-specific keys. Credentials encrypted using the previous encryption scheme were migrated Named credentials are to the new framework. available in: All Editions. Your administrator defines external systems in external data sources and named credentials. External Salesforce Connect is data sources specify how to access data or content that’s stored outside your Salesforce org. Named available in: Developer credentials specify callout endpoints, which receive Web service callouts from your org. Edition and for an extra cost in: Enterprise, Performance, Before you begin, your administrator: and Unlimited Editions. • Sets up the external data source or named credential to use per-user authentication. Files Connect for • Grants you access to the external data source or named credential. cloud-based external data • Verifies that your org can connect to the external system. sources is available in: Professional, Enterprise, • Tells you the authentication settings to enter. Performance, Unlimited, • Sets up the community, if applicable, by using the Salesforce Tabs + Visualforce template. and Developer Editions If the community is built with the Customer Service template, only your administrator can set up and manage your authentication settings for external systems. You can’t complete these steps on your own. USER PERMISSIONS
If you don’t see the expected settings or options, contact your administrator. To store authentication settings for an external data 1. Access your authentication settings for external systems in one of the following ways. source: From within a community: • The data source enabled under External • If you have a community license, click My Settings > Authentication Settings for External Data Source Access Systems. To store authentication • Otherwise, from your personal settings, enter Authentication, then select settings for a named Authentication Settings for External Systems credential: From Salesforce, go to your personal settings and enter Authentication in the Quick • The named credential enabled under Named Find box, then select Authentication Settings for External Systems. Credential Access 2. Click New or Edit. To edit another user’s authentication settings for 3. Complete the fields. external systems: • Manage Users Field Description External If you’re not sure which option to select, ask your administrator. System • External Data Source: Provides access to external objects, whose Definition data is stored outside your Salesforce organization. • Named Credential: Enables your actions to trigger authenticated callouts to the endpoint that’s specified in the named credential. A named credential can handle the authentication for an external data source. In this scenario, your administrator instructs you to select Named Credential in this field to access external objects.
935 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Field Description External Data Source Which field appears depends on what’s selected for External System Definition. or If you’re not sure which option to select, ask your administrator. Your administrator can change Named Credential the option labels to make them more relevant or easier to distinguish from each other.
User Available only to administrators. Select the user whose authentication settings you’re entering.
4. Select the authentication protocol that’s required by the external system. If you’re not sure which option to select, ask your administrator. • If you select Password Authentication, enter your username and password for the external system. • If you select OAuth 2.0, complete the following fields.
Field Description Authentication If you’re not sure which option to select, ask your administrator. Your administrator can change Provider the option labels to make them more relevant or easier to distinguish from each other.
Scope If you’re not sure what to enter, ask your administrator. Specifies the scope of permissions to request for the access token.
Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status.
5. Click Save.
SEE ALSO: Define External Data Sources Grant Access to Authentication Settings for External Data Sources Define a Named Credential Grant Access to Authentication Settings for Named Credentials Add Tabs to Your Salesforce Tabs + Visualforce Site Personalize Your Salesforce Experience
936 Extend Salesforce with Clicks, Not Code Work with External Data Sources
External Object Relationships
External objects support standard lookup relationships, which use the 18-character Salesforce record EDITIONS IDs to associate related records with each other. However, data that’s stored outside your Salesforce org often doesn’t contain those record IDs. Therefore, two special types of lookup relationships are Available in: both Salesforce available for external objects: external lookups and indirect lookups. Classic (not available in all External lookups and indirect lookups compare a specific field’s values on the parent object to the orgs) and Lightning relationship field’s values on the child object. When values match, the records are related to each Experience other. Salesforce Connect is To create an external object relationship, create a custom field on the child object with one of the available in: Developer following field types. If the child is an external object, you can instead change the field type of an Edition and for an extra cost existing custom field to one of the following. in: Enterprise, Performance, and Unlimited Editions • Lookup Relationship Files Connect for • External Lookup Relationship cloud-based external data • Indirect Lookup Relationship sources is available in: This table summarizes the types of relationships that are available to external objects. Professional, Enterprise, Performance, Unlimited, Note: Federated Search supports only external lookup relationships, and the Federated and Developer Editions Search external object is always the parent. Federated Search is available in: Enterprise, Relationship Allowed Child Allowed Parent Parent Field for Matching Professional, Unlimited, Objects Objects Records and Developer Editions Lookup Standard Standard The 18-character Salesforce Custom Custom record ID External
External lookup Standard External The External ID standard field Custom External
Indirect lookup External Standard You select a custom field with Custom the External ID and Unique attributes
Lookup Relationship Fields on External Objects Use a lookup relationship when the external data includes a column that identifies related Salesforce records by their 18-character IDs. External Lookup Relationship Fields on External Objects Use an external lookup relationship when the parent is an external object.
937 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Indirect Lookup Relationship Fields on External Objects Use an indirect lookup relationship when the external data doesn’t include Salesforce record IDs.
SEE ALSO: Create Custom Fields Change the Custom Field Type Relationships on External Objects Include a Files Connect Data Source in Global Search Object Relationships Overview
Lookup Relationship Fields on External Objects
Use a lookup relationship when the external data includes a column that identifies related Salesforce EDITIONS records by their 18-character IDs. A lookup relationship field links a child standard, custom, or external object to a parent standard Available in: both Salesforce or custom object. A user who’s editing a child record can click the field’s lookup icon to select a Classic (not available in all specific parent record, and a user who’s viewing a parent record can view a related list of child orgs) and Lightning records. Experience When you create a lookup relationship field on an external object, enter the External Column Name Salesforce Connect is that contains the 18-character Salesforce IDs for identifying the parent records. available in: Developer Edition and for an extra cost Example: in: Enterprise, Performance, • Account record (parent standard object) displays a related list of external SAP sales orders and Unlimited Editions (child external object). Files Connect for • Account record (parent standard object) displays a related list of support cases (child cloud-based external data standard object). sources is available in: Professional, Enterprise, Performance, Unlimited, SEE ALSO: and Developer Editions External Object Relationships Federated Search is Create Custom Fields available in: Enterprise, Professional, Unlimited, Relationships on External Objects and Developer Editions Include a Files Connect Data Source in Global Search
938 Extend Salesforce with Clicks, Not Code Work with External Data Sources
External Lookup Relationship Fields on External Objects
Use an external lookup relationship when the parent is an external object. EDITIONS An external lookup relationship links a child standard, custom, or external object to a parent external object. Available in: both Salesforce Classic (not available in all The values of the standard External ID field on the parent external object are matched against the orgs) and Lightning values of the external lookup relationship field. For a child external object, the values of the external Experience lookup relationship field come from the specified External Column Name. When you sync two external system tables with a lookup relationship field, an external lookup Salesforce Connect is available in: Developer relationship for the mapped external objects is automatically created. This auto mapping happens Edition and for an extra cost only if in: Enterprise, Performance, • The parent and child objects are synced from the same data source. and Unlimited Editions • The parent object is already synced or the parent and child objects are in the same sync Files Connect for operation. cloud-based external data Creating an external lookup relationship on the external object for a lookup relationship on a table sources is available in: is supported by Cross Org, OData 4.0, and Custom Apex adapters. For the OData2.0 adapter, it’s Professional, Enterprise, supported only in the default Olingo library and not supported in OData4J. Performance, Unlimited, and Developer Editions Example: Federated Search is • External product catalog item (parent external object) displays a related list of support available in: Enterprise, cases (child standard object). Professional, Unlimited, and Developer Editions • External customer (parent external object) displays a related list of external orders (child external object).
Example: For the cross-org adapter for Salesforce Connect, suppose that you store contacts and accounts in the provider org. From the subscriber org, you want to view each account’s related contacts. To do so, create an external lookup field on the subscriber org’s Contact external object. Link that external lookup field to the subscriber org’s Account external object. Then set up the page layouts for the Account external object to include a related list that displays the related Contact external object records.
Example: In this screenshot, a record detail page for the Business_Partner external object includes two related lists of child objects. This example shows how external lookup relationships and page layouts enable users to view related data from within and from outside their Salesforce org on a single page. • Account standard object (1) • Sales_Order external object (2)
939 Extend Salesforce with Clicks, Not Code Work with External Data Sources
SEE ALSO: External Object Relationships Create Custom Fields Change the Custom Field Type Relationships on External Objects Include a Files Connect Data Source in Global Search
940 Extend Salesforce with Clicks, Not Code Sync Data Between Salesforce and Heroku
Indirect Lookup Relationship Fields on External Objects
Use an indirect lookup relationship when the external data doesn’t include Salesforce record IDs. EDITIONS An indirect lookup relationship links a child external object to a parent standard or custom object. When you create an indirect lookup relationship field on an external object, you specify the parent Available in: both Salesforce object field and the child object field to match against each other. Classic (not available in all orgs) and Lightning Specifically, you select a custom unique, external ID field on the parent object to match against the Experience child’s indirect lookup relationship field, whose values are determined by the specified External Column Name. Salesforce Connect is available in: Developer If the external system uses case-sensitive values in the specified External Column Name, make sure Edition and for an extra cost that the parent object field is also case-sensitive. When you define the parent object’s custom field, in: Enterprise, Performance, select External ID, Unique, and Treat "ABC" and "abc" as different values (case sensitive). and Unlimited Editions Note: Only objects that have a custom field with the External ID and Unique Files Connect for attributes are available as parent objects in indirect lookup relationships. If you don't see the cloud-based external data desired object when you create an indirect lookup relationship field, add a custom unique, sources is available in: external ID field to that object. Professional, Enterprise, Performance, Unlimited, Example: and Developer Editions • Account record (parent standard object) displays a related list of SAP sales orders (child Federated Search is external object) with matching customer IDs that aren’t Salesforce IDs. available in: Enterprise, • Contact record (parent standard object) displays a related list of social media posts (child Professional, Unlimited, external object) with matching social media handles. and Developer Editions
SEE ALSO: External Object Relationships Create Custom Fields Change the Custom Field Type Relationships on External Objects Include a Files Connect Data Source in Global Search
Sync Data Between Salesforce and Heroku
Heroku Connect lets you sync data between Salesforce and Heroku Postgres. EDITIONS Using Heroku Connect with Heroku Postgres, you can build Heroku apps that interact with your Salesforce data using your favorite language, like Ruby, Node.js, Python, PHP, Java, Scala or Clojure Available in: Salesforce or web framework like Rails, Django, or Play. For more information, refer to the Heroku Connect Classic website and the Heroku Connect documentation on the Heroku Dev Center website. Available for: Developer, Enterprise, Performance, Organization Sync and Unlimited Editions This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable.
941 Extend Salesforce with Clicks, Not Code Build Your Own Salesforce App
Managing Organization Sync This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable. Actions in the Organization Sync Record Queue This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable.
Managing Organization Sync This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable.
Actions in the Organization Sync Record Queue This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable.
Build Your Own Salesforce App
An app is a collection of items that work together to serve a particular function. Salesforce apps EDITIONS come in two flavors: Classic and Lightning. Classic apps are created and managed in Salesforce Classic. Lightning apps are created and managed in Lightning Experience. You can customize both Available in: Salesforce types of app to match the way your users work. Classic (not available in all Classic apps are a collection of standard and custom tabs, including: orgs), Lightning Experience, and the Salesforce mobile • Most standard objects, including Home, the main Chatter feed, Groups, and People app • Your org’s custom objects Available in: Contact • Visualforce tabs Manager, Group, • Lightning component tabs Professional, Enterprise, • Canvas apps via Visualforce tabs Performance, Unlimited, and Developer Editions • Web tabs Lightning apps are a collection of items that include everything from the Classic apps list, plus Lightning page tabs, and utilities like Sales Dialer. In Lightning apps, you can customize the app’s USER PERMISSIONS logo and enhance its branding by customizing the color of the navigation bar. To view apps: You can also upgrade Classic apps to Lightning apps in Lightning Experience, but the two versions • View Setup and of the app must then be managed separately in their own environments. Configuration Salesforce provides standard apps such as Sales and Service. To manage apps: • Customize Application You can also build your own on-demand apps by grouping items into new custom apps. A custom app consists of a label, a description, and an ordered list of items, which often includes tabs. You can also add custom logos and branding to your custom apps. In Salesforce Classic, custom apps are listed in the Lightning Platform app menu, which is a dropdown list displayed at the top of every page.
942 Extend Salesforce with Clicks, Not Code Build Your Own Salesforce App
In Lightning Experience and the Salesforce mobile app, you can find your available custom apps in the App Launcher ( ). In Lightning Experience, to see all your available Salesforce apps and items, click View All.
When you choose an app, your screen changes to reflect the contents of that app. For example, if you switch from an app that contains Opportunities to another app that doesn’t, the Opportunities item disappears. In addition, the app might display a different default landing tab when selected. Apps are associated with profiles. Profiles control which tabs you can see or hide, as well as which apps are available to you.
943 Extend Salesforce with Clicks, Not Code App Tools
App Tools What is a Subtab App? An app is a group of tabs that work as a unit to provide application functionality. Similarly, a subtab app is a collection of tabs that appears on the Chatter profile page. A subtab app can include both default and custom tabs. Lightning Platform Home Page The Lightning Platform Home page contains options for building and managing applications. Configuring System Overview Messages
SEE ALSO: Create Custom Apps for Salesforce Classic Set the Default Sort Order for Apps Salesforce App Considerations
App Tools
The platform includes innovative point-and-click app-building tools that give you the power to EDITIONS customize Salesforce to meet the needs of your business. You can also build your own apps to share and store information that is important to you. You don’t need any programming knowledge to Available in: Salesforce use these tools. You can find them in Salesforce Classic Setup by selecting Create, and in Lightning Classic (not available in all Experience Setup by entering App in the Quick Find box to get started. orgs) and Lightning The platform also includes app building tools that require some programming knowledge. You can Experience find tools that require advanced programming knowledge in Salesforce Classic Setup by selecting Available in: Contact Develop, and in Lightning Experience Setup by entering Custom Code in the Quick Find Manager, Group, box. Professional, Enterprise, Performance, Unlimited, Create Apps in Salesforce Classic with App Quick Start Developer, and Database.com Editions App quick start is a fast way to create a basic Classic app in just one step. App Quick Start: Next Steps for Building and Managing Apps in Salesforce Classic After you've created a basic working app with app quick start in Salesforce Classic, build out the app with more objects and fields, define its access settings, and add users to share your app with them. Create Custom Apps for Salesforce Classic Create custom apps to give your Salesforce Classic users access to everything they need all in one place. Lightning Apps With apps in Lightning Experience, members of your org can work more efficiently by easily switching between apps. Users can open apps you’ve created from the App Launcher. What’s most important to sales reps? Accounts, events, and organizations. How about sales managers? Reports and dashboards make the top of the list. Lightning apps take things to another level past Classic apps by letting you brand your apps with a custom color, logo, and utility bar. Tips for Creating Apps in Lightning Experience It’s time for the fun part: deciding how to set up Lightning apps for your users. Here are some tips for planning Lightning apps for your org.
944 Extend Salesforce with Clicks, Not Code App Tools
Create Lightning Apps As in Salesforce Classic, you can create apps in Lightning Experience, but with even more bells and whistles. You can brand and customize Lightning apps to help your users work more efficiently. For example, you can create a Lightning app for your finance department that includes all important items (including tabs) that users need to complete common tasks. You can customize the navigation bar color, brand it with a logo, and make the app available in the App Launcher for the user profiles associated with the finance department. Customize Lightning Apps with the Lightning App Builder When you edit a Lightning app from the App Manager in Setup, you’re brought into the Lightning App Builder to manage the app’s settings. Update app branding, navigation, and other options, and manage the Lightning pages assigned to that app all in one place. Add a Utility Bar to Lightning Apps The utility bar is a specialized type of Lightning page that gives your users quick access to common productivity tools, like Notes and Recent Items. It appears as a fixed footer that users can access to open utilities in docked panels. Some utilities support pop-out, which lets them open in a new browser window. Lightning App Navigation Bar Items Most of the items that appear in the App Launcher can appear in a Lightning app navigation bar. To add items to an app’s navigation bar, you can use the Lightning app creation wizard, which lets you choose from a list of available items. Upgrade Classic Apps to Lightning Apps You can upgrade a Classic app to a Lightning app in Lightning Experience, enhancing it for your Lightning Experience users with a customized color, logo, utility bar, and more items like Lightning pages supported in the navigation bar. Salesforce App Considerations Keep these considerations in mind when working with apps in either Lightning Experience or Salesforce Classic.
Create Apps in Salesforce Classic with App Quick Start
App quick start is a fast way to create a basic Classic app in just one step. EDITIONS 1. From Setup, enter Apps in the Quick Find box, then select Apps, and click Quick Start. Alternatively, from the Lightning Platform Home page, click Add App under Getting Started, Available in: Salesforce or App Quick Start under Quick Links. Classic (not available in all orgs), Lightning Experience, 2. Enter the information needed for your app. and the Salesforce mobile app Field Name Description Available in: Contact App Label The app's name that appears in the Lightning Manager, Group, Platform app menu. The label can have a Professional, Enterprise, maximum of 40 characters, including spaces. Performance, Unlimited, Plural Label The plural name of the object. This name and Developer Editions appears on the tab. USER PERMISSIONS Singular Label A name used to refer to the object in any user interface pages. To create apps: Gender If it's appropriate for your org’s default • Customize Application language, specify the gender of the label. This AND field appears if the org-wide default language Manage Profiles and expects gender. Permission Sets
945 Extend Salesforce with Clicks, Not Code App Tools
Field Name Description Starts with a vowel sound If it's appropriate for your org’s default language, enable this option if your label should be preceded by “an” instead of “a”.
3. Click Create. 4. On the You’re All Set! page, click here to add new fields to your app. 5. To see your app as it will appear to users, click Go To My App. The app quick start: • Generates an app label and API name (a unique name that's used to refer to the object when using the Lightning Platform API). • Generates an object label and API name. • Generates a tab label, and associates the tab with the object. • Enables feed tracking for the object. Feed tracking lets people follow records of that object type and see Chatter feed updates. • Enables access to the app and tab in your user profile. Any users who have the “Modify All Data” permission can also access the object. • Generates a permission set that grants access to the new custom object. • Assigns the permission set to the user who creates the app.
Note: If you’re in a custom app, only the tabs included in the app appear and include the Create button.
After you've created an app, you can extend it with more components, specify access settings, and add users to your org.
SEE ALSO: App Quick Start: Next Steps for Building and Managing Apps in Salesforce Classic Salesforce App Considerations
946 Extend Salesforce with Clicks, Not Code App Tools
App Quick Start: Next Steps for Building and Managing Apps in Salesforce Classic
After you've created a basic working app with app quick start in Salesforce Classic, build out the EDITIONS app with more objects and fields, define its access settings, and add users to share your app with them. Available in: Salesforce 1. Build out your app with the basic components used in apps. Classic (not available in all orgs), Lightning Experience, • Create objects, which are custom database tables that allow you to store information specific and the Salesforce mobile to your app. app • Create tabs that are associated with the objects you've created. Available in: Contact • For each object, create fields to store the information that's important to your organization. Manager, Group, • Create validation rules, which verify that the data users enter meets the standards you Professional, Enterprise, specify before they save a record. Performance, Unlimited, For quick shortcuts to these tools, use the Lightning Platform quick access menu, which is and Developer Editions available from object list view pages and record detail pages. USER PERMISSIONS 2. Create user profiles or permission sets. These are collections of settings and permissions that determine what users can do in an app. To create objects, tabs, 3. Specify the types of access that users will have to the app. fields, and validation rules: • Customize Application a. Make your app visible using profiles or permission sets. To create users: b. Make your object tabs visible. • Manage Internal Users c. Set the object permissions for the objects you created. To create profiles and permission sets: 4. Add users to your organization. When adding users, be sure to assign them the appropriate • Manage Profiles and profiles or permission sets you created so they can access your app. Permission Sets
SEE ALSO: Create Apps in Salesforce Classic with App Quick Start Salesforce App Considerations
947 Extend Salesforce with Clicks, Not Code App Tools
Create Custom Apps for Salesforce Classic
Create custom apps to give your Salesforce Classic users access to everything they need all in one EDITIONS place. If you're new to custom apps, we recommend using Lightning Platform quick start to create an Available in: Salesforce app. With this tool, you can generate a basic working app in just one step. Classic (not available in all orgs), Lightning Experience, If you’ve already created the objects, tabs, and fields you need for your app, follow these steps. With and the Salesforce mobile this option, you create an app label and logo, add items to the app, and assign the app to profiles. app 1. From Setup, enter Apps in the Quick Find box, then select Apps. Available in: Contact 2. Click New. Manager, Group, 3. If the Salesforce console is available, select whether you want to define a custom app or a Professional, Enterprise, Salesforce console. Performance, Unlimited, and Developer Editions 4. Give the app a name and description. An app name can have a maximum of 40 characters, including spaces. USER PERMISSIONS 5. Optionally, brand your app by giving it a custom logo. 6. Select which items to include in the app. To view apps: • View Setup and 7. Optionally, set the default landing tab for your new app using the Default Landing Tab Configuration drop-down menu below the list of selected tabs. This determines the first tab a user sees when logging into this app. To manage apps: • Customize Application 8. Choose which profiles the app will be visible to. 9. Check the Default box to set the app as that profile’s default app, meaning that new users with the profile see this app the first time they log in. Profiles with limits are excluded from this list. 10. Click Save.
SEE ALSO: Build Your Own Salesforce App Salesforce App Considerations
Lightning Apps
With apps in Lightning Experience, members of your org can work more efficiently by easily switching EDITIONS between apps. Users can open apps you’ve created from the App Launcher. What’s most important to sales reps? Accounts, events, and organizations. How about sales managers? Reports and Available in: Lightning dashboards make the top of the list. Lightning apps take things to another level past Classic apps Experience by letting you brand your apps with a custom color, logo, and utility bar. Available in: Contact Lightning apps contain everything you expect from a custom app, such as custom and standard Manager, Group, objects, and custom tabs. But Lightning apps can also include Lightning page tabs and utilities like Professional, Enterprise, Lightning Voice. The navigation model of Lightning apps is optimized for efficiency, with actions Performance, Unlimited, on certain items like Opportunities in the navigation bar. You can even append navigation items and Developer Editions to a Lightning app that you found on AppExchange and installed from a managed package. Custom apps from Salesforce Classic automatically work in Lightning Experience and can be upgraded to Lightning apps. Classic apps appear in the list of apps in Setup alongside your Lightning apps, and are available from the App Launcher as long as their Show in Lightning Experience attribute is enabled.
948 Extend Salesforce with Clicks, Not Code App Tools
However, the reverse isn’t true for Lightning apps. Lightning apps aren’t available in Salesforce Classic. You can assign multiple user profiles to multiple apps. Also, you can assign as many user profiles to one app as you need to. For instance, you have several groups involved with inside sales. Assign all the groups to your inside sales app, and they all have access to it. To switch between apps, users can use the App Launcher. This makes it easy for users to switch contexts and still have access to the items, objects, and pages they need most. You can view all the apps in your org from the App Manager. In Lightning Experience Setup, enter App in the Quick Find box, then select App Manager.
SEE ALSO: Create Lightning Apps Upgrade Classic Apps to Lightning Apps Salesforce App Considerations
Tips for Creating Apps in Lightning Experience
It’s time for the fun part: deciding how to set up Lightning apps for your users. Here are some tips EDITIONS for planning Lightning apps for your org. The best time to create Lightning apps is when you’re rolling out Lightning Experience. So make Available in: Lightning creating Lightning apps a part of your rollout strategy. Check out the Trailhead module “Lightning Experience Experience Rollout” for many great ideas to help you make a smooth transition. Available in: Enterprise, Talk to your users. Ask them what their priorities are. Customizing tabs in apps gives you a unique Professional, Performance, opportunity to engage with your users. Each group of users has its own priorities. Find out which Unlimited, and Developer objects and items represent their highest priorities. Editions • Ask users to post feedback to a Chatter group. • Publish polls. • Schedule lunch sessions. Everyone likes a free lunch, and nearly everybody is happy to express their opinion. Create a master list of objects that everyone in your org wants. Then trim down the list for each group—sales reps, sales managers, execs, and so on. The menus for every user group share some common objects, like Home, Tasks, and Feed. Keep the high-priority items for each group at the top. Put low-priority items at the bottom, or remove them altogether. Users can always go to the App Launcher to get the items they use less often.
949 Extend Salesforce with Clicks, Not Code App Tools
Create Lightning Apps
As in Salesforce Classic, you can create apps in Lightning Experience, but with even more bells and EDITIONS whistles. You can brand and customize Lightning apps to help your users work more efficiently. For example, you can create a Lightning app for your finance department that includes all important Available in: Lightning items (including tabs) that users need to complete common tasks. You can customize the navigation Experience bar color, brand it with a logo, and make the app available in the App Launcher for the user profiles associated with the finance department. Available in: Contact Manager, Group, App 1. From the Home tab in Setup, enter in the Quick Find box, then select App Manager. Professional, Enterprise, 2. Click New Lightning App, and walk through the New Lightning App wizard. Performance, Unlimited, Here are some things you can do in the wizard: and Developer Editions • Give your app a name, set its primary color, and give it a logo. USER PERMISSIONS The app description displays alongside the icon in the App Launcher. Make sure that the description is meaningful to your users. To view apps: • View Setup and • Choose whether to override a custom theme’s brand image and navigation bar color with Configuration the brand image and color from the app. To manage apps: • Choose which type of navigation to use—standard or console. • Customize Application • Choose which form factors your app is available for. • Add a utility bar for common processes and tools, like Recent Items, Notes, Dialer, and Open CTI. • Customize which items appear in the app’s navigation bar.
Note: If you add more than 50 default navigation items to an app, your users can’t personalize the app’s navigation bar.
When organizing the navigation bar, the item at the top of the list becomes your app’s landing page on both desktop and mobile. The order of items in the navigation bar also determines the default objects shown in the Top Results page on the search results page. After the user interacts with the app for 15 days, Top Results reflects the user's most frequently used objects. If the user doesn’t have access or permissions to the app, Top Results includes the Account, Contact, Opportunity, Case, Lead, People (User), and Group objects until the user’s most frequently used objects are determined.
• Assign the app to user profiles.
SEE ALSO: Lightning Apps Create and Edit a Custom Lightning Console App Add a Utility Bar to Lightning Apps Salesforce App Considerations
950 Extend Salesforce with Clicks, Not Code App Tools
Customize Lightning Apps with the Lightning App Builder
When you edit a Lightning app from the App Manager in Setup, you’re brought into the Lightning EDITIONS App Builder to manage the app’s settings. Update app branding, navigation, and other options, and manage the Lightning pages assigned to that app all in one place. Lightning App Builder is 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager available in: both Salesforce Classic and Lightning 2. Click on a Lightning app’s row, and select Edit. Experience Here are some things you can do from the App Settings tab. Lightning apps are available • Change your app’s name, primary color, and logo. in: Lightning Experience • Override the org theme with your app’s brand image and nav bar color. Available in: Group, • Add a utility bar for common processes and tools, like Recent Items, Notes, Dialer, and Open Professional, Enterprise, CTI. Performance, Unlimited, • Manage which default items appear in the app’s navigation bar. and Developer Editions • Manage user profile assignments. On the Navigation Items tab, you can control which objects and other items—like Visualforce USER PERMISSIONS pages or Lightning components—are included in your app. To create a custom object by To manage apps, and to importing data from a spreadsheet, click Create at the top of the Available Items section. create and save Lightning 3. Click the Pages tab in the Lightning App Builder header to see all the active Lightning pages pages in the Lightning App Builder: assigned to the app, create pages, and open existing pages, even ones not associated with the • Customize Application app. To view apps, and to view Tip: If you create pages for your app, when finished, don’t forget to click Activation to Lightning pages in the make them active for your users and assign them to the app. Lightning App Builder: • View Setup and Configuration SEE ALSO: Lightning Apps Create Lightning Apps Lightning App Builder
951 Extend Salesforce with Clicks, Not Code App Tools
Add a Utility Bar to Lightning Apps
The utility bar is a specialized type of Lightning page that gives your users quick access to common EDITIONS productivity tools, like Notes and Recent Items. It appears as a fixed footer that users can access to open utilities in docked panels. Some utilities support pop-out, which lets them open in a new Available in: Lightning browser window. Experience Utilities harness the power of Lightning components. When you set up a utility bar, you select which Available in: Contact Lightning components to use as utilities. However, not all Lightning components can be utilities. Manager, Group, To be added to a utility bar, a Lightning component must implement the Professional, Enterprise, flexipage:availableForAllPageTypes interface. This interface also makes the Performance, Unlimited, component usable on all types of Lightning pages. To add a Lightning web component to the and Developer Editions utility bar, see Lightning Web Components Developer Guide: Configure a Component for the Utility Bar.
To create a background utility item, implement the lightning:backgroundUtilityItem USER PERMISSIONS interface. Background utility items are added the same way as normal utility items, but don’t appear in the utility bar. The icon appears next to background utility items on the utility item list. If you To view apps: have only background utility items in your utility bar, the utility bar doesn’t appear in your app. You • View Setup and need at least one non-background utility item in your utility bar for it to appear. Configuration You can add or edit a utility bar at any time. To manage apps: • Customize Application 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager. 2. To edit or add a utility bar to an existing app, click Edit in the dropdown menu next to your app. To create a Lightning app with a utility bar, click New Lightning App. 3. Click the Utility Items tab and add the utilities you want. Specify component and utility properties, like the height and width of the utility panel, and what label and icon to display in the utility bar. Some utilities have properties that can’t be changed.
Tip: A Lightning page region can contain up to 100 components. We recommend adding no more than 10 utilities, and that you keep the utility labels short and sweet. You want your users to quickly find the tools and processes they need most.
Example: Here’s a utility bar with the Recent Items and Notes utilities.
When creating a utility bar for your app, keep these things in mind:
952 Extend Salesforce with Clicks, Not Code App Tools
• Utility bars created using the Lightning App Wizard or in the Lightning App Builder can be assigned to only one Lightning app. However, utility bars created using the API can be assigned to multiple Lightning apps. • The utility bar doesn’t support Visualforce pages or components. • The utility bar doesn’t fully support the Chatter Publisher and Feed components. • The History utility works in Lightning console apps only. • The Omni-Channel utility works in the Lightning Service Console app only. • The default utility bar alignment matches the user’s language setting alignment. For example, English is read left to right. If you select Default and a user’s language is set to English, the utility bar appears at the bottom of the left side of the screen. If you select Mirrored, the utility bar appears at the bottom of the right side of the screen.
Using Pop-Out Utilities Utilities that support pop-out can be “popped out” of the utility bar and into their own separate child windows. To pop a utility out, click the icon. From there, you can pop the utility back into the utility bar with the icon, or close the utility. Pop-out utilities are the Lightning equivalent to multi-monitor components in Classic.
SEE ALSO: Customize Your Lightning Console App with Utilities Create Lightning Apps Salesforce Console Developer Guide: Using Background Utility Items Salesforce Console Developer Guide: Using Pop-Out Utilities
Using Pop-Out Utilities Utilities that support pop-out can be “popped out” of the utility bar and into their own separate child windows. To pop a utility out, click the icon. From there, you can pop the utility back into the utility bar with the icon, or close the utility. Pop-out utilities are the Lightning equivalent to multi-monitor components in Classic.
Note: Popping-out docked utility bar items isn't supported in Lightning Experience on iPad Safari.
Standard Utilities Pop-out is supported for these standard utilities. Standard utilities are utilities that are included with Salesforce. • Open CTI Softphone • History • Rich Text • Report Chart • Visualforce • Flow • List View • Recent Items • Chatter Feed • Chatter Publisher • Notes
953 Extend Salesforce with Clicks, Not Code App Tools
Custom Utilities Pop-out is available for custom utilities. To enable pop-out for custom utilities, activate the Utility Bar: Enable Pop-Out for Custom Utilities critical update. The critical update enables pop-out for all utilities in the “Custom” and “Custom – Managed” categories. Test your custom utilities in a sandbox environment before you enable the update.
Disabling Pop-Out If you don’t want your custom utility to be popped out, you can disable pop-out in two ways. Disabling Pop-Out within the Component Use the lightning:utilityItem interface in your component and set the supportsPopOut attribute to false to disable pop-out.
Disabling pop-out within the component itself is a useful and simple way to ensure that the component can never be popped out. Disabling Pop-Out with the Lightning Console JavaScript API Use the disableUtilityPopOut() method and set the disabled argument to true to disable utility pop-out. If you’re migrating from a Classic console app and using a Visualforce page for your utility, we automatically respect if setCustomConsoleComponentPopoutable is set to false. Disabling pop-out with the Lightning Console JavaScript API allows you to enable and disable pop-out in real time.
Lightning App Navigation Bar Items
Most of the items that appear in the App Launcher can appear in a Lightning app navigation bar. EDITIONS To add items to an app’s navigation bar, you can use the Lightning app creation wizard, which lets you choose from a list of available items. Available in: Lightning The list of available items contains only those items in your org that are eligible for Lightning app Experience navigation bars, which includes: Available in: Enterprise, • Most standard objects, including Home, the main Chatter feed, Groups, and People Professional, Performance, • Your org’s custom objects and apps Unlimited, and Developer Editions • Visualforce tabs • Lightning component tabs USER PERMISSIONS • Lightning page tabs • Canvas apps via Visualforce tabs To view navigation menus: • Web tabs • View Setup and Configuration If the Lightning app was installed from a managed package, you can append navigation items To create navigation menus: below the original set of navigation items included in the Lightning app, which are locked. • Customize Application Note: You can’t add Connected apps like Gmail™ and Microsoft® Office 365™ to the navigation bar. Users can continue to access them from the App Launcher.
954 Extend Salesforce with Clicks, Not Code App Tools
Upgrade Classic Apps to Lightning Apps
You can upgrade a Classic app to a Lightning app in Lightning Experience, enhancing it for your EDITIONS Lightning Experience users with a customized color, logo, utility bar, and more items like Lightning pages supported in the navigation bar. Available in: Lightning Note: You can’t upgrade a Salesforce Classic console app to Lightning Experience. You can Experience choose to display or hide the app in the Lightning Experience App Launcher, but you can’t Available in: Contact edit the app from the App Manager page in Lightning Experience Setup. To get started in Manager, Group, Lightning Experience, customize these Salesforce-provided Lightning console apps: Service Professional, Enterprise, Console and Sales Console. You can also recreate your Salesforce Classic console app in Performance, Unlimited, Lightning Experience, but using the Salesforce out-of-the-box app is faster and easier. and Developer Editions 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager. 2. Find the Classic app that you want to upgrade in the apps list. USER PERMISSIONS
Note: A checkmark in the Visible in Lightning Experience column means that the app To view apps: is accessible in Lightning Experience via the App Launcher and is fully functional. Even • View Setup and though a Classic app works in Lightning Experience, it doesn’t take advantage of all the Configuration benefits of being a Lightning app. That’s why we recommend that you upgrade it. To manage apps: • Customize Application 3. Click , and select Upgrade. 4. Review the app properties and update them if necessary. If you have custom Lightning Home pages assigned to profiles in your org, and the app you’re upgrading is visible in Lightning Experience, you see a checkbox that lets you apply those Home page profile assignments to the upgraded app. Selecting the checkbox ensures that users see the custom Home page assigned to their profile when they're working in the upgraded app, and that you can modify those Home page assignments if you need to.
5. Click Upgrade. Your Classic app is copied and upgraded for Lightning Experience. You now have two versions of the app: a Classic version, and a Lightning version. After you upgrade it, the Classic app is no longer accessible in Lightning Experience via the App Launcher. You still see the Classic app in the apps list, but with the Visible in Lightning column deselected. The two versions of your app now must be managed separately. Future changes you make to the Classic app won’t be reflected in the Lightning version of the app, and vice versa.
Note: You can toggle the availability of your Classic apps in Lightning Experience by selecting or deselecting Show in Lightning Experience on the Classic app’s detail page.
SEE ALSO: Lightning Apps Salesforce App Considerations
955 Extend Salesforce with Clicks, Not Code App Tools
Salesforce App Considerations
Keep these considerations in mind when working with apps in either Lightning Experience or EDITIONS Salesforce Classic. Available in: Salesforce General Classic (not available in all orgs), Lightning Experience, • You can delete custom apps, but not standard apps. Deleting a custom app removes it from and the Salesforce mobile the apps menu and the App Launcher, but doesn’t delete any associated objects. If you created app objects for an app, consider deleting them as well. Available in: Contact • Salesforce Classic console apps are custom apps. Manager, Group, • You can’t change an app’s type—such as standard to connected or vice versa—after you create Professional, Enterprise, it. Performance, Unlimited, • For Salesforce Platform and Salesforce Platform One license users, the Platform standard app and Developer Editions is the only app listed in the Lightning Platform app menu and the Lightning Experience App Launcher. For details about specifying a unique label for the Platform standard app in Salesforce Classic, see Create Custom Apps for Salesforce Classic on page 948. • To assign apps to user profiles in Professional Edition, you must have user profiles enabled for your org.
Classic Apps Consider these requirements when choosing a custom app logo for a Classic app from the document library: • The image must be in GIF or JPEG format and less than 20 KB. • If the image is larger than 300 pixels wide by 55 pixels high, then it is scaled to fit. • For the best on-screen display, we recommend that you use an image with a transparent background. • The Externally Available checkbox must be selected on the document’s properties so that users can view the image.
Lightning Apps • The number of Lightning Apps you can create in an org varies by edition.
Edition Lightning Apps Limit Professional Edition 10
Enterprise Edition 25
Unlimited Edition Unlimited
• A Lightning app’s description displays in the App Launcher, so we recommend that you keep the description concise. • Users can’t remove the items you include in the navigation bar, and they can’t personalize the navigation bar when it contains more than 50 items. For example, if you include 32 items in an app’s navigation bar, users can add 18 more personal items. • Consider these requirements when choosing a custom app image for apps in Lightning Experience: – App images represent your app in both Lightning Experience and the Salesforce app. – Choose a JPG, PNG, BMP, or GIF image that's smaller than 5 MB. – For best results, upload an image that's 128 by 128 pixels. Images larger than the maximum display of 128 by 128 pixels are automatically resized.
956 Extend Salesforce with Clicks, Not Code What is a Subtab App?
• Even if you haven’t selected the option to override themes in the App Manager, your app’s brand image and color always override the Lightning Lite and Lightning Blue themes. • If you restrict an app to one type of device, only users viewing the app on that device can access it. For example, if you assign your app to the Phone form factor, your desktop users don’t see the app in the App Launcher. Only your Salesforce mobile app users can see it. • Not all objects that appear in the App Launcher can appear in an app, but it’s easy to figure out which ones can. When you start the wizard from the Lightning Experience App Manager, you see all available items for a navigation bar. • Navigation items in a Lightning app installed from a managed package are locked. You can’t remove or reorder them. However, you can append other navigation items so that they’re accessible in the Lightning app. • You can create records and access recent records and lists for certain items directly from the navigation bar. Items with next to their name support this feature, with a few exceptions. Tasks and Notes allow you to create a record but you can't access recent records or lists. Reports and Dashboards allow you to see recent records but you can't see recent lists or create a record. • Some tabs, such as web tabs and Visualforce tabs, aren't highlighted when you select them on the navigation bar. For example, when you select Contacts, the tab is highlighted (1). However, when you select a web tab, the page displays but the tab isn’t highlighted (2).
What is a Subtab App?
An app is a group of tabs that work as a unit to provide application functionality. Similarly, a subtab EDITIONS app is a collection of tabs that appears on the Chatter profile page. A subtab app can include both default and custom tabs. Available in: both Salesforce Users can see different sets of tabs on the profile page depending on their context. Subtab apps Classic (not available in all are the various sets of tabs available on specific pages, such as users’ profile pages. orgs) and Lightning Experience These default subtab apps determine which tabs display, depending on the user’s context. Available in: Contact Subtab App Displayed to the user when viewing... Manager, Group, Professional, Enterprise, Profile (Others) Another user inside their internal organization Performance, Unlimited, Profile (Self) Their own profile inside their internal and Developer Editions organization
Profile in Communities (Others) Another user while inside a community. It’s shown only if Communities is enabled.
Profile in Communities (Self) Their own profile inside a community. It’s shown only if Communities is enabled.
957 Extend Salesforce with Clicks, Not Code What is a Subtab App?
Note: End users can’t customize the display of subtab apps. Administrators can hide tabs within subtab apps using the Tab Hidden option in Tab Settings. Users can see tabs set to Default Off and Default On.
Managing Subtab Apps You can view and customize the subtab apps on users’ profile pages. Controlling Subtab App Visibility Once you have configured subtab apps, you can specify which users can see specific tabs on the profile page.
Managing Subtab Apps
You can view and customize the subtab apps on users’ profile pages. EDITIONS From Setup, enter Apps in the Quick Find box, then select Apps to display your organization’s subtab apps. Available in: Salesforce Classic (not available in all You can do the following: orgs), Lightning Experience, • To view details for a subtab app, click the name in the Subtab Apps section. This displays its and the Salesforce mobile properties, such as which tabs are part of the app, including any tabs that are not yet deployed. app Click custom tabs in the Included Tabs list to view details. Available in: Contact • To change the properties of a subtab app, click Edit to choose the tabs to include in the subtab Manager, Group, app, change their display order, and set the Default Landing Tab. Professional, Enterprise, Performance, Unlimited, Note: Administrators can change permission sets or profile settings to limit users’ access and Developer Editions to each tab. This allows administrators to make specific tabs available to some users, but not to others. USER PERMISSIONS
SEE ALSO: To view apps: What is a Subtab App? • View Setup and Configuration Controlling Subtab App Visibility To manage apps: • Customize Application
958 Extend Salesforce with Clicks, Not Code Lightning Platform Home Page
Controlling Subtab App Visibility
Once you have configured subtab apps, you can specify which users can see specific tabs on the EDITIONS profile page. To control the visibility of tabs within a subtab app: Available in: Salesforce Classic (not available in all 1. From Setup, enter Profiles in the Quick Find box, then select Profiles. orgs), Lightning Experience, 2. Do one of the following: and the Salesforce mobile • Original profile user interface—Click Edit next to the profile you want to modify and scroll app to the Tab Settings section. Available in: Contact • Enhanced profile user interface—Click the profile you want to modify and click Object Manager, Group, Settings. Click the object you want to modify and click Edit. Professional, Enterprise, Performance, Unlimited, Note: Some profiles, including Chatter External and Chatter Free users, don’t have the and Developer Editions permissions needed to view subtab apps.
3. Change the tab settings. USER PERMISSIONS End users can’t customize the display of subtab apps. Administrators can hide tabs within subtab To view apps: apps using the Tab Hidden option in Tab Settings. Users can see tabs set to Default • View Setup and Off and Default On. Configuration 4. (Original profile user interface only) To reset users’ tab customizations to the tab visibility settings To manage apps: that you specify, select Overwrite users’ personal tab customizations. • Customize Application 5. Click Save.
SEE ALSO: What is a Subtab App? Managing Subtab Apps
Lightning Platform Home Page
The Lightning Platform Home page contains options for building and managing applications. EDITIONS You access the Lightning Platform Home page from Setup. In Lightning Experience: Available in: both Salesforce Classic (not available in all • The left sidebar, which you can browse or search, provides access to all setup actions, tasks, orgs) and Lightning and tools. Experience • The Quick Find lets you quickly navigate to any node using a keyword. Quick Find is the best Available in: all editions way to find what you’re looking for if you know its name. except Database.com • The Create menu gives you quick access to common Setup creation functions—including users, custom objects, custom tabs, apps, email templates, and processes—without having to drill down through the Setup tree to get the page. You can get to the Create menu from any page USER PERMISSIONS in Setup. To access the Lightning • A carousel of quick-access tiles gives you instant access to important setup tools and information, Platform Home page: as well as the release notes. There’s a link to download SalesforceA—which lets you do Salesforce • Customize Application administration from a mobile app—and a link to the System Status screen so you can view your org’s performance and usage data.
959 Extend Salesforce with Clicks, Not Code Lightning Platform Home Page
• The Most Recently Used list shows your most recently used records or customization features in Setup. You can quickly link back to what you were working on by clicking its name. • The Object Manager provides a one-stop shop for managing all objects in your organization, both standard and custom. In Salesforce Classic: • The left sidebar, which you can browse or search, provides access to all setup actions, tasks, and tools. • The Getting Started box contains a tool for generating a basic app in a single step and links to information about extending and managing apps. This box doesn’t appear if you’ve previously dismissed it. • The Recent Items list shows recent metadata items that you’ve viewed, edited, or created and their related objects. • The System Overview messages box displays messages to remind you when your organization reaches its usage limits. The System Overview messages box is not enabled by default. • The Quick Links box provides links for managing tools, users, apps, security, and data. • The Community box showcases available resources. If you’ve previously dismissed this box, it reappears with each new release. • The right pane includes external links that are useful for developers and administrators.
Recent Items List (Beta) The Recent Items list shows recent metadata items that you’ve viewed, edited, or created and their related objects.
Recent Items List (Beta)
The Recent Items list shows recent metadata items that you’ve viewed, edited, or created and their EDITIONS related objects.
Note: The Recent Items list is in beta. It is production quality but has known limitations. Available in: Salesforce Classic (not available in all The Recent Items list includes: orgs) and Lightning Experience • Apex classes • Apex triggers Available in: all editions except Database.com • Approval processes • Apps • Custom report types • Email templates • Fields • Objects • Page layouts • Permission sets • Profiles • Record types • Static resources • Tabs • Users • Validation rules • Visualforce pages • Visualforce components
960 Extend Salesforce with Clicks, Not Code Configuring System Overview Messages
• Workflow email alerts • Workflow field updates • Workflow outbound messages • Workflow rules • Workflow tasks
Note: The Recent Items list in Setup is independent of the Recent Items section in the sidebar column of many Salesforce pages. The list in Setup shows items that administrators use, while the Recent Items section in the sidebar displays records with which end users have worked.
Configuring System Overview Messages
Note: The system overview page shows only the items enabled for your organization. For EDITIONS example, your system overview page shows workflow rules only if workflow is enabled for your organization. Available in: both Salesforce Add system overview usage messages to the Salesforce Home page to remind you when your Classic (not available in all organization approaches its limits. You can expand, collapse, and dismiss the system overview orgs) and Lightning Experience messages that appear on the Home page. By default, the system overview home page messages are enabled. Available in: All Editions To configure the system overview messages on the Home page: except Personal and Database.com 1. From Setup, enter System Overview in the Quick Find box, then select System Overview. USER PERMISSIONS 2. Click Configure Messages. 3. Select or deselect the types of system overview messages to show or hide on the Home page. To configure system messages: 4. Click OK. • Customize Application Important: System overview messages only appear on the Salesforce Home page when your organization approaches its limits. When you enable or dismiss system overview messages, it only impacts your individual view of the messages.
Lightning App Builder
The Lightning App Builder is a point-and-click tool that makes it easy to create custom pages for EDITIONS the Salesforce mobile app and Lightning Experience, giving your users what they need all in one place. The Lightning App Builder is also a one-stop shop for configuring Lightning apps. Available in: both Salesforce You can access the Lightning App Builder from Setup by entering Lightning App Builder Classic and Lightning in the Quick Find box and then selecting Lightning App Builder. Experience
With the Lightning App Builder, you can build: Available in: Group • Single-page apps that drill down into standard pages Essentials, Professional, • Dashboard-style apps, such as apps to track top sales prospects or key leads for the quarter Enterprise, Performance, Unlimited, and Developer • “Point” apps to solve a particular task, such as an expense app for users to enter expenses and Editions monitor expenses they’ve submitted • Custom record pages for your objects, tailored to the needs of your users
961 Extend Salesforce with Clicks, Not Code Create a Custom App Page: The Big Picture
• Custom Home pages containing the components and features that your users use most
But that’s not all. When you edit a Lightning app from the App Manager in Setup, you’re brought into the Lightning App Builder to manage the app’s settings. You can update the app’s branding, navigation, app options, and manage the Lightning pages assigned to that app all inside the Lightning App Builder. The Lightning App Builder supports the same browsers as Lightning Experience and isn’t supported on mobile browsers. The minimum recommended resolution for the Lightning App Builder is 1280x1024.
SEE ALSO: Create an App Home Page with the Lightning App Builder Create and Configure Lightning Experience Record Pages Supported Browsers and Devices for Lightning Experience Lightning Aura Components Developer Guide Lightning Web Components Developer Guide
Create a Custom App Page: The Big Picture With just a few steps, you can create an app page that lets your Lightning Experience and Salesforce mobile app users access the most important objects and items in your custom app. Custom app pages are built using Lightning pages. 1. Before creating your page, determine which components you want to include and the global actions your users need. 2. Create the Lightning page. 3. Add actions to your page. 4. Activate your Lightning page in the Lightning App Builder.
962 Extend Salesforce with Clicks, Not Code Lightning Pages
Activation lets you create a custom tab for your app page, set its visibility, and add it to the Salesforce “Mobile Only” app navigation and Lightning app navigation bar all in one place.
Lightning Pages A Lightning page is a custom layout that lets you design pages for use in the Salesforce mobile app or Lightning Experience. Lightning pages occupy a middle ground between page layouts and Visualforce pages. Like a page layout, Lightning pages allow you to add custom items to a page. However, these items, instead of being fields or Visualforce components, are Lightning components, which allow much more flexibility. The structure of a Lightning page adapts for the device it’s viewed on. The template you choose when creating the page controls how it displays on a given device. The Lightning page’s template divides the page into regions.
Lightning pages are built using Lightning components—compact, configurable, and reusable elements that you can drop into regions of the page in the Lightning App Builder. You can use a Lightning page to create an app page that you can add to the navigation bar of a Lightning app, which makes it appear when that app is viewed in both Lightning Experience and the Salesforce mobile apps. An app page gives your users quick access to the objects and items that are most important in that app. You can also use a Lightning page to create a customized Home page for Lightning Experience, or a custom record page for Lightning Experience and the Salesforce mobile app. And if you have integrated Salesforce with Microsoft® Outlook® or Gmail™, you can create a custom Email Application pane. If you have a console app, you can create a Lightning page with pinned regions to let your users view and work with records while navigating between subtabs.
Lightning pages support these components: Standard Components Standard components are Lightning components built by Salesforce.
963 Extend Salesforce with Clicks, Not Code Lightning Pages
Custom Components Custom components are Lightning components that you or someone else have created. With some configuration, custom Lightning components can work in the Lightning App Builder. Third-Party Components on AppExchange The AppExchange provides a marketplace for Lightning components. You can find packages containing components already configured and ready to use in the Lightning App Builder.
Example: This Lightning app page in the Salesforce mobile app has a list view component, a recent items component, and one global action.
Lightning Page Types You can create different types of Lightning pages with the Lightning App Builder. After you set a Lightning page’s type, you can’t change it.
App Page App pages are supported both in the Salesforce mobile app and Lightning Experience. Use an app page to create a home page for a third-party app that you can add directly into the Salesforce mobile app and Lightning Experience navigation menus. Your users then have an app home page where they can quickly access the most important objects and items. Add global actions to an app page to enhance its functionality. Global actions allow a user to do things from your app page, such as add call details, create and update records, send email, and create a task. When a user visits a Lightning page in the Salesforce mobile app, the page’s actions appear in its action bar. In Lightning Experience, actions appear in the highlights panel at the top of the page.
Important: Create actions in the full Salesforce site before adding them to your app page.
App pages support only global actions. Standard Chatter actions, such as Post, File, Link, and Poll, aren’t supported. When a user visits an app page in the Salesforce mobile app or Lightning Experience, only the actions that you specify for the page are displayed. If you haven’t specified any actions, no actions appear.
964 Extend Salesforce with Clicks, Not Code Lightning Pages
Home Page Create Home pages with features relevant to specific types of users, and assign the customized pages to different apps or app-and-user-profile combinations. Custom Home pages are supported in Lightning Experience only.
Record Page With a record page, you can create a customized version of an object’s record page, tailoring it to your users’ needs. Custom record pages are supported in Lightning Experience and the Salesforce mobile app.
Note: Actions you see on Lightning Experience record pages and the Home page are taken from object and global page layouts. You can’t add, edit, or remove actions on these pages using the Lightning App Builder.
Email Application Pane Create custom email application panes to let users work with Salesforce content that’s most relevant to them in Microsoft® Outlook® and Gmail™. Custom email application panes are supported in Salesforce Classic and Lightning Experience.
SEE ALSO: Create an App Home Page with the Lightning App Builder Create and Configure Lightning Experience Record Pages
Lightning Page Templates
Lightning page templates are Lightning components that have been configured to serve as templates EDITIONS for custom Lightning pages. Page templates can support different form factors, such as desktop or phone. When you create a Lightning page in the Lightning App Builder, you can select a page Lightning App Builder template that matches the device you’re designing the page for. available in: both Salesforce Home page templates are desktop-only. Standard app page templates support both desktop and Classic and Lightning phone. Standard record page templates support both desktop and phone, except the console Experience pinned region templates, which are desktop only. If a form factor isn’t on the options list when you Lightning Home and utility try to assign a Lightning page, then the page template doesn’t support it. bar pages available in: When working on a page in the Lightning App Builder, you can use the form factor switcher to Lightning Experience preview what the page looks like on different devices that the template supports. Lightning app and record Custom Lightning page template components are supported for record pages, app pages, and pages available in: both the Home pages. You can create custom page templates only in Aura. For more information, see “Create Salesforce mobile app and a Custom Lightning Page Template Component” in the Lightning Aura Components Developer Lightning Experience Guide. Email application pane When switching your Lightning record pages to a different template, keep these considerations in pages available in: both mind. Salesforce Classic and Lightning Experience • You can’t switch to a template that supports a smaller scope of devices than the original template. For example, if you have a page using a template that supports both desktop and Available in: Group phone, you can’t switch the page to use a template that supports only phone or only desktop. Essentials, Professional, When you choose to switch, the list of available templates reflects this rule and shows only the Enterprise, Performance, templates that you can switch to. Unlimited, and Developer • If you switch to a page template that doesn’t support the form factor of a component on your Editions page, that component is dropped from the page at run time.
965 Extend Salesforce with Clicks, Not Code Lightning Pages
• You can’t switch from a non-pinned region template to a pinned region template.
Standard Lightning Page Components
Standard components are Lightning components built by Salesforce. Several standard components EDITIONS are available when creating Lightning pages.
Note: The components listed here are supported across all page types, except when otherwise Lightning App Builder indicated. This list doesn’t show all available standard components. Other standard component available in: both Salesforce types are available and vary based on the type of page you create and with which object the Classic and Lightning Experience page is associated. Some standard components have required properties that you must configure for the component Lightning Home and utility to work on the page. When you add a component to a Lightning page in the Lightning App Builder, bar pages available in: its required properties are marked with an asterisk. Lightning Experience A Lightning page region can contain up to 100 components. Lightning app and record pages available in: both the If you have a page to be used in the Salesforce mobile app, use only Lightning components that Salesforce mobile app and the mobile app supports. See Data Available in the Salesforce Mobile App. Lightning Experience
Email application pane Accordion pages available in: both Use the Accordion component to organize your components into collapsible sections. You can put Salesforce Classic and multiple components in each section and customize the section name. You can have up to 25 Lightning Experience sections, but we recommend no more than 10. Available in: Group The Accordion component is supported for record and Home pages. Essentials, Professional, Enterprise, Performance, Note: Programmatic versions of the accordion components don’t provide the same Unlimited, and Developer functionality as their App Builder counterparts. For example, lightning-accordion Editions and lightning:accordion components don’t currently support lazy loading.
Actions & Recommendations Component Give your users a to-do list in the Actions & Recommendations component. Show a variety of steps, including screen flows, field service mobile flows, quick actions, and recommendations from your Next Best Action strategies. When a user opens a flow, in a console app it starts in a subtab. In a navigation app, it starts in a window. You can add this component to supported object pages in Lightning Experience. For more information, see Lightning Flow for Service and the Actions & Recommendations Component.
Activities Display the timeline of the activities of the record. This component appears only if Default Activities View is set to Activity Timeline. The component can contain Create a Record quick actions that point to the Event and Task objects. It contains Log A Call and Send Email actions for each of your org’s accounts, contacts, contracts, leads, opportunities, and activity-enabled custom object records.
Note: On the Case object, the component only shows the timeline of the activities. Actions appear in a Chatter Publisher component.
For more information, see Activities View and Actions in Lightning Experience.
966 Extend Salesforce with Clicks, Not Code Lightning Pages
After Conversation Work (Beta) Display a countdown after a customer conversation ends. During the After Conversation Work (ACW) countdown period, support agents can complete closing tasks like sending follow-up emails, updating a case, or finalizing their notes. Agents can exit the countdown early by closing the call record or let it run its course. When the time runs out, the agent is considered available to help the next customer whether or not they’ve closed the call record. After Conversation Work is available only for Voice Call channels. To learn more, see Configure After Conversation Work (Beta).
App Launcher Component The App Launcher displays a user’s available Salesforce apps and the connected apps the administrator has configured. Users navigate between apps using the App Launcher. This component is supported in API version 35.0 and later. Contact Salesforce to enable the App Launcher component for the Lightning App Builder in your organization.
C360 Global Profiles The C360 Global Profile component shows the matched Customer 360 profile data related to the person account record in the page layout. This component retrieves data from Customer 360 Data Manager for your single customer view. Some of the data in this component isn't stored locally in your Service Cloud org if the data originated in another data source connected to Customer 360 Data Manager. Your admin user can determine which data is copied into your Service Cloud and which data is queried on demand via this component and Customer 360 Data Federation Services. This component displays data in Customer 360 Data Manager that’s matched back to the person account record. The component shows these fields. • Name — First and Last or Family name of a person. • Email — Email addresses of a person • Phone — Phone numbers of a person, grouped by the Primary Phone Type: Home, Business, Fax, Mobile, Other. • Address — Mailing address for a person, used as either a Billing Address, a Shipping Address, or both. • In the Lightning App Builder, users can set component visibility rules, if needed, by defining filter criteria for either a record field or another field.
Note: Removing Data Mappings from the Cloud Information Model in Customer 360 Data Manager can remove data visible in this component.
C360 Order History The C360 Order History component shows the ecommerce order history for the person account that was matched to B2C Commerce orders through Customer 360 Data Manager. This component displays ecommerce order data from B2C Commerce retrieved by the Customer 360 Data Federation Service. Otherwise, an admin must copy and store order data locally in your Service Cloud org. These fields are displayed in this component. • Order No. — The customer’s order number, generated by B2C Commerce. The values in this field are hyperlinks, which open a separate UI for the Order Details. • Checkout Date — The date on which the customer placed the order on the website. • Order Status — The status of the customer’s order, such as Not Shipped, Shipped, or Returned. • Total Amount — The total amount, in the site’s currency, paid by the customer for the order. • WebsiteID — The B2C Commerce site ID as defined in Business Manager.
967 Extend Salesforce with Clicks, Not Code Lightning Pages
Note: Removing Data Mappings from Commerce Cloud in Customer 360 Data Manager can remove data visible in this component.
Call Recording Player Use this component to listen to audio recordings of calls. The Call Recording Player component is available only for the Voice Call object. This component is available in the Lightning App Builder in orgs where Service Cloud Voice is turned on. To view and use this component, users need the Contact Center Agent permission set. Because the Call Recording Player doesn't have an alternative text-based transcript, we recommend adding the Conversation Body component underneath the Call Recording Player to support accessibility.
Chatter Component As of API version 38.0, the Feed component has been renamed Chatter in the Lightning App Builder. Use it to place a publisher and feed combo on a record page.
Chatter Feed Component Use the Chatter Feed component to place a feed anywhere on a record page. The feed gives you a way to view posts, comments, and questions. Its attribute, Feed Type, takes one of these values. • Bookmarked—Shows a feed of all items the current user has bookmarked. • What I Follow—Shows a feed of all items the current user has followed. • To Me—Shows a feed of all items where the current user is mentioned. No coding is required to join a feed to a publisher. The connection is made automatically with the publisher and any feed on the page. The Chatter Feed component is available in API version 38.0 and later.
Chatter Publisher Component Use the Chatter Publisher component to place a feed publisher anywhere on a record page. The publisher gives you a way to post, poll, or ask a question in a feed. Its attribute, Type, has the default value Global. Use the value Record when you want to associate the publisher with an object's feed. Then posts that are created with the publisher are associated with the record rather than the global Chatter feed. Use the Chatter Publisher component with the Chatter Feed component to get a full feed experience. No coding is required to join a publisher to a feed. The connection is made automatically with the publisher and any feed on the page. The Chatter Publisher component is available in API version 38.0 and later.
Conversation Body Use this component to let agents view call transcripts in Service Cloud Voice. The Conversation Body component is available only for the Voice Call object. Transcripts are generated in real time during the call and the complete transcript is stored on the call record. As the call progresses, the transcript is generated and displayed in the component. Configure transcription data streams in Amazon Web Services to generate call transcripts. To view and use this component, users need the Contact Center Agent permission set.
Customer Experience Score (Pilot) The Customer Experience Score component lets users view the score participants gave a particular record and the average score for all records of that object. You can add this component to custom objects and these standard objects: Account, Case, Contact, and User. To use this component, you must enable Salesforce Surveys in your org. This component is supported in API version 47.0 and later. For more information, see Customer Experience Score.
968 Extend Salesforce with Clicks, Not Code Lightning Pages
Note: We provide Customer Experience Score component to selected customers through a pilot program that requires agreement to specific terms and conditions. To be nominated to participate in the program, contact Salesforce. Pilot programs are subject to change, and we can’t guarantee acceptance. Customer Experience Score component isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only based on generally available products and features.
Dynamic Actions Bar Component (Pilot) With this component you can add action buttons anywhere on your Lightning record and app pages. Add, delete, and change the order of actions in the Dynamic Actions Bar. You can also control the visibility of the component and of individual actions in the component, based on record field, permission, or user.
Note: We provide the Dynamic Actions Bar component to selected customers through a pilot program that requires agreement to specific terms and conditions. To be nominated to participate in the program, contact Salesforce. Pilot programs are subject to change, and we can’t guarantee acceptance. Dynamic Actions Bar component isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only based on generally available products and features. To set the visibility of individual actions in the Dynamic Actions Bar component at runtime: 1. In the Dynamic Actions Bar properties pane, click an action name to open the Action dialog. 2. Under Set Action Visibility in the Action dialog, click Add Filter. 3. Select Record Field to control action visibility for a record field, or Advanced to control action visibility for a record, permission, or user. 4. Click the Field name field and select a field from the dropdown list (for Record Field), or select a field type and then select a field (for Advanced). 5. Select an operator and enter a value, then click Done. Considerations • This component is supported only for Lightning Experience desktop on record and app pages. • The Dynamic Actions Bar supports all standard and custom global actions. • This component is supported as a source for Dynamic Interactions on app pages only. See Dynamic Interactions in the Lightning App Builder on page 1005. • Email quick action and FeedItem.MobileSmartActions actions aren’t supported for the Dynamic Actions Bar. • If no actions are supported for the current object, a message appears in the Lightning App Builder properties pane.
Einstein Field Recommendations Component The Einstein Field Recommendations component recommends values for picklist, checkbox, and lookup fields on cases. It’s used in Einstein Case Classification and Einstein Case Wrap-Up, and is available only if you enabled one or both of those features. Einstein’s field value recommendations are based on data from recently closed cases. The component has two types: Case Classification and Case Wrap-Up. To learn more about using this component with Einstein Case Classification, see Display Recommendations in the Service Console. Available in API version 49.0 and later.
969 Extend Salesforce with Clicks, Not Code Lightning Pages
Einstein Next Best Action Component The Einstein Next Best Action component displays suggested recommendations and actions on a record page. Use strategies to apply your org’s business rules to display context-specific suggestions to users. For more information, see Einstein Next Best Action Component.
Einstein Predictions Component The Einstein Predictions component displays predictions and recommendations on a Lightning record page for a standard or custom object. For more information, see Add Einstein Predictions to a Lightning Page.
Einstein Replies Component The Einstein Replies component recommends stock replies that support agents can insert into chat and messaging sessions. It’s used in Einstein Reply Recommendations, and is available only if that feature is enabled. The replies that Einstein recommends are based on past closed chats. To learn more, see Einstein Reply Recommendations. If Einstein Reply Recommendations is enabled, this component appears automatically on the Chat and Messaging console tabs for any users with the View and Act on Einstein Reply Recommendations user permission. Available in API version 49.0 and later.
Highlights Panel Component The Highlights Panel component displays key record fields along with page-level actions. The fields that appear in the highlights panel come from the compact layout assigned to the object. The actions in the highlights panel come from the Salesforce Mobile and Lightning Experience Actions section of the page layout. Record highlights show up to the first 7 fields on desktop and up to the first 10 fields in the Salesforce mobile app. To streamline your highlights panel by not showing the second row of information and reducing the size of the first row, select the Show as collapsed (desktop only) checkbox. To show fewer action buttons, reduce the number using the Number of Visible Action Buttons (desktop only) attribute. To display the highlights horizontally or vertically (desktop only), drag the Highlights Panel component into a region with the horizontal or vertical dimensions you want. The highlights panel adjusts to fit the region’s space. For example, if you drag it into a narrow column, the highlights display vertically. If you drag it to a full-page width column, the highlights display horizontally.
Event Insights Component The Event Insights component shows Salesforce IoT data about your customers’ connected devices on Lightning record pages alongside your CRM data. Salesforce IoT must be enabled, and you need an active orchestration to set up the Event Insights component. You can put up to five IoT orchestration variables in your Event Insights component. In the Lightning App Builder, you specify the parent record, the orchestration to pull the variables from, and the variables to show. You set the component visibility by filtering on record type. Each device (instance) can have up to 1 MB of data. Event message and device allocations follow your normal Salesforce IoT allocations. This component is supported in API version 44.0 and later.
List View Component The List View component points to a list view and displays the first few records from that view. It supports all public and shared list views that are associated with standard and custom objects, except:
970 Extend Salesforce with Clicks, Not Code Lightning Pages
• Activity • ContentVersion (Files) • User • UserProfile By default, a List View component displays the first three records in the list, but you can set it to show a maximum of 30. You can’t give a List View component a custom name. The component’s name is derived from the name of the list view filter you select when you configure the component. In the Lightning App Builder, the Object dropdown list for this component displays only those objects that have list views associated with them. Adding too many List View components can cause page performance issues. Use them sparingly.
Order Product Summaries by Recipient Component Use the Order Product Summaries by Recipient component to display order product details on an Order Summary record page. This component is available in Salesforce Order Management. The Order Product Summaries by Recipient component displays information about the order delivery group summaries associated with the order summary, including the order product summaries associated with them. The displayed order product summary fields are defined by the Order Product Summaries related list on the OrderDeliveryGroup object page layout. To modify the columns in this component on the order summary details page, edit the related list on the Order Delivery Group page layout, not the Order Summary page layout. You can create a custom filter to control which order delivery group summary records are displayed.
Order Summary Totals Use the Order Summary Totals component to display order financial totals on an Order Summary record page. This component is available in Salesforce Order Management. You can customize the panel title and which values to display.
Phone Use this component to give agents easy access to the Service Cloud Voice softphone call controls so they can mute, hold, and end call. This component is displayed when an agent accepts a call and is hidden when the call ends. The Phone component is available for the Account, Case, Contact, and Voice Call objects, and for custom objects. To view and use this component, users need the Contact Center Agent permission set.
Quip Document Component Use the Quip Document component to embed Quip documents directly in records. Set up any Quip document as a template so that your users can quickly create documents on Salesforce records. When you set up the Quip Document component in Lightning App Builder, you can choose different modes. • Allow different documents on each record. Let users attach different documents to different records, or create and embed new documents from scratch. Admins can programmatically attach preselected documents to different records. • Use the same document for every record. Choose an existing document to embed in each record associated with a given object. • Use a template to create new documents for each record. Specify a template from which users can create and embed documents on a per-record basis. You can use any Quip document as a template. You can set up the template to add record data to documents.
971 Extend Salesforce with Clicks, Not Code Lightning Pages
• Use different templates for different records. Specify different templates for different records on the same object. This option requires you to programmatically pre-populate the component field with the URLs of different templates rather than manually choosing a single template URL.
Rebate Types Panel Component The Rebate Types Panel component allows you to select and apply eligible rebate types and incentives to a mapped object. This component is supported in API version 52.0 and later.
Note: To view and use this component, users need the Rebate Management license.
Rebate Types Tab Component The Rebate Types component is used in combination with the Rebate Types Panel component to view and modify the benefit tiers associated with the applied rebate types and incentives. This component is supported in API version 52.0 and later.
Note: To view and use this component, users need the Rebate Management license.
Recent Items Component The Recent Items component displays a list of the most recently used items. The default is three, but you can set it to show a maximum of 30. In the Lightning App Builder, you can specify which objects’ records appear in the recent items list. The Recent Items component supports these objects, based on the specified properties: • All custom objects. • All standard objects for which both of these conditions are true: – A compact layout is defined for the object. – The object is tracked in the most recently used objects list.
Note: The object isn’t supported for this component when it meets both of these criteria but isn’t in the list of available objects when you configure the component. Although they appear in the available objects list, the Task, Report, KnowledgeArticle, and Article objects aren’t supported for this component. If an object is tracked in the most recently used objects list, one or both of the LastViewedDate or LastReferencedDate fields are present.
Record Detail Component The Record Detail component displays fields and sections from the page layout associated with the object. When users view the Lightning record page, they see different fields and sections based on their profile and page layout assignments. You can’t add, remove, or move the fields and sections when you’re viewing the component in the Lightning App Builder. You can only make field and section changes on the page layout.
Related List - Single Component Use the Related List – Single component to include a single related list for a record in your Lightning page. To include all related lists for a record, use the Related Lists component. You can configure this component to display a related list for the record associated with your page, or you can display information for the parent record. Using a parent record is optional.
972 Extend Salesforce with Clicks, Not Code Lightning Pages
This component is supported in API version 39.0 and later. You can use it in record pages only.
Tip: Make sure that the page layout for your users includes the related list you want to use. If using a parent record, update the parent record’s page layout.
Related List Quick Links Component The Related List Quick Links component displays a set of links. Users can hover over the links to see all the related list columns without opening the View All page. Header actions, mass actions, row actions, and text wrapping are all available on the hover pane. The component displays two rows of related list links in large or medium page regions, and six rows in small regions. Users can view the remaining related list links by clicking Show All, which expands the component. When a user hovers over a related list quick link, it displays the first 10 items in the related list. The content of this component is based on the set of related lists on the object's page layout plus the user’s preferences. Users can customize the order of the quick links. They can also exclude the ones they don't want in their personal settings. To exclude, they can enter Customize My Pages in the Quick Find box, selecting Customize My Pages, then clicking the object. The Open Activities and Activity History related lists aren't supported for this component. You can use this component in record pages only.
Related Record Component Use the Related Record component to display the details of a related record, including the details of a parent record, in your Lightning page. This component provides your users with built-in record creation, inline edit, and the ability to unlink a record and link a new one. This functionality is possible because the component uses actions. This component is supported in API version 39.0 and later. You can use it only in record pages. Keep these considerations in mind when using the Related Record component. • To use the component, an object must have an associated quick action to update the records. Some lookup fields have default actions. If no actions are available for your lookup, follow the links in the Lightning App Builder property editor to create the actions. • To change the displayed fields for the Related Record component, configure different lookup fields, and customize the associated action in Setup. If you don’t see the action or can’t modify it, create one. Also, ensure that the lookup field to the related object is included on the page layout of the main object. Otherwise the component can’t be refreshed. • To let users look up two levels of record relationships, specify the first-level lookup and then the second-level lookup. You must specify a first-level lookup before you can add a second-level lookup. • To let users look up polymorphic fields, select a polymorphic lookup field type on the first-level lookup or on the second-level lookup. • To use the Parent Case, Asset, and Case Source lookup fields on cases, change the field-level security to visible instead of hidden. Otherwise, your users see an error. • Users without Read access to the value of a lookup field see an error. • Person account records that display in contact Related Record components are read-only. • Cases are linked to default accounts that can’t be removed (unlinked) from the component unless the contact is also removed at the same time. • The Related Record component typically uses quick action metadata to determine which fields to show. However, if the user viewing the component has read-only access to the related record, a compact layout is used to render the fields instead. As a result, a read-only user sees a smaller set of fields.
973 Extend Salesforce with Clicks, Not Code Lightning Pages
Report Chart Component Use the Report Chart component to include a chart from a report in your Lightning page. If you leave the component’s Label field blank, the component’s label is derived from the report’s label. The chart refreshes if its report data is more than one day old. In the component properties, you can choose to display a refresh button to enable users to refresh the chart. Saving the report’s definitions also updates the chart data in the component. Setting a filter on the report chart data is supported only for record pages. If you set a filter option, the Report Chart component displays only that filtered data to users. This component is supported in API version 32.0 and later. It doesn’t work with reports in the My Personal Custom Reports folder. Report Chart components that refer to reports in the Unfiled Public Reports folder aren’t deployable when you include them in a package.
Rich Text Component Use the Rich Text component to add text and simple HTML markup to your Lightning page.
Note: JavaScript, CSS, iframes, and other advanced markup aren’t supported. To use advanced HTML elements in a component, we recommend using a Visualforce page component or a custom Lightning component. The Rich Text component uses Quill as its text editor. Keep these considerations in mind when using the text editor. • Quill wraps each line of text with tags. The tags can increase the number of characters in the rich text API value when you save the text. If you get a max length warning, break up the text into two Rich Text components. • In Quill, the default color for text is gray in the editor, but the text renders black in the output. • Selecting text using keyboard shortcuts, such as with Cmd+A, and then typing something new resets the formatting of the existing text. You can include up to 4,000 characters in the Rich Text component. This component is supported in API version 32.0 and later.
Salesforce Surveys Component The Salesforce Surveys component adds an active survey to your Lightning page, so you can collect data from your users while they work on Salesforce records. This component is supported in API version 42.0 and later.
Note: To create surveys and add them to Lightning pages, you must enable Salesforce Surveys in your org.
Send Email Later - Pending List The Send Email Later - Pending List component shows the list of scheduled emails. From this list, your users can see pending emails, cancel an email, edit its scheduled time, or edit its content.
Tableau CRM Dashboard Component The Tableau CRM Dashboard component surfaces an entire dashboard right where people work. The dashboard is fully functional and interactive. Users can refresh them, apply filters, and click chart segments to drill into filtered reports. Dashboards need space to display charts and tables. If an embedded dashboard is squished into too small a space, then a collapsed version displays instead of the full dashboard. Users can click View Dashboard to open a collapsed dashboard. Available in API version 41.0 and later. The Dashboard component isn’t available on record pages. Private dashboards aren’t available.
974 Extend Salesforce with Clicks, Not Code Lightning Pages
Tabs Component Use the Tabs component to add tabs to a region of your Lightning page. Choose from a set of standard tabs or create custom tabs to enhance record and Home pages for your Lightning Experience users. The Tabs component is supported only for Lightning Experience record and Home pages. You can place up to 100 tabs in a Tabs component. This component is supported in API version 36.0 and later.
Twitter Component Social Accounts and Contacts must be enabled for your organization before you can add the Twitter component to a Lightning page.
Visualforce Page Component Use the Visualforce Page component to include a Visualforce page in your Lightning page. If you leave the component’s Label field blank, the label is taken from the Visualforce page that you assign to it. If you leave the Height field blank, the Visualforce page’s height defaults to 300 pixels when it displays in the Salesforce mobile app. This component is supported in API version 32.0 and later. To appear in the Salesforce mobile app or Lightning Experience, the Visualforce page must have the Available for Salesforce mobile apps and Lightning pages option selected. This option is available for pages that are set to API version 27.0 and later.
Wave Dashboard Component Use the Wave Dashboard component to include Tableau CRM dashboards in your Lightning page. Contact Salesforce to enable the Wave Dashboard component for the Lightning App Builder. Select the dashboard to display from the dropdown list. If you leave the Height field blank, the dashboard’s height defaults to 300 pixels when it displays in your Lightning page. You can control the visibility of the dashboard’s title and specify whether the dashboard appears when an error occurs. With the Open Links in New Windows attribute, you can specify where links from the dashboard to other assets are opened. With the Filter attribute, you can use JSON to filter dataset fields at run time. For more information, see Embed Tableau CRM Dashboards in Lightning Pages.
SEE ALSO: Custom Lightning Page Components
975 Extend Salesforce with Clicks, Not Code Lightning Pages
Custom Lightning Page Components
The Lightning App Builder supports custom Lightning components. EDITIONS Custom components in your org that are configured for use in the Lightning App Builder appear in the Lightning Components pane. Lightning App Builder available in: both Salesforce Classic and Lightning Experience
Lightning Home and utility bar pages available in: Lightning Experience
Lightning app and record pages available in: both the Salesforce mobile app and Lightning Experience
Email application pane pages available in: both Salesforce Classic and Lightning Experience
Available in: Group Essentials, Professional, Enterprise, Performance, Unlimited, and Developer Editions
If you have a page to be used in the Salesforce mobile app, use only Lightning components that the mobile app supports. See Data Available in the Salesforce Mobile App. Your custom Lightning components don’t automatically work on Lightning pages or in the Lightning App Builder. To make a custom component usable in both: 1. Configure the component and its component bundle so that they’re compatible with the Lightning App Builder and Lightning pages. For Aura components, see the Lightning Aura Components Developer Guide. For Lightning web components, see the Lightning Web Components Developer Guide. . 2. Deploy My Domain in your org. When you deploy My Domain, references and links to Lightning resources are in the format https://MyDomainName.lightning.force.com. You can configure custom components to support different devices. For instance, you have a record page whose template supports both phone and desktop, and you activate the page for both. Then you add a phone-only component to the page. When the page is viewed on a phone, users see the component. When the page is viewed on a desktop, the phone-only component doesn’t appear.
976 Extend Salesforce with Clicks, Not Code Lightning Pages
Note: Pull to refresh doesn’t work for custom Lightning web components in the Salesforce mobile app.
SEE ALSO: Standard Lightning Page Components My Domain
Dynamic Lightning Pages
Control when a component appears on a Lightning page by adding filter conditions and logic to EDITIONS its properties in the Lightning App Builder. For example, you can construct a filter that causes a rich text component on an opportunity page to display when the opportunity’s amount is greater than Lightning App Builder or equal to $1 million. available in: Salesforce Component visibility properties appear when you select a component on a record, app, or Home Classic and Lightning page in the Lightning App Builder. This behavior applies to standard components, custom Experience components, and components from AppExchange. No need to do anything to your custom Lightning pages available in: components. It’s all handled by the Lightning App Builder. Lightning Experience and the On record pages, you can choose record fields or advanced fields, such as fields from related objects Salesforce mobile app or from a global object like User. Field values in component visibility filters can’t span more than five fields. For example, Available in: Group Record.Account.Owner.Manager.Manager.Manager.LastName has six spans, Essentials, Professional, and therefore isn’t supported. Enterprise, Performance, Unlimited, and Developer Editions
App and Home pages aren’t associated with an object, so the filters you can use are limited to other contexts, such as User, User Permission, or Device. But that doesn’t mean that they’re less powerful. If you don’t define a filter, the component displays on the Lightning page as usual. When you define one or more filters and set the filter logic for a component, the component is hidden until the filter logic criteria are met.
In the Lightning App Builder, components that have at least one filter assigned are indicated with an icon ( ).
977 Extend Salesforce with Clicks, Not Code Lightning Pages
Visibility Rules on Dynamic Forms Fields and Field Sections You can make your Lightning record pages even more dynamic by setting visibility filters on Field and Field Section components. For example, you can have a field or set of fields hidden until a person with a certain profile, permission, or viewing on a certain device visits the page. Be careful when setting up visibility rules on multiple components in the same region. If your rules cause all the components in a region to be invisible at run time, the region will be empty. Visibility rules on fields are respected in the edit, clone, inline edit, and new record screens. Component visibility rules on field sections behave differently than they do on fields. Visibility rules on fields are assessed dynamically. Changes a user makes while editing a record can make fields appear and disappear as visibility rules are evaluated. Visibility rules on field sections aren't dynamic and don't react to what a user does while editing. Field section visibility rules are evaluated only after the record is saved.
Component Visibility Based on Form Factor With a filter using the Device context, you can set a component to display exclusively when its page is viewed in a specific experience, such as a phone or a desktop.
Custom Lightning components can also be set to support different form factors. For Lightning web components, see “Configure Your Component for Different Form Factors.” For Aura components, see “Aura Component Bundle Design Resources.”
Supported Objects, Fields, Field Types, and Operators Two objects aren’t supported for component visibility filters: ProcessInstanceStep and ProcessInstanceWorkItem. On record pages, component visibility filters rely on the data captured in fields associated with the page’s object. Not all fields, field types, and operators are supported. These field types are supported: • String type fields: Autonumber, Currency, Email, Number, Percent, Phone, Text, Text Area, URL • ID • Checkbox (boolean) • Geolocation • Picklist • Formula fields which resolve to one of the above types • Roll-up summary fields which resolve to one of the above types These operators are supported:
978 Extend Salesforce with Clicks, Not Code Lightning Pages
• CONTAINS • = and == (Equal) • <> or != (Not Equal) • > (Greater Than) • >= (Greater Than or Equal) • < (Less Than) • <= (Less Than or Equal)
SEE ALSO: Formula Operators and Functions Standard Lightning Page Components
Build Localized Component Labels and Attribute Values on Lightning Pages with Custom Labels
When you specify labels or attributes in the Lightning App Builder such as for components or custom EDITIONS tabs, you can use the {!$Label.customLabelName} expression to help define the label or attribute’s value. Lightning App Builder On a Lightning page, custom Tabs component labels and other component attribute values aren’t available in: both Salesforce localized when they’re entered as plain text in the Lightning App Builder. For example, if you have Classic and Lightning an org whose default language is English, and you have a Tabs component with three custom tabs Experience that you entered as Cars, Trucks, and Planes, the non-English users in your org see those tab label Lightning Home pages values as Cars, Trucks, and Planes when they view the page. The tab label values aren’t translated available in: Lightning into your users’ languages. Experience
But configuring custom label values in the Lightning App Builder using the Lightning app and record {!$Label. } customLabelName expression lets users see labels in their chosen language pages available in: both the if you created a translation for that label in their language. Salesforce mobile app and The {!$Label.customLabelName} expression works with any custom labels that you Lightning Experience create in Setup using the custom label feature. The text that you define in the Value field for your custom label displays as the label value when the component renders on a Lightning page. And, Available in: Group if you create a translated value for the label, users using that language in your org see the translated Essentials, Professional, Enterprise, Performance, value. Unlimited, and Developer Expressions are supported only in String type fields in component labels and attributes on app, Editions Home, and record pages. You can’t use an expression in page-level properties. 1. Create a translated custom label in Setup. USER PERMISSIONS For more information, see Translate Custom Labels. To create and save Lightning 2. Navigate to the Lightning App Builder. From Setup, in the Quick Find box, enter App pages in the Lightning App Builder, then select Lightning App Builder. Builder: 3. Open an app, record, or Home Lightning page. • Customize Application 4. Select the component whose label or property you want to replace with your translated custom To view Lightning pages in label. the Lightning App Builder: • View Setup and 5. Enter {!$Label.customLabelName} in the label or attribute field, replacing Configuration “customLabelName” with the name of your custom label.
979 Extend Salesforce with Clicks, Not Code Lightning Pages
Label and property fields that support using this expression have an info bubble that says so.
6. Save your changes. Users in your org whose language is set to the language of your translated label see the label or attribute in its translated value.
Example: Your org’s default language is English, but you want the custom Planes tab on your Lightning page to show a translated custom label for your German users. Here’s how to do it. 1. Create a custom label in Setup with the name Planes_Label, and enter the Value as Planes. That’s what your English users see. 2. From the Translations related list on the custom label detail page, create a translation for the label with the language set to German and the Translation Text value as Flugzeuge. 3. Save the translation. 4. In the Lightning App Builder, open your page and click the Tabs component on the canvas. 5. In the properties pane, click the Planes tab, and in the Custom Label field, replace the Planes plain text with {!$Label.Planes_Label}.
6. Click Done and save your page. When viewing the page, your English users see the tab as Planes, and your German users see the tab as Flugzeuge.
Note: When a field in a component contains an expression, Salesforce can’t validate the value it resolves to. If the expression resolves to a value that’s invalid for the field, sometimes the component doesn’t work as expected. We recommend that you test the page in the translated languages before you make the page with the expression available to users.
980 Extend Salesforce with Clicks, Not Code Create an App Home Page with the Lightning App Builder
Create an App Home Page with the Lightning App Builder
Create a home page for an app that you can add directly into Lightning apps and the Salesforce EDITIONS mobile apps. Your users can then easily access the objects and items that are most important in that app. Lightning App Builder 1. From Setup, enter App Builder in the Quick Find box, then select Lightning App Builder. available in: both Salesforce Classic and Lightning 2. Click New. Experience 3. Select App Page and then click Next. Lightning app pages 4. Give your app page a label, and then click Next. available in: both the The label can be up to 80 characters. Salesforce mobile app and Lightning Experience 5. Select a page template and click Finish. 6. Drag the components that you want onto the page. Available in: Group, Essentials Professional, Drag components up and down to rearrange them. You can also click a component’s top or Enterprise, Performance, bottom border to create an insertion point ( ) for the next component. Unlimited, and Developer 7. Click each component on the page to configure its properties. Editions 8. Click in the empty area of the canvas or on the Page link in the breadcrumb to configure the page properties. USER PERMISSIONS The Description field is limited to 255 characters. The Developer Name field is limited to 80 characters, but if you have a namespaced org, we recommend using fewer than 65 characters. To create and save Lightning pages in the Lightning App When you create a Lightning page, the developer name is derived from the first 40 characters Builder: of the label that you give the page. • Customize Application 9. Optionally add global actions to your page. To view Lightning pages in the Lightning App Builder: a. In the page properties, click Select. • View Setup and b. Add, remove, or reorder the actions for your page. Configuration Actions you select appear on the page’s action bar and in the highlights panel at the top of the page in Lightning Experience. An app page is the only type of Lightning page that you can add actions to in this way. Other Lightning pages derive their actions from the object and global page layouts.
c. Click OK.
10. Click Save when you’re done editing your page. To give your users access to the app page, you must activate it.
SEE ALSO: Activate Your Lightning App Page Lightning App Builder
981 Extend Salesforce with Clicks, Not Code Create a Mobile App Page with the Lightning App Builder
Create a Mobile App Page with the Lightning App Builder
Create a mobile home page for the Salesforce mobile app. Your users can see this page right when EDITIONS they log in.
Note: These steps are similar to Create an App Home Page with the Lightning App Builder. Lightning App Builder That’s because when you create an app page or record page, it can be made available on available in: both Salesforce both Lightning Experience and the Salesforce mobile app. The following steps focus on Classic and Lightning Experience creating an app page for the mobile app only. 1. From Setup, enter App Builder in the Quick Find box, then select Lightning App Builder. Lightning app pages available in: both the 2. Click New. Salesforce mobile app and 3. Select App Page and then click Next. Lightning Experience 4. Give your app page a label, and then click Next. Available in: Group, The label can be up to 80 characters. Essentials Professional, Enterprise, Performance, 5. Select the first template (Header and Left Sidebar) and click Finish. Unlimited, and Developer If this is a mobile-only page, it doesn't matter which template you pick. If you plan to share this Editions page between mobile and desktop users, choose the template most appropriate for desktop use. On mobile devices, the page responsively collapses into a single column. USER PERMISSIONS 6. Make sure you’re viewing the template preview using the Phone form factor. The regions on the template are displayed in a one column layout. To create and save Lightning pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration
982 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
7. Drag the components that you want onto the page. Drag components up and down to rearrange them. You can also click a component’s top or bottom border to create an insertion point ( ) for the next component. To increase mobile adoption, we recommend making available the top features that your users use most frequently. For example, the Recent Items can take them back into the records that they were working with. Also, the List View standard components can be set to their open tasks to improve productivity in the mobile app. Remember that screen space and bandwidth are precious on mobile, so try to limit each page to 4 or 5 components at most. If you overload the page with features, it can be slow and harder to use. See Preview Mobile App Pages in Lightning App Builder on page 983.
8. Click each component on the page to configure its properties. 9. Click in the empty area of the canvas or on the Page link in the breadcrumb to configure the page properties. The Description field is limited to 255 characters. The Developer Name field is limited to 80 characters, but if you have a namespaced org, we recommend using fewer than 65 characters. When you create a Lightning page, the developer name is derived from the first 40 characters of the label that you give the page.
10. Optionally add global actions to your page. Global actions help your users perform tasks easily from the app page, like log a call, create a new case or event etc. a. In the page properties, click Select. b. Add, remove, or reorder the actions for your page. Actions you select appear on the page’s action bar and in the highlights panel at the top of the page in Lightning Experience. An app page is the only type of Lightning page that you can add actions to in this way. Other Lightning pages derive their actions from the object and global page layouts.
c. Click OK.
11. Click Save when you’re done editing your page. To give your users access to the mobile app page, you must activate it. You can limit the page to mobile users during the page activation process. After activation, you can add this to any Lightning App in the App Manager for your users to personalize. If your Lightning App is available on both desktop and mobile, you can use the same page across both. Or create a Lightning App specifically for your mobile users, and add it to the navigation there.
Preview Mobile App Pages in Lightning App Builder
For a consistent experience across devices, use the Lightning App builder to preview your record EDITIONS and app pages. The Salesforce mobile web experience is no longer available after Summer ’20. To customize and Available in: Lightning preview your apps and pages for Lightning Experience or the mobile app, use the App Builder. You Experience can also specify certain components as mobile- or desktop-only. Available in: Group If you need more than a preview, run the Lightning apps and components in the Salesforce mobile Essentials, Professional, app. Testing in the mobile app helps validate that users have the best experience on mobile. Enterprise, Performance, When you build a mobile app page, the steps include: Unlimited, and Developer Editions • Build a new app page with the App Builder on page 982 • Activate the page and add the page to your mobile navigation • Create a Lightning app in the App Manager for your users to personalize
983 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
Watch a Demo (9 minutes) The following sections discuss best practices on building a mobile app page using the App Builder.
Display Mobile-Friendly Components When you create a Lightning app page or record page via the App Builder, the template you choose controls how it displays across devices.
Here are several ideas on including standard components on page 966 for mobile users. The list can vary depending on your user’s role. • The Report Chart component displays helpful data, such as your top deals, based on a filter. • The List View component can display your events, such as today’s agenda. • The Task List component can display your open tasks, overdue tasks, or another list based on a filter. • The Recent Items component lets you get back to the records you are working with recently. • The Launchpad component lets you add a grid of navigation items, such as your contacts or a custom Visualforce page, which users can access with one tap. If standard components don’t meet your requirements, create custom components on page 976.
Customize Actions for the Mobile Page If you’re creating an app page, you can also customize the actions available for the page. On the Page link, click Select under the Actions label.
984 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
Here are several popular actions for mobile users that make them more productive. Again, the list can vary depending on your user’s role. • Log a call • New case • New event • New task For more information, see Salesforce Mobile App Action Bar.
Activate the Page for Mobile Users When you activate the page, you have the option to add the page to both Lightning Experience and mobile app. You can add the page to any mobile-enabled Lightning app. Adding your app page to Lightning Experience makes it available to users viewing the app on desktop and in the Salesforce mobile app.
Enable Users to Personalize Tabs for the Mobile App If you haven't already, enable your Lightning apps for mobile in the App Manager so your users can access the same navigation on all devices. Or create a Lightning app if you want separate navigation items on mobile. To customize your mobile experience, personalize the app on desktop with your favorite tabs, and then use them on the mobile app. This guideline is optional but highly recommended to optimize your users’ mobile experience. For this use case, choose the Desktop and phone form factors.
985 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
Add navigation items, including the app page you created and several basic tabs like Chatter and Groups. Keep the app lightweight since users can personalize their own tabs using this app.
Add the profiles who need mobile access to this app. For example, the mobile app is ideal for your sales and marketing users who need access to the mobile app on the go. Both profiles can then use the mobile app to personalize the tabs they need for their role. If you have multiple Lightning apps available to different users profiles, the profiles also get access to the mobile app.
Personalize Tabs for the Mobile App In Lightning Experience on desktop, users access the Lightning app you created. Go to a list view and open it in a new tab. This adds the list view to the mobile navigation and enable users to be productive in the mobile app.
986 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
After adding tabs, users can edit the mobile navigation items, edit item names, and reorder the items.
987 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
When users log in to the mobile app, the App Launcher lets them switch to the customized Lightning app. For more information, see Customize the Salesforce Mobile App.
The actions you added are displayed on the home page screen with the components you added to the template in the App Builder.
988 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
989 Extend Salesforce with Clicks, Not Code Activate Lightning Experience Home Pages
Activate Lightning Experience Home Pages
Is your custom home page ready for your users? Use the Activation function inside the Lightning EDITIONS App Builder to get the page out to them. You have three activation options. You can make your custom home page the default home page for all users, assign it to specific Lightning apps, or assign Lightning App Builder it to app-and-profile combinations. Assigning the page to a Lightning app or app-and-profile available in: both Salesforce combination gives your users access to a home page customized for the context they’re working Classic and Lightning in. Experience
1. Create a home page or open an existing one in the Lightning App Builder. Lightning Home and utility 2. If you opened a home page that is ready for your users and doesn’t need editing, click Activation. bar pages available in: Lightning Experience 3. If you created a page or opened a page that needs adjustment, make the necessary changes, click Save, and then click Activate. Lightning app and record You have a few options for activating a home page. pages available in: both the • Make the page the org default. Salesforce mobile app and Lightning Experience • Make the page the default home page for specific Lightning apps. Email application pane • Assign the page to a combination of Lightning apps and profiles. pages available in: both 4. On the activation screen, click the tab for the option you’ve chosen, and follow the steps to Salesforce Classic and activate the page. Lightning Experience
Tip: You can also assign home pages from Setup. Enter Home in the Quick Find box, Available in: Group and then select Home. Essentials, Professional, Enterprise, Performance, • Classic apps can be viewed in Lightning Experience, but you can’t display different Unlimited, and Developer home pages assigned for specific apps and profiles. Upgrade Classic apps to Lightning Editions apps from the App Manager to make home page assignments. • If you no longer want a page to be an app or org default, redo the activation process for the page, and select the option to remove it as the default. USER PERMISSIONS • If you activate a page and then return to make changes, you don’t have to activate To create and save Lightning it again. Clicking Save after you make your edits pushes the changes to your users. pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration
990 Extend Salesforce with Clicks, Not Code Activate Your Lightning App Page
Activate Your Lightning App Page
To make your custom app page available to users, you must activate it. You can also rename the EDITIONS Lightning page tab, adjust its visibility, and set its position in the navigation list. The Lightning App Builder’s activation feature makes this process easy. Lightning App Builder 1. To open your app page, from Setup, enter Lightning App Builder in the Quick Find available in: both Salesforce box, select Lightning App Builder, and then click Edit next to the page. Classic and Lightning Experience 2. In the Lightning App Builder, click Activation. 3. Update the activation properties, if desired. Lightning Home and utility bar pages available in: You can: Lightning Experience • Change the page’s custom tab label. By default, the label that you give the Lightning page Lightning app and record is used as the label for its custom tab. pages available in: both the • Change the custom tab’s icon. The icon that you choose here is used as the icon for the Salesforce mobile app and page in the mobile app and in Lightning Experience. Lightning Experience
• Adjust the app page custom tab’s visibility. Email application pane Note: If you select System Administrators only, the tab is set to Default On pages available in: both for System Administrators. For all other users, it’s set to Default Off and doesn’t Salesforce Classic and Lightning Experience show up in the navigation of the apps it has been assigned to, but users can see the tab in the App Launcher in Lightning Experience and on the All Tabs page in Salesforce Available in: Group Classic. Essentials, Professional, If you select Active for all users, the tab is set to Default On for all users. It Enterprise, Performance, appears in the visible tabs for its associated app, in the App Launcher in Lightning Unlimited, and Developer Experience, and on the All Tabs page in Salesforce Classic. Editions
4. Add the page to one or more Lightning apps. USER PERMISSIONS Adding your app page to Lightning Experience makes it available to users viewing the app on desktop and in the Salesforce mobile app. To create and save Lightning pages in the Lightning App 5. Set the page’s position in the Salesforce “Mobile Only” app navigation. Builder: The first item that you put in the mobile navigation list becomes your users’ landing page. • Customize Application To view Lightning pages in 6. Click Activate. the Lightning App Builder: Your Lightning page is now ready for your mobile and Lightning Experience users! • View Setup and Configuration To enable your users to personalize the app with their favorite tabs, create a new Lightning App in the App Manager. They can then use the tabs in the Salesforce mobile app.
Tip: You can give your app page a custom icon image by editing the style of the page’s custom tab in Setup.
SEE ALSO: Create Lightning Page Tabs Tab Settings
991 Extend Salesforce with Clicks, Not Code Create Lightning Page Tabs
Create Lightning Page Tabs
Before you can include a Lightning app page in the Salesforce mobile apps or in a Lightning app, EDITIONS you must create a custom tab for it. When you first activate an app page in the Lightning App Builder, a tab is created for the page as Available in: both Salesforce part of the activation process. You can also create a tab for the page manually in Setup before you Classic (not available in all activate it. orgs) and Lightning Experience You can create a custom tab only for an App Page type of Lightning page. 1. From Setup, enter Tabs in the Quick Find box, then select Tabs. Available in: All editions 2. Click New in the Lightning Page Tabs related list. USER PERMISSIONS 3. Choose a Lightning page for the tab. 4. Enter a label. To create and edit custom tabs: This text is used as the display name for the Lightning page. • Customize Application 5. Select a tab style to set a color scheme and icon for the Lightning page tab. 6. Enter a description of the tab, if desired, and click Next. 7. Choose the user profiles the new custom tab is available for.
Note: In Salesforce Classic, the Default On and Default Off options for Lightning page tabs don’t work the same way as for other custom tabs. The Lightning page menu item appears for the selected profiles in Salesforce for Android and Salesforce for iOS whether you choose Default On or Default Off. Select the Tab Hidden option to hide the Lightning page for the selected profiles.
8. Click Save.
Tip: When creating a custom icon for your Lightning page tab, follow these image guidelines. The icon should: • Be less than 10k in size • Be 120 x 120 pixels • Be a PNG with a transparent background • Have a resolution of 72 dpi • Not include a color background • Not include outer shadows on the inner icon graphic
992 Extend Salesforce with Clicks, Not Code Create and Configure Lightning Experience Record Pages
Create and Configure Lightning Experience Record Pages
Use the Lightning App Builder to add, remove, or reorder components on a record page to give EDITIONS users a customized view for each object’s records. 1. Create a record page for Lightning Experience in one of these ways. Lightning App Builder available in: both Salesforce a. From the Setup menu on a record page, select Edit Page. Classic and Lightning Experience
Lightning Home and utility bar pages available in: Lightning Experience
Lightning app and record pages available in: both the Salesforce mobile app and Lightning Experience
Email application pane pages available in: both Salesforce Classic and Lightning Experience
Available in: Group Essentials, Professional, When you select Edit Page for the first time, Salesforce makes a copy of the standard page. Enterprise, Performance, This copy is what you edit in the Lightning App Builder. If a customized page exists and is Unlimited, and Developer active, selecting Edit Page opens that page to edit. Editions b. Create a page from the Lightning App Builder list page in Setup. To find it, enter App Builder in the Quick Find box, then select Lightning App Builder. USER PERMISSIONS To create an empty page, select a page template. To create a page prepopulated with standard components, clone the system default page. To create and save Lightning pages in the Lightning App c. Clone an existing custom Lightning page from its detail page or from the Lightning page Builder: list in Setup. • Customize Application d. Click New Page from the Pages list inside the Lightning App Builder. To view Lightning pages in the Lightning App Builder: 2. In the Lightning App Builder, add, edit, or remove components to change the page’s layout. • View Setup and Reorder components by dragging them around the canvas. Configuration 3. In the page properties, give your customized page a unique, descriptive label. To get to the page properties, click Page from the breadcrumb at the top of the properties pane.
4. Save your page.
993 Extend Salesforce with Clicks, Not Code Add and Customize Tabs on Lightning Pages Using the Lightning App Builder
Hang on, you’re not done yet! To make your customized record page available to your Lightning Experience and mobile users, you must activate it. You can activate the page from the Save dialog when you save it for the first time or later using the Activation button.
SEE ALSO: Add and Customize Tabs on Lightning Pages Using the Lightning App Builder Lightning App Builder Considerations Lightning App Builder Limits and Limitations
Add and Customize Tabs on Lightning Pages Using the Lightning App Builder
With the Lightning App Builder, you can create, update, delete, and change the order of tabs and EDITIONS tab sets on record and Home pages in Lightning Experience. Configure the tabs that your users see, name them whatever you like, and add components to each tab. Lightning App Builder 1. Open a Home or record page for Lightning Experience in one of these ways. available in: both Salesforce Classic and Lightning a. From the Setup menu, select Edit Page. Experience
Lightning Home and utility bar pages available in: Lightning Experience
Lightning app and record pages available in: both the Salesforce mobile app and Lightning Experience
Email application pane pages available in: both Salesforce Classic and Lightning Experience
Available in: Group Essentials, Professional, Enterprise, Performance, When you select Edit Page for the first time, Salesforce makes a copy of the standard page. Unlimited, and Developer This copy is what you edit in the Lightning App Builder. If a customized page exists and is Editions active, selecting Edit Page opens that page to edit.
b. Open a page from the Lightning App Builder list page in Setup. To find it, enter App USER PERMISSIONS Builder in the Quick Find box, then select Lightning App Builder. To create and save Lightning 2. Add a Tabs component to the page. pages in the Lightning App A default set of tabs is added. Builder: 3. To add a tab, click Add Tab in the Tabs component properties. • Customize Application 4. Customize a tab by clicking it in the properties pane. You can select a different standard label To view Lightning pages in or click Custom and enter the tab name you want. the Lightning App Builder: • View Setup and Configuration
994 Extend Salesforce with Clicks, Not Code Add and Customize Tabs on Lightning Pages Using the Lightning App Builder
Note: Custom tab labels in the Tabs component—including those installed from packages—aren’t translated. For example, if you create a custom Goals tab in English, then view the page as a user whose language is set to French, the tab still displays as Goals. However, you can use the {!$Label.customLabelName} expression in a component label or attribute to represent a custom label that you create in Setup using the custom label feature. For more information, see “Build Localized Component Labels and Attribute Values on Lightning Pages with Custom Labels on page 979.”
5. To add your first component to a tab, select the tab on the canvas and then drop the component directly below it.
6. Reorder tabs in the Tabs properties pane by dragging and dropping them into position. You can’t drag and drop individual tabs on the canvas.
SEE ALSO: Create and Configure Lightning Experience Record Pages Lightning App Builder Considerations Personalize the Navigation Bar in Lightning Experience
995 Extend Salesforce with Clicks, Not Code Activate Lightning Experience Record Pages
Activate Lightning Experience Record Pages
Is your custom record page ready for your users? Use the Activation function inside the Lightning EDITIONS App Builder to get the page out to them. You can make your custom record page the default record page for all users, assign it to specific Lightning apps, or assign it to record types and profiles. Lightning App Builder Assigning the page to a Lightning app, record type, or profile gives your users access to a record available in: both Salesforce page customized for the context they’re working in. Classic and Lightning 1. Create a record page or open an existing one in the Lightning App Builder. Experience 2. If you opened a record page that is ready for your users and doesn’t need editing, click Lightning Home and utility Activation. bar pages available in: Lightning Experience 3. If you created a page or opened a page that needs adjustment, make the necessary changes, click Save, and then click Activate. Lightning app and record You have a few options for activating a record page. pages available in: both the • Make the page the org default for the object. Salesforce mobile app and Lightning Experience • Make the page the default object record page for specific Lightning apps. Email application pane • Assign the page to a combination of Lightning apps, record types, and profiles. pages available in: both • Assign the page to a form factor, such as a desktop or phone. Salesforce Classic and Lightning Experience 4. On the activation screen, click the tab for the option you’ve chosen, and follow the steps to activate the page. Available in: Group Essentials, Professional, SEE ALSO: Enterprise, Performance, Create and Configure Lightning Experience Record Pages Unlimited, and Developer Editions Lightning App Builder Considerations
USER PERMISSIONS
To create and save Lightning pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration
Break Up Your Record Details with Dynamic Forms
The more fields that you have on your page layout, the more that the Record Detail component EDITIONS becomes a monolithic block of fields that you can’t customize. With Dynamic Forms, you can migrate the fields and sections from your page layout as individual components into the Lightning App Available in: Lightning Builder. Then, you can configure them just like the rest of the components on the page, and give Experience the users of that page only the fields and sections that they need. Dynamic Forms benefits you three ways. Available in: Group, Professional, Enterprise, • An instant upgrade from page layouts: Place fields and sections wherever you want. Performance, Unlimited, • Dynamic layouts: Use visibility rules to show and hide fields and sections. and Developer Editions
996 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
• Simpler layout management: – Manage the fields and sections on your pages in the Lightning App Builder without touching the page layout editor. – Reduce the number of page layouts you need with component visibility rules. – Take advantage of a single assignment model for the Lightning page instead of the dual model of assigning a Lightning page and a page layout.
You can start using Dynamic Forms in two ways. • Create a custom object record page, then drag Field and Field Section components onto it. • Open an existing record page and migrate its record details using the migration wizard. Dynamic Forms doesn’t only affect how your users see fields on a record page. It also affects what they see when they click to edit, create, or clone a record. On Dynamic Forms-based pages, the fields that users see when creating, editing, or cloning come from the fields on the page, not from the page layout.
Note: Dynamic Forms is supported on record pages for custom objects only.
Migrate a Record Page to Dynamic Forms With Dynamic Forms, you can migrate the fields and sections from your existing record pages as individual components in the Lightning App Builder. Then you can configure them just like the rest of the components on the page, and give the users of that page only the fields and sections that they need. Dynamic Forms is supported only for custom objects. Required and Read-Only Fields in Dynamic Forms Universally required fields retain their status when you’re working with them on a Dynamic Forms-based Lightning page. However, you can make other fields required or read-only just for the page you’re working on. Dynamic Forms and Mobile The Dynamic Forms Field Section component and the Field components that go inside it are desktop-only. But your mobile users are still covered. The Record Detail - Mobile component gives your mobile users a way to see the record details on a Dynamic Forms-enabled page.
997 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
Dynamic Forms Tips and Considerations Keep these tips and considerations in mind when working with Dynamic Forms. Dynamic Forms Limitations Keep these limitations in mind when working with Dynamic Forms. Dynamic Forms Known Issues Keep these known issues in mind when working with Dynamic Forms.
Migrate a Record Page to Dynamic Forms
With Dynamic Forms, you can migrate the fields and sections from your existing record pages as EDITIONS individual components in the Lightning App Builder. Then you can configure them just like the rest of the components on the page, and give the users of that page only the fields and sections that Available in: Lightning they need. Dynamic Forms is supported only for custom objects. Experience 1. Open an existing custom object record page for Lightning Experience in one of these ways. Available in: Group, a. From the Setup menu on a record page, select Edit Page. Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create and save Lightning pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration
When you select Edit Page for the first time, Salesforce makes a copy of the standard page. This copy is what you edit in the Lightning App Builder. If a customized page exists and is active, selecting Edit Page opens that page to edit.
b. From the Object Manager in Setup, open a custom object, then select Lightning Record Pages. c. Open a custom object record page from the Lightning App Builder list page in Setup. To find it, enter App Builder in the Quick Find box, then select Lightning App Builder.
2. Click the Record Detail component. 3. In the component detail pane, click Upgrade Now to start the Dynamic Forms migration wizard.
998 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
4. Walk through the wizard, and select which page layout has the fields that you want to migrate to the page. Why choose a page layout when the Fields tab has all the fields you need? Well, the upgrade wizard takes the fields and sections from the page layout you choose and automatically adds them to your page. Just a few clicks and you’re done. No need to drag all those fields manually. As long as a field is inside a Field Section component, you can put it anywhere on the page, even inside tabs.
Note: By default, fields and field sections are migrated into an Accordion component to prevent page performance issues. If you disable this option, migrated fields and sections are added to the page in place of the Record Detail component. If the Record Detail was in a region that's visible on page load, and you have a lot of fields, disabling this option can significantly impair page performance.
As part of the migration process, the Record Detail component is removed from the page, replaced with fields and sections that you can configure and place anywhere you like.
999 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
If your record page supports the phone form factor, a “Record Detail - Mobile” component is added to your page as part of the migration. This new component is unique to Dynamic Forms. It displays the standard record detail fields and sections to your users when they view the page on a mobile device.
SEE ALSO: Dynamic Forms and Mobile Break Up Your Record Details with Dynamic Forms
Required and Read-Only Fields in Dynamic Forms
Universally required fields retain their status when you’re working with them on a Dynamic EDITIONS Forms-based Lightning page. However, you can make other fields required or read-only just for the page you’re working on. Available in: Lightning A field set to Required in the field definition in the Object Manager is a universally required field. Experience Its Required value isn’t editable in the field’s properties in the Lightning App Builder property panel. Also, the read-only status of some standard fields—such as Created By, Last Modified By, Owner, Available in: Group, and Record Type—can’t be changed in the Lightning App Builder property panel. Professional, Enterprise, Performance, Unlimited, Fields marked as Required or Read-Only on a page layout retain that state when migrated into a and Developer Editions Dynamic Forms-based page. You can find all universally required fields for your page in the Universally Required Fields section of the Fields palette. Fields that you make required at the page layout level or in the Lightning App Builder property panel don’t appear in the Universally Required Fields section of the palette. If you set a field on a Lightning page to Required or Read-Only in the Lightning App Builder property panel, the behavior applies only to the field on that page, not all instances of the field.
1000 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
Be sure to include required fields on your Lightning pages. They aren’t added automatically. If there are required fields missing from the page, and the missing required fields don't have values, users can’t save a record after editing, creating, or cloning it. Don’t hide universally required fields with visibility filters.
SEE ALSO: Break Up Your Record Details with Dynamic Forms Require Field Input to Ensure Data Quality Considerations for Universally Required Fields
Dynamic Forms and Mobile
The Dynamic Forms Field Section component and the Field components that go inside it are EDITIONS desktop-only. But your mobile users are still covered. The Record Detail - Mobile component gives your mobile users a way to see the record details on a Dynamic Forms-enabled page. Available in: Lightning When you migrate a record page that supports both desktop and phone to Dynamic Forms, a Experience Record Detail - Mobile component is added to the page for you. Available in: Group, But when you create a fresh page using a template that supports both desktop and phone, after Professional, Enterprise, adding the fields and field sections, you must add the Record Detail - Mobile component to the Performance, Unlimited, page yourself. and Developer Editions The Record Detail - Mobile component wraps fields from the Record Detail component into a mobile-only container. So, on pages that support both desktop and phone, your desktop users see the Field Section components, and your mobile users see the Record Detail - Mobile component.
Example: Here’s what a page that you create in desktop mode in the Lightning App Builder looks like when viewed on a phone. The Field Section components just below the Highlights Panel on desktop are dropped on mobile, and the Record Detail - Mobile component takes over to deliver the sections and fields.
1001 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
The Record Detail - Mobile component displays with an “Unsupported form factor” message when viewed on a page in the Lightning App Builder in Desktop preview mode.
SEE ALSO: Migrate a Record Page to Dynamic Forms Break Up Your Record Details with Dynamic Forms
Dynamic Forms Tips and Considerations
Keep these tips and considerations in mind when working with Dynamic Forms. EDITIONS
General Considerations Available in: Lightning Experience • When you switch page templates on a page that uses Dynamic Forms, the list of available templates contains only the templates that are supported for your Dynamic Forms-enabled Available in: Group, page. Professional, Enterprise, • The Owner and Record Type fields get special handling in Dynamic Forms. They’re set to Performance, Unlimited, Read-Only, and that state isn’t editable in the properties pane. and Developer Editions • You can add more than one instance of the same field to a Lightning page, but all instances of that field on the page show the same data. • Programmatic versions of the accordion components don’t provide the same functionality as their App Builder counterparts. For example, lightning-accordion and lightning:accordion components don’t currently support lazy loading. • Expanding or collapsing a field section while designing a page has no effect on whether a section is expanded or collapsed for users during runtime. • When you clone a record based on a Dynamic Forms-enabled page that has visibility rules, all the fields referenced in the visibility rules are added to the cloned record, regardless of whether those fields are on the page. • When you save a new record with an empty custom object name, the API populates the custom object name field with the record ID. So make sure that the Name field is on the page and is marked as required.
Visibility Rules and Dynamic Forms • If a field is hidden on a page due to a visibility rule, and a user edits the value of the field, its new or changed value isn’t saved. • Dependent picklist fields don’t respect visibility rules. Even if they have visibility rules assigned to them, dependent picklist fields still appear in the View All Dependencies list. • Component visibility rules on field sections behave differently than they do on fields. Visibility rules on fields are assessed dynamically. Changes a user makes while editing a record can make fields appear and disappear as visibility rules are evaluated. Visibility rules on field sections aren't dynamic and don't react to what a user does while editing. Field section visibility rules are evaluated only after the record is saved.
Tips • We recommend not having both a Record Detail component and field sections on the same page. If you do, users can have issues with the page, including: – Multiple, overlapping save and cancel bars when both are on the page and both in inline edit. – Visibility rules on Field and Field Section components not working properly.
1002 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
– When users create, edit, or clone a record, the fields they see come from the Field Sections on the page, not from the Record Detail. – Field sections are top-down-left-right tab order only, while Record Detail is left-right-top-down tab order, which can cause confusion. As a result, fields inside a Field Section sometimes don’t line up horizontally, while Record Detail fields do.
• Don’t place Field Section components on mobile-only Lightning pages. Field Section components are desktop-only and don’t appear when the page is viewed on a phone. • You can use one Lightning page for both desktop and phone. Add the Record Detail - Mobile component to the same page with your Field Section components. Your desktop users see the Field Section components, and your mobile users see the Record Detail - Mobile component.
SEE ALSO: Dynamic Forms Limitations Dynamic Forms Known Issues Break Up Your Record Details with Dynamic Forms
Dynamic Forms Limitations
Keep these limitations in mind when working with Dynamic Forms. EDITIONS
Limitations Available in: Lightning Experience • Dynamic Forms is supported on record pages for custom objects only. • Dynamic Forms doesn’t work in Internet Explorer 11. Users with IE 11 who try to view a page Available in: Group, that uses Dynamic Forms see a page with an error. Professional, Enterprise, • Dynamic Forms doesn’t work on pages based on pinned region templates and custom templates. Performance, Unlimited, and Developer Editions • Blank spaces aren’t supported. • You can add up to 100 fields per column in a Field Section component. • Only fields and sections containing fields are included when migrating a page to Dynamic Forms. Other elements on the page layout, such as custom links and blank spaces, aren't included. • If the page layout you choose to migrate has more fields and sections than we can handle, we migrate up to the first 100 sections in each region and the first 100 fields in each column. The rest of the fields are dropped, even if they’re required fields. You can manually add the dropped items later. If you change your mind after you make the switch, you can click the undo button ( ) to roll back the changes. • If you convert a section from two columns to one, the new single column can only hold 100 fields. If you had more than 100 fields total between the two columns, when you switch to a single column, the first 100 fields are moved into the single column, and the rest of the fields are dropped. If you change your mind after switching to single column, you can revert the change by immediately clicking the undo button ( ).
1003 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
• Users can expand or collapse field sections only while in view or inline edit mode, not in the full edit, create, or clone windows.
SEE ALSO: Knowledge Article: Extended Support for Accessing Lightning Experience Using Microsoft Internet Explorer 11 Dynamic Forms Tips and Considerations Dynamic Forms Known Issues Break Up Your Record Details with Dynamic Forms
Dynamic Forms Known Issues
Keep these known issues in mind when working with Dynamic Forms. EDITIONS • Density settings for field sections aren’t respected in Lightning App Builder preview. Lightning App Builder preview always shows the Comfy setting for field sections. Proper density settings Available in: Lightning are applied during runtime. Experience • If you click View All Dependencies from the Path component, the dependencies that you see Available in: Group, come from the record details on the page layout, not from the Dynamic Forms fields on the Professional, Enterprise, page. Performance, Unlimited, • If you create a record from a lookup, the fields on the window that appears come from the and Developer Editions record details, not from the Dynamic Forms fields on the page. • The CurrencyISOCode field doesn’t display as required (with the asterisk) at runtime, although it still behaves as required. • When you hover over fields in the palette, the data types shown are inaccurate. • On a Dynamic Forms-based page, multiple instances of the same lookup field that look up to an object that’s not supported in the UI API result in a page error. See the User Interface API Developer Guide for the list of supported objects. • Fields in two-column Field Section components don’t horizontally align correctly. • For a non-UI API supported object that has a Forms-enabled object as a related list, if you click New from the related list, the parent lookup field doesn't appear in the New dialog. But you can save the new record. • A record’s printable view is based on the fields from its default page layout, not the fields on the Dynamic Forms-based page. • Dynamic Forms field components aren’t supported inside the Macro Builder. When a Dynamic Forms-enabled record page is opened inside of the Macro Builder, the field components don’t appear.
Visibility Rule Known Issues with Dynamic Forms • Visibility rules based on parent object fields don’t work correctly. • When you clone a record based on a Dynamic Forms-enabled page that has visibility rules, all the fields referenced in the visibility rules are added to the cloned record, regardless of whether those fields are on the page. The field value used in the rule evaluation and the field’s saved value on the cloned record can vary, depending on the cloning user’s access to the field used in the visibility rule. – If the user has read and write access to the field used in the visibility rule, and the field has a value, the source record's original value is used in the rule evaluation and saved to the cloned record. – If the user has read and write access to the field used in the visibility rule, and the field has no value, the source record's blank value is used in the rule evaluation, but the cloned record saves with the field’s default value. – If the user has only read access to the field used in the visibility rule, the source record's original value is used in the rule evaluation, but the cloned record saves with the field’s default value.
1004 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
– If the user doesn’t have read or write access to the field used in the visibility rule, the source value is treated as blank, and the cloned record saves with the field’s default value.
SEE ALSO: Dynamic Forms Tips and Considerations Dynamic Forms Limitations Break Up Your Record Details with Dynamic Forms
Dynamic Interactions in the Lightning App Builder
Dynamic Interactions is part of our continuing drive to make Lightning pages more dynamic and EDITIONS interactive. With Dynamic Interactions, an event occurring in one component on a Lightning page, such as the user clicking an item in a list view, can update other components on the page. Dynamic Available in: Lightning Interactions lets admins create applications with components that communicate and transform Experience based on user interactions, all in the Lightning App Builder UI. It unlocks capabilities that previously were reserved only for developers. Available in: Group, To get the most out of Dynamic Interactions, admins and developers work together. Professional, Enterprise, Performance, Unlimited, Developers write custom components that power the Dynamic Interactions. The developer defines and Developer Editions the events that the component supports and then exposes the events in the Lightning App Builder UI. Then, in the Lightning App Builder, an admin configures the event by setting up the interactions between the components. Dynamic Interactions has four major building blocks. • Event—Anything that can trigger an interaction, such as a mouse click, a button press, or a change in a field’s value. • Interaction—An activity that happens between the source and the target. • Source—The item triggering the event. Currently, only custom Lightning web components and the Dynamic Actions Bar component (Pilot) on page 969 are supported as sources. • Target—The item that’s the target of the interaction. Any component on a Lightning page can be a target. An event occurring in one component (the source) can trigger changes in one or more other components on the page (the targets). A single source can have multiple targets.
Note: Dynamic Interactions is supported only on app pages, and interactions are limited to activity between components.
Example: Kai (they/them) and Rina (she/her) are an admin and developer team. Kai wants to give their on-the-go users an easy way to check the location of various accounts so that they can plan efficient site visits using a simple app page. Kai enlists Rina’s help to make this happen. As a developer, Rina knows that she can wire up events between components using code. But she wants to give Kai the power to configure the event interactions in the way that they need to without having to come back to her every time a change is necessary. Rina creates a custom source component for Kai, plus two other components to act as event targets. After installing the new components in their org, Kai has an app page with three custom components: Account List, Account Detail, and Account Location (a map).
1005 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
The source component is the Account List on the left. It has an Item Selected event enabled, which Rina exposed to the Lightning App Builder UI using new Dynamic Interactions code. After Kai finishes configuring the event interactions, when a user clicks a list item in the Account List component, the event fires. The Account Detail component updates to show that account’s details. At the same time, the Account Location component pinpoints that account’s location on a map. Every new click or tap on an account in the list results in updating the content in the other two components.
SEE ALSO: Lightning Web Components Dev Guide: Configure a Component for Dynamic Interactions in the Lightning App Builder Lightning Web Components Dev Guide: XML Configuration File Elements
1006 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
Configure Interactions in the Lightning App Builder
After you have a custom source component with exposed events in your org, you can assign event EDITIONS targets and configure the event interactions in the Lightning App Builder. 1. From Setup, in the Quick Find box, enter App Builder, then select Lightning App Builder. Available in: Lightning Experience 2. Edit an existing app page, or click New to create one. 3. In the Lightning App Builder, add a custom source component to your page. Available in: Group, If you don’t have target components on your page, add those too. Professional, Enterprise, Performance, Unlimited, 4. Click the source component on the canvas. and Developer Editions 5. In the properties pane, click the Interactions tab. 6. Under the desired event, click Add Interaction. USER PERMISSIONS The properties pane changes to show you the interaction details. To create and save Lightning 7. Select an interaction. pages in the Lightning App Currently, the only interaction available is Update Properties. Builder: • Customize Application 8. Select the target component for the interaction. To view Lightning pages in Components are listed with their region location to help you select the correct component the Lightning App Builder: when you work on pages with components spread across multiple regions. • View Setup and Configuration
9. Configure the target component properties. When you select a target component, its properties appear in the Interaction Details pane. There you define the value that you want each target property to have when the interaction happens. If you leave a target property blank, its value remains unchanged when the event triggers. To use an expression to define a target property value dynamically, click . Checkbox properties have a No change option. If you’ve changed the value of a checkbox property, use this option to reset it back to its original value, and to indicate that you want its value to remain unchanged when the event triggers.
10. Save the page.
SEE ALSO: Dynamic Interactions in the Lightning App Builder Dynamic Interactions Considerations
1007 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
Expressions in Dynamic Interactions Target Properties
An expression is a small chunk of code that can be evaluated to a value. It can be as literal and EDITIONS simple as 1+1 or a more complex combination of variables, operators, and functions. One expression is supported for Dynamic Interactions in the Lightning App Builder: Available in: Lightning {!Event.eventPropertyName}. You can use this expression when setting target Experience component property values in the Lightning App Builder UI and in Metadata API. The value of the eventPropertyName part of the expression varies based on which properties the developer Available in: Group, makes available for the event in the source component. Professional, Enterprise, Performance, Unlimited, Note: If you see the button on a target property, you can set its value with an expression. and Developer Editions With an expression, you can pass a value, such as a record ID or an API name, to the target item. Then when the event fires, the target item can use that value. Using an expression to define a property value makes the event interaction dynamic. We can illustrate this with an example of an app page with custom Account List and Account Location components. Here, an admin is configuring an interaction between the Account List source component and the Account Location target component.
The goal for the interaction in this example is that when a user clicks an account in the list, the Account Location component updates to show the selected account’s location as a point on a map. But the Account Location component needs to know the record ID of the selected account to do that. Passing the record ID into the Account Location component tells the component which record to look at to pull the address information. In this case, the developer made the recId property available as part of the event, so the target value can be set to the active list item’s record ID using the {!Event.recId} expression.
1008 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
Why not enter a 15- or 18-digit record ID into the field? If you do, any item clicked in the Account List always resolves to that one record ID, which isn’t dynamic and is incorrect. If the developer makes more than one target property available, you can set the property to be passed in by starting to type the expression in the field. After the period, you can use autocomplete to select which property to use in the expression. But don’t forget to add the ending bracket } after you make your selection.
Note: Expression autocomplete doesn’t work when: • Using expressions in the rich text editor • Typing an expression in a text field without first clicking the expression button ( )
SEE ALSO: Configure Interactions in the Lightning App Builder Dynamic Interactions Limits and Limitations Dynamic Interactions in the Lightning App Builder
Dynamic Interactions Considerations
Keep these considerations in mind when working with Dynamic Interactions. EDITIONS • Informational components within target components are ignored when the target component’s properties are shown in the Event property editor. Available in: Lightning • If you switch page templates for a page that contains Dynamic Interactions, the available Experience template list shows only templates that support Dynamic Interactions. Available in: Group, • Aura components re-render when an interaction targeting them is triggered. Professional, Enterprise, • Autocomplete doesn’t work when entering an expression in the rich text editor. Performance, Unlimited, and Developer Editions
1009 Extend Salesforce with Clicks, Not Code Guidance for App Builder
• After a component’s event metadata is used on a Lightning page or released as part of a managed package, certain breaking changes aren’t allowed, such as removing the event, renaming a property, or changing a property type.
Dynamic Interactions Limits and Limitations
Keep these considerations in mind when working with Dynamic Interactions in the Lightning App EDITIONS Builder. • Dynamic Interactions is supported only on app pages. Available in: Lightning • Only LWC custom components can be source components, but any component present on Experience the page (Aura or LWC) can be a target. Available in: Group, • Dynamic Interactions isn’t supported on pages based on custom page templates. Professional, Enterprise, • Only String and Rich Text type properties can use expressions to define their values. Performance, Unlimited, • The “required” property restriction isn’t respected when defining a new value for a target and Developer Editions property in Dynamic Interactions, regardless of its type or whether it’s defined with an expression. • Event is the only context supported for expressions in interactions. • You can use expressions only for properties of type String, Integer, and Boolean. • You can’t set a target property value as an array or list of values, such as a multi-select picklist. • You can set a target property value of a String attribute to empty or a Boolean attribute to false using Metadata API but not in the Lightning App Builder UI. • Dynamic Interactions doesn’t work in the Mobile Only app in the Salesforce mobile app or in the legacy tablet mobile experience. • When a dependent property is autopopulated with a value based on a selection you made or a value you entered in another property, the autopopulated value isn’t saved unless you “touch” the dependent property field by clicking into it or tabbing to it.
Guidance for App Builder
Get suggestions for improving your Lightning pages just when you need them. Guidance for App EDITIONS Builder gives you feedback for enhancing your Lightning pages right in the design phase, via tips in a docked prompt. Available in: Lightning Tips are available for categories such as performance, usability, and structural issues. Some issues Experience that the tips cover are also captured in the Salesforce Optimizer report. For example, if two components on a page are identical, you see a tip that tells you so. After you fix the issue, the tip Available in: Group disappears. Essentials, Professional, Enterprise, Performance, Unlimited, and Developer Editions
1010 Extend Salesforce with Clicks, Not Code Guidance for App Builder
If there are tips available for your page, you see an indicator icon on the Help menu. To hide the tips docked prompt while you design your page, go to the Help menu and select Mute Tips. You can reopen the tips prompt by selecting View Tips.
SEE ALSO: Lightning App Builder Considerations Salesforce Help: Improve Your Implementation with Salesforce Optimizer
1011 Extend Salesforce with Clicks, Not Code Lightning Page Performance
Lightning Page Performance
Several factors can negatively affect your Lightning page’s performance at runtime. For example, EDITIONS your users can run into page performance issues if they aren’t using the latest version of a Salesforce recommended browser to view the page. Some factors you can control, and others you can’t. Here Lightning App Builder are some ways you can improve performance while configuring your page in the Lightning App available in: both Salesforce Builder. Classic and Lightning Consider the number, type, and placement of components on the page. These design-related issues Experience can cause a page to load slowly: Lightning Home and utility • Too many components visible on page load bar pages available in: • Too many heavy-impact related lists visible, especially those lists with multiple-object Lightning Experience relationships Lightning app and record • Too many fields in your Record Detail component pages available in: both the Salesforce mobile app and • Having the News or Twitter component visible Lightning Experience If your page falls into one or more of these categories, we recommend that you move some components into a non-default tab or Accordion component section, unless you’re designing the Email application pane page for blind or low-vision users. For the heavy-impact related lists, we recommend that you move pages available in: both the related lists lower on their respective page layouts so that they aren’t part of the initial page Salesforce Classic and Lightning Experience load. If your Record Detail component has many fields, we recommend that you reduce the fields on Available in: Group your page layout to fewer than 60. Alternatively, move the Record Detail component into a Essentials, Professional, non-default tab or Accordion section so that it’s not part of the initial page load. Enterprise, Performance, Unlimited, and Developer For pages that are viewed on a phone, we recommend a maximum of eight visible components Editions per page. If a page has more than eight, put some in a tab or Accordion section or hide them for mobile with a visibility filter. You can see how your pages are performing in the Lightning Usage App from the App Launcher. It shows you the most used pages in your org and their page load time by browser or by page. Performance Analysis for App Builder automatically runs when you build a page. If your page performance is poor or moderate, recommendations to improve performance appear. You can manually check a Lightning record page’s runtime performance at any time by clicking Analyze from the Lightning App Builder toolbar. It assesses page performance based on all visible standard and custom components on the page. Components in nondefault tabs and Accordion sections aren’t analyzed. The User Metrics card provides 90 days of your org’s user data such as browser speeds, network latency, and number of cores. Use this information to help you decide which Performance Analysis for App Builder recommendations to take.
Note: Salesforce measures performance in Experienced Page Time (EPT). The page load time mentioned here and in the Performance Analysis for App Builder tool is EPT.
Considerations • If a page has more than 5 related lists or more than 25 fields in the record detail, users can encounter performance issues when viewing the page in the Salesforce mobile app. • In the Performance Analysis for App Builder tool: – Components that are restricted to the desktop form factor via a visibility rule aren’t included in the phone form factor performance assessment. – Analysis of page performance on a phone is available only on pages whose template supports the phone form factor.
1012 Extend Salesforce with Clicks, Not Code Lightning App Builder Considerations
– Components aren't the only factors influencing page load time, so the numbers in the component impact chart don't add up to 100% of the predicted page load time. – Analysis of pages for the desktop form factor is measured in seconds. For the phone form factor, the page is scored based on the components that are visible when the page loads on a phone. – User metrics are org-specific or page-specific data. Previously activated pages display metrics from visits to that page. New pages display metrics from visits to all org pages. Metrics displayed in a sandbox can differ from metrics in production.
SEE ALSO: Supported Browsers and Devices Technical Requirements and Performance Best Practices Measure Performance for Your Salesforce Org Get Lightning Experience Adoption Insights with the Lightning Usage App
Lightning App Builder Considerations
Keep these considerations in mind when working with Lightning pages and Lightning apps in the EDITIONS Lightning App Builder. Lightning App Builder General available in: both Salesforce Classic and Lightning • The Lightning App Builder supports the same browsers as Lightning Experience and isn’t Experience supported on mobile browsers. The minimum recommended resolution for the Lightning App Lightning Home and utility Builder is 1280x1024. bar pages available in: • To reduce user confusion, give each tab and Accordion section a unique label. Lightning Experience • The Lightning App Builder palette displays only the components that are available for the Lightning app and record devices supported by the page template. For example, you’re working on a page whose template pages available in: both the supports only desktop, the component palette contains components that support desktop, Salesforce mobile app and whether they support desktop only or both desktop and phone. Lightning Experience • When you open a record page in the Lightning App Builder, you see only the components that are available for the object tied to that page. For person account pages, some of the components Email application pane pages available in: both you see apply only to business accounts. Salesforce Classic and • When viewing a page in the Lightning App Builder, the form factor switcher displays only the Lightning Experience devices that the page template supports. • If the Lightning App Builder canvas view is switched to a form factor that a component on the Available in: Group page doesn’t support, that component displays as a placeholder with a warning. Essentials, Professional, Enterprise, Performance, • When a component is viewed on a device that the component doesn’t support, it’s dropped Unlimited, and Developer from the page. Editions • If you’re curious about a component, click it to see more information in the properties pane. • You can create and edit a record page even if you don’t have permission to access the object that the page is associated with. You can add, remove, delete, and reconfigure components on the page, but you don’t see any of the content for the components that are based on that object. • In Salesforce Classic, Lightning page tabs don’t display on the All Tabs page when you click . Lightning page tabs also don’t appear in the Available Tabs list when you customize the tabs for your apps.
1013 Extend Salesforce with Clicks, Not Code Lightning App Builder Considerations
• When editing navigation items in a Lightning app, consider how many items you include. Users can’t remove the items you include in the navigation bar, and they can’t personalize the navigation bar when it contains more than 50 items. For example, if you include 32 items in an app’s navigation bar, users can add 18 more personal items. Users can personalize the navigation to add or move items, but users can't remove or rename the items that you add. • Put the activity timeline component at the bottom of a layout, with no other components beneath it. • On Lightning Experience record pages, a Record Detail component that contains more than four external lookup fields breaks the page at runtime.
Page Templates • The Three Regions template and the pinned region templates are designed with Lightning console apps in mind. They feature a main region and two sidebars with fixed proportional widths. The main region is 50%, and the side region widths are each 25%. Three-region templates require more screen width to display correctly. Three-region templates can display incorrectly on certain devices or monitors with low resolutions. • When switching page templates, if a region in the template that you’re switching to has more than 25 components mapped to it, all components after the 25th are dropped from the page. You can proceed with the template swap, but you must then manually add the dropped components from the palette and reconfigure their properties. • The console pinned region templates let users view and work with records while navigating subtabs in console apps. These templates also work in apps with standard navigation. However, we recommend that you use a non-pinned region template in standard apps because those apps don’t benefit from a pinned region. When working with pinned region templates, keep the following in mind. – The templates are available only for record pages. – Pinned regions don’t support theming. For example, if you use custom theming to brand your app with the color green, the pinned region doesn’t apply the green color.
Page Activation and Assignment • If a device isn’t on the options list when you try to assign a Lightning page as the org default, the page template doesn’t support it. • You can see which record pages are activated for which Lightning app and which form factor in the Lightning Record Pages related list in the Object Manager. • If you no longer want a page to be an app or org default, redo the activation process for the page, and select the option to remove it as the default. • If you activate a page and then return to make changes, you don’t have to activate it again. Clicking Save after you make your edits pushes the changes to your users. • If you no longer want a page assigned to a particular form factor, redo the activation process, and select the option to remove it. • If you activate a page for only one form factor, you can add support for another form factor later as long as the page’s template supports it. • Changes that you make to Lightning record page assignments aren’t immediately reflected in the Salesforce mobile app. To see a newly assigned record page, close and restart the Salesforce mobile app. • If there are no custom app-level page assignments set for the Service Console or Lightning Sales Console apps, users viewing those apps in the Salesforce mobile app see the org default record page assigned to the object instead of the system app default record page. • If you assign a custom record page as the org-wide default for an object, it becomes the default page for that object across all your Lightning apps. It also appears as the default record page for that object in Classic apps when you open them in Lightning Experience. • Accounts and person accounts have different standard default pages to begin with. However, when you create a Lightning page for accounts and assign it as the default for an org or an app, that page becomes the org or app default for business accounts and
1014 Extend Salesforce with Clicks, Not Code Considerations and Limitations for Flows in Lightning Pages
person accounts. To display a custom record page for person accounts, create a custom account record page, then assign it to the person account record type.
Component Visibility Rules • If a visibility filter assigns a component to “Device equals desktop,” the component appears on a page when viewed in Lightning Experience on a desktop and when viewed in a browser on an iPad. • The Salesforce mobile app on an iPad uses the phone form factor. Salesforce viewed in a browser on an iPad uses the desktop form factor. These form factors affect components on record pages differently. – If the visibility filter is “Device not equal to desktop” or “Device equals phone,” the component appears on record pages in the Salesforce mobile app on a phone and an iPad. It doesn’t appear on pages viewed in a browser on an iPad. – If the visibility filter is “Device not equal to phone,” the component appears on record pages in Lightning Experience on a desktop and on pages viewed in a browser on an iPad. It doesn’t appear in the Salesforce mobile app on a phone or an iPad.
Pages and Packages • If you package a Lightning page that references protected labels, then if a subscriber org clones that page, the protected labels cause the components that use them on the cloned page to be invalid. • A Lightning page installed from a managed package appears in the Lightning pages list with a Clone option rather than Edit or Delete. The Edit and Delete buttons are also replaced with Clone on the installed page’s detail page.
SEE ALSO: Create and Configure Lightning Experience Record Pages Lightning App Builder Limits and Limitations Supported Browsers and Devices
Considerations and Limitations for Flows in Lightning Pages
Here are some things to keep in mind when you add a flow component to a Lightning page. EDITIONS Lightning pages always use Lightning runtime, so also review Limitations of Lightning Runtime for Flows. Available in: both Salesforce Classic and Lightning Running Flows from a Lightning Page Experience When a user opens a Lightning page that has a flow component, the flow runs when the page loads. Make sure that the flow doesn’t perform any actions – such as create or delete records Available in: Essentials, – before the first screen. Professional, Enterprise, Performance, Unlimited, Input Variable Limitations and Developer Editions • These variables aren’t supported. – Collection variables – Record variables – Record collection variables
• The component supports only manually entered values for input variables. • Text input variables accept a maximum length of 4,000 characters.
1015 Extend Salesforce with Clicks, Not Code Lightning App Builder Limits and Limitations
Deployment Considerations Change sets and the Metadata API deploy all flows as inactive, which users can’t run. If you deploy a Lightning page (known as FlexiPage in the API) that contains a flow component, make sure to activate the flow.
Lightning App Builder Limits and Limitations
Keep these limits and limitations in mind when working with Lightning pages and Lightning apps EDITIONS in the Lightning App Builder. • In Salesforce Classic, the Default On and Default Off options for Lightning page tabs don’t work Lightning App Builder the same way as for other custom tabs. The Lightning page menu item appears for the selected available in: both Salesforce profiles in Salesforce for Android, Salesforce for iOS, and Salesforce mobile web whether you Classic and Lightning choose Default On or Default Off. Select the Tab Hidden option to hide the Lightning page Experience for the selected profiles. Lightning Home and utility • You can place up to 100 tabs in a Tabs component. bar pages available in: • A Lightning page region can contain up to 100 components. Lightning Experience • Lightning component global actions aren’t supported for app pages. Lightning app and record • Page overrides by profile aren’t supported in packaging. They are supported in change sets, pages available in: both the but have to be added manually. Salesforce mobile app and Lightning Experience • Dropdown menus in the Lightning App Builder can display up to 200 items. Enter a few characters, and all available matches are displayed as you type. Email application pane • Although you can add the Potential Duplicates component to person account pages, the pages available in: both Salesforce Classic and component doesn’t display duplicate person accounts. Lightning Experience • Custom tab labels in the Tabs component—including those installed from packages—aren’t translated. For example, if you create a custom Goals tab in English, then view the page as a Available in: Group user whose language is set to French, the tab still displays as Goals. However, you can use the Essentials, Professional, {!$Label.customLabelName} expression in a component label or attribute to represent Enterprise, Performance, a custom label that you create in Setup using the custom label feature. For more information, Unlimited, and Developer see “Build Localized Component Labels and Attribute Values on Lightning Pages with Custom Editions Labels on page 979.”
Component Visibility Rules • A component can have up to 10 filters. • Visibility filters aren’t supported for individual tabs inside the Tabs component. • Some person account fields, including Email and Mobile, can’t be used in filters.
SEE ALSO: Lightning App Builder Considerations
Resources for the Point & Click Administrator
In addition to online help, Salesforce creates guides and tip sheets to help you learn about our features and successfully administer Salesforce.
1016 Extend Salesforce with Clicks, Not Code Resources for the Point & Click Administrator
Platform and Apps
Guides and Tip Sheets For End Users For Admins Implementing State and Country/Territory Picklists
Useful Workflow Rules
Useful Approval Processes
Salesforce Sites Implementation Guide
Formulas
Guides and Tip Sheets For End Users For Admins Useful Formula Fields
Tips for Reducing Formula Size
Using Date and Date/Time in Formulas
Useful Validation Rules
1017 INDEX
C N clickjack protection Notification Builder 461 Site.com 528 Custom fields P references 242 Prompts 57, 63, 68, 70, 72–73, 75, 77 Custom Help 93 S I Site.com In-App Guidance 57 clickjacking 528
1018
Note: Rich text editors in custom rich text area fields have minor formatting differences in Lightning Experience and the Salesforce mobile app, as compared to Salesforce Classic. For more information, see Editing Rich Text Area Fields in Records. The tags can include the following attributes.
alt face size
background height src
border href style
class name target
colspan rowspan width
277 Extend Salesforce with Clicks, Not Code Customize Fields
The following URL protocols are supported. • http: • https: • file: • ftp: • mailto: • # • / for relative links
Rich Text Editors Using CKEditor Rich text editors in Salesforce Classic continue to use CKEditor. Beginning in Spring ’21, Salesforce uses CKEditor version 4.14.0. In Salesforce Classic, CKEditor is used by: • Chatter Publisher • Custom Fields • Email • Flow Builder • Groups • Idea Themes • Knowledge Article In Lightning Experience and the Salesforce mobile app, the following features have rich text editors that use CKEditor. • Email Composer, using the Send Email action • Lightning Knowledge These features load the rich text editor in an iframe. To load the editor correctly in an iframe, your browser must use appropriate security settings. Refer to your browser’s instructions to configure the settings. For example: Internet Explorer Make sure that the Launching programs and files in an IFRAME security setting is set to Enable or Prompt. Safari We recommend changing your Privacy settings for cookies to Allow from websites I visit. Chrome Make sure that Block third-party cookies and site data is not selected in the Content settings. To enter content in Internet Explorer 11 on touch-enabled devices running Windows, first click the rich text area field, then tab into the editor.
Add Videos Using the HTML Editor Adding Code Samples to Posts You can paste code samples into your posts in Chatter Answers and Ideas.
SEE ALSO: Editing Rich Text Area Fields in Records Rich Text Fields in Knowledge Articles
278 Extend Salesforce with Clicks, Not Code Customize Fields
Add Videos Using the HTML Editor
Available in: Salesforce Classic and Lightning Experience USER PERMISSIONS
Available in: Enterprise, Performance, Unlimited, and Developer Editions To create or change custom fields: • Customize Application Approved Video Sites • app.ustudio.com • dailymotion.com • documentforce.com • fast.wistia.net • force.com • ooyala.com • play.vidyard.com • player.youku.com • players.brightcove.net • salesforce.com • salesforce-sites.com • sites.com • ustream.tv • visualforce.com • videos.sproutvideo.com • vimeo.com • youtube.com (including youtube.co.uk, youtube.ca, youtube.com.br, youtube.es, youtube.fr, youtube.ie, youtube.jp, youtube.nl, youtube-nocookie.com, and youtube.pl) 1. Copy the
Button Description Lets you paste the
Lets you paste the
3. Click Save.
279 Extend Salesforce with Clicks, Not Code Customize Fields
Note: If you run into problems embedding videos, check your browser security settings. Some browsers block iframe elements. Also, embedded videos are removed from emails when you insert Knowledge articles into case emails. Also, you can't send embedded videos via email.
SEE ALSO: Rich Text Editor
Adding Code Samples to Posts You can paste code samples into your posts in Chatter Answers and Ideas. When you enable Chatter Answers and Ideas, users can add code samples to their posts. Code can be copied from any text editor and pasted into the body of a post with the formatting preserved. 1. Copy the code sample from a text editor to your clipboard. 2. In the editor, enter the text for your posts and click the button to add the code sample. 3. Paste the code sample into the Add a code sample text box and click OK. The code sample appears in the body of the post with its formatting intact.
Change the Custom Field Type
1. From the management settings for the field’s object, go to Fields. EDITIONS Note: For fields on Salesforce Knowledge article types, from Setup, enter Knowledge Article Types in the Quick Find box, select Knowledge Article Types, and Available in: both Salesforce then select an article type. Classic and Lightning Experience 2. Click Edit next to the custom field you want to change. Available in: All Editions 3. Click Change Field Type. Standard Objects are not 4. Select a new data type and click Next. available in Database.com 5. Enter a field label, name, and any other attributes, and then save your changes. Salesforce Connect external objects are available in: Developer Edition and for Notes on Changing Custom Field Types an extra cost in: Enterprise, Performance, and SEE ALSO: Unlimited Editions Custom Field Types Which Standard Fields Can I Encrypt? USER PERMISSIONS Which Custom Fields Can I Encrypt? To change custom fields: Find Object Management Settings • Customize Application
Notes on Changing Custom Field Types Note these considerations before you convert fields from one type to another: • Only convert custom fields that there’s no data for or you risk losing your data. Changing the data type of an existing custom field can cause data loss in these situations:
280 Extend Salesforce with Clicks, Not Code Customize Fields
– Changing to or from type Date or Date/Time – Changing to Number from any other type – Changing to Percent from any other type – Changing to Currency from any other type – Changing from Checkbox to any other type – Changing from Picklist (Multi-Select) to any other type – Changing to Picklist (Multi-Select) from any other type Currently defined picklist values are retained when you change a picklist to a multi-select picklist. If records contain values that aren’t in the picklist definition, those values are deleted from those records when the data type changes.
– Changing from Auto Number to any other type – Changing to Auto Number from any type except Text – Changing from Text to Picklist – Changing from Text Area (Long) to any type except Email, Phone, Text, Text Area, or URL
• If data is lost, any list view based on the custom field is deleted, and assignment and escalation rules can be affected. • You can’t change the data type of any custom field that is mapped for lead conversion. • If you change the data type of a custom field that‘s set as an external ID, choosing a data type other than text, number, or email causes the field to no longer act as an external ID. • The option to change the data type of a custom field isn’t available for all data types. For example, an existing custom field can’t be converted into an encrypted field nor can an encrypted field be converted into another data type. • In Salesforce Knowledge article types, the file field type can't be converted into other data types. • You can’t change the data type of a custom field referenced by other items in Setup such as Visualforce pages, Apex code, processes, or flows. • Changing a custom field type can require changing many records at once. If your request is queued to process these changes efficiently, you receive an email notification when the process has completed. • Before changing a custom field’s type, make sure it isn’t the target of a workflow field update or referenced in a field update formula that would be invalidated by the new type. • If you encrypt a custom field using Shield Platform Encryption, you can’t change the field type. These data types have other restrictions when you convert them:
Data Type Description Auto Number If you convert an auto-number field into a text field, the data in that field remains unchanged. Also, you can safely convert a text custom field into an auto-number field without losing your data. Converting an auto-number field into any other data type results in data loss. Auto-number fields can contain a maximum of 30 characters. Before converting a text custom field into an auto-number field, change any records that contain more than 30 characters in that field.
Formula Formula fields are special read-only fields that can’t be converted to any other data type. Likewise, you can’t convert any other field type into a formula field.
281 Extend Salesforce with Clicks, Not Code Customize Fields
Data Type Description Picklist Changing your custom picklists into custom checkboxes is simple. If you select Checkbox as the new data type, you can choose which picklist values to map to checked boxes and unchecked boxes. You can change custom picklists into multi-select picklists without losing any data. Since your records contain only a single value of that picklist, that value is still selected but users can select more values.
Relationships • You can convert relationship fields to nonrelationship fields and vice versa, but only on external objects. • If your org has a large number of records, Salesforce displays a waiting page after you request to change a master-detail into a lookup relationship or a lookup into a master-detail relationship. • After you have created a roll-up summary field on an object, you cannot convert the object's master-detail relationship into a lookup relationship. • If any records on an object have a null value set for the lookup field, you can’t convert the lookup relationship to a master detail relationship. • If you convert a master-detail relationship to a lookup for a custom object on the “detail” side, the org-wide default for the object is automatically updated to Public Read/Write. Similarly, converting a lookup to a master-detail-relationship changes the org-wide default to Controlled by Parent.
Text By default, an upper bound limit of 4,000 is applied to inactive unrestricted picklists for each field. If you exceed this limit when converting a text field to a picklist field, you receive an error message. You can’t convert a defined unique text field to a picklist or a multi-select picklist.
Text Area (Long) When you convert a long text area field to an Email, Phone, Text, Text Area, or URL type field, the record data is truncated to the first 255 characters of the field.
Text Area (Rich) You can convert rich text area fields into long text area fields only. Any images get deleted the next time you save the long text area field. After converting, markup is hidden in the long text area field but it isn’t removed from the record, so if you change your mind, you can restore the markup before you save the record.
SEE ALSO: Change the Custom Field Type Custom Metadata Type Fields
282 Extend Salesforce with Clicks, Not Code Customize Fields
Define Default Field Values
Define a default value for a field. Use a formula to generate dynamic values or constants for static EDITIONS values. 1. Create a custom field. See Create Custom Fields. You can also define a default value for an Available in: both Salesforce existing custom field. See Edit Custom Fields. Classic and Lightning Experience 2. Choose the type of field and click Next. For a list of the types available for default values, see Default Field Values. Available in: Contact 3. Enter the attributes for the field. Manager, Group, Professional, Enterprise, 4. Enter a default value or define a formula to calculate the default value. Performance, Unlimited, and Developer Editions Note: You can define a formula for default values only where appropriate. For example, the default value options for a checkbox field are limited to the options available for those types of fields, such as Checked or Unchecked. USER PERMISSIONS For picklists, a valid formula result is either a constant or the API name of an entry in the To view default field values: Values list. The formula result has higher precedence than the default assigned in the • View Setup and Values list. If the formula doesn’t generate a valid result, the default assigned in the Values Configuration list is entered in the field. If a default isn’t assigned to the Values list, no value is entered To define or change default in the picklist field. field values: • Customize Application 5. Click Next. 6. Set the field-level security to determine whether the field is visible for specific profiles, and click Next. 7. Choose the page layouts that display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is added to the bottom of the user detail page. 8. Click Save to finish or Save & New to create more custom fields. You must specify a default value for required campaign member custom fields. To avoid uniqueness errors, don’t assign default values to fields that are both required and unique.
Default Field Values Prepopulate field values with defaults to save your users time and improve consistency. Default field values make your users more productive by reducing the number of fields they need to fill in manually. Useful Default Field Value Formulas Default Field Value Considerations Be aware of the behavior and rules when you assign default values to custom fields.
283 Extend Salesforce with Clicks, Not Code Customize Fields
Default Field Values
Prepopulate field values with defaults to save your users time and improve consistency. Default EDITIONS field values make your users more productive by reducing the number of fields they need to fill in manually. Available in: both Salesforce Default field values automatically insert the value of a custom field when a new record is created. Classic (not available in all You can use a default value on a formula for some types of fields or exact values, such as Checked orgs) and Lightning or Unchecked for checkbox fields. Experience After you have defined default values: Available in: Contact Manager, Group, 1. The user chooses to create a new record. Professional, Enterprise, 2. Default field value is executed. Performance, Unlimited, 3. Salesforce displays the edit page with the default field value prepopulated. and Developer Editions 4. The user enters the fields for the new record. 5. The user saves the new record. The user can change the field’s value but the initial default field value is only executed once, during record creation. For example, you can set the default field value on a custom lead field to seven days after the creation date to signify when to contact the lead again. You can change this value later, but you cannot automatically restore the value that was seven days after the creation date. Set up default field values for the following types of custom fields: • Checkbox • Currency • Date • Date/Time • Email • Number • Percent • Phone • Picklist • Text • Text Area • Time • URL For a description of these types, see Custom Field Types on page 225.
SEE ALSO: Define Default Field Values Default Field Value Considerations Useful Default Field Value Formulas Reference Custom Metadata Type Records in Default Values
284 Extend Salesforce with Clicks, Not Code Customize Fields
Useful Default Field Value Formulas
EDITIONS Maximum Discount Rate Your organization may apply different discount rates to opportunities based on the department of Available in: both Salesforce the person creating the opportunity. Use the following example to set a default value for a custom Classic (not available in all field called Discount Rate on opportunities. orgs) and Lightning Experience
Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To view default field values: • View Setup and Configuration To define or change default field values: • Customize Application
CASE(User.Department, "IT", 0.25, "Field", 0.15, 0)
In this example, the formula inserts a discount rate of 25% on any opportunity created by a user in the IT department or 15% on any opportunity created by someone in the Field department. A zero is applied if the creator doesn't belong to either of these departments. This is a custom percent field on opportunities that uses the standard user field Department.
Product Language You might want to associate a product with its language so that your users know the type of documentation or adapter to include. Use the following default value formula to automatically set the language of a product based on the country of the user creating the product. In this example, the default value is Japanese if the user's country is Japan and English if the user's country is US. If neither is true, the default value unknown is inserted into the Product Language field.
CASE($User.Country , "Japan", "Japanese", "US", "English","unknown")
Tax Rate Use this default value formula to set the tax rate of an asset based on the user's city. Create a custom percent field with the following default value:
IF($User.City = "Napa", 0.0750, IF($User.City = "Paso Robles", 0.0725, IF($User.City = "Sutter Creek", 0.0725, IF($User.City = "Los Olivos", 0.0750, IF($User.City = "Livermore", 0.0875, null ) )
285 Extend Salesforce with Clicks, Not Code Customize Fields
) ) )
In this example, a tax rate of 8.75% is applied to an asset when the user's address is in the city of Livermore. When none of the cities listed applies, the Tax Rate field is empty. You can also use the Tax Rate field in formulas to automatically calculate taxable amounts and final sales prices.
Default Field Value Considerations
Be aware of the behavior and rules when you assign default values to custom fields. EDITIONS Default field values automatically insert the value of a custom field when a new record is created. You can use a default value on a formula for some types of fields or exact values, such as Checked Available in: both Salesforce or Unchecked for checkbox fields. Review the following considerations before incorporating default Classic (not available in all field values in your organization. orgs) and Lightning Experience • If a default value is based on the value of a merge field, Salesforce uses the value of the merge field at the time the default value is executed. If the value of the merge field changes later, the Available in: Contact default value is not updated. Manager, Group, • Users can change or remove the default field value on a record. Professional, Enterprise, Performance, Unlimited, • Don’t assign default values to fields that are both required and unique, because uniqueness and Developer Editions errors can result. • If you make an activity custom field universally required, you must also provide a default value. • If an activity custom field is unique, you cannot provide a default value. • Default field values are different from formula fields in the following ways: they are only executed once, at record creation; they are not read only; and the user can change the value but cannot restore the default field value. • Since the default value is inserted before users enter any values in the new record, you cannot use the fields on the current record to create a default field value. For example, you cannot create a default field value on a contact that uses the first initial and last name because those values are not available when you click New to create a contact record. However, you can use the record type because it is selected before the record edit page displays. • Record type default field values have precedence over an object’s default field values. • To apply a different default value for different record types, use the record type as a merge field in a CASE function within the default field value setup. • Fields that are not visible to the user due to field-level security are still available in the formula for a default field value. • Connect Offline and Salesforce for Outlook do not display default values. However, Salesforce inserts the default values when a user syncs unless the user entered a value. • Default field values are not available in the Self-Service portal. • Lead conversion, Web-to-Lead, and Web-to-Case do not execute default field values. • Visualforce pages don’t support default field values.
Note: You can define a formula for default values only where appropriate. For example, the default value options for a checkbox field are limited to the options available for those types of fields, such as Checked or Unchecked. For picklists, a valid formula result is either a constant or the API name of an entry in the Values list. The formula result has higher precedence than the default assigned in the Values list. If the formula doesn’t generate a valid result, the default assigned in the Values list is entered in the field. If a default isn’t assigned to the Values list, no value is entered in the picklist field.
286 Extend Salesforce with Clicks, Not Code Customize Fields
Validation Rules
Improve the quality of your data using validation rules. Validation rules verify that the data a user EDITIONS enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns Available in: both Salesforce a value of “True” or “False”. Validation rules also include an error message to display to the user Classic and Lightning when the rule returns a value of “True” due to an invalid value. Experience
Important: We don’t recommend using a custom number field that Einstein Prediction Available in: Essentials, Builder manages in a validation rule. If the prediction changes the field value in a way that Contact Manager, Group, violates the validation rule, you can’t update the record that uses the field. If you get a Professional, Enterprise, validation rule error when saving a record that contains an Einstein Prediction Builder field, Performance, Unlimited, edit, deactivate, or delete the validation rule. Developer, and Database.com Editions After you have defined validation rules: 1. The user chooses to create a record or edit an existing record. 2. The user clicks Save. 3. All validation rules are verified. • If all data is valid, the record is saved. • If any data is invalid, the associated error message displays without saving the record.
4. The user makes the necessary changes and clicks Save again. You can specify the error message to display when a record fails validation and where to display it. For example, your error message can be “The close date must occur after today's date.” You can choose to display it near a field or at the top of the page. Like all other error messages, validation rule errors display in red text and begin with the word “Error”.
Note: In Salesforce Classic, users with custom profiles must have Read permission on a standard object to view validation rules for that object.
Important: Validation rules apply to new and updated records for an object, even if the fields referenced in the validation rule aren’t included in a page layout or an API call. Validation rules don't apply if you create records for an object with Quick Create. If your organization has multiple page layouts for the object on which you create a validation rule, verify that the validation rule works on each layout. If your organization has any integrations that use this object, verify that the validation rule works for each integration.
Managing Validation Rules Define Validation Rules Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value. Clone Validation Rules Activate Validation Rules Validation Rules Fields Tips for Writing Validation Rules
287 Extend Salesforce with Clicks, Not Code Customize Fields
Validation Rule Considerations Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value. Review these considerations before implementing validation rules in your organization.
SEE ALSO: Examples of Validation Rules Custom Metadata Type Fields and Validation Rules Custom Metadata Types and Validation Rule Formulas Set an AI Prediction Field Einstein Prediction Builder Edit Object Permissions in Profiles
Managing Validation Rules
Validation rules verify that the data a user enters in a record meets the standards you specify before EDITIONS the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include Available in: both Salesforce an error message to display to the user when the rule returns a value of “True” due to an invalid Classic and Lightning value. Experience From the validation rules page you can: Available in: Essentials, • Define a validation rule. Contact Manager, Group, • Click Edit next to a rule name to update the rule fields. Professional, Enterprise, Performance, Unlimited, • Delete a validation rule. Developer, and • Click a validation rule name to view more details or to clone the rule. Database.com Editions • Activate a validation rule.
SEE ALSO: Examples of Validation Rules
288 Extend Salesforce with Clicks, Not Code Customize Fields
Define Validation Rules
Validation rules verify that the data a user enters in a record meets the standards you specify before EDITIONS the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include Available in: both Salesforce an error message to display to the user when the rule returns a value of “True” due to an invalid Classic and Lightning value. Experience Before creating validation rules, review the Validation Rule Considerations. Available in: Essentials, 1. From the management settings for the relevant object, go to Validation Rules. Contact Manager, Group, Professional, Enterprise, 2. In the Validation Rules related list, click New. Performance, Unlimited, Note: The detail page of a custom activity field does not list associated validation rules. Developer, and To edit the validation rule for a custom activity field, select the validation rule from Setup Database.com Editions by entering Activities in the Quick Find box, then selecting Activities and choose Task Validation Rules or Event Validation Rules. USER PERMISSIONS
3. Enter the properties of your validation rule. To view field validation rules: 4. To check your formula for errors, click Check Syntax. • View Setup and Configuration
SEE ALSO: To define or change field validation rules: Validation Rules • Customize Application Clone Validation Rules Tips for Writing Validation Rules Examples of Validation Rules
Clone Validation Rules
1. From the management settings for the relevant object, go to Validation Rules. EDITIONS 2. In the Validation Rules related list, click the name of the validation rule. 3. Click Clone. Available in: both Salesforce Classic and Lightning 4. Define the new rule based on the original rule. Experience
5. Click Save to finish or Save & New to create additional validation rules. Available in: Essentials, Note: The detail page of a custom activity field does not list associated validation rules. To Contact Manager, Group, edit the validation rule for a custom activity field, select the validation rule from Setup by Professional, Enterprise, Performance, Unlimited, entering Activities in the Quick Find box, then selecting Activities and choose Developer, and Task Validation Rules or Event Validation Rules. Database.com Editions
SEE ALSO: USER PERMISSIONS Define Validation Rules Validation Rules Fields To view field validation rules: • View Setup and Activate Validation Rules Configuration To define or change field validation rules: • Customize Application
289 Extend Salesforce with Clicks, Not Code Customize Fields
Activate Validation Rules
1. From the management settings for the relevant object, go to Validation Rules. EDITIONS 2. Click Edit next to the rule you want to activate. 3. To activate the rule, select Active, and save your changes. Available in: both Salesforce Classic and Lightning 4. To deactivate the rule, deselect Active, and save your changes. Experience
Note: The detail page of a custom activity field does not list associated validation rules. Available in: Essentials, Contact Manager, Group, Professional, Enterprise, SEE ALSO: Performance, Unlimited, Define Validation Rules Developer, and Validation Rules Fields Database.com Editions Find Object Management Settings USER PERMISSIONS
To view field validation rules: • View Setup and Configuration To define or change field validation rules: • Customize Application
Validation Rules Fields
Field Description EDITIONS
Rule Name Unique identifier of up to 40 characters with no spaces or special Available in: both Salesforce characters such as extended characters. Classic and Lightning Experience Active Checkbox that indicates if the rule is enabled. Available in: Essentials, Description A 255-character or less description that distinguishes the validation Contact Manager, Group, rule from others. For internal purposes only. Professional, Enterprise, Error Condition The expression used to validate the field. See Build a Formula Field Performance, Unlimited, Formula and Formula Operators and Functions. Developer, and Database.com Editions Error Message The message that displays to the user when a field fails the validation rule. If your organization uses the Translation Workbench, you can translate the error message into the languages Salesforce supports. See Enable or Disable Translation Workbench.
Error Location Determines where on the page to display the error. To display the error next to a field, choose Field and select the field. If the error location is a field, the validation rule is also listed on the detail page of that field. If the error location is set to a field that is later deleted, to a field that is read only, or to a field that isn’t visible on
290 Extend Salesforce with Clicks, Not Code Customize Fields
Field Description the page layout, Salesforce automatically changes the location to Top of Page.
Note: Error messages can only be displayed at the top of the page in validation rules for case milestones and Ideas.
SEE ALSO: Define Validation Rules
Tips for Writing Validation Rules
• Consider all the settings in your organization that can make a record fail validation, including EDITIONS assignment rules, field updates, field-level security, or fields hidden on a page layout. • Be careful not to create contradicting validation rules for the same field; otherwise, users won’t Available in: both Salesforce be able to save the record. Classic and Lightning Experience Tip: A poorly designed validation rule can prevent users from saving valid data. Make sure you thoroughly test a validation rule before activating it. You can also use the debug Available in: Essentials, log to monitor the details of your rule implementation. Contact Manager, Group, Professional, Enterprise, • When referencing related fields in a validation formula, make sure those objects are deployed. Performance, Unlimited, • Use the RecordType.Id merge field in your formula to apply different validations for Developer, and different record types. Database.com Editions • You don’t have to begin a validation rule formula with the IF function. Any Boolean error condition expression works. For example: – Correct: CloseDate < TODAY() – Incorrect: IF(CloseDate < TODAY(), TRUE, FALSE)
• Keep in mind that when a validation rule contains the BEGINS or CONTAINS function, it processes blank fields as valid. For example, if you have a validation rule that tests whether the serial number of an asset begins with “3”, all assets with a blank serial number are considered valid. • When using a validation rule to ensure that a number field contains a specific value, use the ISBLANK function to include fields that don’t contain any value. For example, to validate that a custom field contains a value of ‘1’, use the following validation rule to display an error if the field is blank or any other number:
OR (ISBLANK (field__c), field__c<>1)
• Avoid using the IsClosed or IsWon opportunity merge fields in validation formulas. Instead, use the ISPICKVAL function to determine if the Stage contains the appropriate value. For example, the following validation formula makes a custom Project Start Date field required whenever the Stage is “Closed Won”:
AND(ISPICKVAL(StageName, "Closed Won"), ISBLANK(Project_Start_Date__c))
• Simplify your validation formulas by using checkbox fields, which don't require any operator because they return true or false. For example, the following validation formula checks to be sure an opportunity has opportunity products using the HasOpportunityLineItem merge field before users can save a change to it:
NOT(OR(ISNEW(),HasOpportunityLineItem))
291 Extend Salesforce with Clicks, Not Code Customize Fields
Tips for Writing Validation Rule Error Messages • Give instructions. An error message like “invalid entry” doesn’t tell the user what type of entry is valid. Write something more specific, such as “Close Date must be after today.” • Always include the field label. Users might not know what field is failing validation, especially if the error message appears at the top of the page.
Note: When defining validation rules, you can set the error location to Top of Page or Field. If the error location is set to a field that is later deleted, to a field that is read only, or to a field that isn’t visible on the page layout, Salesforce automatically changes the location to Top of Page.
• If you have a multilingual organization, translate your error messages. You can translate error messages using the Translation Workbench. • Assign corresponding numbers to validation rules and their error messages. This allows you to identify the source of the error.
SEE ALSO: Define Validation Rules Validation Rule Considerations
Validation Rule Considerations
Validation rules verify that the data a user enters in a record meets the standards you specify before EDITIONS the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include Available in: both Salesforce an error message to display to the user when the rule returns a value of “True” due to an invalid Classic (not available in all value. Review these considerations before implementing validation rules in your organization. orgs) and Lightning Experience
How Salesforce Processes Validation Rules Available in: Essentials, Salesforce processes rules in the following order: Contact Manager, Group, Professional, Enterprise, 1. Validation rules Performance, Unlimited, 2. Assignment rules Developer, and Database.com Editions 3. Auto-response rules 4. Workflow rules (with immediate actions) 5. Escalation rules In addition, • When one validation rule fails, Salesforce continues to check other validation rules on that field or other fields n the page and displays all error messages at once. • If validation rules exist for activities and you create an activity during lead conversion, the lead converts but a task isn’t created. • Validation rules are only enforced during lead conversion if validation and triggers for lead conversion are enabled in your organization. • Campaign hierarchies ignore validation rules. • Salesforce runs validation rules before it creates records submitted via Web-to-Lead and Web-to-Case and then creates records that have valid values. • To give a default value to a division field before the validation rule evaluation, the division field must be on the page layout. • Validation rules continue to run on individual records if the owner is changed. If the Mass Transfer tool is used to change the ownership of multiple records, however, validation rules don’t run on those records.
292 Extend Salesforce with Clicks, Not Code Customize Fields
Validation Rule Field Restrictions Validation rule formulas don’t or can’t refer to: • Compound fields, including addresses, first and last names, and dependent picklists and lookups
Note: However, you can use compound fields in ISNULL, ISBLANK, and ISCHANGED functions.
• Campaign statistic fields, including statistics for individual campaigns and campaign hierarchies • Merge fields for auto-number or compound address fields, such as Mailing Address
Note: You can use merge fields for individual address fields, such as Billing City, in validation rule formulas.
In relation to other fields and functions in Salesforce, validation rules behave as follows: • The detail page of a custom activity field doesn't list associated validation rules. • Workflow rules and some processes can invalidate previously valid fields. Invalidation occurs because updates to records based on workflow rules and also on process scheduled actions don’t trigger validation rules. • Process record updates on immediate actions do fire validation rules. • You can’t create validation rules for relationship group members. • You can use roll-up summary fields in validation rules because the fields don’t display on edit pages. Don’t use roll-up summary fields as the error location.
Lookup Filters vs. Validation Rules Validation rules and lookup filters achieve similar ends, but offer different advantages. Use a lookup filter: • To improve user efficiency by limiting the number of available options in a lookup search dialog. • To improve user efficiency by automating filters on lookup search dialogs that your users manually set. Use a validation rule: • If you're close to the maximum number of lookup filters allowed. • To implement a complex business rule that requires you to use a formula. Formulas can reference fields that basic filter criteria can't reference, such as fields on the parent of the source object. Formulas can also use functions. For example, use ISNEW to apply the rule only on record creation, or ISCHANGED to apply the rule only when a field changes.
SEE ALSO: Define Validation Rules Activate Validation Rules Examples of Validation Rules
293 Extend Salesforce with Clicks, Not Code Customize Fields
Examples of Validation Rules
Review examples of validation rules for various types of apps that you can use and modify for your EDITIONS own purposes. Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. Available in: both Salesforce Use the following samples for validation rules in Salesforce and Salesforce AppExchange apps, Classic and Lightning including: Experience Available in: Contact Sample Account Address Validation Rules Manager, Group, Professional, Enterprise, Sample Account Validation Rules Performance, Unlimited, Sample Call Center Validation Rules Developer, and Sample Experience Cloud Site Validation Rules Database.com Editions Sample Contact Validation Rules USER PERMISSIONS Sample Cross Object Validation Rules Sample Date Validation Rules To view field validation rules: • View Setup and Sample Number Validation Rules Configuration Sample Opportunity Management Validation Rules To define or change field Sample Quote Validation Rules validation rules: • Customize Application Sample User, Role, and Profile Validation Rules Miscellaneous Sample Validation Rules
SEE ALSO: Validation Rules Define Validation Rules
Sample Account Address Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
294 Extend Salesforce with Clicks, Not Code Customize Fields
Canadian Billing Postal Code
Field Value Description: Validates that the account Billing Zip/Postal Code is in the correct format if Billing Country is Canada.
Formula: AND( OR(BillingCountry = "CAN", BillingCountry = "CA", BillingCountry = "Canada"), NOT(REGEX(BillingPostalCode, "((?i)[ABCEGHJKLMNPRSTVXY]\\d[A-Z]?\\s?\\d[A-Z]\\d)?")) )
Error Message: Canadian postal code must be in A9A 9A9 format.
Error Location: Billing Zip/Postal Code
Billing Zip Code Is in Billing State
Field Value Description: Validates that the account Billing Zip/Postal Code is valid by looking up the first five characters of the value in a custom object called Zip_Code__c that contains a record for every valid zip code in the US. If the zip code is not found in the Zip_Code__c object, or the Billing State does not match the corresponding State_Code__c in the Zip_Code__c object, an error is displayed.
Formula: VLOOKUP( $ObjectType.Zip_Code__c.Fields.City__c , $ObjectType.Zip_Code__c.Fields.Name , LEFT(BillingPostalCode,5)) <> BillingCity
Error Message: Billing Zip Code does not exist in specified Billing State.
Error Location: Billing Zip/Postal Code
295 Extend Salesforce with Clicks, Not Code Customize Fields
US Billing Zip Code
Field Value Description: Validates that the account Billing Zip/Postal Code is in 99999 or 99999-9999 format if Billing Country is USA or US.
Formula: AND( OR(BillingCountry = "USA", BillingCountry = "US"), NOT(REGEX(BillingPostalCode, "\\d{5}(-\\d{4})?")) )
Note: This example uses the REGEX function; see Shipping Zip Code if you are not familiar with regular expressions.
Error Message: Zip code must be in 99999 or 99999-9999 format.
Error Location: Billing Zip/Postal Code
296 Extend Salesforce with Clicks, Not Code Customize Fields
Shipping Zip Code
Field Value Description: Validates that the account Shipping Zip/Postal Code is in 99999 or 99999-9999 format if Shipping Country is USA or blank.
Formula: AND( OR(ShippingCountry = "USA", ISBLANK(ShippingCountry)), OR( AND(LEN(ShippingPostalCode) <>5, LEN(ShippingPostalCode) <> 10), NOT(CONTAINS("0123456789", LEFT( ShippingPostalCode, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 2, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 3, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 4, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 5, 1))), AND( LEN(ShippingPostalCode) = 10, OR( MID( ShippingPostalCode , 6, 1) <> "-", NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 7, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 8, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 9, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 10, 1))) ) ) ) )
Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
Tip: You can also validate zip codes using a regular expression; for an example of a formula using a regular expression, see REGEX on page 401.
Error Message: Zip code must be in 99999 or 99999-9999 format.
Error Location: Shipping Zip/Postal Code
297 Extend Salesforce with Clicks, Not Code Customize Fields
Valid Billing State (US)
Field Value Description: Validates that the account Billing State/Province is a valid two-character abbreviation if Billing Country is US, USA, or blank.
Formula: AND ( OR(BillingCountry = "US", BillingCountry="USA", ISBLANK(BillingCountry)), OR( LEN(BillingState) < 2, NOT( CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & "IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & "NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & "WA:WV:WI:WY", BillingState) )))
Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
Error Message: A valid two-letter state code is required.
Error Location: Billing State/Province
Valid Billing Province (Canada)
Field Value Description: Validates that the account Billing State/Province is a valid two-character abbreviation if Billing Country is CA or CAN.
Formula: AND ( OR(BillingCountry = "CA", BillingCountry="CAN"), OR( LEN(BillingState) < 2, NOT( CONTAINS("AB:BC:MB:NB:NL:NT:NS:NU:ON:PC:QC:SK:YT", BillingState) )))
Error Message: A valid two-letter province code is required.
Error Location: Billing State/Province
298 Extend Salesforce with Clicks, Not Code Customize Fields
Valid Shipping State
Field Value Description: Validates that the account Shipping State/Province is a valid two-character abbreviation if Shipping Country is US, USA, or blank.
Formula: AND ( OR(ShippingCountry = "US", ShippingCountry="USA", ISBLANK(ShippingCountry)), OR( LEN(ShippingState) < 2, NOT( CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & "IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & "NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & "WA:WV:WI:WY", ShippingState) )))
Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
Error Message: A valid two-letter state abbreviation is required.
Error Location: Shipping State/Province
Valid Shipping Province (Canada)
Field Value Description: Validates that the account Shipping State/Province is a valid two-character abbreviation, if Billing Country is CA or CAN.
Formula: AND ( OR(ShippingCountry = "CA", ShippingCountry="CAN"), OR( LEN(ShippingState) < 2, NOT( CONTAINS("AB:BC:MB:NB:NL:NT:NS:NU:ON:PC:QC:SK:YT", ShippingState) )))
Error Message: A valid two-letter province abbreviation is required.
Error Location: Shipping State/Province
299 Extend Salesforce with Clicks, Not Code Customize Fields
Valid Billing Country
Field Value Description: Validates that the account Billing Country is a valid ISO 3166 two-letter code.
Formula: OR( LEN(BillingCountry) = 1, NOT( CONTAINS( "AF:AX:AL:DZ:AS:AD:AO:AI:AQ:AG:AR:AM:" & "AW:AU:AZ:BS:BH:BD:BB:BY:BE:BZ:BJ:BM:BT:BO:" & "BA:BW:BV:BR:IO:BN:BG:BF:BI:KH:CM:CA:CV:KY:" & "CF:TD:CL:CN:CX:CC:CO:KM:CG:CD:CK:CR:CI:HR:" & "CU:CY:CZ:DK:DJ:DM:DO:EC:EG:SV:GQ:ER:EE:ET:FK:" & "FO:FJ:FI:FR:GF:PF:TF:GA:GM:GE:DE:GH:GI:GR:GL:" & "GD:GP:GU:GT:GG:GN:GW:GY:HT:HM:VA:HN:HK:HU:" & "IS:IN:ID:IR:IQ:IE:IM:IL:IT:JM:JP:JE:JO:KZ:KE:KI:" & "KP:KR:KW:KG:LA:LV:LB:LS:LR:LY:LI:LT:LU:MO:MK:" & "MG:MW:MY:MV:ML:MT:MH:MQ:MR:MU:YT:MX:FM:MD:MC:" & "MC:MN:ME:MS:MA:MZ:MM:MA:NR:NP:NL:AN:NC:NZ:NI:" & "NE:NG:NU:NF:MP:NO:OM:PK:PW:PS:PA:PG:PY:PE:PH:" & "PN:PL:PT:PR:QA:RE:RO:RU:RW:SH:KN:LC:PM:VC:WS:" & "SM:ST:SA:SN:RS:SC:SL:SG:SK:SI:SB:SO:ZA:GS:ES:" & "LK:SD:SR:SJ:SZ:SE:CH:SY:TW:TJ:TZ:TH:TL:TG:TK:" & "TO:TT:TN:TR:TM:TC:TV:UG:UA:AE:GB:US:UM:UY:UZ:" & "VU:VE:VN:VG:VI:WF:EH:YE:ZM:ZW", BillingCountry)))
Error Message: A valid two-letter country code is required.
Error Location: Billing Country
Sample Account Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Account Number Is Numeric Classic and Lightning Experience
Field Value Available in: Contact Description: Validates that the Account Number is numeric if not blank. Manager, Group, Professional, Enterprise, Formula: Performance, Unlimited, AND( Developer, and ISBLANK(AccountNumber), Database.com Editions NOT(ISNUMBER(AccountNumber)) )
Error Message: Account Number is not numeric.
Error Location: Account Number
300 Extend Salesforce with Clicks, Not Code Customize Fields
Account Number Length
Field Value Description: Validates that the Account Number is exactly seven digits (if it is not blank). The number seven is simply illustrative. You can change this to any number you like.
Formula: AND( ISBLANK(AccountNumber), LEN(AccountNumber) <> 7 )
Error Message: Account Number must be seven digits.
Error Location: Account Number
Annual Revenue Range
Field Value Description: Validates that the account Annual Revenue is not negative and does not exceed $100 billion. This limit is designed to catch typos.
Formula: OR( AnnualRevenue < 0, AnnualRevenue > 100000000000 )
Error Message: Annual Revenue cannot exceed 100 billion.
Error Location: Annual Revenue
Sample Call Center Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: Essentials, Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
301 Extend Salesforce with Clicks, Not Code Customize Fields
Conditionally Require Description When Case Reason is “Other”
Field Value Description: Validates that a custom field called Other Reason contains a value if a case has a Case Reason of “Other.”
Formula: AND( ISPICKVAL( Reason, "Other" ), ISBLANK(Other_Reason__c) )
Error Message: Description of Other Reason is required.
Error Location: Other Reason
Prevent Open Cases from Being Reset to New
Field Value Description: If a case is already open, prevents the Status from being changed back to “New.”
Formula: AND( ISCHANGED( Status ), NOT(ISPICKVAL(PRIORVALUE( Status ), "New")), ISPICKVAL( Status, "New") )
Error Message: Open case Status cannot be reset to New.
Error Location: Status
Restrict Status of Re-Opened Cases
Field Value Description: Validates that the case Status is “Re-opened” when a closed case is opened again.
Formula: AND( ISCHANGED( Status ), OR( ISPICKVAL(PRIORVALUE( Status ), "Closed"), ISPICKVAL(PRIORVALUE( Status ), "Closed in SSP")), NOT( ISPICKVAL( Status, "Re-Opened")) )
Error Message: Closed case can only be changed to “Re-opened.”
Error Location: Status
302 Extend Salesforce with Clicks, Not Code Customize Fields
Prevent Case Milestone Completion After Cases Are Closed
Field Value Description: Validates that a milestone's Completion Date can't occur after the case's Status is Closed.
Formula: Case.IsClosed = true
Error Message: You can't complete a milestone after a case is closed.
Error Location: Top of Page
Prevent Case Milestone Completion Before Case Creation Dates
Field Value Description: Validates that the milestone's Completion Date has occurred after the case's Date/Time Opened.
Formula: CompletionDate >= Case.CreatedDate && CompletionDate <= Case.ClosedDate
Error Message: The milestone Completion Date must occur after the date the case was created and before the case was closed.
Error Location: Top of Page
Sample Experience Cloud Site Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Preventing Offensive Language in Questions Classic and Lightning Experience
Field Value Available in: Contact Description: Prevents users from entering offensive language in the Title and Manager, Group, Professional, Enterprise, Description fields when asking a question. Performance, Unlimited, Formula: Developer, and OR(CONTAINS(Title, 'darn'), CONTAINS(Body, Database.com Editions 'darn'))
Error Message: Question title or description contains offensive language.
303 Extend Salesforce with Clicks, Not Code Customize Fields
Preventing Offensive Language in Replies
Field Value Description: Prevents users from entering offensive language when replying to a question.
Formula: OR(CONTAINS(Body, 'darn'), CONTAINS(Body, 'dang'))
Error Message: Reply contains offensive language.
Preventing Offensive Language in Ideas
Field Value Description: Prevents users from entering offensive language in the Title and Description fields when posting an idea.
Formula: OR(CONTAINS(Title, 'darn'), CONTAINS(Body, 'darn'))
Error Message: Idea title or description contains offensive language.
Preventing Offensive Language in Idea Comments
Field Value Description: Prevents users from entering offensive language when posting a comment.
Formula: OR(CONTAINS(CommentBody , 'darn'), CONTAINS(CommentBody, 'dang'))
Error Message: Comment contains offensive language.
Sample Contact Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
304 Extend Salesforce with Clicks, Not Code Customize Fields
Mailing Address Fields Are Required
Field Value Description: Validates that the contact Mailing Street, Mailing City, and Mailing Country are provided.
Formula: OR( ISBLANK( MailingStreet ), ISBLANK( MailingCity ), ISBLANK( MailingCountry ) )
Error Message: Mailing Street, City, and Country are required.
Error Location: Top of Page
Mailing Street Is Required
Field Value Description: Validates that the contact Mailing Street is provided.
Formula: ISBLANK( MailingStreet )
Error Message: Mailing Street is required.
Error Location: Mailing Street
305 Extend Salesforce with Clicks, Not Code Customize Fields
Mailing Zip Code
Field Value Description: Validates that the contact Mailing Zip/Postal Code is in 99999 or 99999-9999 format if Mailing Country is USA or blank.
Formula: AND( OR(MailingCountry = "USA", ISBLANK(MailingCountry)), OR( AND(LEN(MailingPostalCode) <>5, LEN(MailingPostalCode) <> 10), NOT(CONTAINS("0123456789", LEFT( MailingPostalCode, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 2, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 3, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 4, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 5, 1))), AND( LEN(MailingPostalCode) = 10, OR( MID( MailingPostalCode , 6, 1) <> "-", NOT(CONTAINS("0123456789", MID( MailingPostalCode , 7, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 8, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 9, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 10, 1))) ) ) ) )
Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
Tip: You can also validate zip codes using a regular expression; for an example of a formula using a regular expression, see REGEX on page 401.
Error Message: Zip code must be in 99999 or 99999-9999 format.
Error Location: Mailing Zip/Postal Code
306 Extend Salesforce with Clicks, Not Code Customize Fields
Phone Number Has International Format
Field Value Description: Validates that the Phone number begins with a plus sign (+) for country code. Note that this validation rule conflicts with the ten-digit rule.
Formula: LEFT(Phone, 1) <> "+"
Error Message: Phone number must begin with + (country code).
Error Location: Phone
US Phone Number Has Ten Digits
Field Value Description: Validates that the Phone number is in (999) 999-9999 format. This works by using the REGEX function to check that the number has ten digits in the (999) 999-9999 format.
Formula: NOT(REGEX(Phone, "\\D*?(\\d\\D*?){10}"))
Error Message: US phone numbers should be in this format: (999) 999-9999.
Error Location: Phone
Sample Cross Object Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Discounts Must Be Within Range Classic and Lightning Experience This example consists of three validation rules on opportunity products. The examples below work together to help you manage discount amounts for products and require a custom percent field Available in: Contact on opportunity products called Line Discount. The examples below also require you to use Manager, Group, price books and customize the Product Family field to include the following values: Professional, Enterprise, Software, Consulting, and Training. Performance, Unlimited, Developer, and Software Discounts Database.com Editions
Field Value Description: Prevents users from saving software products with a discount over 10 percent.
Formula: AND(Line_Discount__c > 0.10, ISPICKVAL(Product2.Family, "Software"))
307 Extend Salesforce with Clicks, Not Code Customize Fields
Field Value Error Message: The discount must be 10% or less for software products.
Error Location: Line Discount
Consulting Discounts
Field Value Description: Prevents users from saving consulting products with a discount over 15 percent.
Formula: AND(Line_Discount__c > 0.15, ISPICKVAL(Product2.Family, "Consulting"))
Error Message: The discount must be 15% or less for consulting products.
Error Location: Line Discount
Training Discounts
Field Value Description: Prevents users from saving training products with a discount over 20 percent.
Formula: AND(Line_Discount__c > 0.20, ISPICKVAL(Product2.Family, "Training"))
Error Message: The discount must be 20% or less for training products.
Error Location: Line Discount
Prevent Changing Opportunity Products on Closed Opportunities This example consists of two validation rules: one on opportunity products and another on opportunities.
Field Value Description: Prevents users from editing opportunity products after an opportunity is closed. Create the following validation rule example on opportunity products.
Formula: OR(ISPICKVAL(Opportunity.StageName, "Closed Won"), ISPICKVAL(Opportunity.StageName, "Closed Lost"))
Error Message: Cannot change opportunity products for closed opportunities.
308 Extend Salesforce with Clicks, Not Code Customize Fields
Field Value Error Location: Top of Page
The following validation rule is on opportunities.
Field Value Description: Prevents users from deleting opportunity products after an opportunity is closed. Create the following validation rule example on opportunities. It uses a custom roll-up summary field on opportunities that counts the number of opportunity products on an opportunity.
Formula: AND(OR(ISPICKVAL(StageName, "Closed Won"), ISPICKVAL(StageName, "Closed Lost")), Number_of_Line_Items__c < PRIORVALUE(Number_of_Line_Items__c) )
Error Message: Cannot delete opportunity products for closed opportunities.
Error Location: Top of Page
Prevent Saving a Case When Account Does Not Have Support
Field Value Description: Prevents users from saving a case for an account that does not have support. This example assumes you have a custom checkbox field on accounts called Allowed Support that tracks if the account has support.
Formula: Account.Allowed_Support__c = FALSE
Error Message: Unable to create cases for this account because it is not signed up for support.
Error Location: Top of Page
Prevent Saving a Case When Contact is No Longer with the Company
Field Value Description: Prevents users from saving an open case associated with a contact that is no longer with the company. This example uses a custom checkbox field on contacts called No Longer With Company.
309 Extend Salesforce with Clicks, Not Code Customize Fields
Field Value Formula: AND(Contact.Not_Longer_With_Company__c, NOT(IsClosed))
Error Message: Unable to save this case because the related contact is no longer with the company. To continue, choose another contact.
Error Location: Contact Name
Sample Date Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Date Must Be a Weekday Classic and Lightning Experience
Field Value Available in: Contact Description: Validates that the value of a custom date field is a weekday (not Manager, Group, Professional, Enterprise, Saturday or Sunday). Performance, Unlimited, Formula: Developer, and CASE(MOD( My_Date__c - DATE(1900, 1, 7), 7), Database.com Editions 0, 0, 6, 0, 1) = 0
Error Message: Date must be a weekday.
Error Location: My Date
Date Must Be a Weekend Day
Field Value Description: Validates that the value of a custom date field is a Saturday or Sunday.
Formula: CASE( MOD( My_Date__c - DATE(1900, 1, 7), 7), 0, 1, 6, 1, 0) = 0
Error Message: Date must be a weekend day.
Error Location: My Date
310 Extend Salesforce with Clicks, Not Code Customize Fields
Date Must Be in the Current Month
Field Value Description: Validates that a custom date field contains a date within the current month and year.
Formula: OR ( YEAR( My_Date__c ) <> YEAR ( TODAY() ), MONTH( My_Date__c ) <> MONTH ( TODAY() ) )
Error Message: Date must be in the current month.
Error Location: My Date
Date Must Be in the Current Year
Field Value Description: Validates that a custom date field contains a date within the current year.
Formula: YEAR( My_Date__c ) <> YEAR ( TODAY() )
Error Message: Date must be in the current year.
Error Location: My Date
Date Must Be the Last Day of the Month
Field Value Description: Validates whether a custom field called My Date is the last day of the month. To do this, it determines the date of the first day of the next month and then subtracts 1 day. It includes special case logic for December.
Formula: DAY(My_Date__c) <> IF(Month(My_Date__c)=12, 31, DAY(DATE(YEAR(My_Date__c),MONTH(My_Date__c)+1,1) - 1))
Error Message: Date must be the last day of the month.
Error Location: My Date
311 Extend Salesforce with Clicks, Not Code Customize Fields
Date Must Be Within One Year of Today
Field Value Description: Validates whether a custom field called Follow-Up Date is within one year of today’s date. This example assumes a 365 day year. (It does not handle leap years.)
Formula: Followup_Date__c - TODAY() > 365
Error Message: Follow-Up Date must be within one year of today.
Error Location: Follow-Up Date
Day of Month Cannot Be Greater Than 15
Field Value Description: Validates that a custom field called Begin Date contains a date in the first 15 days of the specified month.
Formula: DAY( Begin_Date__c ) > 15
Error Message: Begin Date cannot be after the 15th day of month.
Error Location: Begin Date
End Date Cannot Be Before Begin Date
Field Value Description: Validates that a custom field called End Date does not come before another custom field called Begin Date.
Formula: Begin_Date__c > End_Date__c
Error Message: End Date cannot be before Begin Date.
Error Location: Begin Date
312 Extend Salesforce with Clicks, Not Code Customize Fields
Expiration Date Cannot Be Before Close Date
Field Value Description: Validates that a custom field called Expiration Date does not come before Close Date.
Formula: Expiration_Date__c < CloseDate
Error Message: Expiration Date cannot be before Close Date.
Error Location: Expiration Date
Sample Number Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Time Cards Must Total 40 Hours Classic and Lightning Experience
Field Value Available in: Contact Description: Ensures that users cannot save a time card record with more than Manager, Group, Professional, Enterprise, 40 hours in a work week. This example requires five custom fields on Performance, Unlimited, your custom object, one for each day of work. Developer, and Formula: Database.com Editions Monday_Hours__c + Tuesday_Hours__c + Wednesday_Hours__c + Thursday_Hours__c + Friday_Hours__c > 40
Error Message: Your total hours cannot exceed 40.
Error Location: Top of Page
Number Cannot Be Negative
Field Value Description: Validates that a custom field called Hours Worked is not a negative number.
Formula: Hours_Worked__c < 0
Error Message: Hours Worked cannot be less than zero.
Error Location: Hours Worked
313 Extend Salesforce with Clicks, Not Code Customize Fields
Number Must Be Even
Field Value Description: Validates that a custom field called Ark Passengers is a non-negative even number.
Formula: OR( Ark_Passengers__c < 0, MOD( Ark_Passengers__c, 2) <> 0 )
Error Message: Ark Passengers must be a positive even number.
Error Location: Ark Passengers
Number Must Be Odd
Field Value Description: Validates that a custom field called Socks Found is a non-negative odd number.
Formula: OR( Socks_Found__c < 0, MOD( Socks_Found__c, 2) = 0 )
Error Message: Socks Found must be an odd number.
Error Location: Socks Found
Number Must Be a Multiple of Five
Field Value Description: Validates that a custom field called Multiple of 5 is a multiple of five.
Formula: MOD( Multiple_of_5__c, 5) <> 0
Error Message: Number must be a multiple of five.
Error Location: Multiple of 5
314 Extend Salesforce with Clicks, Not Code Customize Fields
Number Must Be an Integer
Field Value Description: Validates that a custom field called My Integer is an integer.
Formula: FLOOR( My_Integer__c) <> My_Integer__c
Error Message: This field must be an integer.
Error Location: My Integer
Number Must Be Between -50 and 50
Field Value Description: Validates that a custom field called Volume is between -50 and 50.
Formula: ABS( Volume__c) > 50
Error Message: Volume must be between -50 and 50.
Error Location: Volume
Number Range Validation
Field Value Description: Validates that the range between two custom fields, Salary Min and Salary Max, is no greater than $20,000.
Formula: (Salary_Max__c - Salary_Min__c) > 20000
Error Message: Salary range must be within $20,000. Adjust the Salary Max or Salary Min values.
Error Location: Salary Max
315 Extend Salesforce with Clicks, Not Code Customize Fields
Percentage Must Be Between Zero and 100
Field Value Description: Validates that a custom field called Mix Pct is between 0 and 100%. Note that percent fields are expressed divided by 100 in formulas (100% is expressed as 1; 50% is expressed as 0.5).
Formula: OR( Mix_Pct__c > 1.0, Mix_Pct__c < 0.0 )
Error Message: Mix Pct must be between 0 and 100%.
Error Location: Mix Pct
Sample Opportunity Management Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Conditionally-Required Field Based on Opportunity Stage Classic and Lightning Experience
Field Value Available in: Contact Description: Validates that a custom field called Delivery Date is provided Manager, Group, Professional, Enterprise, if an opportunity has advanced to the Closed Won or Performance, Unlimited, Negotiation/Review stage. Developer, and Formula: Database.com Editions AND ( OR ( ISPICKVAL(StageName, "Closed Won"), ISPICKVAL(StageName, "Negotiation/Review")), ISBLANK(Delivery_Date__c) )
Error Message: Delivery Date is required for this stage.
Error Location: Delivery Date
316 Extend Salesforce with Clicks, Not Code Customize Fields
Close Date Cannot Be Prior to Current Month
Field Value Description: Validates that the Close Date of an opportunity is not within a month prior to the current month. Note the use of ISNEW and ISCHANGED in this formula to ensure the condition is only checked when the opportunity is being created or the Close Date field is modified subsequently.
Formula: AND( OR ( ISNEW(), ISCHANGED( CloseDate )), CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1) )
Error Message: Close Date cannot be prior to current month.
Error Location: Close Date
Close Date Must Be a Future Date
Field Value Description: Ensures that users do not change the Close Date of an opportunity to a day in the past.
Formula: SampleDate < TODAY()
Error Message: Close Date cannot be a day in the past.
Error Location: Close Date
Discounts on Opportunities
Field Value Description: Validates that a custom discount percent field is between 0 and 40%.
Formula: OR(Discount_Rate__c < 0, Discount_Rate__c > 0.40)
Error Message: The Discount Rate must not exceed 40%.
Error Location: Discount Rate
317 Extend Salesforce with Clicks, Not Code Customize Fields
High-Value Opportunity Must Be Approved Before Closed
Field Value Description: Opportunities with amounts greater than $50,000 require that a custom checkbox field called Approved is checked in order to change the stage to Closed Won or Closed Lost. To automate this, set field-level security on the Approved checkbox so that it can only be checked via a custom approval process (Enterprise Edition, Unlimited Edition, or Performance Edition).
Formula: AND( OR( ISPICKVAL(StageName,"Closed Won"), ISPICKVAL(StageName,"Closed Lost")), (Amount > 50000), NOT(ISPICKVAL(Approval_Status__c ,"Approved")))
Error Message: All high-value opportunities must be approved for closure. Click the Request Close button.
Error Location: Top of Page
Opportunity Amount Cannot Exceed $10 Million
Field Value Description: Validates that opportunity Amount is positive and no more than $10 million. This limit is designed to catch typos.
Formula: OR( Amount < 0, Amount > 10000000 )
Error Message: Amount cannot exceed $10 million.
Error Location: Amount
Opportunity Check for Products
Field Value Description: Validates that an opportunity has at least one opportunity product before users can save a change to an opportunity.
Formula: NOT(OR(ISNEW(),HasOpportunityLineItem))
Error Message: You must add products to this opportunity before saving.
Error Location: Top of Page
318 Extend Salesforce with Clicks, Not Code Customize Fields
Opportunity Must Have Products if Beyond “Needs Analysis” Stage
Field Value Description: Validates that an opportunity has opportunity products before the Stage can move beyond Needs Analysis.
Formula: AND ( CASE( StageName, "Value Proposition", 1, "Id. Decision Makers", 1, "Perception Analysis", 1, "Proposal/Price Quote", 1, "Negotiation/Review", 1, "Closed Won", 1, 0) = 1, NOT(HasOpportunityLineItem) )
Error Message: Opportunity products are required to advance beyond the Needs Analysis stage.
Error Location: Top of Page
Opportunity Name Format
Field Value Description: Validates that an opportunity contains a hyphen as a way of enforcing an “[Account] - [Amount]” opportunity naming convention.
Formula: FIND( " - ", Name ) = 0
Error Message: Opportunity Name should use “[Account] - [Amount]” format.
Error Location: Opportunity Name
319 Extend Salesforce with Clicks, Not Code Customize Fields
Prevent Sales Reps from Moving Opportunity Stage Backwards
Field Value Description: Prevent sales reps from changing opportunity Stage “backwards” to specific values, once they have accepted the opportunity via a custom approval process. The approval process sets the custom Accepted Flag checkbox to True.
Formula: AND( Accepted_Flag__c, OR ( ISPICKVAL( StageName, "Stage 1"), ISPICKVAL( StageName, "Stage 2")) )
Error Message: Invalid stage for accepted opportunity.
Error Location: Stage
Probability Must Be 100% for Won Opportunities
Field Value Description: Validates that the probability of a won opportunity is properly set to 100%. This is useful for data cleanliness and reporting purposes.
Formula: AND ( ISPICKVAL( StageName, "Closed Won"), Probability <> 1)
Error Message: Probability must be 100% for won opportunities.
Error Location: Probability
Probability Must Be Zero for Lost Opportunities
Field Value Description: Validates that the probability of a lost opportunity is properly set to zero. This is useful for data cleanliness and reporting purposes.
Formula: AND ( ISPICKVAL( StageName, "Closed Lost"), Probability <> 0)
Error Message: Probability must be 0% for lost opportunities.
Error Location: Probability
320 Extend Salesforce with Clicks, Not Code Customize Fields
Project Start Date
Field Value Description: Validates that a field is conditionally required based on the values of other fields. Use this validation formula to ensure that users include a Project Start Date for an opportunity that is closed/won.
Formula: AND(ISPICKVAL(StageName, "Closed Won"), ISNULL(Project_Start_Date__c))
Error Message: Project start date is required for won opportunities.
Error Location: Project Start Date
Sample Quote Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Display Error if Quote Line Item Discount Exceeds 40% Classic and Lightning Experience
Field Value Available in: Contact Description: Shows an error if a quote line item's discount exceeds 40%. Manager, Group, Professional, Enterprise, Formula: Performance, Unlimited, Discount > .40 Developer, and Database.com Editions Error Message: The discount on this quote line item cannot exceed 40%.
Error Location: Discount on quote
Sample User, Role, and Profile Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions
321 Extend Salesforce with Clicks, Not Code Customize Fields
Discount Percent Does Not Exceed Role-Based Limit
Field Value Description: Validates that a custom field on opportunities called Discount Percent does not exceed a maximum value that varies depending on the user’s role. The default maximum is 15%.
Formula: Discount_Percent__c > VLOOKUP($ObjectType.Role_Limits__c.Fields.Limit__c, $ObjectType.Role_Limits__c.Fields.Name, $UserRole.Name)
Error Message: Discount (%) exceeds limit allowed for your role.
Error Location: Discount Percent
Expense Amount Does Not Exceed User's Max Allowed Expense
Field Value Description: Validates a custom field called Expense Amount against a custom user field called Max Allowed Expense.
Formula: Expense_Amount__c > $User.Max_Allowed_Expense__c
Error Message: Amount cannot exceed your maximum allowed expense.
Error Location: Expense Amount
Only Record Owner Can Change Field
Field Value Description: Ensures that only the record owner can make changes to a custom field called Personal Goal.
Formula: AND( ISCHANGED( Personal_Goal__c ), Owner <> $User.Id )
Error Message: Only record owner can change Personal Goal.
Error Location: Personal Goal
322 Extend Salesforce with Clicks, Not Code Customize Fields
Only Record Owner or Administrator Can Change Field
Field Value Description: Ensures that a user can make changes to a custom field called Personal Goal only if the user is the record owner or has a custom profile of “Custom: System Admin.”
Formula: AND( ISCHANGED( Personal_Goal__c ), Owner <> $User.Id, $Profile.Name <> "Custom: System Admin" )
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
Error Message: Only record owner or administrator can change Personal Goal.
Error Location: Personal Goal
Opportunity Close Date Can Only Be Back-Dated by Administrator
Field Value Description: Validates that the Close Date of an opportunity does not fall prior to the current month, except for users who have a custom profile called “Custom: System Admin.”
Formula: AND( OR ( ISNEW(), ISCHANGED( CloseDate )), CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1), $Profile.Name <> "Custom: System Admin" )
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
Error Message: Close Date cannot be prior to current month.
Error Location: Close Date
323 Extend Salesforce with Clicks, Not Code Customize Fields
Miscellaneous Sample Validation Rules
For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Allow Number to Be Increased but Not Decreased Classic and Lightning Experience
Field Value Available in: Contact Description: Allows a custom field called Commit Amount to be increased Manager, Group, Professional, Enterprise, but not decreased after initial creation. This rule uses the Performance, Unlimited, PRIORVALUE() function to compare the updated value of the field to Developer, and its value prior to update. Database.com Editions Formula: PRIORVALUE(Commit_Amount__c) > Commit_Amount__c
Error Message: Commit Amount cannot be decreased.
Error Location: Commit Amount
California Driver's License
Field Value Description: Ensures that a custom field called Drivers License is in the correct A9999999 format when the Mailing State is “CA”.
Formula: AND( MailingState = "CA", NOT(REGEX(Drivers_License__c, "([A-Z]\\d{7})?")) )
Error Message: Invalid California driver's license format.
Error Location: Drivers License
324 Extend Salesforce with Clicks, Not Code Customize Fields
Force Users to Check “I Accept Terms” to Enter Certain Values
Field Value Description: Uses a checkbox labeled “I accept terms” to force the user to select a checkbox in order to enter a value called Number of Days that exceeds their Paid Time Off (PTO) balance available.
Formula: AND( NOT( I_accept_terms__c ), Number_of_Days__c > $User.PTO_Balance__c )
Error Message: Request will cause a negative PTO balance. You must accept Negative PTO Balance terms.
Error Location: I accept terms
Prohibit Changes to a Field After It Has Been Saved
Field Value Description: Prevents users from changing a custom field called Guaranteed Rate after it has been saved initially.
Formula: AND( NOT( ISNEW() ), ISCHANGED( Guaranteed_Rate__c ) )
Error Message: Guaranteed Rate cannot be changed.
Error Location: Guaranteed Rate
325 Extend Salesforce with Clicks, Not Code Customize Fields
Social Security Number Format
Field Value Description: Validates that a custom text field called SSN is formatted in 999-99-9999 number format (if it is not blank). The pattern specifies: • Three single digits (0-9):\\d{3} • A dash • Two single digits (0-9):\\d{2} • A dash • Four single digits (0-9):\\d{4}
Formula: NOT( OR( ISBLANK(Social_Security_Number__c), REGEX( Social_Security_Number__c , "[0-9]{3}-[0-9]{2}-[0-9]{4}") ) )
Error Message: SSN must be in this format: 999-99-9999.
Error Location: SSN
Valid Currency
Field Value Description: Validates selected currency against an explicit subset of active currencies in your organization using the Currency picklist. Use this example if you only allow some of the active currencies in your organization to be applied to certain types of records.
Formula: CASE(CurrencyIsoCode, "USD", 1, "EUR", 1, "GBP", 1, "JPY", 1, 0) = 0
Error Message: Currency must be USD, EUR, GBP, or JPY.
Error Location: Currency
326 Extend Salesforce with Clicks, Not Code Customize Fields
Valid Credit Card Number
Field Value Description: Validates that a custom text field called Credit_Card_Number is formatted in 9999-9999-9999-9999 or 9999999999999999 number format when it is not blank. The pattern specifies: • Four digits (0-9) followed by a dash: \\d{4}- • The aforementioned pattern is repeated three times by wrapping it in () {3} • Four digits (0-9) • The OR character (|) allows an alternative pattern of 16 digits of zero through nine with no dashes: \\d{16}
Formula: NOT( REGEX( Credit_Card_Number__c , "(((\\d{4}-){3}\\d{4})|\\d{16})?"))
Error Message: Credit Card Number must be in this format: 9999-9999-9999-9999 or 9999999999999999.
Error Location: Credit Card Number
Valid IP Address
Field Value Description: Ensures that a custom field called IP Address is in the correct format, four 3-digit numbers (0-255) separated by periods.
Formula: NOT( REGEX( IP_Address__c, "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.) {3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ))
Error Message: Error: IP Address must be in form 999.999.999.999 where each part is between 0 and 255.
Error Location: IP Address
327 Extend Salesforce with Clicks, Not Code Customize Fields
Website Extension
Field Value Description: Validates a custom field called Web Site to ensure its last four characters are in an explicit set of valid website extensions.
Formula: AND( RIGHT( Web_Site__c, 4) <> ".COM", RIGHT( Web_Site__c, 4) <> ".com", RIGHT( Web_Site__c, 4) <> ".ORG", RIGHT( Web_Site__c, 4) <> ".org", RIGHT( Web_Site__c, 4) <> ".NET", RIGHT( Web_Site__c, 4) <> ".net", RIGHT( Web_Site__c, 6) <> ".CO.UK", RIGHT( Web_Site__c, 6) <> ".co.uk" )
Error Message: Web Site must have an extension of .com, .org, .net, or .co.uk.
Error Location: Web Site
Require Field Input to Ensure Data Quality
Improve the quality of data that users enter in Salesforce by creating universally required fields. EDITIONS A universally required field is a custom field. It must have a value whenever a record is saved within Salesforce, the Lightning Platform API, Connect Offline, Salesforce for Outlook, the Self-Service Available in: both Salesforce portal, or automated processes such as Web-to-Lead and Web-to-Case. Making a field required on Classic (not available in all a page layout or through field-level security ensures that users must enter a value. Making a field orgs) and Lightning required universally gives you a higher level of data quality beyond the presentation level of page Experience layouts. Available in: Contact You can make the following types of custom fields universally required: Manager, Group, Professional, Enterprise, • Currency Performance, Unlimited, • Date Developer, and • Date/Time Database.com Editions • Email Connect Offline, Salesforce • Master-Detail Relationship (always required) for Outlook, the Self-Service portal, Web-to-Lead, and • Number Web-to-Case are not • Percent available in Database.com • Phone . • Picklist • Text • Text Area • URL To make a custom field universally required, select the Required checkbox when defining the custom field.
328 Extend Salesforce with Clicks, Not Code Customize Fields
Note: You must specify a default value for required campaign member custom fields. If you make a user field universally required, you must specify a default value for that field.
Relationship group members do not support universally required fields.
Considerations for Universally Required Fields
Considerations for Universally Required Fields
A universally required field is a custom field. It must have a value whenever a record is saved within EDITIONS Salesforce, the Lightning Platform API, Connect Offline, Salesforce for Outlook, the Self-Service portal, or automated processes such as Web-to-Lead and Web-to-Case. Review the following Available in: both Salesforce considerations before making your custom fields universally required. Classic (not available in all • Standard fields cannot be universally required. orgs) and Lightning Experience • Universally required fields are required across all record types. • Edit pages always display universally required fields, regardless of field-level security. Available in: Contact Manager, Group, • When designing your page layouts, universally required fields: Professional, Enterprise, – Cannot be removed from a page layout Performance, Unlimited, – Are automatically added to the end of the first section of a page layout if not already on it Developer, and Database.com Editions – Cannot be read only or optional – Display in bold, indicating they are always visible Standard Objects, Page Layouts, Connect Offline, – Are disabled on the field properties page because you cannot remove the required setting Salesforce for Outlook, the • Universally required fields are only enforced during lead conversion if validation and triggers Self-Service portal, Web-to-Lead, and for lead conversion are enabled in your organization. Web-to-Cases are not • Quick Create does not enforce universally required fields. available in Database.com • If you make an activity custom field universally required, you must also provide a default value. • You must include universally required fields in your import files or the import will fail. • Don’t assign default values to fields that are both required and unique, because uniqueness errors can result. • You cannot make a field universally required if it is used by a field update that sets the field to a blank value. • Required fields may be blank on records that existed before making the field required. When a user updates a record with a blank required field, the user must enter a value in the required field before saving the record. • Web-to-Lead and Web-to-Case request data is not validated by Salesforce. Invalid data isn’t saved when requests are submitted. For example, if your custom field is a currency field and a user enters alphabetic characters such as “Abc” instead of numbers, the request is still submitted but with no value saved in the custom currency field.
SEE ALSO: Require Field Input to Ensure Data Quality
329 Extend Salesforce with Clicks, Not Code Customize Fields
About Field Sets
A field set is a grouping of fields. For example, you could have a field set that contains fields describing EDITIONS a user's first name, middle name, last name, and business title. When a field set is added to a Visualforce page, developers can loop over its fields and render them. If the page is added to a Available in: Salesforce managed package, administrators can add, remove, or reorder fields in a field set to modify the Classic fields presented on the Visualforce page without modifying any code. The same Visualforce page can present different sets of information, depending on which fields a subscriber prefers to keep. Available in: Group, Professional, Enterprise, As an administrator, you can create or edit field sets for your organization, or edit any installed field Performance, Unlimited, set. Field sets are available on all standard objects that support custom fields, and any organization and Developer Editions that supports creating Visualforce pages.
Note: Only fields available in the API can be added to field sets.
Fields added to a field set can be in one of two categories: • If a field is marked as Available for the Field Set, it exists in the field set, but the developer hasn’t presented it on the packaged Visualforce page. Administrators can display the field after the field set is deployed by moving it from the Available column to the In the Field Set column. • If a field is marked as In the Field Set, the developer has rendered the field on the packaged Visualforce page by default. Administrators can remove the field from the page after the field set is deployed by removing it from the In the Field Set column.
Creating and Editing Field Sets Field Sets Required Bit
SEE ALSO: Create Custom Fields Developer's Guide: Visualforce Developer's Guide ISVforce Guide
Creating and Editing Field Sets
Salesforce has a drag-and-drop WYSIWYG tool for creating and editing field sets The enhanced EDITIONS field sets editor is enabled by default, and provides all of the functionality of the original editor, as well as additional functionality and an easier-to-use WYSIWYG interface. Available in: Salesforce 1. From the management settings for the appropriate object, go to Field Sets, and then click New. Classic 2. Enter a Field Set Label. This is the name presented to subscribers who install the field through Available in: Contact a managed package. Manager, Group, 3. Optionally, enter a name for your field set. This is used by your Visualforce page to reference Professional, Enterprise, Performance, Unlimited, the field set. and Developer Editions 4. In the Where is this used? area, provide a brief description of which Visualforce pages use the field set, and for what purpose. This information helps a subscriber understand where and how an installed field set is being used, so that they can populate it with their own fields. 5. Save your changes.
330 Extend Salesforce with Clicks, Not Code Customize Fields
6. To add fields to the field set, drag the fields from the object palette and drop them into the Available for the Field Set or the In the Field Set container. The fields in the Available for the Field Set container are not initially visible on the Visualforce page. The fields in the In the Field Set container are visible by default.
Note: In the field set, you can span to fields that reference multiple objects. When you span a field into a field set that references multiple objects, the only field you can span to is the Name object. You can drag and drop a field from one container to the other. The vertical order of the In the Field Set list indicates the order of how the fields render on Visualforce pages.
7. To remove a field from the field set, drag the element back to the object palette, or click next to the element. 8. To make a field required, double click the element or click ( ) next to it and select the Required checkbox.
Note: Indicates the field is required and must have a value to save the record.
9. Save your changes.
Important: The total number of cross object spans within the In the Field Set container can't exceed 25.
After a field set is deployed in your organization, you can always mark fields that are in the Available for the Field Set list as In the Field Set, or vice versa. To do so: 1. Find the field set that you want to edit. From Setup enter Installed Packages in the Quick Find box, select Installed Packages, click an installed package, and then click the field set you want to edit. Alternatively, if you know which object contains the field set you want to edit, go to the object detail page and click Edit in the field set related list. 2. If you didn't create the field set initially, you'll only be able to edit the fields within the field set. To move fields between containers, drag and drop a field from one container to the other. To change the order of a rendered field, drag a field up or down the list and drop the field in the order you want it to appear. 3. Save your changes.
SEE ALSO: About Field Sets
Field Sets Required Bit
You can define a field as required when you create or edit field sets. You may want to define a field EDITIONS as required to ensure a user enters the necessary information on a field. The required field is only available in the In the Field Set container. If you define a field as required in the In Available in: Salesforce the Field Set container, and remove the field from the In the Field Set, the Classic required attribute is removed. Available in: Group, Note: If you remove fields that were made required by an installed managed package from Professional, Enterprise, the In the Field Set container, the required attribute isn’t removed from those Performance, Unlimited, fields. and Developer Editions To define a field as required in a field set, see Creating and Editing Field Sets on page 330
SEE ALSO: About Field Sets
331 Extend Salesforce with Clicks, Not Code Customize Fields
Roll-Up Summary Field
A roll-up summary field calculates values from related records, such as those in a related list. You EDITIONS can create a roll-up summary field to display a value in a master record based on the values of fields in a detail record. The detail record must be related to the master through a master-detail relationship. Available in: both Salesforce For example, you want to display the sum of invoice amounts for all related invoice custom object Classic (not available in all records in an account’s Invoices related list. You can display this total in a custom account field orgs) and Lightning called Total Invoice Amount. Experience
You can perform different types of calculations with a roll-up summary field. You can count the Available in: Contact number of detail records related to a master record. Or, you can calculate the sum, minimum value, Manager, Group, or maximum value of a field in the detail records. Professional, Enterprise, Before you begin creating roll-up summary fields for your organization, review the implementation Performance, Unlimited, tips and best practices. Developer, and Database.com Editions Implementation Tips Administration • Create roll-up summary fields on: – Any custom object that is on the master side of a master-detail relationship – Any standard object that is on the master side of a master-detail relationship with a custom object – Opportunities using the values of opportunity products related to the opportunity – Accounts using the values of related opportunities – Campaigns using campaign member status or the values of campaign member custom fields
Note: Campaign member custom formula fields that reference fields derived from leads or contacts are not supported.
• The types of fields you can calculate in a roll-up summary field depend on the type of calculation. For example, – Number, currency, and percent fields are available when you select SUM as the roll-up type. – Number, currency, percent, date, and date/time fields are available when you select MIN or MAX as the roll-up type.
• Sometimes you can’t change the field type of a field that you reference in a roll-up summary field. • Make sure that the filter for your roll-up summary doesn't encounter a formula field that results in “#Error!”. If one of your filter criteria uses a formula field that results in an error, no matches are returned for that filter criterion. For example, your roll-up summary filter is “Formula Field equals 10”. Two records contain errors, and one contains the value “10” in that field. In this case, your summary includes only the record with the value “10.” • Salesforce does not recalculate the value of campaign roll-up summary fields when leads or contacts are deleted. Select the Force a mass recalculation of this field option on the edit page of the roll-up summary field to manually recalculate the value. • You can’t use long text area, multi-select picklist, Description fields, system fields like Last Activity, cross-object formula fields, and lookup fields in the field column of roll-up summary filters. • Auto number fields are not available as the field to aggregate in a roll-up summary field. • After you have created a roll-up summary field on an object, you cannot convert the object's master-detail relationship into a lookup relationship. • Roll-up summary fields are not available for mapping lead fields of converted leads. Management
332 Extend Salesforce with Clicks, Not Code Customize Fields
• If a roll-up summary field doesn’t contain cross-object field references or functions that derive values on the fly, such as NOW or TODAY, it can calculate the values of formula fields.
Note: The value of a formula field can result in “#Error!”, which affects the summarized total. If your roll-up summary type is COUNT, records are included regardless of whether they contain a formula field with an error. However, when the Field to Aggregate is a formula field that results in “#Error!”, calculations of type MIN, MAX, and SUM exclude those formula values.
• Changes to the value of a roll-up summary field can trigger assignment rules to run. If a roll-up summary field is part of the criteria in an assignment rule, the field’s new value is used to evaluate whether to reassign the record. • A roll-up summary field can trigger workflow rules and field validations. However, workflow rules and field validations do not fire when the following changes cause a mass recalculation of roll-up summary values: – Changing the roll-up summary definition (such as the object, function, or field being aggregated) – Changing the expression of a formula field referenced in a roll-up summary field – Replacing picklist values for picklist fields referenced in the roll-up summary filter – Changing picklist record type definitions – Changing currency conversion rates – Changing price book entries
• Calculating roll-up summary field values can take up to 30 minutes, depending on the number of records affected and other factors. • You aren’t prevented from creating roll-up summary fields that can result in invalid values, such as February 29 in a non-leap year. If a roll-up summary field results in an invalid value, the value is not recalculated. The field continues to display with an invalid roll-up summary icon ( ) until you change the values being summarized. • If your organization uses multiple currencies, the currency of the master record determines the currency of the roll-up summary field. For example, if the master and detail records are in different currencies, the detail record value is converted into the currency of the master record. • Changing a conversion rate triggers roll-up summary fields to recalculate. If you’re using multiple currencies, we recommend changing the conversion rate from Manage Currencies in Setup, and not from the API. If you change the rate from the API, related jobs that are less than 24 hours old can interfere with your change. For details, see Edit Conversion Rates. • If your organization has advanced currency management enabled, currency roll-up summary fields are invalid if they are on accounts and summarizing opportunity values, or on opportunities and summarizing custom object values. • Salesforce prevents users from saving a record if it invalidates a related record. For example, a master record has a validation rule that requires the roll-up summary field value to be greater than 100. If the user’s change to a related child record would put the value over 100, the user can’t save the record. • If a lookup field references a record that has been deleted, Salesforce clears the value of the lookup field by default. Alternatively, you can choose to prevent records from being deleted if they’re in a lookup relationship. To be used in a roll-up summary field with a Roll-Up Type of COUNT or SUM, the lookup field must have the What to do if the lookup record is deleted? option set to Don’t allow deletion of the lookup record that’s part of a lookup relationship. If the option Clear the value of this field. You can’t choose this option if you make the field required is selected, you can’t create a COUNT or SUM roll-up summary field that pulls data from your lookup field.
• When multiple currencies are enabled in an org and corporate currency is different from the currency set on the record, the UI and the database for roll-up summary field values can display different decimal values. Values in the UI are displayed as two decimal places, whereas the database displays the exact value, which can be several decimal places. This behavior is due to the way values are stored in the database. The UI precision doesn’t affect the precision of the database, which is a floating-point value.
333 Extend Salesforce with Clicks, Not Code Customize Fields
In some cases, there can be small numerical remainders after deletion or filtering of records when you use SUM as the roll-up type. To correct the value, select the Force a mass recalculation of this field option on the edit page of the roll-up summary field to manually recalculate the value.
• When you delete a roll-up summary field using Metadata API, the field isn't saved in the Recycle Bin. The field is purged even if you don’t set the purgeOnDelete deployment option to true.
Best Practices • Apply field-level security to your roll-up summary fields if they calculate values that you do not want visible to users. Fields that your users cannot see due to field-level security settings on the detail record are still calculated in a roll-up summary field. • If you have validation rules, consider how they affect roll-up summary fields. The value in a roll-up summary field changes when the values in the detail records change. So, validation errors can display when saving either the detail or master record. • Because roll-up summary fields are not displayed on edit pages, you can use them in validation rules but not as the error location for your validation. • Avoid referencing a roll-up summary field from a child record. The roll-up summary fields referenced from child records can have outdated values, because their parent records have not been updated. Instead, reference roll-up summary fields from parent records. Your roll-up summary fields will always have updated values, because that rule runs after the parent value has been updated. If you’re trying to enforce a record limit of 25 on the parent roll-up summary field, create validation rules on your child objects. When you add a child record, your validation rule on the child object can check if the count is already 25 or greater.
AND(ISNEW(), Sample.Line_Count__c >= 25)
• Plan your implementation of roll-up summary fields carefully before creating them. Once created, you cannot change the detail object selected or delete any field referenced in your roll-up summary definition. • Advanced currency management affects roll-up summary fields. If your organization enables advanced currency management, delete the currency roll-up summary fields on accounts that summarize opportunity values and on opportunities that summarize custom object values. Otherwise, the fields continue to display with an invalid roll-up summary icon because their values are no longer calculated. • Automatically derived fields, such as current date or current user, aren’t allowed in a roll-up summary field. Forbidden fields include formula fields containing functions that derive values on the fly, such as DATEVALUE, NOW, and TODAY. Formula fields that include related object merge fields are also not allowed in roll-up summary fields. • When you refer to a roll-up summary field in a list view or report, you can’t use certain qualifiers, including: – Starts with – Contains – Does not contain – Includes – Excludes – Within
334 Extend Salesforce with Clicks, Not Code Customize Fields
Defining Roll-Up Summaries Define roll-up summary fields on the object that is on the master side of a master-detail relationship.
SEE ALSO: Create Custom Fields Custom Fields Allowed Per Object
Defining Roll-Up Summaries
Define roll-up summary fields on the object that is on the master side of a master-detail relationship. EDITIONS If a relationship does not already exist, first create a master-detail relationship between the master object that displays the value and the detail object containing the records you are summarizing. Available in: both Salesforce Classic and Lightning To define a roll-up summary field: Experience 1. Create a custom field on the object where you want the field displayed. Summary fields summarize the values from records on a related object, so the object on which you create the Available in: Contact field should be on the master side of a master-detail relationship. For instructions on creating Manager, Group, Professional, Enterprise, a custom field, see Create Custom Fields on page 218. Performance, Unlimited, 2. Choose the Roll-Up Summary field type, and click Next. Developer, and 3. Enter a field label and any other attributes. Click Next. Database.com Editions 4. Select the object on the detail side of a master-detail relationship. This object contains the records you want to summarize. USER PERMISSIONS
5. Select the type of summary: To view roll-up summary field definitions: Type Description • View Setup and Configuration COUNT Totals the number of related records. To edit roll-up summary field SUM Totals the values in the field you select in the Field to Aggregate definitions: option. Only number, currency, and percent fields are available. • Customize Application
MIN Displays the lowest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
MAX Displays the highest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
6. Enter your filter criteria if you want a selected group of records in your summary calculation. If your organization uses multiple languages, enter filter values in your organization's default language. When you use picklists to specify filter criteria, the selected values are stored in the organization's default language. If you edit or clone existing filter criteria, first set the Default Language on the Company Information page to the same language that was used to set the original filter criteria. Otherwise, the filter criteria may not be evaluated as expected.
7. Click Next. 8. Set the field-level security to determine whether the field should be visible for specific profiles, and click Next.
335 Extend Salesforce with Clicks, Not Code Customize Fields
9. Choose the page layouts that should display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is automatically added to the bottom of the user detail page. 10. Click Save to finish or Save & New to create more custom fields.
SEE ALSO: Roll-Up Summary Field
Lookup Filters
Improve user productivity and data quality with lookup filters. Lookup filters are administrator EDITIONS settings that restrict the valid values and lookup dialog results for lookup, master-detail, and hierarchical relationship fields. Available in: both Salesforce Administrators specify the restrictions by configuring filter criteria that compare fields and values Classic (not available in all on: orgs) and Lightning Experience • The current record (source) • The lookup object (target) Available in: All Editions except for Database.com. • The user's record, permissions, and role • Records directly related to the target object USER PERMISSIONS For example, you can: • Restrict the Account Name field on opportunities to allow only accounts with a record type To manage lookup filters: of Customer, filtering out Partner and Competitor. • Customize Application • Restrict the Account Name field on opportunities to allow only active accounts. • Restrict the Contact field on cases to allow only contacts associated with the account specified in the Account Name field on the case record. • Restrict the Account Name field on cases to allow only users with the “International Sales” profile to create or edit cases for accounts outside the United States.
Tip: When you define a lookup filter, you can choose from a list of filter criteria that Salesforce suggests. The list is based on the relationships between objects in your org. To see the suggested criteria, select Insert Suggested Criteria. In Salesforce Classic, administrators can make lookup filters required or optional. In Lightning Experience, all lookup filters are required, even if admins specify them as optional in Setup. • For fields with required lookup filters, values that match the lookup filter criteria appear in the lookup dialog. When editing the record, users can't save invalid values that they type in the field. If a user tries to save an invalid value, Salesforce displays an error message, which administrators can customize. • For fields with optional lookup filters (Salesforce Classic only), values that match the lookup filter criteria appear in the lookup dialog. To remove the filter and view all search results for the lookup field, users can select Show all results in the lookup dialog. Also, optional lookup filters let users save values that don't match the lookup filter criteria without Salesforce displaying any error message. Lookup filter criteria can compare fields on the source object with different types of fields on the target object as long as the fields are compatible.
Source Object Field Type Compatible Target Object Field Types
Currency Currency, Roll-Up Summary
Date Date, Date/Time, Roll-Up Summary
336 Extend Salesforce with Clicks, Not Code Customize Fields
Date/Time Date, Date/Time, Roll-Up Summary
Hierarchy Hierarchy, Lookup, Master-Detail
Lookup Hierarchy, Lookup, Master-Detail
Master-Detail Lookup, Hierarchy, Master-Detail
Number Number, Percent, Roll-Up Summary
Percent Number, Percent, Roll-Up Summary
Picklist Text, Text Area, Email, URL
Roll-Up Summary Currency, Number, Date, Date/Time, Roll-Up Summary
Supported Objects Salesforce supports lookup filters on relationship fields that point to: • Accounts • Assets • Badges • Badges Received • Business Hours • Campaigns • Cases • Contacts • Content Folders • Contracts • Endorsements • Entitlements • Ideas • Leads • Opportunities • Order Products • Orders • Products • Quotes • Service contracts • Skill Users • Skills • Social Personas • Solutions • Thanks • User Provisioning Accounts
337 Extend Salesforce with Clicks, Not Code Customize Fields
• User Provisioning Logs • User Provisioning Requests • Users • Work Order Line Items • Work Orders • Zones • Custom objects
Define Lookup Filters Delete or Deactivate Lookup Filters View a List of Lookup Filters for a Target Object Dependent Lookups Considerations for Lookup Filters Notes on Using Lookup Filters with Person Accounts Lookup Filters Best Practices Lookup Filter Examples Limitations on Lookup Filters
Define Lookup Filters
1. You can create lookup filters for new relationship fields in step 3 of the custom field wizard. EDITIONS a. From the management settings for the field’s object, go to Fields. b. Click Edit next to the name of the lookup or master-detail relationship field to which you Available in: both Salesforce Classic (not available in all want to apply the filter. orgs) and Lightning 2. In the Lookup Filter Options section, click Show Filter Settings. Experience 3. Specify the filter criteria a record must meet to be a valid value. To specify criteria, click Insert Available in: All Editions Suggested Criteria and choose from a list of suggested criteria, or manually enter your own except for Database.com. criteria. To enter your own criteria: a. In the first column, click the lookup icon or start typing in the text box and select a field. USER PERMISSIONS b. In the second column, select an operator. To define lookup filters: c. In the third column, select Value if Salesforce should compare the field in the first column • Customize Application with a static value, or select Field if Salesforce should compare the field in the first column with the value of another field. d. In the fourth column, enter the value or select the field that Salesforce should compare with the field in the first column.
Note: • Click Add Filter Logic to add Boolean conditions. • Select a suggested field from the Field text box. You can only select fields on the current record, the lookup object, or the user record. You can also choose related fields that are one relationship away from the lookup object. Salesforce assists you by listing the available fields and relationships when you click the lookup icon or click inside the text box. • Lookup filter criteria can compare fields of different types as long as they are compatible.
338 Extend Salesforce with Clicks, Not Code Customize Fields
• Value-based filters are supported in Lightning Experience and Salesforce Classic.
4. Specify whether the filter is required or optional. For fields with optional lookup filters (Salesforce Classic only), values that match the lookup filter criteria appear in the lookup dialog. To remove the filter and view all search results for the lookup field, users can select Show all results in the lookup dialog. Also, optional lookup filters let users save values that don't match the lookup filter criteria without Salesforce displaying any error message.
Note: In Lightning Experience, all filters are required, even if admins specify them as optional in Setup. There’s no Show all results view. For required lookup filters, specify whether you want Salesforce to display the standard error message or a custom message when a user enters an invalid value.
5. Optionally, enter text to display in the lookup search dialog. Consider text that guides users in their searches and explains the business rule that the lookup filter implements. 6. Leave Enable this filter selected. 7. Save your changes.
SEE ALSO: Considerations for Lookup Filters Dependent Lookups Lookup Filter Examples Find Object Management Settings
Delete or Deactivate Lookup Filters
1. From the managements settings for the relationship field’s object, go to Fields. EDITIONS 2. Scroll to the Custom Fields & Relationships related list. 3. Click the name of the field containing the lookup filter. Available in: both Salesforce Classic (not available in all 4. Click Edit. orgs) and Lightning 5. To deactivate the lookup filter, deselect Enable this filter, then save your changes. Experience Deactivating a lookup filter preserves the lookup filter configuration but: Available in: All Editions • Prevents it from applying to the relationship field except for Database.com. • Prevents it from impacting the cross-object references limit • Removes it as a dependency for fields referenced in the lookup filter criteria USER PERMISSIONS
6. To delete the lookup filter, click Clear Filter Criteria, then save your changes. To define lookup filters: • Customize Application Deleting a lookup filter permanently removes it. You can’t recover deleted lookup filters.
SEE ALSO: Dependent Lookups Considerations for Lookup Filters Find Object Management Settings
339 Extend Salesforce with Clicks, Not Code Customize Fields
View a List of Lookup Filters for a Target Object
You can quickly see a list of all of the lookup filters that restrict the values of each target object. This EDITIONS is useful when creating similar filters for a target object. Also, lookup filters that reference fields on related objects count against the cross-object reference limit, which is the number of unique Available in: both Salesforce relationships allowed for a target object. The Related Lookup Filters list lets you see which lookup Classic (not available in all filters might impact that limit. orgs) and Lightning To see which lookup filters affect the limit for a particular target object, from the management Experience settings for the object, go to Related Lookup Filters. Available in: All Editions except for Database.com. SEE ALSO: Dependent Lookups USER PERMISSIONS Considerations for Lookup Filters To define lookup filters: • Customize Application
Dependent Lookups
A dependent lookup is a relationship field with a lookup filter that references fields on the source EDITIONS object. For example, you can configure the case Contact field to only show contacts associated with the account selected in the case Account Name field. Available in: both Salesforce When a user changes the value of a referenced field on the source object, Salesforce immediately Classic and Lightning verifies that the value in the dependent lookup still meets the lookup filter criteria. If the value Experience doesn't meet the criteria, an error message is displayed and users can't save the record until the Available in: All Editions value is valid. If the referenced field on the source object is a lookup, master-detail, or hierarchy field, users can't USER PERMISSIONS change its value by typing. Instead, users must click the lookup icon and select a value in the lookup search dialog. To manage dependent lookups: Tip: Dependent lookups are supported in Visualforce pages. • Customize Application
SEE ALSO: Define Lookup Filters Lookup Filter Examples
340 Extend Salesforce with Clicks, Not Code Customize Fields
Considerations for Lookup Filters
• On the Fields page, the icon indicates all fields with active lookup filters. The icon EDITIONS indicates that the lookup filter is required. • The lookup filters you create in Salesforce also appear in the partner portal and Customer Portal. Available in: both Salesforce • Lookup filters are case-sensitive. Classic (not available in all orgs) and Lightning • If you convert a required lookup filter with a custom error message to be optional, Salesforce Experience deletes the message. • If you create a lookup filter that invalidates an existing value for that field, the value persists. Available in: All Editions However, when a user edits the record, Salesforce displays an error message and requires the except for Database.com. user to change the invalid value before saving. • You can’t save changes that cause required lookup filters on related records to contain invalid USER PERMISSIONS values. To manage lookup filters: • Versions 16.0 and higher of the Salesforce API support lookup filters. Lookup filters are enforced • Customize Application when you load data through the API. • If you configure a lookup filter to show inactive users only, the relationship field has no valid options. Inactive users are never valid for relationship fields that point to the User object. • If you create a filtered lookup on a field that looks up to another object, deploy both objects into the organization at the same time. • If the field criteria include a master-detail relationship field, lookup field filters don’t work. • If the value of a controlling field invalidates the value of a dependent master-detail relationship field, Salesforce doesn’t display an error message. • Dependent lookups are supported in Visualforce pages. • In Lightning Experience, a lookup filter doesn’t work if a field referenced in the filtered lookup criteria isn't added to the page layout. When a user opens the lookup dialog box, the value being searched is automatically deleted. To avoid this issue, add the missing field that is being used in the lookup field filter criteria to the page layout. • Knowledge articles don’t support lookup filters. • Value-based filters are supported in Lightning Experience and Salesforce Classic. • If an unlocked 2GP package installs a lookup filter, then a later version of the package deletes that lookup filter, the lookup filter isn’t removed from the subscriber org. The lookup filter must be deleted manually instead. • When changing ownership of a record in Salesforce Classic, fields on the record that have active lookup filters aren’t validated. As a workaround, we recommend doing lookup filter validation for a record’s fields before changing the record’s owner.
Spanning Relationships in Lookup Filters Filter criteria can include fields related to the target object (one level only). For example, a lookup field points to a contact. The lookup filter can reference fields on the account related to the contact using the Account Name relationship field. The lookup field can also reference fields on the contact related to the contact via the Reports To relationship field. For required lookup filters, each field referenced on a related lookup object counts against the number of unique relationships allowed for the referenced object. The relationships aren’t counted against the source object. For example, the two unique relationships described above count against the number allowed for the Contact object. Optional lookup filters don't count against the limit on the number of unique relationships allowed per object. To see which lookup filters affect the limit for a particular target object, from the management settings for the object, go to Related Lookup Filters.
341 Extend Salesforce with Clicks, Not Code Customize Fields
Lookup Filters vs. Validation Rules Validation rules and lookup filters achieve similar ends, but offer different advantages. Use a lookup filter: • To improve user efficiency by limiting the number of available options in a lookup search dialog. • To improve user efficiency by automating filters on lookup search dialogs that your users manually set. Use a validation rule: • If you're close to the maximum number of lookup filters allowed. • To implement a complex business rule that requires you to use a formula. Formulas can reference fields that basic filter criteria can't reference, such as fields on the parent of the source object. Formulas can also use functions. For example, use ISNEW to apply the rule only on record creation, or ISCHANGED to apply the rule only when a field changes.
SEE ALSO: Lookup Filters Dependent Lookups
Notes on Using Lookup Filters with Person Accounts
If your organization uses person accounts, note the following: EDITIONS • Person Accounts don't support Contact filters; however, Person Accounts support Account filters. For example, if the Account field has a dependent lookup filter that's added to a Person Available in: both Salesforce Account, dependent lookups are supported. If the Contact field has a dependent lookup filter Classic (not available in all that's added to a Person Account, dependent lookups aren't supported. orgs) and Lightning Experience • Lookup filter criteria on Account Name only apply to business accounts, not person accounts. For example, your lookup filter criteria is Account Name does not contain book. Available in: All Editions Business accounts with “book” in the name, such as John’s Bookstore, aren’t valid. Person except for Database.com. accounts with “book” in the name, such as John Booker, are valid. The person accounts show in the lookup dialog for the Account field. If you must filter on the name for a person account, use the First Name or Last Name fields instead. • To restrict the values of a lookup field to one type of account (person or business), use the Is Person Account field in your lookup filter criteria. For example, to restrict a lookup to only person accounts, include the following in your lookup filter criteria: Is Person Account equals True. • You can't package lookup filters that reference standard fields specific to person accounts, such as the Email and Title fields.
SEE ALSO: Lookup Filters
342 Extend Salesforce with Clicks, Not Code Customize Fields
Lookup Filters Best Practices
Custom Help EDITIONS Define custom help for fields with lookup filters to let users know about the business rule the filter enforces. For example, if the lookup filter restricts the Account Name on opportunities Available in: both Salesforce to only allow active accounts, define custom help that states You can only associate Classic (not available in all active accounts with opportunities. orgs) and Lightning Error Messages Experience Customize lookup filter error messages to guide users who type invalid values. For example, if Available in: All Editions the lookup filter restricts the Account Name on opportunities to only allow active accounts, except for Database.com. define an error message that states Value doesn't exist or isn't an active account.
Important: Salesforce translates the standard error message for required lookup filters, but not custom error messages. Use the Translation Workbench to translate lookup filter custom error messages. To restore the standard error message after modifying it, click Reset to default message. Working with Master-Detail Relationship Fields When creating a lookup filter on a master-detail relationship field, verify that the current values of the field on all of the detail records meet the criteria you specify. If you specify criteria that an existing value doesn't meet, Salesforce prevents the user from saving changes to the detail record. If this occurs, the user must first modify the value on the master record to meet the criteria. For example, consider a custom object with a master-detail relationship field that points to accounts. If you define a lookup filter that excludes all accounts with a Create Date before 01/01/2009, verify that no existing records of that custom object have a master-detail relationship with any account created before 2009. A quick way to do this is to create a report that shows all accounts with a Create Date before 01/01/2009. Profile-Based Lookup Filters Use Current User Profile: ID in filter criteria to define different filter criteria for different users, or to let administrators enter values that don't match the criteria. Avoid using Current User Profile: Name due to technical limitations on standard profiles. If you enter Current User Profile: Name or Profile: Name in the Field column of your lookup filter criteria, Salesforce displays a lookup icon in that row. Click the lookup icon to select from a list of existing profiles rather than typing profile names. Record IDs vs. Record Names To reference a specific record in filter criteria, use the ID of the record instead of its name. IDs are always unique whereas names are not. Testing After creating a lookup filter, test it to make sure it is not too restrictive. Depending on their permissions, some users may have read-only access to some relationship fields; ensure your lookup filters don't prevent those users from editing records critical to their job functions. Dependent Lookups on Page Layouts and Mini Page Layouts in the Console When designing page layouts with dependent lookups: • If a dependent lookup is above its controlling field on a layout, make its lookup filter optional or redesign the layout. Moving a required dependent lookup above its controlling field may confuse users who typically start from the top of a page when entering data. • Ensure that both the controlling and dependent fields are visible so users can correct invalid values.
343 Extend Salesforce with Clicks, Not Code Customize Fields
Lookup Filters and the Lookup Filter Fields Search Layout Don’t reference the same fields in both lookup filter criteria and the Lookup Filter Fields search layout. Users might assume that results from their custom search override administrator-controlled lookup filters.
SEE ALSO: Lookup Filters
Lookup Filter Examples
EDITIONS Record Types in Lookup Filters If the value of a relationship field should only consist of records with a particular record type, specify Available in: both Salesforce the record type in a lookup filter. For example, if the Account Name field on opportunities Classic (not available in all should only have accounts with a Customer Account custom record type, define the following orgs) and Lightning lookup filter to restrict users to only creating or editing opportunities associated with accounts that Experience have a Customer Account record type, excluding accounts with Partner Account and Competitor Available in: All Editions Account record types: except for Database.com.
Filter Criteria Record types available in: Account Name: Account Record Type equals value Customer Professional, Enterprise, Account Performance, Unlimited, Custom Error Message and Developer Editions Account does not exist or is not a customer account. Lookup Window Text USER PERMISSIONS You can only associate customer accounts to an opportunity. Search results only display customer accounts. To define lookup filters: • Customize Application
Record Status in Lookup Filters If the value of a relationship field should only consist of records with particular status, specify the status in a lookup filter. For example, consider a Job Application object with a relationship field that points to the Position object. If the relationship field should only have open positions, define the following lookup filter to restrict users to only creating or editing job applications for positions with the Status field set to Open: Filter Criteria Position: Status equals value Open Custom Error Message Position does not exist or is not an open position. Lookup Window Text You can associate only open positions with job applications. Search results display open positions only.
Profiles in Lookup Filters When a business rule does not apply to users with every profile, use the Current User Profile global variable fields to define lookup filters that only affect users with a particular profile.
344 Extend Salesforce with Clicks, Not Code Customize Fields
For example, the following lookup filter on the Case object Account Name field restricts users with a “Domestic Sales” profile to only creating or editing opportunities associated with accounts that have a billing country of “USA” while allowing other users to associate opportunities with any account: Filter Criteria 1. Current User Profile: Name equals value Domestic Sales 2. Account Name: Billing Country equals value USA 3. Current User Profile: Name not equal to value Domestic Sales Filter Logic (1 AND 2) OR 3 Custom Error Message Account does not exist or the account billing country is not USA. Domestic sales reps can only create opportunities for accounts in the United States. Lookup Window Text Search results show only United States accounts in the for domestic sales representatives. You can modify the above example to simultaneously restrict users with a “Global Sales” custom profile to only associating opportunities to accounts with a non-US billing country: Filter Criteria 1. Current User Profile: Name equals value Global Sales 2. Account Name: Billing Country not equal to value USA 3. Current User Profile: Name equals value Domestic Sales 4. Account Name: Billing Country equals value USA 5. Current User Profile: Name not equal to value Global Sales, Domestic Sales Filter Logic (1 AND 2) OR (3 AND 4) OR 5 Custom Error Message Account does not exist or the account billing country is not in your sales area. Sales reps can only create opportunities for accounts in their sales area. Lookup Window Text Search results only display accounts in your region.
Important: If you do not include line 5 in the filter criteria, users who are not in Global Sales or Domestic Sales cannot select or save any values on account records.
Roles in Lookup Filters When a business rule does not apply to users in every role, use the Current User Role global variable fields to define lookup filters that only affect users with particular roles. For example, in a recruiting application that has a Position object with a lookup field to a Compensation Package object, you can restrict users from editing or creating positions that have an executive compensation plan unless they are executive administrators or vice presidents. To do this, define the following lookup filter on the Position object Compensation Package Name field: Filter Criteria 1. Current User Role: Name does not start with value VP
345 Extend Salesforce with Clicks, Not Code Customize Fields
2. Current User Role: Name does not equal value Executive Administrator 3. Compensation Package: Plan Type does not equal value Executive 4. Current User Role: Name starts with value VP 5. Current User Role: Name equals value Executive Administrator Filter Logic ((1 OR 2) AND 3) OR (4 OR 5) Custom Error Message The compensation plan does not exist, or you have selected an executive compensation plan but do not have access to create executive positions. Lookup Window Text Search results only display compensation plans that are relevant to positions you are allowed to create.
Important: Include the condition you are testing and the opposite condition. In this example, lines 1, 2, and 3 of the filter criteria ensure that users who are not VPs or Executive Administrators cannot select Executive compensation plans, while lines 4 and 5 ensure that VPs and Executive Administrators can select Executive compensation plans.
Blank Values in Lookup Filters Your lookup filter criteria might reference a field that users often leave blank. You can design your lookup filter criteria to accept blank values by using the Add Filter Logic in the filter criteria to create an OR condition. For example, if you have a Partner Contact custom field on opportunities, restrict the field to only allow contacts that are associated to an account with a Partner Account record type, or private contacts not associated with any account. Filter Criteria 1. Partner Contact: Account: Account Record Type equals value Partner Account 2. Partner Contact: Account: Account Name equals value Filter Logic 1 OR 2 Custom Error Message The partner contact must be associated with a partner account, or must be a private contact. Lookup Window Text Search results only display contacts from partner accounts or your private contacts.
User IDs in Lookup Filters Using user IDs in optional lookup filters can significantly improve user efficiency by first showing lookup search dialog results that are most relevant to the user while still allowing users to see all results if necessary. For example, on a lookup field to accounts, you can create an optional lookup filter that restricts the search results to accounts that the user owns in the search lookup dialog results. If the user is looking for an account that someone else owns, the user can remove the filter. Filter Criteria Current User: User ID equals Field Account: Owner ID Lookup Window Text By default, search results only display accounts you own. To search all accounts, click “Show all results.”
346 Extend Salesforce with Clicks, Not Code Customize Fields
Simple Dependent Lookups If the value of a relationship field should depend on the value of another relationship field on the current record, specify the field to field comparison in the criteria. For example, if the case Contact Name field should only have contacts associated to the account specified in the case Account Name field, use the following lookup filter: Filter Criteria Contact Name: Account ID equals field Case: Account ID Custom Error Message Contact does not exist or is not associated to the case account. Lookup Window Text Search results only display contacts associated to the case account.
Note: When comparing lookup fields in lookup filter criteria, Salesforce always uses the ID of the relationship field, not the name.
Complex Lookup Filters and Dependent Lookups Achieving complex business rules with lookup filters often involves combing your rules with filter logic and fields of various types. For example, consider an app for booking conference rooms that has the following data model:
Object Fields
Meeting • Meeting Name • Office lookup to the Office object • Projector Required checkbox • Number of Participants number field • Conference Room lookup to the Conference Room object
Conference Room • Conference Room Name • Has Projector checkbox • Number of Seats Available number field • Conference Room Location lookup to the Office object
Office • Office Name
The following lookup filter on the meeting Conference Room field restricts the valid values to conference rooms that have a projector if the meeting requires one, as well as the necessary number of seats: Filter Criteria 1. Meeting: Projector Required equals field Meeting Conference Room: Has Projector 2. Meeting: Projector Required equals value False 3. Conference Room: Number of Seats Available greater or equal field Meeting: Number of Participants Filter Logic (1 OR 2) AND 3
347 Extend Salesforce with Clicks, Not Code Customize Fields
Custom Error Message Conference room not found or is insufficient for your meeting. Lookup Window Text Search results only display conference rooms that can support your meeting requirements. To refine the valid values even further, incorporate the office where the conference room is located: Filter Criteria 1. Meeting: Projector Required equals field Meeting Conference Room: Has Projector 2. Meeting: Projector Required equals value False 3. Conference Room: Number of Seats Available greater than field Meeting: Number of Participants 4. Meeting: Office equals Field Conference Room: Conference Room Location Filter Logic (1 OR 2) AND 3 AND 4 Custom Error Message Conference room not found or is insufficient for your meeting. Lookup Window Text Search results only display conference rooms that can support your meeting requirements.
SEE ALSO: Considerations for Lookup Filters
Limitations on Lookup Filters These limitations apply to lookup filters. • Lookup filter criteria can’t reference these types of fields: – Relationship fields on activities – System fields that are always read only, such as Created By and Modified By – Relationship fields that support queues, such as Case Owner and Lead Owner
• Each object can have up to five active required lookup filters. In Salesforce Classic, you can also have an unlimited number of optional lookup filters. If you reach the limit of required lookup filters, create optional filters. When a user saves a record, use validation rules to enforce your business rule. In Lightning Experience, all lookup filters are required. • Lookup filters aren’t available for external lookup relationship fields. • Lookup filters on currency fields don't convert currencies. For example, your organization uses multiple currencies and there’s lookup filter criteria Expected Revenue greater than 100000. The lookup shows all records with an Expected Revenue field value greater than 100,000, regardless of the currency. • You can’t use special date values, such as “Today” or “This Month,” in lookup filter criteria. • You can’t delete fields that are referenced in an active lookup filter. • You can’t change the field type of fields referenced by an active lookup filter. • You can add up to 10 criteria rows in a lookup filter.
348 Extend Salesforce with Clicks, Not Code Customize Fields
• Lookup filter criteria can’t reference these types of fields on the source object: – Autonumber – Email – Encrypted – Formula
Note: Formula fields containing "$USER", "$USERROLE", "$PROFILE", or "$SOURCE" are supported.
– GeoLocation – Long text area – Multi-select picklist – Roll-up summary – Text – Text (Encrypted) – Text area (Rich) – Text area (Long) – Time – URL
• Lookup auto-completion doesn’t work for user lookups with other dropdown lists. Auto-completion is primarily for organizations that have set up either a partner portal or customer portal. • In enhanced list views, you can’t change fields that dependent lookup filter criteria reference. • Lookup filters don’t support mass owner changes. If your lookup filter criteria reference the Owner field, performing a mass owner change can result in incorrect values. The incorrect values aren’t noticeable until you try to save the record. • If a formula references global merge fields that the lookup filter doesn’t support, the lookup filter can’t reference the formula. • Lookup filter criteria on Account Name only apply to business accounts, not person accounts. For example, your lookup filter criteria is Account Name does not contain book. Business accounts with “book” in the name, such as John’s Bookstore, aren’t valid. Person accounts with “book” in the name, such as John Booker, are valid. The person accounts show in the lookup dialog for the Account field. If you must filter on the name for a person account, use the First Name or Last Name fields instead.
Fields: What’s Different or Not Available in the Salesforce Mobile App
Not every Lightning Experience feature is in the Salesforce mobile app. Find out what’s different. EDITIONS
Fields Available in: Lightning Experience and the Unsupported Fields Salesforce mobile app for • division fields iOS and Android Combo Boxes Available in: all editions • Combo boxes, which combine a picklist with a text field, aren’t available. Typically the text field is available but the picklist is not. Lookup Fields • User-defined lookup filter fields aren't supported. • You can’t create a record from a lookup field like you can in Lightning Experience.
349 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Lookup fields in Salesforce Classic show record names regardless of sharing permissions. As a result, users can see the names of records that they can’t access. In Lightning Experience and the Salesforce mobile app, lookup fields respect sharing permissions and only show the name of records that the user can access. The one exception is owner lookup fields, which always display the name of the record's owner, regardless of sharing permissions. Picklist Fields • Controlling and dependent picklists are supported, but doesn’t display indicators on create and edit pages for these fields. To determine if a picklist field is dependent, and which picklist field controls it, switch to the full site. • Disabled picklists aren’t grayed out like they are in the full site. Phone Number Fields • The keypad that displays in phone number fields doesn’t include parentheses, hyphens, or periods, and doesn’t apply any phone number formatting when you save the record. To apply a specific phone number format, edit the record in the full site. Rich Text Area Fields Support for rich text area fields varies by the version of the Salesforce mobile app and the type of device.
App Version View Rich Text Area Fields Edit Rich Text Area Fields Salesforce for Android Yes Yes
Salesforce for iOS Yes Yes
User Fields • While user detail pages aren’t available in the app, user fields are supported and appear on user profiles, in related lists, and so forth. • There are some issues when these user fields appear in related lists or mobile cards. – The Company Name field is blank if an internal user is viewing a mobile card or related list entry related to another internal user. If the referenced user is an external user, the company name appears correctly. – The Active field is blank unless the user is inactive.
Calculate Field Values With Formulas
A formula is an algorithm that derives its value from other fields, expressions, or values. Formulas EDITIONS can help you automatically calculate the value of a field based on other fields. Watch a Demo: Getting Started With Formulas (Salesforce Classic) Available in: both Salesforce Classic and Lightning This video gives a brief introduction to Salesforce formulas, accessing the formulas editor in the Experience app, and how to use the editor tools to create formulas. Available in: All Editions Where are Formulas Used in Salesforce? Reports and Approvals are Many areas in Salesforce use formulas. Before you begin using formulas, review the differences not available in in their uses. Database.com Formula Data Types The data type of a formula determines the type of data you expect returned from your formula. Elements of a Formula A formula can contain references to the values of fields, operators, functions, literal values, or other formulas.
350 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Formula Operators and Functions Use these operators and functions when building formulas. All functions are available everywhere that you can include a formula—such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified. Using Date, Date/Time, and Time Values in Formulas Date formulas are useful for managing payment deadlines, contract ages, or any other features of your organization that are time or date dependent. Build a Formula Field Your custom formula fields require special attributes. Formula Field Limits and Restrictions Before you create formula fields, be aware of their limits and limitations. Formula Best Practices You can use the Formula Editor in Salesforce to construct a simple formula with a few clicks. But what if you want to build something more complex? Use these tips to help you map out formula logic and make it easier to troubleshoot errors. Examples of Advanced Formula Fields Review examples of formula fields for various types of apps that you can use and modify for your own purposes. Formulas: How Do I ... ? Common Formula Errors Review common errors that can occur with formulas and how to fix them.
Where are Formulas Used in Salesforce?
Many areas in Salesforce use formulas. Before you begin using formulas, review the differences in EDITIONS their uses. Available in: both Salesforce Use Formulas for: To: Classic and Lightning Approval Processes Define the criteria a record must meet to enter the approval process. Experience
Approval Steps Define the criteria a record must meet to enter the approval step. Available in: All Editions Reports and Approvals are Assignment Rules for Define the criteria the lead or case must meet for it to be assigned. not available in Leads and Cases Database.com Auto-Response Rules for Define the criteria a lead or case must meet to trigger an auto-response Leads and Cases rule.
Case Escalation Rules Specify criteria a case must meet for it to be escalated.
Custom Buttons and Define the content for custom links and buttons. Links
Custom Fields Create custom formula fields that automatically calculate a value based on other values, merge fields, or expressions. Users can view formula fields on record detail pages but can’t see the underlying algorithm or edit the value of a formula field.
Note: Custom formula fields are not available in Connect Offline, Web-to-Lead forms, or Web-to-Case forms.
351 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use Formulas for: To: Custom Summary Formulas in Automatically calculate more totals based on existing report summaries using the values, merge Reports fields, or expressions you specify. Users can’t change these totals.
Data Validations Verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can include a formula such as CloseDate >= TODAY().
Default Field Values Apply a value to a custom field when a user creates a record. Use formulas to define a default value such as TODAY() + 7. Users can change a default value. Default field values can be based on a formula using values, merge fields, or expressions you specify.
Escalation Rules Define the criteria that a case must meet to be escalated.
Formula Fields Automatically calculate the value of a custom field using the values, merge fields, or expressions you specify. Users can’t change the value of a formula field.
Reports Create custom summary formulas in your reports to calculate more totals based on the existing summaries in that report.
S-Controls Define the content for s-controls.
Validation Rules Prevent users from entering an invalid value in a standard or custom field. Validation rules can be based on formulas and display an error message to users when the value they enter is not valid.
Workflow Field Updates Automatically change the value of a field to a value you specify. The formula can include other values, merge fields, or expressions. You can set field updates to occur as a result of a workflow rule or an approval process.
Workflow Rules Define the criteria a record must meet to trigger a workflow rule.
Visualforce Pages Define the content for Visualforce pages.
Common Formula Processes
When are they Read only? Can include Can specify null Can include executed? functions? handling? references to parent merge fields? Default Field Values Record creation No Yes No No
Formula Fields Record display Yes Yes Yes Yes
Validation Rules Record save Not applicable Yes No Yes
Workflow Rules Record save Not applicable Yes No Yes
Approval Processes Record submitted Not applicable Yes No Yes for approval
Field Updates Workflow or Not applicable Yes No Yes approval process
352 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
When are they Read only? Can include Can specify null Can include executed? functions? handling? references to parent merge fields? Custom Summary Report display Yes Yes, a limited subset Yes No Formulas for Reports of functions
Formula Data Types The data type of a formula determines the type of data you expect returned from your formula.
Data Type Description Checkbox Returns a true or false value. The field appears as a checkbox in record detail pages and reports. Use True for checked values and False for unchecked values.
Currency Returns a number in currency format of up to 18 digits with a currency sign.
Note: Salesforce uses the round-half-to-even tie-breaking rule for currency fields. For example, 23.5 becomes 24, 22.5 becomes 22, −22.5 becomes −22, and −23.5 becomes −24.
Date Returns data that represents a day on the calendar. The current date can be acquired by calling the built-in function TODAY() in a formula. This data type is not available for custom summary formulas in reports.
Date/Time Returns data that represents a moment in time. A date/time field includes the date and also the time of day including hour, minutes, and seconds. You can insert the current date and time in a formula using the NOW() function. This data type is not available for custom summary formulas in reports.
Number Returns a positive or negative integer or decimal of up to 18 digits. Salesforce uses the round half up tie-breaking rule for numbers in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35.
Percent Returns a number in percent format of up to 18 digits followed by a percent sign. Percent data is stored as a decimal divided by 100, which means that 90% is equal to 0.90.
Text Returns a string of up to 3900 characters. To display text in addition to the formula output, insert that text in quotes. Use the text data type for text, text area, URL, phone, email, address, and auto-number fields. This data type isn’t available for custom summary formulas in reports.
Note: Text area isn’t a supported data type.
353 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Data Type Description Time Returns data that represents a moment in time, without the date. A time field includes the time of day by hour, minutes, seconds, and milliseconds. You can insert the current time in a formula using the TIMENOW() function.
Note: In formula expressions, use the international date format (ISO) for text arguments. For example, use TIMEVALUE("11:30:00.000") instead of TIMEVALUE("11:30 AM").
SEE ALSO: Build a Formula Field
Elements of a Formula A formula can contain references to the values of fields, operators, functions, literal values, or other formulas. Use any or all of these elements to build a formula.
Element Description Name Literal A text string or number you enter that is not calculated or changed. For example, if you have a value that’s always multiplied Value by 2% of an amount, your formula would contain the literal value of 2% of that amount:
ROUND((Amount*0.02), 2)
This example contains every possible part of a formula: • A function called ROUND used to return a number rounded to a specified number of decimal places. • A field reference called Amount. • An operator, *, that tells the formula builder to multiply the contents of the Amount field by the literal value, 0.02. • A literal number, 0.02. Use the decimal value for all percents. To include actual text in your formula, enclose it in quotes. • The last number 2 in this formula is the input required for the ROUND function that determines the number of decimal places to return.
Field Reference the value of another custom or standard field using a merge field. The syntax for a merge field is field_name Reference for a standard field or field_name__c for a custom field. The syntax for a merge field on a related object is object_name__r.field_name. Use the Insert Field button or the drop-down list to insert a merge field in your formula where necessary. To reference a field from a custom metadata type record, use
$CustomMetadata.CustomMetadataTypeAPIName.RecordAPIName.FieldAPIName
.
Function A system-defined formula that can require input from you and returns a value or values. For example, TODAY() does not require input but returns the current date. The TEXT(value) function requires your percent, number, or currency input and returns text.
354 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Element Description Name
Operator A symbol that specifies the type of calculation to perform or the order in which to do it. For example, the + symbol specifies two values should be added. The open and close parentheses specify which expressions you want evaluated first.
Comment An annotation within a formula that begins with a forward slash followed by an asterisk (/*). and concludes with an asterisk followed by a forward slash (*/). For example,
/*This is a formula comment*/
Comments are ignored when processing a formula. Comments are useful for explaining specific parts of a formula to anyone viewing the formula definition. For example:
AND( /*competitor field is required, check to see if field is empty */ LEN(Competitor__c) = 0, /* rule only enforced for ABCD record types */ RecordType.Name = "ABCD Value", /* checking for any closed status, allows for additional closed picklist values in the future */ CONTAINS(TEXT(StageName), "Closed") )
You can also use comments to comment out sections of your formula when debugging and checking the syntax to locate errors in the formula.
Note: • Nesting comments causes a syntax error. For example, you cannot save a formula that has the following:
/* /* comment */ */
• Commenting out a whole formula causes a syntax error. • Comments count against the character and byte size limits in formulas.
Formula Operators and Functions Use these operators and functions when building formulas. All functions are available everywhere that you can include a formula—such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified.
Note: • Within an email template, merge fields can only be used in formula functions and operations when the merge field belongs to the record the email will be related to, otherwise these fields won’t resolve. • Extraneous spaces in the samples below are ignored.
• Math Operators • Logical Operators • Text Operators • Date and Time Functions • Logical Functions
355 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Math Functions • Text Functions • Summary Functions • Advanced Functions
Math Operators
Operator Description + (Add) Calculates the sum of two values.
- (Subtract) Calculates the difference of two values.
* (Multiply) Multiplies its values.
/ (Divide) Divides its values.
^ (Exponentiation) Raises a number to a power of a specified number.
() (Open Parenthesis and Specifies that the expressions within the open parenthesis and close parenthesis are evaluated first. All Close Parenthesis) other expressions are evaluated using standard operator precedence.
Logical Operators
Operator Description = and == (Equal) Evaluates if two values are equivalent. The = and == operators are interchangeable.
<> and != (Not Equal) Evaluates if two values aren’t equivalent.
< (Less Than) Evaluates if a value is less than the value that follows this symbol.
> (Greater Than) Evaluates if a value is greater than the value that follows this symbol.
<= (Less Than or Equal) Evaluates if a value is less than or equal to the value that follows this symbol.
>= (Greater Than or Equal) Evaluates if a value is greater than or equal to the value that follows this symbol.
&& (AND) Evaluates if two values or expressions are both true. Use this operator as an alternative to the logical function AND.
|| (OR) Evaluates if at least one of multiple values or expressions is true. Use this operator as an alternative to the logical function OR.
Text Operators
Operator Description & (Concatenate) Connects two or more strings.
356 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Date and Time Functions
Function Description ADDMONTHS Returns the date that is the indicated number of months before or after a specified date. If the specified date is the last day of the month, the resulting date is the last day of the resulting month. Otherwise, the result has the same date component as the specified date.
DATE Returns a date value from year, month, and day values you enter. Salesforce displays an error on the detail page if the value of the DATE function in a formula field is an invalid date, such as February 29 in a non-leap year.
DATEVALUE Returns a date value for a date/time or text expression.
DATETIMEVALUE Returns a year, month, day, and GMT time value.
DAY Returns a day of the month in the form of a number between 1 and 31.
HOUR Returns the local time hour value without the date in the form of a number from 1 through 24.
MILLISECOND Returns a milliseconds value in the form of a number from 0 through 999.
MINUTE Returns a minute value in the form of a number from 0 through 60.
MONTH Returns the month, a number between 1 (January) and 12 (December) in number format of a given date.
NOW Returns a date/time representing the current moment.
SECOND Returns a seconds value in the form of a number from 0 through 60.
TIMENOW Returns a time value in GMT representing the current moment. Use this function instead of the NOW function if you only want to track time, without a date.
TIMEVALUE Returns the local time value without the date, such as business hours.
TODAY Returns the current date as a date data type.
WEEKDAY Returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday.
YEAR Returns the four-digit year in number format of a given date.
Logical Functions
Function Description AND Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false.
BLANKVALUE Determines if an expression has a value and returns a substitute expression if it doesn’t. If the expression has a value, returns the value of the expression.
CASE Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn't equal to any values, it returns the else_result.
IF Determines if expressions are true or false. Returns a given value if true and another value if false.
357 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Function Description ISBLANK Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE.
ISCLONE Checks if the record is a clone of another record and returns TRUE if one item is a clone. Otherwise, returns FALSE.
ISNEW Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE.
ISNULL Determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE.
Important: Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas.
ISNUMBER Determines if a text value is a number and returns TRUE if it is. Otherwise, it returns FALSE.
NOT Returns FALSE for TRUE and TRUE for FALSE.
NULLVALUE Determines if an expression is null (blank) and returns a substitute expression if it is. If the expression is not blank, returns the value of the expression.
Important: Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas.
OR Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false.
PRIORVALUE Returns the previous value of a field.
Math Functions
Function Description ABS Calculates the absolute value of a number. The absolute value of a number is the number without its positive or negative sign.
CEILING Rounds a number up to the nearest integer, away from zero if negative.
DISTANCE Calculates the distance between two locations in miles or kilometers.
EXP Returns a value for e raised to the power of a number you specify.
FLOOR Returns a number rounded down to the nearest integer, towards zero if negative.
GEOLOCATION Returns a geolocation based on the provided latitude and longitude. Must be used with the DISTANCE function.
LN Returns the natural logarithm of a specified number. Natural logarithms are based on the constant e value of 2.71828182845904.
358 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Function Description LOG Returns the base 10 logarithm of a number.
MAX Returns the highest number from a list of numbers.
MCEILING Rounds a number up to the nearest integer, towards zero if negative.
MFLOOR Rounds a number down to the nearest integer, away from zero if negative.
MIN Returns the lowest number from a list of numbers.
MOD Returns a remainder after a number is divided by a specified divisor.
ROUND Returns the nearest number to a number you specify, constraining the new number by a specified number of digits.
SQRT Returns the positive square root of a given number.
Text Functions
Function Description BEGINS Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't.
BR Inserts a line break in a string of text.
CASESAFEID Converts a 15-character ID to a case-insensitive 18-character ID.
CONTAINS Compares two arguments of text and returns TRUE if the first argument contains the second argument. If not, returns FALSE.
FIND Returns the position of a string within a string of text represented as a number.
GETSESSIONID Returns the user’s session ID.
HTMLENCODE Encodes text and merge field values for use in HTML by replacing characters that are reserved in HTML, such as the greater-than sign (>), with HTML entity equivalents, such as >.
HYPERLINK Creates a link to a URL specified that is linkable from the text specified.
IMAGE Inserts an image with alternate text and height and width specifications.
INCLUDES Determines if any value selected in a multi-select picklist field equals a text literal you specify.
ISPICKVAL Determines if the value of a picklist field is equal to a text literal you specify.
JSENCODE Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (').
JSINHTMLENCODE Encodes text and merge field values for use in JavaScript inside HTML tags by replacing characters that are reserved in HTML with HTML entity equivalents and inserting escape characters before unsafe JavaScript characters. JSINHTMLENCODE(someValue) is a convenience function that is equivalent to JSENCODE(HTMLENCODE((someValue)). That is, JSINHTMLENCODE first encodes someValue with HTMLENCODE, and then encodes the result with JSENCODE.
LEFT Returns the specified number of characters from the beginning of a text string.
359 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Function Description LEN Returns the number of characters in a specified text string.
LOWER Converts all letters in the specified text string to lowercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided.
LPAD Inserts characters you specify to the left-side of a text string.
MID Returns the specified number of characters from the middle of a text string given the starting position.
RIGHT Returns the specified number of characters from the end of a text string.
RPAD Inserts characters that you specify to the right-side of a text string.
SUBSTITUTE Substitutes new text for old text in a text string.
TEXT Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. Also, converts picklist values to text in approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, validation rules, formula fields, field updates, and custom buttons and links.
TRIM Removes the spaces and tabs from the beginning and end of a text string.
UPPER Converts all letters in the specified text string to uppercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided.
URLENCODE Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with %20, and exclamation points are replaced with %21.
VALUE Converts a text string to a number.
Summary Functions The following functions are available with summary, matrix, and joined reports.
Function Description PARENTGROUPVAL This function returns the value of a specified parent grouping. A “parent” grouping is any level above the one containing the formula. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels.
PREVGROUPVAL This function returns the value of a specified previous grouping. A “previous” grouping is one that comes before the current grouping in the report. Choose the grouping level and increment. The increment is the number of columns or rows before the current summary. The default is 1; the maximum is 12. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels.
360 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Advanced Functions
Function Description CURRENCYRATE Returns the conversion rate to the corporate currency for the given currency ISO code. If the currency is invalid, returns 1.0.
GETRECORDIDS Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list.
IMAGEPROXYURL Securely retrieves external images and prevents unauthorized requests for user credentials.
INCLUDE Returns content from an s-control snippet. Use this function to reuse common code in many s-controls.
ISCHANGED Compares the value of a field to the previous value and returns TRUE if the values are different. If the values are the same, this function returns FALSE.
JUNCTIONIDLIST Returns a JunctionIDList based on the provided IDs.
LINKTO Returns a relative URL in the form of a link (href and anchor tags) for a custom s-control or Salesforce page.
PREDICT Returns an Einstein Discovery prediction for a record based on the specified record ID or for a list of fields and their values.
REGEX Compares a text field to a regular expression and returns TRUE if there is a match. Otherwise, it returns FALSE. A regular expression is a string used to describe a format of a string according to certain syntax rules.
REQUIRESCRIPT Returns a script tag with source for a URL you specify. Use this function when referencing the Lightning Platform AJAX Toolkit or other JavaScript toolkits.
URLFOR Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page.
VLOOKUP Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function.
Formula Operators and Functions A–H Formula Operators and Functions I–Z
SEE ALSO: Examples of Advanced Formula Fields Time Custom Field
Formula Operators and Functions A–H Use the following operators and functions when building formulas. Click the name of the operator or function to view more details. All functions are available everywhere that you can include a formula such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified.
Note: Extraneous spaces in the samples are ignored.
361 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
+ (Add)
Description: Calculates the sum of two values.
Use: value1 + value2 and replace each value with merge fields, expressions, or other numeric values.
Formula Field Example: Amount + Maint_Amount__c + Services_Amount__c This formula calculates the sum of the product Amount, maintenance amount, and services fees. Maint amount and Service Fees are custom currency fields.
Report Example: EMAIL_OPT_OUT:SUM + DO_NOT_CALL:SUM calculates all Email Opt Out fields plus all Do Not Call fields on the leads in your report. This formula is a number data type that returns a positive integer.
Validation Rule Example: Let’s say you have a custom object that allows users to track the total number of hours worked in a week. Use the following example to ensure that users can’t save a time card record with more than 40 hours in a work week.
Monday_Hours__c + Tuesday_Hours__c + Wednesday_Hours__c + Thursday_Hours__c + Friday_Hours__c > 40
Use a formula like this one in a validation rule to display the following error message when the total number of hours entered for each work day is greater than 40: “Your total hours can’t exceed 40.” This example requires five custom fields on your custom object, one for each day of work.
- (Subtract)
Description: Calculates the difference of two values.
Use: value1 - value2 and replace each value with merge fields, expressions, or other numeric values.
Example: Amount - Discount_Amount__c This formula calculates the difference of the product Amount less the Discount Amount. Discount Amount is a custom currency field.
Report Example: AMOUNT:SUM - Product.Discount_Amount__c:SUM calculates the difference of all Amount fields and all Discounted Amount custom fields on the products in your report. This formula is a currency data type that returns a currency sign and decimal places.
* (Multiply)
Description: Multiplies its values.
362 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: value1 * value2 and replace each value with merge fields, expressions, or other numeric values.
Example: Consulting_Days__c * 1200 This formula calculates the number of consulting days times 1200 given that this formula field is a currency data type and consulting charges a rate of $1200 per day. Consulting Days is a custom field.
Report Example: RowCount * AGE:AVG calculates the record count times the average age value of your report. This formula is a number data type that returns a positive or negative integer or decimal.
/ (Divide)
Description: Divides its values.
Use: value1 / value2 and replace each value with merge fields, expressions, or other numeric values.
Example: AnnualRevenue/ NumberOfEmployees This formula calculates the revenue amount per employee using a currency field.
IF(NumberOfOpportunities > 0, NumberOfWonOpportunities / NumberOfOpportunities, null)
This formula calculates the win rate of opportunities on a campaign.
Report Example: % Won Opportunities WON:SUM / RowCount calculates the percent of Won opportunities using a record count representing the number of all opportunities in your report. This formula is a number data type that returns a positive or negative integer. % Difference between Cost and Sales Price (TOTAL_PRICE:SUM - QUANTITY:SUM * Product2.Cost__c:SUM) / (QUANTITY:SUM * Product2.Cost__c:SUM) calculates the average percent difference between what a product costs and its selling price on a product-by-product level. Product2.Cost__c:SUM is a custom currency field named Cost on products, which includes the cost of each product. This formula is a percent data type that returns a positive or negative integer. For best results, use this formula on a summary Opportunities with Products report that is summarized by Product Name and includes summary totals for Quantity, Total Price, and Cost.
^ (Exponentiation)
Description: Raises a number to a power of a specified number.
Use: number^integer and replace number with a merge field, expression, or another numeric value; replace integer with a merge field that contains an integer, expression, or any integer.
Example: NumberOfEmployees^4 calculates the number of employees to the 4th power.
363 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Report Example: ACTIVE:SUM ^ 2 calculates the number of active Salesforce users to the 2nd power for administration. This formula is a number data type that returns a positive integer.
Tips: Avoid replacing integer with a negative number.
() (Open Parenthesis and Close Parenthesis)
Description: Specifies that the expressions within the open parenthesis and close parenthesis are evaluated first. All other expressions are evaluated using standard operator precedence.
Use: (expression1) expression2... and replace each expression with merge fields, expressions, or other numeric values.
Example: (Unit_Value__c - Old_Value__c) / New_Value__c calculates the difference between the old value and new value divided by the new value.
Report Example: (DURATIONHOURS:SUM * RowCount) / 24 calculates the duration of all event times the record count per 24 hours. This formula is a percent data type that returns a positive or negative integer or decimal, representing what percent of a day is spent on events.
= and == (Equal)
Important: Don’t use this function for a null comparison, such as MyDateTime__c == null. Use ISBLANK instead.
Description: Evaluates if two values are equivalent. The = and == operators are interchangeable.
Use: expression1=expression2 or expression1 == expression2, and replace each expression with merge fields, expressions, or other numeric values.
Example: Due Date Due Date = CreatedDate + 5 returns true if the due date is equal to five days following a record’s created date. Commission Amount
IF(Probability =1, ROUND(Amount*0.02, 2), 0)
This formula calculates the 2% commission amount of an opportunity that has a probability of 100%. All other opportunities have a commission value of 0. Possible results: • An opportunity with a Probability of 90% has a commission of 0. • An opportunity with a Probability of 100% and an Amount of $100,000 has a commission of $2,000.
<> and != (Not Equal)
Important: Don’t use this function for a null comparison, such as MyDateTime__c != null. Use ISBLANK instead.
364 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Description: Evaluates if two values aren’t equivalent.
Use: expression1 <> expression2 or expression1 != expression2, and replace each expression with merge fields, expressions, or other numeric values.
Example: IF(Maint_Amount__c + Services_Amount__c<> Amount, "DISCOUNTED", "FULL PRICE")
This formula displays DISCOUNTED on product if its maintenance amount and services amount don’t equal the product amount. Otherwise, displays FULL PRICE. Note that this example uses two custom currency fields for Maint Amount and Services Amount.
< (Less Than)
Description: Evaluates if a value is less than the value that follows this symbol.
Use: value1 < value2 and replace each value with merge fields, expressions, or other numeric values.
Example: IF(AnnualRevenue < 1000000, 1, 2) assigns the value 1 with revenues less than one million and the value 2 to revenues greater than one million.
> (Greater Than)
Description: Evaluates if a value is greater than the value that follows this symbol.
Use: value1 > value2 and replace each value with merge fields, expressions, or other numeric values.
Example: IF(commission__c > 1000000, "High Net Worth", "General") assigns the High Net Worth value to a commission greater than one million. Note, this is a text formula field that uses a commission custom field.
<= (Less Than or Equal)
Description: Evaluates if a value is less than or equal to the value that follows this symbol.
Use: value1 <= value2 and replace each value with merge fields, expressions, or other numeric values.
Example: IF(AnnualRevenue <= 1000000, 1, 2) assigns the value 1 with revenues less than or equal to one million and the value 2 with revenues greater than one million.
>= (Greater Than or Equal)
Description: Evaluates if a value is greater than or equal to the value that follows this symbol.
365 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: value1 >= value2 and replace each value with merge fields, expressions, or other numeric values.
Example: IF(Commission__c >= 1000000, "YES", "NO") assigns the YES value with a commission greater than or equal to one million. Note, this is a text formula field that uses a custom currency field called Commission.
&& (AND)
Description: Evaluates if two values or expressions are both true. Use this operator as an alternative to the logical function AND.
Use: (logical1) && (logical2) and replace logical1 and logical2 with the values or expressions that you want evaluated.
Example: IF((Price<100 && Quantity<5),"Small", null) This formula displays Small if the price is less than 100 and quantity is less than five. Otherwise, this field is blank.
|| (OR)
Description: Evaluates if at least one of multiple values or expressions is true. Use this operator as an alternative to the logical function OR.
Use: (logical1) || (logical2) and replace any number of logical references with the values or expressions you want evaluated.
Example: IF((ISPICKVAL(Priority, "High")) || (ISPICKVAL(Status , "New")), ROUND(NOW()-CreatedDate, 0), null) This formula returns the number of days a case has been open if the Status is new or the Priority is high. If the case was opened today, this field displays a zero.
Validation Rule Example: (Discount_Rate__c < 0) || (Discount_Rate__c > 0.40)
This validation rule formula displays the following error message when the Discount Rate custom field isn’t between 0 and 40%: "Discount Rate cannot exceed 40%."
& (Concatenate)
Description: Connects two or more strings.
Use: string1&string2 and replace each string with merge fields, expressions, or other values.
Example: "Expense-" & Trip_Name__c & "-" & ExpenseNum__c This formula displays the text Expense- followed by trip name and the expense number. This is a text formula field that uses an expense number custom field.
366 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
ABS
Description: Calculates the absolute value of a number. The absolute value of a number is the number without its positive or negative sign.
Use: ABS(number) and replace number with a merge field, expression, or other numeric value that has the sign you want removed.
Example: ABS(ExpectedRevenue) calculates the positive value of the Expected Revenue amount regardless of whether it’s positive or negative.
ADDMONTHS
Description: Returns the date that is the indicated number of months before or after a specified date. If the specified date is the last day of the month, the resulting date is the last day of the resulting month. Otherwise, the result has the same date component as the specified date.
Use: ADDMONTHS (date, num) and replace date with the start date and num with the number of months to be added.
Example: ADDMONTHS (StartDate, 5) Adds 5 months to the start date. For example, if the start date is September 20, 2017, the resulting date is February 20, 2018, If the start date is September 30, 2017, the resulting date is February 28, 2018.
AND
Description: Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false. Use this function as an alternative to the operator && (AND).
Use: AND(logical1,logical2,...) and replace logical1,logical2,... with the values that you want evaluated.
Formula Field Example: IF(AND(Price<1,Quantity<1),"Small", null) This formula displays Small if the price and quantity are less than one. This field is blank if the asset has a price or quantity greater than one.
BEGINS
Description: Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't.
Use: BEGINS(text, compare_text) and replace text, compare_text with the characters or fields you want to compare.
367 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: IF(BEGINS (Product_type__c, "ICU"), "Medical", "Technical") This example returns the text Medical if the text in any Product Type custom text field begins with ICU. For all other products, it displays Technical.
Tips: • This function is case-sensitive so be sure your compare_text value has the correct capitalization. • When using this function in a validation rule or workflow rule, fields that are blank are considered valid. For example, if you have a validation rule that tests to see if the serial number of an asset begins with “3,” all assets that have a blank serial number are considered valid.
BLANKVALUE
Description: Determines if an expression has a value and returns a substitute expression if it doesn’t. If the expression has a value, returns the value of the expression.
Use: BLANKVALUE(expression, substitute_expression) and replace expression with the expression you want evaluated; replace substitute_expression with the value you want to replace any blank values.
Example: Example 1 BLANKVALUE(Department, “Undesignated”) This formula returns the value of the Department field if the Department field contains a value. If the Department field is empty, this formula returns the word Undesignated. Example 2 (BLANKVALUE(Payment_Due_Date__c, StartDate +5) This formula returns the date five days after the contract start date whenever Payment Due Date is blank. Payment Due Date is a custom date field.
Tips: • Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas. • A field is not empty if it contains a character, blank space, or zero. For example, a field that contains a space inserted with the spacebar is not empty. • Use the BLANKVALUE function to return a specified string if the field doesn't have a value; use the ISBLANK function if you only want to check if the field has a value. • If you use this function with a numeric field, the function only returns the specified string if the field doesn't have a value and isn't configured to treat blank fields as zeroes.
BR
Description: Inserts a line break in a string of text.
Use: BR()
368 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: CASE(ShippingCountry, "USA", ShippingStreet & BR() & ShippingCity & ", " & ShippingState & " " & ShippingPostalCode & BR() & ShippingCountry, "France", ShippingStreet & BR() & ShippingPostalCode & " " & ShippingCity & BR() & ShippingCountry, "etc")
This formula field displays a formatted mailing address for a contact in standard format, including spaces and line breaks where appropriate depending on the country.
Tips: • Don't remove the parentheses after the function name. • Keep the parentheses empty. They don't contain values. • Remember to surround the BR() with concatenation operators: &. • Avoid using this function in mail merge templates. • This function isn't available in custom buttons and links, s-controls, or reports.
CASE
Description: Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn't equal to any values, it returns the else_result.
Use: CASE(expression,value1, result1, value2, result2,..., else_result) and replace expression with the field or value you want compared to each specified value. Replace each value and result with the value that must be equivalent to return the result entry. Replace else_result with the value you want returned when the expression doesn't equal any values.
Formula Field Example: Days Open for Cases Use this example of a custom formula field called Days Open to display different text depending on the number of days a case has been open:
CASE(Days_Open__c, 3, "Reassign", 2, "Assign Task", "Maintain")
The following text is displayed: • “Reassign” for any case open three days. • “Assign Task” for any case open two days. • “Maintain” for all other cases. Last Activity Month
369 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This formula field displays the month of the last activity or None if there are no activities.
CASE(MONTH(LastActivityDate), 1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", 7, "July", 8, "August", 9, "September", 10, "October", 11, "November", 12, "December", "None")
Default Value Example: Discount Rate Use the following default value formula to insert a different discount rate on an opportunity based on the department of the person creating the opportunity:
CASE(User.Department, "IT", 0.25, "Field", 0.15, 0)
In this example, the formula inserts a discount rate of 25% on any opportunity created by a user in the IT department or 15% on any opportunity created by someone in the Field department. A zero is applied if the creator doesn't belong to either of these departments. This is a custom percent field on opportunities that uses the standard user field Department. Product Language You might want to associate a product with its language so that your users know the type of documentation or adapter to include. Use the following default value formula to automatically set the language of a product based on the country of the user creating the product. In this example, the default value is Japanese if the user's country is Japan and English if the user's country is US. If neither is true, the default value unknown is inserted into the Product Language field.
CASE($User.Country , "Japan", "Japanese", "US", "English","unknown")
Tips: • Be sure your value1, value2... expressions are the same data type. • Be sure your result1, result2... expressions are the same data type. • CASE functions can’t contain functions that return true or false. Instead, make true or false expressions return numbers such as:
CASE(1, IF(ISPICKVAL (Term__c, "12"), 1, 0), 12 * Monthly_Commit__c, IF(ISPICKVAL(Term__c, "24"), 1, 0), 24 * Monthly_Commit__c, 0)
In this formula, Term is a picklist field that is multiplied by the Monthly Commit whenever it contains the value 1 for true.
• The else_result value is required.
370 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• CASE functions return an error whenever any of the expressions return an error, regardless of which one should be returned. For example, CASE(Field__c,"Partner", "P", "Customer", "C", LEFT(Field__c, -5)) returns an error even if the value of the field is “Partner” or “Customer” because the last statement is illogical. • If the field in your CASE function is blank, it returns your else_result value. For example, this formula: CASE(Days_Open__c, 3, "Reassign", 2, "Assign Task", "Maintain") displays Maintain if the Days Open field is blank, 0, or any value other than 2 or 3. • Use CASE functions to determine if a picklist value is equal to a particular value. For example the formula CASE(Term__c, "12", 12 * Monthly_Commit__c, "24", 24 * Monthly_Commit__c, 0) multiplies the Monthly Commit amount by 12 whenever the Term is 12 or multiplies the Monthly Commit amount by 24 whenever the Term is 24. Otherwise, the result is zero.
CASESAFEID
Description: Converts a 15-character ID to a case-insensitive 18-character ID.
Use: CASESAFEID(id) and replace id with the object’s ID.
Example: CASESAFEID (Id)
This formula replaces the 15-character ID with the 18-character, case-insensitive ID.
Tips: • Convert to 18-character IDs for better compatibility with Excel. • The CASESAFEID function is available everywhere that you can define a formula except reports and s-controls.
CEILING
Description: Rounds a number up to the nearest integer, away from zero if negative.
Use: CEILING(number) and replace number with the field or expression you want rounded.
Example: CEILING(2.5) returns 3, which is 2.5 rounded up to the nearest integer. CEILING(-2.5) returns -3, which is -2.5 rounded away from zero for a negative number.
CONTAINS
Description: Compares two arguments of text and returns TRUE if the first argument contains the second argument. If not, returns FALSE.
Use: CONTAINS(text, compare_text) and replace text with the text that contains the value of compare_text.
371 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: IF(CONTAINS(Product_Type__c, "part"), "Parts", "Service")
This formula checks the content of a custom text field named Product_Type and returns Parts for any product with the word “part” in it. Otherwise, it returns Service. Note that the values are case-sensitive, so if a Product_Type field contains the text “Part” or “PART,” this formula returns Services.
Tips: • This function is case-sensitive so be sure your compare_text value has the correct capitalization. • When using this function in a validation rule or workflow rule, fields that are blank are considered valid. For example, if you have a validation rule that tests to see if the serial number of an asset contains “A,” all assets that have a blank serial number are considered valid. • The CONTAINS function doesn't support multi-select picklists. Use INCLUDES to see if a multi-select picklist has a specific value.
CURRENCYRATE
Description: Returns the conversion rate to the corporate currency for the given currency ISO code. If the currency is invalid, returns 1.0.
Use: CURRENCYRATE(currency_ISO_code) and replace currency_ISO_code with a currency ISO code, such as “USD”.
Example: CURRENCYRATE(”USD”) returns the conversion rate to US dollars.
DATE
Description: Returns a date value from year, month, and day values you enter. Salesforce displays an error on the detail page if the value of the DATE function in a formula field is an invalid date, such as February 29 in a non-leap year.
Use: DATE(year,month,day) and replace year with a four-digit year, month with a two-digit month, and day with a two-digit day.
Example: DATE(2005, 01, 02) creates a date field of January 2, 2005.
DATEVALUE As of Winter ’20, the DATAVALUE() formula option provides more accurate daylight savings time values without workarounds. The option avoids an existing one-hour discrepancy when processing times between 11:00 PM and 1:00 AM. From Setup, in the Quick Find box, enter Company Information. Under Locale Settings, select Improve DATEVALUE() accuracy for DST.
Important: If your org's custom formulas include workarounds that adjust date values between 11:00 PM and 1:00 AM, remove them before enabling this setting. If you don't remove the workarounds, your data could be inaccurate. Enabling the preference can also increase the compiled size of existing formulas with the DATEVALUE() function.
Description: Returns a date value for a date/time or text expression.
372 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: DATEVALUE(expression) and replace expression with a date/time or text value, merge field, or expression.
Example: Closed Date DATEVALUE(ClosedDate) displays a date field based on the value of the Date/Time Closed field. Date Value DATEVALUE("2005-11-15") returns November 15, 2005 as a date value.
Tips: • If the field referenced in the function isn't a valid text or date/time field, the formula field displays #ERROR! • When entering a date, surround the date with quotes and use the following format: YYYY-MM-DD, that is, a four-digit year, two-digit month, and two-digit day. • If the expression doesn't match valid date ranges, such as the MM isn't between 01 and 12, the formula field displays #ERROR! • Dates and times are always calculated using the user’s time zone, except in list views, reports, and related lists. These items calculate dates and times using Coordinated Universal Time.
DATETIMEVALUE
Description: Returns a year, month, day, and GMT time value.
Use: DATETIMEVALUE(expression) and replace expression with a date/time or text value, merge field, or expression.
Example: Closed Date DATETIMEVALUE(ClosedDate) displays a date field based on the value of the Date/Time Closed field. Date Value DATETIMEVALUE("2005-11-15 17:00:00") returns November 15, 2005 5:00 PM GMT as a date and time value.
Tips: • DATETIMEVALUE is always calculated using GMT time zone and can’t be changed. • When entering a specific date, surround the date with quotes and use the following format: YYYY-MM-DD, that is, a four-digit year, two-digit month, and two-digit day. • If the expression doesn't match valid date ranges, such as the MM isn't between 01 and 12, the formula field displays #ERROR!
DAY
Description: Returns a day of the month in the form of a number between 1 and 31.
Use: DAY(date) and replace date with a date field or value such as TODAY().
373 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: DAY(Code_Freeze__c) returns the day in your custom code freeze date. Note this doesn't work on date/time fields.
DISTANCE
Description: Calculates the distance between two locations in miles or kilometers.
Use: DISTANCE(mylocation1, mylocation2, 'unit') and replace mylocation1 and mylocation2 with two location fields, or a location field and a value returned by the GEOLOCATION function. Replace unit with mi (miles) or km (kilometers).
Examples: Distance between two geolocation fields DISTANCE(warehouse_location__c, store_location__c, 'mi') This formula returns the distance, in miles, between the warehouse and the store. In this example, warehouse_location__c and store_location__c are the names of two custom geolocation fields. Distance between an address field and a geolocation field DISTANCE(BillingAddress, store_location__c, 'mi') This formula returns the distance, in miles, between an account’s billing address and a store. In this example, BillingAddress is the standard billing address field on an Account object, and store_location__c is the name of a custom geolocation field. Distance between a custom geolocation field and fixed coordinates DISTANCE(warehouse_location__c, GEOLOCATION(37.775,-122.418), 'km') This formula returns the distance, in kilometers, between the warehouse and the known latitude and longitude 37.775°, -122.418° (San Francisco). Distances with conditions IF(DISTANCE(warehouse_location__c, ShippingAddress, 'mi')<10, "Near", "Far") This formula updates a text formula field to Near if the distance between the warehouse and the account shipping address compound field is less than 10 miles. Otherwise, it updates the text field to Far.
Tip: Although DISTANCE can be calculated in miles or kilometers, the unit isn't returned in the calculation. If possible, include the unit of measure in the name of your distance formula field, so users know whether the distance is in miles or kilometers.
Tips: • The DISTANCE function returns a number data type. Distance is always calculated in decimals, even if you’re displaying the geolocation notation in degrees, minutes, and seconds in the user interface. Specify the number of decimal places to show when you create a custom field. • The DISTANCE function isn’t available in reports, but it can be used in list views. To use DISTANCE in your reports, set up a formula field, and then reference the field in your reports. • DISTANCE is the only formula function that can use GEOLOCATION parameters. • There are limitations on DISTANCE accuracy and equality calculations.
374 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
– DISTANCE supports only the logical operators > and <, returning values within (<) or beyond (>) a specified radius. – Distance is calculated as a straight line, regardless of geography and topography between the two points. For more details, see “How SOQL Calculates and Compares Distances” in the SOQL and SOSL Reference.
EXP
Description: Returns a value for e raised to the power of a number you specify.
Use: EXP(number) and replace number with a number field or value such as 5.
Example: Exponent of a Literal Value EXP(3) This formula returns the value of e to the third power. Compound Interest Principal__c * EXP(Rate__c * Years__c) This formula calculates the compound interest based on a custom currency field for principal, custom percent field for rate, and custom number field for years.
FIND
Description: Returns the position of a string within a string of text represented as a number.
Use: FIND(search_text, text[, start_num]) and replace search_text with the string you want to find, replace text with the field or expression you want to search, and replace start_num with the number of the character from which to start searching from left to right.
Example: Street Address FIND(" ", Street) returns the character position of the first space in the Street field. You can use this number to find out the length of the street address as a means of separating a street address from street name in an address field. Deriving Website Addresses SUBSTITUTE(Email, LEFT(Email, FIND("@", Email)), "www.") finds the location of the @ sign in a person's email address to determine the length of text to replace with a “www.” as a means of deriving their website address.
Tips: • Be sure to remove the brackets, [ and ], from your formula before validating it. • If the field referenced in your text parameter is blank, the formula field displays 0. • Your search_text parameter is case-sensitive and can't contain any wildcard characters. • If your search doesn't return any results, a 0 displays in the field.
375 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• The start_num parameter is optional. If you don't enter a start_num value, the formula uses the value one, or the first character in the string. • If your start_num isn't greater than zero, a 0 displays in the field. • If your start_num is greater than the length of the text, a 0 displays in the field. • When entering your start_num parameter, remember that some fields like the Website field are unique because a http:// is automatically appended to the beginning of the text you enter. • The first character in a string is designated as one rather than zero.
FLOOR
Description: Returns a number rounded down to the nearest integer, towards zero if negative.
Use: FLOOR(number) and replace number with a number field or value such as 5.245.
Example: FLOOR(2.5) returns 2, which is 2.5 rounded down to the nearest integer. FLOOR(-2.5) returns -2, which is -2.5 rounded towards zero for a negative number.
GEOLOCATION
Description: Returns a geolocation based on the provided latitude and longitude. Must be used with the DISTANCE function.
Use: GEOLOCATION(latitude, longitude) and replace latitude and longitude with the corresponding geolocation, numerical code values.
Examples: Distance between a custom geolocation field and fixed coordinates DISTANCE(warehouse_location__c, GEOLOCATION(37.775,-122.418), 'km') This formula returns the distance, in kilometers, between the warehouse and the known latitude and longitude 37.775°, -122.418° (San Francisco).
Tips: • The GEOLOCATION function returns a location data type that can be used only by, and must be used with, the DISTANCE function. The GEOLOCATION function doesn’t work on its own.
GETRECORDIDS
Description: Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list.
Use: {!GETRECORDIDS(object_type)} and replace object_type with a reference to the custom or standard object for the records you want to retrieve.
376 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Custom Button Example: {!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")} var records = {!GETRECORDIDS($ObjectType.Sample)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one row") } else { for (var n=0; nIn this example, all selected case records are updated with a Status of New. To set this up in your org, create a custom list button for cases with the following attributes: • Display Type is List Button • Behavior is Execute JavaScript • Content Source is OnClick JavaScript Paste the sample code above into the content of your custom button. Finally, add the list button to the page layout that contains the Cases related list, such as accounts or opportunities. Users can select any number of cases in the related list and click the list button to change the status of those cases at once. Notice the check for records[0] == null, which displays a message to users when they don't select at least one record in the list.
Tips: • Use global variables to access special merge fields for s-controls, custom buttons, and links. • Activities are special types of objects. Use {!GETRECORDIDS($ObjectType.Task)} when creating a task list button. Use {!GETRECORDIDS($ObjectType.Event)} when creating an event list button. • This function is only available in custom buttons, links, and s-controls.
GETSESSIONID
Description: Returns the user’s session ID.
Use: GETSESSIONID()
Example: HYPERLINK ("https://www.myintegration.com?sId="& GETSESSIONID() & "?&rowID="&Name & "action=CreateTask","Create a Meeting Request")
creates a link to an application outside of Salesforce, passing the parameters so that it can connect to Salesforce via the API and create the necessary event.
Tips: Important: $Api.Session_ID and GETSESSIONID() return the same value, an identifier for the current session in the current context. This context varies depending on where the global variable or function is evaluated. For example, if you use either in a custom formula field, and that field is displayed on a standard page layout in Salesforce Classic, the referenced session is a basic Salesforce session. That same field (or the underlying variable or formula result), when used in a Visualforce page, references a Visualforce session instead.
377 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Session contexts are based on the domain of the request. That is, the session context changes whenever you cross a hostname boundary, such as from .salesforce.com to .vf.force.com or .lightning.force.com. Session identifiers from different contexts, and the sessions themselves, are different. When you transition between contexts, the old session is replaced by the new one, and the old session is no longer valid. The session ID also changes at this time. Normally Salesforce transparently handles session hand-off between contexts, but if you’re passing the session ID around yourself, you might need to re-access $Api.Session_ID or GETSESSIONID() from the new context to ensure a valid session ID. Not all sessions are created equal. In particular, sessions obtained in a Lightning Experience context have reduced privileges, and don't have API access. You can't use these session IDs to make API calls. {!$Api.Session_ID} isn’t generated for guest users.
HOUR
Description: Returns the local time hour value without the date in the form of a number from 1 through 24.
Use: HOUR(time) and replace time with a time value or value such as TIMENOW().
Examples: HOUR(TIMEVALUE(ClosedDate)) displays only the hour in a time field based on the value of the Time Closed field. HOUR(TIMEVALUE("17:30:45.125")) returns 17.
HTMLENCODE
Description: Encodes text and merge field values for use in HTML by replacing characters that are reserved in HTML, such as the greater-than sign (>), with HTML entity equivalents, such as >.
Use: {!HTMLENCODE(text)} and replace text with the merge field or text string that contains the reserved characters.
Example: If the merge field foo__c contains Enter the user's name, {!HTMLENCODE(foo__c)} results in: <B>Enter the user's name</b>
Tips: This function is only available in custom buttons and links, and in Visualforce.
HYPERLINK
Description: Creates a link to a URL specified that is linkable from the text specified.
Use: HYPERLINK(url, friendly_name [,target]) and replace url with the Web address, replace friendly_name with the link text, and, optionally, replace target with the window or frame in which to display the content.
378 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: Creating Events
HYPERLINK("/00U/e? retURL=%2F006x0000001T8Om&what_id=" & Id, "Create Event")
adds a link called Create Event that, when clicked, creates an event that is associated with the current object. Phone Dialer HYPERLINK("http://servername/call?id=" & Id & "&phone=" & Phone, Phone)creates a linkable phone number field that automatically dials the phone number when clicked. In this example, replace "servername" and "call" with the name of your dialing tool and the command it uses to dial. The merge field, Id, inserts the identifier for the contact, lead, or account record. The first Phone merge field tells the dialing tool what number to call and the last Phone merge field uses the value of the Phone field as the linkable text the user clicks to dial.
Tips: • Hyperlink formula fields are of type text. • Include the protocol and URL in quotes as in HYPERLINK("http://www.cnet.com", "cnet"). • Avoid using text functions such as LEN, LEFT, or RIGHT on HYPERLINK function results. • The URL can’t contain JavaScript. This increases security for your org. Using JavaScript is permitted in packages, sandbox copies, and change sets. • Use a relative link to link to Salesforce pages. If your full link is https://yourInstance.salesforce.com/00U/e, then its relative link is /00U/e. Relative links allow the hyperlink to work correctly on all Salesforce pages. Use the relative URL in a hyperlink formula to add it to a search layout. Make sure to prepend your relative URL with a forward slash “/”. • Use the $Api variable to reference API URLs. • Be sure to remove the brackets, [ and ], from your formula before validating it. • The target parameter is optional. If you don't specify a target, the link opens in a new browser window. Some common target parameters are: _blank Displays link in a new unnamed window. _self Displays link in the same frame or window as the element that refers to it. _parent Displays link in the immediate frameset parent of the current frame. This value is the same as _self if the current frame has no parent. _top Displays link in the full original window, canceling any other frames. This value is the same as _self if the current frame has no parent. For more information on basic HTML tags, consult an HTML reference on the Internet.
379 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• The HYPERLINK function is available everywhere that you can define a formula except default values, field updates, s-controls, validation rules, approval processes, custom buttons and links, and workflow rules.
SEE ALSO: Formula Operators and Functions I–Z Formula Operators and Functions Tips for Working with Hyperlink Formula Fields
Formula Operators and Functions I–Z Use the following operators and functions when building formulas. Click the name of the operator or function to view more details. All functions are available everywhere that you can include a formula such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified.
Note: Extraneous spaces in the samples are ignored.
IF
Description: Determines if expressions are true or false. Returns a given value if true and another value if false.
Use: IF(logical_test, value_if_true, value_if_false) and replace logical_test with the expression you want evaluated; replace value_if_true with the value you want returned if the expression is true; replace value_if_false with the value you want returned if the expression is false.
Formula Field Example: Overdue Payments IF(AND(Payment_Due_Date__c < TODAY(),Payment_Status__c ="UNPAID") , "PAYMENT OVERDUE", null) This formula determines if the payment due date is past and the payment status is “UNPAID.” If so, returns the text “PAYMENT OVERDUE” and if not, leaves the field blank. This example uses a custom date field called Payment Due Date and a text custom field called Payment Status. Insert Tax Rate Use this default value formula to set the tax rate of an asset based on the user's city. Create a custom percent field with the following default value:
IF($User.City = "Napa", 0.0750, IF($User.City = "Paso Robles", 0.0725, IF($User.City = "Sutter Creek", 0.0725, IF($User.City = "Los Olivos", 0.0750, IF($User.City = "Livermore", 0.0875, null ) ) ) ) )
380 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Custom Button Example: {! IF(Sample.BillingCountry = "US", "http://maps.google.com/maps?q="&Sample.BillingStreet& "+"&Sample.BillingCity&"+"&Sample.BillingState&"+ "&Sample.BillingCountry, (IF(Sample.BillingCountry = "UK", "http://maps.google.co.uk/maps?q="&Sample.BillingStreet &"+"&Sample.BillingCity&"+"&Sample.BillingCountry, "http://maps.google.com"))) }
This example uses the IF function to determine if an address is in the United States or United Kingdom so that it can use the appropriate type of Google map to display the address.
Tips: • Make sure your value_if_true and value_if_false expressions are the same data type. • When using an IF function with the $Profile.UserType variable to determine the type of Salesforce user license the logged in user has, use the following values: – Standard for Salesforce – PowerPartner for PRM User – CustomerSuccess for Customer Portal User – PowerCustomerSuccess for Customer Portal Manager For example, use the following formulas to determine if the logged in user has the license type in quotes:
IF(ISPICKVAL($Profile.UserType ,"Standard"), 100, 0.1)
IF(ISPICKVAL($Profile.UserType ,"PowerPartner"), 100, 0.1)
IF(ISPICKVAL($Profile.UserType ,"CustomerSuccess"), 100, 0.1)
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
IMAGE
Description: Inserts an image with alternate text and height and width specifications.
Use: IMAGE(image_url, alternate_text, height, width) and replace image_url with the full path to the image. Replace alternate_text with the string of text you want to appear when the image can’t be rendered for some reason. This text can be used by screen reader software. Replace height with the vertical size of the image in pixels. Replace width with the horizontal size of the image in pixels. For reports, images aren't automatically resized to fit into a report column. Use the height and width parameters to explicitly size the image so it fits into the column without being partially cut off.
381 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: HYPERLINK("ymsgr:sendIM?" & Yahoo_Name__c, IMAGE("http://opi.yahoo.com/online?u=" & Yahoo_Name__c & "&m;=g&t;=0", "Yahoo")) This formula displays a clickable Yahoo! Messenger icon indicating if the person is logged on to the service. Users can click the icon to launch a Yahoo! Messenger conversation with the person. This example uses a custom text field called Yahoo Name on contacts where you can store the contact's Yahoo! Messenger ID.
Tips: • The height and width parameters are optional. • Use a text string to replace the image_url and alternate_text parameters. Surround each text string in quotes. • Use numbers to replace the height and width parameters. • Add images to your Documents tab if you want to display them elsewhere. For example, store the image of a product in a document folder, copy the URL to the document, and paste that URL in the image_url parameter of a formula field on the Products tab. • If you use Internet Explorer, you sometimes must to change your security settings so that Explorer doesn’t display a warning prompt when images use HTTP protocol. See the online help for Internet Explorer for instructions on changing your security settings. • The IMAGE function cannot include the GETSESSIONID function as one of its arguments. • The IMAGE function is available only in formula fields and email templates. • You can’t display an image related to a contact in a custom formula field if it’s referenced through a person account.
IMAGEPROXYURL
Description: Securely retrieves external images and prevents unauthorized requests for user credentials.
Use: and replace http://exampledomain.com/pic.png with your image.
Example: alt="Salesforce on Twitter" />
This IMAGEPROXYURL function retrieves and displays an image from Twitter’s image host, an external source. This function loads the Salesforce Twitter profile image over HTTPS. This function also prevents the image from making unauthorized requests for user credentials.
Tips: • Use IMAGEPROXYURL for all images hosted on servers you don’t control. • The rendered image URL can change at any time. Don’t copy and paste it anywhere. • Don’t use the rendered image URL outside of Salesforce.
382 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
INCLUDE
Description: Returns content from an s-control snippet. Use this function to reuse common code in many s-controls.
Use: {!INCLUDE(source, [inputs])} and replace source with the s-control snippet you want to reference. Replace inputs with any information you need to pass the snippet.
S-Control Example: Including Header Snippet
{! INCLUDE($SControl.Header_Snippet, [title = "My Title", theme = "modern"])}
This example references a snippet that provides a header for a page that you created to display in a Web tab. It displays the page title “My Title.” Use the $SControl global variable to reference a custom s-control. Including Input Parameters Use the following two examples to see how you can create a reusable snippet and include it in an s-control.
{!$Request.titleText}
This snippet requires two input parameters: titleTheme and titleText. It is a reusable HTML tag that presents a page title and theme based on input parameters. Next, create an s-control that includes this snippet:
{! INCLUDE($SControl.Title_Snippet, [titleTheme = "modern", titleText = "My Sample Title"]) } ... Insert your page specific content here ... This s-control uses the snippet titled Title_Snippet to display the title of the page “My Sample Title” and modern theme. Replace Insert your page specific content here with your own HTML content and use the s-control as the source of a Web tab to create your own pages in Salesforce.
Tips: • Because this function references an s-control snippet and does not copy it, it always runs the latest content of the s-control snippet. Remember that making a change to your s-control snippet affects all INCLUDE functions that refer to it. • Use the $Request global variable to access any information inside the snippet. • This function is only available in custom buttons, links, and s-controls.
INCLUDES
Description: Determines if any value selected in a multi-select picklist field equals a text literal you specify.
383 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: INCLUDES(multiselect_picklist_field, text_literal) and replace multiselect_picklist_field with the merge field name for the multi-select picklist; and replace text_literal with the multi-select picklist value you want to match in quotes.
Examples: INCLUDES(Hobbies__c, "Golf") returns TRUE if one of the selected values in the Hobbies custom multi-select picklist field is Golf.
Tips: • The text_literal expression must be of type text and enclosed in quotes. It cannot be a merge field or the result of a function. • Salesforce returns an error if any of the following occurs: – You do not provide a text_literal expression. – You provide an empty text_literal expression, such as "" or " ".
• Use ISBLANK to determine if a multi-select picklist field is empty. • Use the PRIORVALUE function inside the INCLUDES function to check if the previous value of a multi-select picklist field included a specific value. For example:
INCLUDES( PRIORVALUE(multiselect_picklist_field), text_literal )
ISBLANK
Description: Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE.
Use: ISBLANK(expression) and replace expression with the expression you want evaluated.
Example: (IF(ISBLANK(Maint_Amount__c), 0, 1) + IF(ISBLANK(Services_Amount__c), 0,1) + IF(ISBLANK(Discount_Percent__c), 0, 1) + IF(ISBLANK(Amount), 0, 1) + IF(ISBLANK(Timeline__c), 0, 1)) / 5
This formula takes a group of fields and calculates what percent of them are being used by your personnel. This formula field checks five fields to see if they are blank. If so, a zero is counted for that field. A “1” is counted for any field that contains a value, and this total is divided by five (the number of fields evaluated). This formula requires you to select the Treat blank fields as blanks option under Blank Field Handling while the Advanced Formula subtab is showing.
Tips: • Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas. • A field is not empty if it contains a character, blank space, or zero. For example, a field that contains a space inserted with the spacebar is not empty.
384 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Use the BLANKVALUE function to return a specified string if the field doesn't have a value; use the ISBLANK function if you only want to check if the field has a value. • If you use this function with a numeric field, the function only returns TRUE if the field has no value and is not configured to treat blank fields as zeroes. • If you use this function with a picklist, use ISBLANK(TEXT()) to convert the picklist items into a text value.
ISCHANGED
Description: Compares the value of a field to the previous value and returns TRUE if the values are different. If the values are the same, this function returns FALSE.
Use: ISCHANGED(field) and replace field with the name of the field you want to compare.
Validation Rule Example: The following validation rule prevents users from changing an object name after it has been created: ISCHANGED(Name). NOT(AND(ISCHANGED(Priority), ISPICKVAL(Priority, “Low”))) is a validation rule that ensures if a user changes the Priority of a case, the new priority cannot be “Low.” NOT(AND(ISCHANGED(CloseDate), OR(MONTH(CloseDate) <> MONTH(TODAY()), YEAR(CloseDate) <> YEAR(TODAY())),$Profile.Name <> "Sales Manager")) is a validation rule that prevents a user from changing the Close Date of an opportunity to a date outside of the current month and year unless that user has the “Sales Manager” profile.
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
Tips: • This function is available only in: – Assignment rules – Validation rules – Field updates – Workflow rules if the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited . – Formula criteria for executing actions in Process Builder.
• Use the NOT function to reverse the return values of TRUE and FALSE. • This function returns FALSE when evaluating any field on a newly created record. • If a text field was previously blank, this function returns TRUE when it contains any value. • For number, percent, or currency fields, this function returns TRUE when: – The field was blank and now contains any value – The field was zero and now is blank – The field was zero and now contains any other value
385 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
ISCLONE
Description: Checks if the record is a clone of another record and returns TRUE if one item is a clone. Otherwise, returns FALSE.
Use: ISCLONE()
Validation Rule Example: Use (ISCLONE() to create a validation rule on an object and identify a record that’s a clone of another record.
Tips: • This function cannot be used with fields. • Use the NOT function to reverse the return values of TRUE and FALSE.
ISNEW
Description: Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE.
Use: ISNEW()
Validation Rule Example: Use the following validation rule to prevent users from creating a record with a close date in the past. AND (ISNEW(), CloseDate < TODAY()) checks if the user is creating a new opportunity and, if so, ensures that the Close Date is today or after today. Use this validation rule to ensure users add at least one product to an opportunity after they have created it.
NOT(OR(ISNEW(),HasOpportunityLineItem))
In this example, the validation rule formula displays the following error message when an existing opportunity does not have any products: “You must add products to this opportunity before saving.” This does not display an error on the initial save because they cannot add products until after saving the record initially; but it prevents them from resaving or closing an opportunity that does not contain products.
Tips: • This function is available only in validation rules, field updates, workflow rules, assignment rules, and processes. • Use the NOT function to reverse the return values of TRUE and FALSE. • This function always returns FALSE when used in a workflow rule with a time-based trigger. • This function always returns FALSE when used in a field update for an approval action.
ISNULL
Important: Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas.
Description: Determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE.
386 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: ISNULL(expression) and replace expression with the expression you want evaluated.
Example: (IF(ISNULL(Maint_Amount__c), 0, 1) + IF(ISNULL(Services_Amount__c), 0,1) + IF(ISNULL(Discount_Percent__c), 0, 1) + IF(ISNULL(Amount), 0, 1) + IF(ISNULL(Timeline__c), 0, 1)) / 5
This formula takes a group of fields and calculates what percent of them are being used by your personnel. This formula field checks five fields to see if they are blank. If so, a zero is counted for that field. A “1” is counted for any field that contains a value, and this total is divided by five (the number of fields evaluated). This formula requires you to select the Treat blank fields as blanks option under Blank Field Handling while the Advanced Formula subtab is showing.
Validation Rule Example: AND(ISPICKVAL(StageName, "Closed Won"), ISNULL(Project_Start_Date__c))
This validation rule makes the Project Start Date custom date field conditionally required whenever the stage is Closed Won.
Tips: • Text fields are never null, so using this function with a text field always returns false. For example, the formula field IF(ISNULL(new__c) 1, 0) is always zero regardless of the value in the New field. For text fields, use the ISBLANK function instead. • Multi-select picklist fields are never null in s-controls, buttons, and email templates, so using this function with a multi-select picklist field in those contexts always returns false. • Empty date and date/time fields always return true when referenced in ISNULL functions. • Don’t use ISNULL for date/time fields. • Choose Treat blank fields as blanks for your formula when referencing a number, percent, or currency field in an ISNULL function. Choosing Treat blank fields as zeroes gives blank fields the value of zero so none of them will be null. • Merge fields can be handled as blanks, which can affect the results of components like s-controls because they can call this function. • When using a validation rule to ensure that a number field contains a specific value, use the ISNULL function to include fields that do not contain any value. For example, to validate that a custom field contains a value of '1', use the following validation rule to display an error if the field is blank or any other number:
OR(ISNULL(field__c), field__c<>1)
ISNUMBER
Description: Determines if a text value is a number and returns TRUE if it is. Otherwise, it returns FALSE.
Use: ISNUMBER(text) and replace text with the merge field name for the text field.
387 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Validation Rule Example: OR(LEN(Bank_Account_Number__c) <> 10, NOT(ISNUMBER(Bank_Account_Number__c)))
This validation rule ensures a custom text field called Bank Account Number is a number of 10 digits and is not blank.
Tips: • This function returns FALSE for blank values. • The ISNUMBER function is not aware of your locale. For example, ISNUMBER("123,12") and ISNUMBER("1 000") return FALSE even if the user's locale is “French.” • Chinese, Japanese, Korean, and special characters including a space return FALSE. • The ISNUMBER function returns TRUE for scientific formatting such as “2E2” or “123.123.”
ISPICKVAL
Description: Determines if the value of a picklist field is equal to a text literal you specify.
Use: ISPICKVAL(picklist_field, text_literal) and replace picklist_field with the merge field name for the picklist; replace text_literal with the picklist value in quotes. text_literal cannot be a merge field or the result of a function.
Examples: Contract Activation IF(ISPICKVAL(Status, "Activated"), NOW()-ActivatedDate, null) calculates the number of days since the contract was activated. If the contract status is not “Activated,” this field is blank. Commission Amounts
IF(ISPICKVAL(StageName, "Closed Won"), ROUND(Amount *0.02, 2), 0)
This example calculates the commission amount for any opportunity that has a “Closed Won” stage. The value of this field will be the amount times 0.02 for any closed/won opportunity. Open or lost opportunities will have a zero commission value. Competitor-Triggered Workflow
ISPICKVAL(Stage, “Closed Lost”) && INCLUDES(Competitor__c, “Acme”)
In a workflow rule or process, this formula configures Salesforce to trigger the associated actions if the Competitor multi-select picklist field on a lost business is Acme.
Tips: • Replace picklist_field with a custom or standard field of type picklist. • Your text_literal expression must be of type text and enclosed in quotes. It cannot be a merge field or the result of a function. • Use CASE functions to determine if a picklist value is equal to a particular value.
388 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• When using the ISPICKVAL function to return the previous value of a picklist field, include the PRIORVALUE function inside the ISPICKVAL function as in this example:
ISPICKVAL(PRIORVALUE (picklist_field), text_literal)
JSENCODE
Description: Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (').
Use: {!JSENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters.
Example: If the merge field foo__c contains Enter the user's name, {!JSENCODE(foo__c)} results in: \u003CB\u003EEnter the user\'s name\u003C\/b\u003E
Tips: This function is only available in custom buttons and links, and in Visualforce.
JSINHTMLENCODE
Description: Encodes text and merge field values for use in JavaScript inside HTML tags by replacing characters that are reserved in HTML with HTML entity equivalents and inserting escape characters before unsafe JavaScript characters. JSINHTMLENCODE(someValue) is a convenience function that is equivalent to JSENCODE(HTMLENCODE((someValue)). That is, JSINHTMLENCODE first encodes someValue with HTMLENCODE, and then encodes the result with JSENCODE.
Use: {!JSINHTMLENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters.
Example: If the merge field foo__c contains Enter the user's name, {!JSINHTMLENCODE(foo__c)} results in: <B>Enter the user's name</b>
Tips: • This function is only available in custom buttons and links, and in Visualforce.
JUNCTIONIDLIST
Description: Returns a JunctionIDList based on the provided IDs. A JunctionIDList is a string array of referenced ID values that represent the many-to-many relationship of an underlying junction entity.
Use: JUNCTIONIDLIST(id, id,...) and replace id with the Salesforce ID you want to use.
389 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Example: JUNCTIONIDLIST(Case.ContactId) This formula returns the case’s contact record ID. When used on the email action for cases, you can use this formula as a predefined value for the To Recipients field. Using this formula as a predefined value for the field ensures that sent emails are always associated with a Salesforce record. In the case feed publisher, users see the contact name instead of the ID or email address.
Tips: • You can enter IDs only. • You can use the JUNCTIONLISTID formula with the To Recipients, CC Recipients, and BCC Recipients fields to send emails to multiple contacts and users. However, these fields work only with the email action for cases.
LEFT
Description: Returns the specified number of characters from the beginning of a text string.
Use: LEFT(text, num_chars) and replace text with the field or expression you want returned; replace num_chars with the number of characters from the left you want returned.
Example: TRIM(LEFT(LastName, 5)) & "-" & TRIM(RIGHT(SSN__c, 4)) This formula displays the first five characters of a name and the last four characters of a social security number separated by a dash. Note that this example uses a text custom field called SSN.
Tips: • Reference auto-number fields as text fields in formulas. • If the num_chars value is less than zero, Salesforce replaces the value with zero.
LEN
Description: Returns the number of characters in a specified text string.
Use: LEN(text) and replace text with the field or expression whose length you want returned.
Example: LEN(PartNumber__c) This formula returns the number of characters in a Product Code field.
LINKTO
Description: Returns a relative URL in the form of a link (href and anchor tags) for a custom s-control or Salesforce page.
Use: {!LINKTO(label, target, id, [inputs], [no override]} and replace label with the text for the link, target with the URL, and id with a reference to the record. Inputs are optional and can include any additional parameters you want to add to the link. The no override argument is also optional and defaults to “false.” It applies to targets for standard Salesforce pages such as $Action.Account.New. Replace no override with “true” when you
390 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
want to display a standard Salesforce page regardless of whether you have defined an override for it elsewhere.
S-Control Example: New Account S-Control
{!LINKTO("Create a New Account", $Action.Account.New, $ObjectType.Account)} This example allows users to click a link to create a new account. It is useful in account list views or Web tabs where you want users to create an account directly from that page. Use the $Action global variable to access the new account page in Salesforce. New Email Window S-Control
{!LINKTO("Email link", "mailto:support@yourcompany.com?subject=Please%20Help")}; This example launches a new email window addressed to support@yourcompany.com with the subject “Please Help” whenever a user clicks “Mail link.” Link to Another S-Control
{!LINKTO("Check for duplicates", $Scontrol.dedup_account, Account.Id)} Use this example to generate a page containing a hyperlink labeled “Check for duplicates.” When users click this link, Salesforce runs your custom s-control. This example assumes you have already created a custom s-control to find duplicate accounts and merge their information.
Tips: • Avoid using this function in an inline s-control if you want it to open in a new window. • Enclose multiple inputs in brackets to indicate they are together:
{!LINKTO("View Case", $Action.Case.View, Case.Id, [parm1="A", parm2="B"])}
• Set inputs to null if you do not have any to pass yet you want to set the no override argument:
{!LINKTO("View Case", $Action.Case.View, Case.Id, null, true)}
• When you override the tab home page for a standard or custom tab, use the tab’s $Action global variable as the target value, and the tab’s object type for the id value. For example, LINKTO("Accounts Tab", $Action.Account.Tab, $ObjectType.Account) • This function is only available in custom buttons, links, and s-controls.
391 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
LN
Description: Returns the natural logarithm of a specified number. Natural logarithms are based on the constant e value of 2.71828182845904.
Use: LN(number) and replace number with the field or expression for which you want the natural logarithm. Note: the LN function is the inverse of the EXP function.
Example: LN(10) returns the natural logarithm of 10, which is 2.30. LN(Value__c) returns the natural logarithm of a custom number field called Value.
LOG
Description: Returns the base 10 logarithm of a number.
Use: LOG(number) and replace number with the field or expression from which you want the base 10 logarithm calculated.
Example: Salary LOG(Salary__c) calculates the logarithm of a person’s salary. In this example, Salary is a custom currency field. Hydrogen -LOG(Hydrogen__c) calculates the pH and acidity using the LOG function and a custom number field called Hydrogen, which represents the concentration of Hydrogen ions in the liquid measured in moles per liter.
LOWER
Description: Converts all letters in the specified text string to lowercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided.
Use: LOWER(text, [locale]) and replace text with the field or text you wish to convert to lowercase, and locale with the optional two-character ISO language code or five-character locale code, if available.
Example: MYCOMPANY.COM LOWER("MYCOMPANY.COM") returns “mycompany.com.” Ticker Symbol LOWER(TickerSymbol) returns the text in Ticker Symbol in lower case characters. Applying Turkish Language Locale Rules The Turkish language has two versions of the letter “i”: one dotted and one dotless. The locale rules for Turkish require the ability to capitalize the dotted i, and allow the dotless I to be lowercase. To correctly use the LOWER() function with the Turkish language locale, use the Turkish locale code tr in the LOWER() function as follows: LOWER(text, "tr")
392 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This ensures that Salesforce does not transform any dotted i in the text to a dotless I.
LPAD
Description: Inserts characters you specify to the left-side of a text string.
Use: LPAD(text, padded_length[, pad_string]) and replace the variables: • text is the field or expression you want to insert characters to the left of. • padded_length is the number of total characters in the text that will be returned. • pad_string is the character or characters that should be inserted. pad_string is optional and defaults to a blank space. If the value in text is longer than pad_string, text is truncated to the size of padded_length.
Example: Field Name: Padding LPAD(Name, 20) truncates the Name field after 20 characters. For example, if the name is mycompany.com, the value returned is "mycompany.com." My_Company: No Change LPAD('my_company.com', 14, 'z') returns “my_company.com” without change because it has 14 characters. Field Name Padded with Z LPAD(Name, 15, 'z') returns the name “zmycompany.com.” Field Name: Truncating LPAD(Name, 2) truncates the name after the second character. For example, if the name is mycompany.com, the value returned is “my.”
Tips: Leading blank spaces and zeros are omitted.
MAX
Description: Returns the highest number from a list of numbers.
Use: MAX(number, number,...) and replace number with the fields or expressions from which you want to retrieve the highest number.
Example: Service Charge MAX(0.06 * Total_Cost__c, Min_Service_Charge__c) In this example, the formula field calculates a service charge of 6% of the total cost or a minimum service charge, whichever is greater. Note that Min Service Charge is a custom currency field with a default value of $15. However, you could make it a formula field if your minimum service charge is always the same amount.
393 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Book Royalties
MAX(0.10 * Pages__c, (Retail_Price__c * 0.07) * Total_Sold__c)
This formula determines which amount to pay in royalties for a book. It displays the greater of two amounts: $0.07 for each book sold or $0.10 per page. It assumes you have custom number fields for Pages and Total Sold and a custom currency field for Retail Price. Commissions
MAX($User.Commission_Percent__c * Price, Price * Account_Discount__c, 100)
This formula determines what commission to log for an asset based on which is greater: the user's commission percentage of the price, the price times the discount percent stored for the account or 100 dollars. This example assumes you have two custom percent fields on users and assets.
MCEILING
Description: Rounds a number up to the nearest integer, towards zero if negative.
Use: MCEILING(number)
Example: MCEILING(2.5) returns 3, which is 2.5 rounded up to the nearest integer. MCEILING(-2.5) returns -2, which is -2.5 rounded up towards zero for a negative number.
MFLOOR
Description: Rounds a number down to the nearest integer, away from zero if negative.
Use: MFLOOR(number)
Example: MFLOOR(2.5) returns 2, which is 2.5 rounded down to the nearest integer. MFLOOR(-2.5) returns -3, which is -2.5 rounded away from zero for a negative number.
MID
Description: Returns the specified number of characters from the middle of a text string given the starting position.
Use: MID(text, start_num, num_chars) and replace text with the field or expression to use when returning characters; replace start_num with the number of characters from the left to use as a starting position; replace num_chars with the total number of characters to return.
Example: MID(Division, 3, 4) returns four characters of the Division name beginning with the third character from the left. On a user record, this represents the department code.
394 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
MILLISECOND
Description: Returns a milliseconds value in the form of a number from 0 through 999.
Use: MILLISECOND(time) and replace time with a time value or value such as TIMENOW().
Examples: MILLISECOND(TIMEVALUE(ClosedDate)) displays only the milliseconds in a time field based on the value of the Time Closed field. MILLISECOND(TIMEVALUE("17:30:45.125")) returns 125.
MIN
Description: Returns the lowest number from a list of numbers.
Use: MIN(number, number,...) and replace number with the fields or expressions from which you want to retrieve the lowest number.
Example: 401K Matching
MIN(250, Contribution__c /2)
This example formula determines which amount to provide in employee 401K matching based on a matching program of half of the employee's contribution or $250, whichever is less. It assumes you have custom currency field for Contribution. Bonus
MIN(Gross__c * Bonus_Percent__c, Performance__c / Number_of_Employees__c)
This example determines an employee's bonus amount based on the smallest of two amounts: the employee's gross times bonus percent or an equally divided amount of the company's performance amount among all employees. It assumes you have custom number field for Number of Employees, a custom percent field for Bonus Percent, and currency custom fields for the employee's Gross and company's Performance.
MINUTE
Description: Returns a minute value in the form of a number from 0 through 60.
Use: MINUTE(time) and replace time with a time value or value such as TIMENOW().
Examples: MINUTE(TIMEVALUE(ClosedDate)) displays only the minutes in a time field based on the value of the Time Closed field. MINUTE(TIMEVALUE("17:30:45.125")) returns 30.
MOD
Description: Returns a remainder after a number is divided by a specified divisor.
395 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: MOD(number, divisor) and replace number with the field or expression you want divided; replace divisor with the number to use as the divisor.
Example: MOD(3, 3) returns 0 MOD(4, 3) returns 1 MOD(123, 100) returns 23 You might want to prevent users from scheduling meetings on a Saturday or Sunday. Use the following example to apply a validation rule to a custom date field called My Date.
CASE(MOD(My_Date__c - DATE(1900, 1, 7), 7), 0, 0, 6, 0, 1) = 0
This example displays the following error message when the value of My Date is not Monday through Friday: “My Date is not a weekday.”
MONTH
Description: Returns the month, a number between 1 (January) and 12 (December) in number format of a given date.
Use: MONTH(date) and replace date with the field or expression for the date containing the month you want returned.
Example: SLA Expiration MONTH(SLAExpirationDate__c) returns the month that your service-level agreement expires. This example uses a custom date field called SLA Expiration Date. Current Month MONTH(TODAY()) returns the current month in a number format. For example, the month of February would be the value “2.”
NOT
Description: Returns FALSE for TRUE and TRUE for FALSE.
Use: NOT(logical) and replace logical with the expression that you want evaluated.
Example: IF(NOT(ISPICKVAL(Status, "Closed")), ROUND(NOW()-CreatedDate, 0), null checks to see if a variable is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number of days open rounded to zero decimal places. If the variable is not open, this field is blank.
396 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
NOW
Description: Returns a date/time representing the current moment.
Use: NOW()
Example: IF(ISPICKVAL(Status, "Open"), ROUND(NOW()-CreatedDate, 0), null) This formula checks to see if a lead is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number of days open rounded to zero decimal places. If the lead is not open, this field is blank.
Tips: • Do not remove the parentheses. • Keep the parentheses empty. They do not need to contain a value. • Use a date/time field in a NOW function instead of a date field. Created Date and Last Modified Date are date/time fields whereas Last Activity Date is a date field. • Use TODAY if you prefer to use a date field. • Dates and times are always calculated using the user’s time zone. • Use addition and subtraction operators with a NOW function and other date/time fields to return a number, representing number of days. For example NOW() - CreatedDate calculates the number of days since the created date of a record. In this example, the formula field data type is a number. • Use addition and subtraction operators with a NOW function and numbers to return a date and time. For example NOW() +5 calculates the date and time five days ahead of now. In this example, the formula field data type is a date/time.
NULLVALUE
Important: Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas.
Description: Determines if an expression is null (blank) and returns a substitute expression if it is. If the expression is not blank, returns the value of the expression.
Use: NULLVALUE(expression, substitute_expression) and replace expression with the expression you want to evaluate; replace substitute_expression with the value you want to replace any blank values.
Example: (NULLVALUE(Sample_Due_Date__c, StartDate +5) This formula returns the date five days after the start date whenever Sample Due Date is blank. Sample Due Date is a custom date field.
Tips: • Avoid using this function with text fields because they are never null even when they are blank. Instead, use the BLANKVALUE function to determine if a text field is blank. • Don’t use NULLVALUE for date/time fields.
397 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Choose Treat blank fields as blanks for your formula when referencing a number, percent, or currency field in a NULLVALUE function. Choosing Treat blank fields as zeroes gives blank fields the value of zero so none of them will be null. • Use the same data type for both the expression and substitute_expression.
OR
Description: Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false. Use this function as an alternative to the operator || (OR).
Use: OR(logical1, logical2...) and replace any number of logical references with the expressions you want evaluated.
Formula Field Example: IF(OR(ISPICKVAL(Priority, "High"), ISPICKVAL(Status, "New")), ROUND(NOW()-CreatedDate, 0), null) This formula returns the number of days a case has been open if the Status is new or the Priority is high. If the case was opened today, this field displays a zero.
Validation Rule Example: OR(Sample_Rate__c < 0, Sample_Rate__c > 0.40)
This validation rule formula displays the following error message when the Sample Rate custom field is not between 0 and 40%: “SampleRate cannot exceed 40%.”
PARENTGROUPVAL
Description: This function returns the value of a specified parent grouping. A “parent” grouping is any level above the one containing the formula. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels.
Use: Summary and Joined: PARENTGROUPVAL(summary_field, grouping_level) Matrix: PARENTGROUPVAL(summary_field, parent_row_grouping, parent_column_grouping) Where summary_field is the summarized field value, grouping_level is GRAND_SUMMARY or the API name of the parent level group for summary reports, and parent_row_level and parent_column_level are the parent levels for matrix reports. In reports with multiple grouping levels, you can set the grouping_level to be any group level higher than the formula display level.
Example: TOTAL_PRICE:SUM/PARENTGROUPVAL(TOTAL_PRICE:SUM, GRAND_SUMMARY)
This formula calculates, for each product, its relative size compared to the grand total. In this example, the report is a summary of opportunities and their products, grouped by Product Name.
398 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
PREDICT
Description: Returns an Einstein Discovery prediction for a record based on the specified record ID or for a list of fields and their values.
Use: PREDICT(PredDefId, [recordId] | [field, value, ...]). Replace PredDefId with the Prediction Definition ID of a deployed prediction in your org. Specify the recordId of the record to predict or a list of fields and their associated values ([field, value, ...]).
Examples: Example with recordId
PREDICT($SmartDataDiscovery.PredictionDefinitions.Recommende_kFjqS_1370.Id, Id)
This example calls the PREDICT function and passes a prediction definition and recordId. Example with List of Fields and Values
PREDICT($SmartDataDiscovery.PredictionDefinitions.Recommende_kFjqS_1370.Id,
‘Customer_Typec’, Text(Customer_Typec), ‘List_Price__c’, List_Price__c)
This example calls the PREDICT function and passes a prediction definition and list of fields with associated values.
Tips: • The specified PredDefId must link to a deployed and active prediction in your Salesforce org. To insert a value, select PredDefId, click Insert Field, select SmartDataDiscovery > Prediction Definitions, select an available prediction, select Prediction Definition Id, and then click Insert.
Note: The syntax for PredDefId must match the following pattern:
$SmartDataDiscovery.PredictionDefinitions..Id
• If you specify a recordId, the function returns a prediction for the data values in that record. • If you specify a list of field names and values, the function returns a prediction for the data values you provided. Be sure to provide all the fields that the prediction requires as input. • Getting predictions from Einstein Discovery predictions requires the View Einstein Discovery Recommendations system permission. To learn more, see Learn About Einstein Discovery Permissions and Permission Sets. • The PREDICT function is available when defining formulas for the following Process Automation components: approval processes, flows, processes (in Process Builder), workflow rules, and Next Best Action. • The PREDICT function is not supported in formula-based fields on Salesforce objects. • To learn more, see Get Predictions in Process Automation Formulas.
399 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
PREVGROUPVAL
Description: This function returns the value of a specified previous grouping. A “previous” grouping is one that comes before the current grouping in the report. Choose the grouping level and increment. The increment is the number of columns or rows before the current summary. The default is 1; the maximum is 12. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels.
Use: PREVGROUPVAL(summary_field, grouping_level [, increment])
Where summary_field is the name of the grouped row or column, grouping_level is the API name of the peer level group whose summary value for the previous grouping is used, and increment is the number of groupings previous. In reports with multiple grouping levels, you can specify the grouping_level to be the same group level as the formula display level or a group level higher than the formula display level.
Example: AMOUNT:SUM - PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE)
This formula calculates, for each month, the difference in amount from the previous month shown in the report. In this example, the report is an opportunity matrix with columns grouped by Close Date and rows by Stage.
PRIORVALUE
Description: Returns the previous value of a field.
Use: PRIORVALUE(field)
Validation Rule Example: The following validation rule prevents users from changing the expected revenue of an opportunity after it is closed: AND(PRIORVALUE(Amount) > Amount, IsClosed).
Tips: • This function is available only in: – Assignment rules – Validation rules – Field updates – Workflow rules if the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited . – Formula criteria for executing actions in Process Builder.
• This function does not return default values. • When users create a new record, this function returns the value of the field referenced rather than null. For example, if you create an account named “Acme,” PRIORVALUE(Account.Name) returns Acme.
400 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• When using the ISPICKVAL function to return the previous value of a picklist field, include the PRIORVALUE function inside the ISPICKVAL function as in this example:
ISPICKVAL(PRIORVALUE (picklist_field), text_literal)
• Use the PRIORVALUE function inside the INCLUDES function to check if the previous value of a multi-select picklist field included a specific value. For example:
INCLUDES( PRIORVALUE(multiselect_picklist_field), text_literal )
REGEX
Description: Compares a text field to a regular expression and returns TRUE if there is a match. Otherwise, it returns FALSE. A regular expression is a string used to describe a format of a string according to certain syntax rules.
Use: REGEX(text, regex_text) and replace text with the text field, and regex_text with the regular expression you want to match.
Validation Rule Example: This example ensures that a custom field called SSN matches a regular expression representing a valid social security number format of the form 999-99-9999.
NOT( OR( LEN (SSN__c) = 0, REGEX(SSN__c, "[0-9]{3}-[0-9]{2}-[0-9]{4}") ) )
Tips: • Regular expression syntax is based on Java Platform SE 6 syntax. However, backslash characters (\) must be changed to double backslashes (\\) because backslash is an escape character in Salesforce. • The Salesforce regular expression engine matches an entire string as opposed to searching for a match within a string. For example, if you are searching for the name Marc Benioff, use the regular expression, .*Marc Benioff.*, to find a match in a string like the following:
According to Marc Benioff, the social enterprise increases customer success.
If you use the regular expression, Marc Benioff, the only string that this regular expression will match is:
Marc Benioff
401 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• Capture groups and substitutions are ignored. • This function is available everywhere formulas exist except formula fields and custom buttons and links.
REQUIRESCRIPT
Description: Returns a script tag with source for a URL you specify. Use this function when referencing the Lightning Platform AJAX Toolkit or other JavaScript toolkits.
Use: {!REQUIRESCRIPT(url)} and replace url with the link for the script that is required. For the AJAX Toolkit:
{!requireScript("/soap/ajax/13.0/connection.js")}
Returns:
Custom Button Example: {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} var c = new sforce.SObject("Case"); c.id = "{!Case.Id}"; c.Status = "New"; result = sforce.connection.update([c]); window.location.reload();
This example sets the Status of a case to “New” whenever a user clicks a custom button from the case detail page. To set this up in your organization, define a custom button for cases that has the following attributes: • Display Type is “Detail Page Button” • Behavior is “Execute JavaScript” • Content Source is “OnClick JavaScript” Next, paste the content above into your custom button definition and add it to your case page layouts.
Tips: • Use global variables to access special merge fields for s-controls. • Use this function when creating custom buttons or links where you have set Behavior to “Execute JavaScript” and Content Source to “OnClick JavaScript” because the script tag must be outside the OnClick code. • This function is only available for custom buttons and links that have Content Source set to “OnClick JavaScript.” • When working in Visualforce, use INCLUDESCRIPT instead.
RIGHT
Description: Returns the specified number of characters from the end of a text string.
402 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: RIGHT(text, num_chars) and replace text with the field or expression you want returned; replace num_chars with the number of characters from the right you want returned.
Example: TRIM(LEFT(LastName, 5))&"-"&TRIM(RIGHT(SSN__c, 4)) displays the first five characters of a name and the last four characters of a social security number separated by a dash. Note that this assumes you have a text custom field called SSN.
Tips: • Reference auto-number fields as text fields in formulas. • If the num_chars value is less than zero, Salesforce replaces the value with zero.
ROUND
Description: Returns the nearest number to a number you specify, constraining the new number by a specified number of digits.
Use: ROUND(number, num_digits) and replace number with the field or expression you want rounded; replace num_digits with the number of decimal places you want to consider when rounding.
Example: ROUND (1.5, 0) = 2 ROUND (1.2345, 0) = 1 ROUND (-1.5, 0) = -2 ROUND (225.49823, 2) = 225.50 Simple Discounting ROUND(Amount-Amount* Discount_Percent__c,2) Use this formula to calculate the discounted amount of an opportunity rounded off to two digits. This example is a number formula field on opportunities that uses a custom percent field called Discount Percent.
Tips: • Enter zero for num_digits to round a number to the nearest integer. • Salesforce automatically rounds numbers based on the decimal places you specify. For example, a custom number field with two decimal places stores 1.50 when you enter 1.49999. • Salesforce uses the round half-up rounding algorithm. Half-way values are always rounded up. For example, 1.45 is rounded to 1.5. –1.45 is rounded to –1.5. • The decimal numbers displayed depend on the decimal places you selected when defining the field in the custom field wizard. The num_digits represents the number of digits considered when rounding.
RPAD
Description: Inserts characters that you specify to the right-side of a text string.
403 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: RPAD(text, padded_length[, 'pad_string']) and replace the variables: • text is the field or expression after which you want to insert characters. • pad_length is the number of total characters in the text string that will be returned. • pad_string is the character or characters to insert. pad_string is optional and defaults to a blank space. If the value in text is longer than pad_string, text is truncated to the size of padded_length.
Example: Field Name: Padding Default RPAD(Name, 20) truncates the Name field after 20 characters. For example, if the name is mycompany.com, the value returned is “mycompany.com.” My_Company: No Change RPAD('my_company.com', 14, 'z') returns “my_company.com” without change because it has 14 characters. Field Name: Padding with a Character RPAD(Name, 15, 'z') returns “mycompany.comz” . Field Name: Truncating RPAD(Name, 2) truncates the name after the second character. For example, if the name is mycompany.com, the value returned is “my.”
Tips: Ending blank spaces are omitted.
SECOND
Description: Returns a seconds value in the form of a number from 0 through 60.
Use: SECOND(time) and replace time with a time value or value such as TIMENOW().
Examples: SECOND(ClosedDate) displays only the seconds in a time field based on the value of the Time Closed field. SECOND(TIMEVALUE("17:30:45.125")) returns 45.
SQRT
Description: Returns the positive square root of a given number.
Use: SQRT(number) and replace number with the field or expression you want computed into a square root.
Example: SQRT(25)returns the square root of 25, which is 5. Amplitude SQRT(Amplitude__c) returns the square root of a custom number field representing the amplitude of an earthquake.
404 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips: • Calculating the square root of a negative number results in an error on the detail page. • Avoid division by zero errors by including an IF function such as: IF(Amplitude__c >= 0, SQRT(Amplitude__c), null).
SUBSTITUTE
Description: Substitutes new text for old text in a text string.
Use: SUBSTITUTE(text, old_text, new_text) and replace text with the field or value for which you want to substitute values, old_text with the text you want replaced, and new_text with the text you want to replace the old_text.
Example: SUBSTITUTE(Name, "Coupon", "Discount")returns the name of an opportunity that contains the term “Coupon” with the opportunity name plus “Discount” wherever the term “Coupon” existed. SUBSTITUTE(Email, LEFT(Email, FIND("@", Email)), "www.") finds the location of the @ sign in a person's email address to determine the length of text to replace with a “www.” as a means of deriving their website address.
Tips: • Each term provided in quotes is case-sensitive. • If the old_text appears more than once, each occurrence is replaced with the new_text value provided, even when that results in duplicates.
TEXT
Description: Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. Also, converts picklist values to text in approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, validation rules, formula fields, field updates, and custom buttons and links.
Use: TEXT(value) and replace value with the field or expression you want to convert to text format. Avoid using any special characters besides a decimal point (period) or minus sign (dash) in this function.
Example: Expected Revenue in Text TEXT(ExpectedRevenue) returns the expected revenue amount of an opportunity in text format without a dollar sign. For example, if the Expected Revenue of a campaign is "$200,000," this formula field displays “200000.” Asset ID SerialNumber &"-"& TEXT(Quantity) returns an asset ID number starting with the serial number and ending with the quantity separated by a dash. The Serial Number field is already text but the Quantity field is a number, requiring the TEXT function before it.
405 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use Picklist Values in Math Equations
VALUE(LEFT(TEXT(Quantity), 5)) * Unit
This formula multiplies the first five numbers of the Quantity picklist by the Unit numeric field. Compare Two Picklists
IF(TEXT(bug_status) = TEXT(case_status), “Match”, “Out of Sync”)
This formula compares the values of the bug_status picklist with values of the case_status picklist. Display Picklist Values From Parent Records
TEXT(Account.Industry)
This formula field on opportunities shows the industry of the associated account. Concatenate Picklist Values
TEXT(Account.Industry) & " - " & TEXT(Account.SubIndustry__c)
This formula field on opportunities shows the industry and subindustry of the associated account.
Validation Rule Examples: Block the Save of a Closed Opportunity CONTAINS(TEXT(Status), "Closed") returns TRUE if the Status picklist contains the value “Closed,” such as “Closed Won” and “Closed Lost.” This validation rule formula blocks users from saving changes to a closed opportunity. Use Numeric Functions on Numeric Picklist Values VALUE(LEFT(TEXT(Quantity), 5)) * Unit > 10000 multiplies the first five numbers of the Quantity picklist by the Unit numeric field, and returns TRUE if the result is greater than 10,000. Directly Compare Two Picklists TEXT(bug_status) = TEXT(case_status) compares the values of the bug_status picklist with values of the case_status picklist, and returns TRUE if they are equal.
Tips: • The returned text is not formatted with any currency, percent symbols, or commas. • Values are not sensitive to locale. For example, 24.42 EUR is converted into the number 24.42. • Percents are returned in the form of a decimal. • Dates are returned in the form of YYYY-MM-DD, that is, a four-digit year and two-digit month and day. • Date/time values are returned in the form of YYYY-MM-DD HH:MM:SSZ where YYYY is a four-digit year, MM is a two-digit month, DD is a two-digit day, HH is the two-digit hour, MM are the minutes, SS are the seconds, and Z represents the zero meridian indicating the time is returned in UTC time zone. • Picklist fields are supported in TEXT functions used in these kinds of formulas: validation rules, approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, formula fields, field updates, and custom buttons and links. In other formulas, use ISPICKVAL or CASE when referencing a picklist field.
406 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• If the text value you enter is a URL, the text automatically converts as a hyperlink.
TIMENOW
Description: Returns a time value in GMT representing the current moment. Use this function instead of the NOW function if you only want to track time, without a date.
Use: TIMENOW()
Example: IF(ISPICKVAL( Rating , "Hot"), TIMENOW(), TIMEVALUE(CreatedDate)) This formula checks to see if a lead is rated “Hot” and if so, returns the current time. Otherwise it returns the time since someone created the lead.
Tips: • Do not remove the parentheses. • Keep the parentheses empty. They do not need to contain a value. • Use TODAY if you prefer to use a date field. • The displayed value is based on the organization’s Locale settings.
TIMEVALUE
Description: Returns the local time value without the date, such as business hours.
Use: TIMEVALUE(value) and replace value with a date/time or text value, merge field, or expression.
Examples: TIMEVALUE(ClosedDate) displays a time value based on the value of the Date/Time Closed field. TIMEVALUE("17:30:45.125") returns 5:30 PM.
Tips: • The displayed value is based on the organization’s Locale settings. • Don’t use TIMEVALUE on a time field. A time field’s value is already in time format. For example, for a time field with API name timefield__c, TIMEVALUE(timefield__c) doesn’t do anything.
TODAY
Description: Returns the current date as a date data type.
Use: TODAY()
Example: TODAY()-Sample_date_c calculates how many days in the sample are left.
Validation Rule Example: SampleDate < TODAY()
This example ensures that users cannot change the Sample Date to any date in the past.
407 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips: • Do not remove the parentheses. • Keep the parentheses empty. They do not need to contain a value. • Use a date field with a TODAY function instead of a date/time field. Last Activity Date is a date field whereas Created Date and Last Modified Date are date/time fields. • See NOW if you prefer to use a date/time field. • Dates and times are always calculated using the user’s time zone. • Use addition and subtraction operators with a TODAY function and other date fields to return a number, representing number of days. For example TODAY()-LastActivityDate calculates the number of days since the last activity date. In this example, the formula field data type is a number. • Use addition and subtraction operators with a TODAY function and numbers to return a date. For example TODAY() +5 calculates the date five days ahead of today. In this example, the formula field data type is a date.
TRIM
Description: Removes the spaces and tabs from the beginning and end of a text string.
Use: TRIM(text) and replace text with the field or expression you want to trim.
Example: TRIM(LEFT(LastName,5))& "-" & RIGHT(FirstName, 1) returns a network ID for users that contains the first five characters of their last name and first character of their first name separated by a dash.
UPPER
Description: Converts all letters in the specified text string to uppercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided.
Use: UPPER(text, [locale]) and replace text with the field or expression you wish to convert to uppercase, and locale with the optional two-character ISO language code or five-character locale code, if available.
Example: MYCOMPANY.COM UPPER("mycompany.com") returns “MYCOMPANY.COM.” MYCOMPANY.COM 123 UPPER("Mycompany.com 123") returns “MYCOMPANY.COM 123.” Applying Turkish Language Locale Rules The Turkish language has two versions of the letter i: one dotted and one dotless. The locale rules for Turkish require the ability to capitalize the dotted i, and allow the dotless I to be lowercase. To correctly use the UPPER() function with the Turkish language locale, use the Turkish locale code tr in the UPPER() function as follows: UPPER(text, "tr")
408 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This ensures that any dotted i in the text does not transform to a dotless I.
URLENCODE
Description: Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with %20, and exclamation points are replaced with %21.
Use: {!URLENCODE(text)} and replace text with the merge field or text string that you want to encode.
Example: If the merge field foo__c contains Mark's page, {!URLENCODE(foo_c)} results in: %3CB%3EMark%27s%20page%3C%2Fb%3E
Tips: • This function is only available in custom buttons and links, and in Visualforce. • Custom buttons and links with URL content sources have separate encoding settings. If you use the URLENCODE function to encode a custom button or link that has an encoding setting specified, Salesforce first encodes the URL according to the custom button or link setting, then encodes the result. For example, if the URL in a custom link contains a space and its encoding setting is UTF8, Salesforce first encodes the space to a plus sign (+), then the URLENCODE function converts the plus sign to its character code, %2B. • When you include the standard Account field on opportunities (Opportunity.Account) in the URLENCODE function, the value of the field is the account ID, not the account name. To encode the account name, create a custom cross-object formula field on opportunities that spans to the account name, and use that field in the URLENCODE function instead of Opportunity.Account. For example, if the cross-object formula is AccountNameFormula__c, use the following:
http://www.google.com/search?q={!URLENCODE (Opportunity.AccountNameFormula__c)}
URLFOR
Description: Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page.
Use: {!URLFOR(target, [id], [inputs], [no override])} and replace target with the URL or action, s-control, or static resource merge variable, id with an optional reference to the record, and inputs with any optional parameters. The no override argument is also optional and defaults to “false.” It applies to targets for standard Salesforce pages such as $Action.Account.New. Replace no override with “true” when you want to display a standard Salesforce page regardless of whether you have defined an override for it elsewhere. The input values can be dynamic. For example, to include an account ID, specify:
{!URLFOR($Page.myVisualforcePage, null, [accountId=Account.Id])}
409 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
The resulting URL includes a parameter with the ID, such as:
https://instance.salesforce.com/apex/myVisualforcePage?accountId=001B0000002txol
You can also use non-string variables, like an SObject variable. For example, if you supply [myAccountParam=Account], the value is converted to a string, and the URL contains ?MyAccountParam=001B0000002txol. You can also use a parameter to supply a static value, such as [param1=55].
Note: Because parameter names are static, you can’t use a variable to determine the parameter name. For example, if you use [myVariable=”value”] and set myVariable to “param1”, the resulting URL includes ?myVariable=value1 and not the param1 value.
Visualforce Example:
In this example, the component references a .jpg file contained within a .zip file that has been uploaded as a static resource. When uploaded, the name of the static resource was defined as TestZip, and the path to the image within the resource is images/Bluehills.jpg.
Tips: • Use global variables to access special merge fields for actions, s-controls, and static resources. • If an input parameter name begins with any character other than a letter or dollar sign ($), enclose it in quotation marks. • Enclose multiple inputs in brackets to indicate they are together:
{!URLFOR($Action.Case.View, Case.Id, [param1="A", param2="B"])}
• Set inputs to null if you do not have any to pass yet you want to set the no override argument:
{!URLFOR($Action.Case.View, Case.Id, null, true)}
• When you override a standard action, that action is no longer available in Salesforce. For example, if you override the new account action, that affects the New button on all pages, such as the account detail page, account related lists on other detail pages, and the Create New dropdown list in the sidebar. To override a standard action yet still access it, use the no override argument in your s-control to reference that action. • When you override the tab home page for a standard or custom tab, use the tab’s $Action global variable as the target value, and the tab’s object type for the id value. For example, URLFOR($Action.Account.Tab, $ObjectType.Account). • This function is only available in custom buttons, links, s-controls, and Visualforce pages.
VALUE
Description: Converts a text string to a number.
410 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Use: VALUE(text) and replace text with the field or expression you want converted into a number.
Example: Lead Number VALUE(Lead_Number__c) returns a number for the text value in the auto-number field Lead Number. This can be useful if you want to use the Lead Number field in a calculation. Note that auto-number fields are actually text fields and must be converted to a number for numeric calculations. Round Robin Lead Assignment MOD(VALUE(Lead_Number__c), 3) This formula is for a custom formula field named Round_Robin_ID that assigns each lead a value of 0, 1, or 2. This formula uses a custom auto-number field called Lead Number that assigns each lead a unique number starting with 1. The MOD function divides the lead number by the number of lead queues available (three in this example) and returns a remainder of 0, 1, or 2. Use the value of this formula field in your lead assignment rules to assign lead records to different queues. For example: • Round_Robin_ID = 0 is assigned to Queue A • Round_Robin_ID = 1 is assigned to Queue B • Round_Robin_ID = 2 is assigned to Queue C
Tips: Make sure the text in a VALUE function doesn’t include special characters other than a decimal point (period) or minus sign (dash). If the text in a VALUE function is a non-numerical/invalid format, the formula isn’t calculated and resolves to a blank value. For example, the formula 1 + VALUE(Text_field__c) produces these results: • If Text field is 123, the result is 124. • If Text field is blank, the result is blank. • If Text field is $123, the result is blank. • If Text field is EUR123, the result is blank.
VLOOKUP
Description: Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function.
Use: VLOOKUP(field_to_return, field_on_lookup_object, lookup_value) and replace field_to_return with the field that contains the value you want returned, field_on_lookup_object with the field on the related object that contains the value you want to match, and lookup_value with the value you want to match.
Validation Rule Example: This example checks that a billing postal code is valid by looking up the first five characters of the value in a custom object called Zip_Code__c that contains a record for every valid zip code in the US. If the zip code is not found in the Zip_Code__c object or the billing state does not match the corresponding State_Code__c in the Zip_Code__c object, an error is displayed.
AND( LEN(BillingPostalCode) > 0, OR(BillingCountry = "USA", BillingCountry = "US"),
411 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
VLOOKUP( $ObjectType.Zip_Code__c.Fields.State_Code__c, $ObjectType.Zip_Code__c.Fields.Name, LEFT(BillingPostalCode,5)) <> BillingState )
Note: • Use this example when the billing country is US or USA. • You can download US zip codes in CSV file format from http://zips.sourceforge.net.
Tips: • The field_to_return must be an auto number, roll-up summary, lookup relationship, master-detail relationship, checkbox, date, date/time, email, number, percent, phone, text, text area, or URL field type. • The field_on_lookup_object must be the Record Name field on a custom object. • The field_on_lookup_object and lookup_value must be the same data type. • If more than one record matches, the value from the first record is returned. • The value returned must be on a custom object. • You cannot delete the custom field or custom object referenced in this function. • This function is only available in validation rules.
WEEKDAY
Description: Returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday.
Use: WEEKDAY(date)
Example: WEEKDAY(customdate1__c) returns the day of the week for the given date in customdate1__c.
YEAR
Description: Returns the four-digit year in number format of a given date.
Use: YEAR(date) and replace date with the field or expression that contains the year you want returned.
Example: YEAR(TODAY())- YEAR(Initial_Meeting__c) returns the number of years since your initial meeting with a client. This example uses a custom date field called Initial Meeting.
SEE ALSO: Formula Operators and Functions A–H Formula Operators and Functions
412 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Using Date, Date/Time, and Time Values in Formulas
Date formulas are useful for managing payment deadlines, contract ages, or any other features of EDITIONS your organization that are time or date dependent. Two data types are used for working with dates: Date and Date/Time. One data type, Time, is Available in: both Salesforce independent of the date for tracking time such as business hours. Most values that are used when Classic and Lightning working with dates are of the Date data type, which store the year, month, and day. Some fields, Experience such as CreatedDate, are Date/Time fields, meaning they not only store a date value, but also Available in: All Editions a time value (stored in GMT but displayed in the users’ time zone). Date, Date/Time, and Time fields are formatted in the user’s locale when viewed in reports and record detail pages. A Time value’s precision is in milliseconds. A Date/Time value’s precision is in seconds. You can use operations like addition and subtraction on Date, Date/Time, and TIme values to calculate a future date or elapsed time between two dates or times. If you subtract one date from another, for example, the resulting value will be the difference between the two initial values in days (Number data type). The same operation between two Date/Time values returns a decimal value indicating the difference in number of days, hours, and minutes. The same operation between two Time values returns millisecond For example, if the difference between two Date/Time values is 5.52, that means the two values are separated by five days, 12 hours (0.5 of a day), and 28 minutes (0.02 of a day). You can also add numeric values to Dates and Date/Times. For example, the operation TODAY() + 3 returns three days after today’s date. For more information and examples of working with dates, see the list of Sample Date Formulas. Throughout the examples, the variables date and date/time are used in place of actual Date and Date/Time fields or values. Keep in mind that complex date functions tend to compile to a larger size than text or number formula functions, so you might run into issues with formula compile size. See Tips for Reducing Formula Size for help with this problem.
TODAY(), NOW() and TIMENOW() The TODAY() function returns the current day, month, and year as a Date data type. This function is useful for formulas where you are concerned with how many days have passed since a previous date, the date of a certain number of days in the future, or if you just want to display the current date. The NOW() function returns the Date/Time value of the current moment. It’s useful when you are concerned with specific times of day as well as the date. The TIMENOW() function returns a value in GMT representing the current time without the date. Use this function instead of the NOW() function if you want the current hour, minute, seconds, or milliseconds. This value is useful for tracking time like work shifts or elapsed time, For details on how to convert between Date values and Date/Time values, see Converting Between Date/Time and Date.
The DATE() Function The DATE() function returns a Date value, given a year, month, and day. Numerical Y/M/D values and the YEAR(), MONTH(), and DAY() functions are valid parameters for DATE(). For example DATE( 2013, 6, 1 ) returns June 1, 2013. Similarly, DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 3, 1) returns the Date value of the first day three months from today in the current year, assuming the date is valid (for example, the month falls between 1 and 12). If the inputted Y/M/D values result in an invalid date, the DATE() function returns an error, so error checking is an important part of working with Date values. You can read about methods for handling invalid dates in Sample Date Formulas.
413 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Converting Between Date/Time and Date Date and Date/Time aren’t interchangeable data types, so when you want to perform operations between Date and Date/Time values, you need to convert the values so they are both the same type. Some functions (such as YEAR(), MONTH(), and DAY()) also only work on Date values, so Date/Time values must be converted first. Use the DATEVALUE( date/time ) function to return the Date value of a Date/Time. For example, to get the year from a Date/Time, use YEAR( DATEVALUE( date/time ) ) ). You can convert a Date value to a Date/Time using the DATETIMEVALUE( date ) function. The time will be set to 12:00 a.m. in Greenwich Mean Time (GMT), and then converted to the time zone of the user viewing the record when it’s displayed. For a user located in San Francisco, DATETIMEVALUE( TODAY() ) returns 5:00 p.m. on the previous day (during Daylight Saving Time) rather than 12:00 a.m. of the current day. See A Note About Date/Time and Time Zones for more information.
Converting Between Date/Time and Time The TIMEVALUE() function returns a Time data type value in “HH:MM:SS.MS” (hours:minutes:seconds.milliseconds) format using a 24-hour clock. Numerical H/M/S/MS values and the HOUR(), MINUTE(), SECONDS(), and MILLISECONDS() functions are valid parameters for TIMEVALUE(). Use the TIMEVALUE(value) function to return the Time value of a Date/Time type, text, merge field or expression. For example, extract the time from a ClosedDate Date/Time value with TIMEVALUE(ClosedDate).
Converting Between Date and Text If you want to include a date as part of a string, wrap the Date value in the TEXT() function to convert it to text. For example, if you want to return today’s date as text, use:
"Today's date is " & TEXT( TODAY() )
This returns the date in the format “YYYY-MM-DD” rather than in the locale-dependent format. You can change the format by extracting the day, month, and year from the date first and then recombining them in the format you want. For example:
"Today's date is " & TEXT( MONTH( date ) ) & "/" & TEXT( DAY( date ) ) & "/" & TEXT( YEAR( date ) ) )
You can also convert text to a Date so you can use the string value with your other Date fields and formulas. You’ll want your text to be formatted as “YYYY-MM-DD”. Use this formula to return the Date value:
DATEVALUE( "YYYY-MM-DD" )
Converting Between Date/Time and Text You can include Date/Time values in a string using the TEXT() function, but you need to be careful of time zones. For example, consider this formula:
"The current date and time is " & TEXT( NOW() )
In this formula, NOW() is offset to GMT. Normally, NOW() would be converted to the user’s time zone when viewed, but because it’s been converted to text, the conversion won’t happen. So if you execute this formula on August 1st at 5:00 PM in San Francisco time (GMT-7), the result is “The current date and time is 2013–08–02 00:00:00Z”.
414 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
When you convert a Date/Time to text, a “Z” is included at the end to indicate GMT. TEXT( date/time ) returns “Z” if the field is blank. So if the Date/Time value you’re working with might be blank, check for this before converting to text:
IF( ISBLANK( date/time ), "", TEXT( date/time ) )
To convert a string to a Date/Time value, use DATETIMEVALUE() passing in a string in the format “YYYY-MM-DD HH:MM:SS”. This method returns the Date/Time value in GMT.
Converting Between Time and Text If you want to include time as part of a string, wrap the Time value in the TEXT() function to convert it to text. For example, if you want to return the current time as text, use:
"The time is " & TEXT( TIMENOW() )
This function returns the time in the format “HH:MM:SS.MS”. You can also convert text to a Time data type so you can use the string value with your other Time fields and formulas. Format your text as “HH:MM:SS.MS” on a 24-hour clock. Use the TIMEVALUE() function:
TIMEVALUE("17:30:45.125")
A Note About Date/Time and Time Zones Date and Date/Time values are stored in GMT. When a record is saved, field values are adjusted from the user’s time zone to GMT, and then adjusted back to the viewer’s time zone when displayed in record detail pages and reports. With Date conversions this doesn't pose a problem, since converting a Date/Time to a Date results in the same Date value. When working with Date/Time fields and values, however, the conversion is always done in GMT, not the user’s time zone. Subtracting a standard Date/Time field from another isn’t a problem because both fields are in the same time zone. When one of the values in the calculation is a conversion from a Text or Date value to a Date/Time value, however, the results are different. Let’s say a San Francisco user enters a value of 12:00 AM on August 2, 2013 in a custom Date/Time field called Date_Time_c. This value is stored as 2013–08–02 07:00:00Z, because the time difference in Pacific Daylight Time is GMT-7. At 12:00 p.m. PDT on August 1st, the user views the record and the following formula is run:
Date_Time_c - NOW()
In the calculation, NOW() is 2013–08–01 19:00:00Z, and then subtracted from 2013–08–02 07:00:00Z, to return the expected result of 0.5 (12 hours). Suppose that instead of NOW(), the formula converts the string “2013–08–01 12:00:00” to a Date/Time value:
Date_Time_c - DATETIMEVALUE( "2013-08-01 12:00:00" )
In this case, DATETIMEVALUE( “2013–08–01 12:00:00” ) is 2013–08–01 12:00:00Z, and returns a result of 0.79167, or 19 hours. There’s no way to determine a user’s time zone in a formula. If all of your users are in the same time zone, you can adjust the time zone difference by adding or subtracting the time difference between the users’ time zone and GMT to your converted values. However, since
415 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
time zones can be affected by Daylight Saving Time, and the start and end dates for DST are different each year, this is difficult to manage in a formula. We recommend using Apex for transactions that require converting between Date/Time values and Text or Date values.
SEE ALSO: Tips for Building Formulas Time Custom Field
Build a Formula Field
Your custom formula fields require special attributes. EDITIONS Note: The Getting Started with Formulas (Salesforce Classic) help video includes a live demo of these steps. Available in: both Salesforce Classic (not available in all 1. Begin building a formula field the same way you create a custom field. See Create Custom Fields orgs) and Lightning on page 218. Experience 2. Select the data type for the formula. Choose the appropriate data type for your formula based Available in: All Editions on the output of your calculation. See Formula Data Types on page 353. 3. Choose the number of decimal places for currency, number, or percent data types. This setting USER PERMISSIONS is ignored for currency fields in multicurrency organizations. Instead, the Decimal Places for your currency setting apply. Salesforce uses the round half up tie-breaking rule for numbers To view formula field details: in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35. • View Setup and 4. Click Next. Configuration 5. Build your formula. Formula fields can contain up to 3,900 characters, including spaces, return To create, change, or delete formula fields: characters, and comments. If your formula requires more characters, create separate formula • Customize Application fields and reference them in another formula field. The maximum number of displayed characters after an evaluation of a formula expression is 1,300 a. If you are building a formula in the Advanced Formula tab or for approvals or rules, such as workflow, validation, assignment, auto-response, or escalation, click Insert Field, choose a field, and click Insert. To create a basic formula that passes specific Salesforce data, select the Simple Formula tab, choose the field type in the Select Field Type drop-down list, and choose one of the fields listed in the Insert Field drop-down list. Build cross-object formulas to span to related objects and reference merge fields on those objects. b. To insert an operator, choose the appropriate operator icon from the Insert Operator drop-down list. c. Optionally, click the Advanced Formula tab to use functions and view other operators and merge fields. Functions are prebuilt formulas that you can customize with your input parameters. d. To insert a function, double-click its name in the list, or select it and click Insert Selected Function. To filter the list of functions, choose a category from the Functions drop-down list. Select a function and click Help on this function to view a description and examples of formulas using that function. e. Consider adding comments to your formula, especially if it is complicated. Comments must begin with a forward slash followed by an asterisk (/*), and conclude with an asterisk followed by a forward slash (*/). Comments are useful for explaining specific parts of a formula to anyone viewing the formula definition. For example:
AND( /*competitor field is required, check to see if field is empty */ LEN(Competitor__c) = 0, /* rule only enforced for ABCD record types */ RecordType.Name = "ABCD Value",
416 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
/* checking for any closed status, allows for additional closed picklist values in the future */ CONTAINS(TEXT(StageName), "Closed") )
6. To check your formula for errors, click Check Syntax. 7. Optionally, enter a description of the formula in the Description box. 8. If your formula references any number, currency, or percent fields, choose an option for handling blank fields. To give any blank fields a zero value, choose Treat blank fields as zeros. To leave these fields blank, choose Treat blank fields as blanks. 9. Click Next. 10. Set the field-level security to determine whether the field should be visible for specific profiles, and click Next. 11. Choose the page layouts that should display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is automatically added to the bottom of the user detail page. 12. Click Save to finish or Save & New to create more custom fields.
Note: Because formula fields are automatically calculated, they are read-only on record detail pages and do not update last modified date fields. Formula fields are not visible on edit pages. In account formulas, all business account fields are available as merge fields. However, account fields exclusive to person accounts such as Birthdate and Email are not available.
Tips for Building Formulas What Is a Cross-Object Formula?
SEE ALSO: Elements of a Formula Merge Fields for Formulas Tips for Building Formulas Formula Operators and Functions
Tips for Building Formulas
Watch a Demo: Formulas: Tips and Gotchas (Salesforce Classic) EDITIONS • Formula fields that a user can see may reference fields that are hidden or read only using field-level security. If the formula field contains sensitive information, use field-level security to Available in: both Salesforce hide it. Classic and Lightning Experience • You can add activity formula fields to task and event page layouts. Note that a task-related formula field on an event page layout may not be useful. Likewise, event-related formula fields Available in: All Editions on task page layouts may not be useful. • To determine if a record is a task or event, use the IsTask merge field. For example:
IF(IsTask, "This is a task", "This is an event")
417 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips for Working with Date and Date/Time Formula Fields Tips for Working with Hyperlink Formula Fields Use these tips to understand how links open from formula custom fields that contain a HYPERLINK function. Tips for Using Merge Fields in Formulas Tips for Working with Number Formula Fields Tips for Working with Picklist and Multi-Select Picklist Formula Fields Tips for Referencing Record Types in Formulas Reference record types in formulas if you want different workflow rules, validation rules, and lookup filters to apply to different record types. Tips for Working with Text Formula Fields
SEE ALSO: Build a Formula Field Common Formula Errors
Tips for Working with Date and Date/Time Formula Fields
• Dates and times are always calculated using the user’s time zone. EDITIONS • Date and date/time fields can’t be used interchangeably. The name alone may not indicate if a field is a date or date/time. For example, Created Date and Last Modified Date Available in: both Salesforce are date/time fields whereas Last Activity Date is a date field. Use the DATEVALUE Classic and Lightning function to convert a date/time field into a date field. Experience
Note: The Created Date and Last Modified Date fields display only the Available in: All Editions date, not the date and time.
• Use addition and subtraction operators with date or date/time fields to calculate duration. For example, subtract a date from another date to calculate the number of days between the two. Likewise, you can subtract the date/time from another date/time to get the number of days between the two as a number. See NOW or TODAY for suggested use. • Use addition and subtraction operators with numbers to return another date or date/time. For example, {!CreatedDate} + 5 calculates the date and time five days after a record’s created date. Note that the expression returns the same data type as the one given; a date field plus or minus a number returns a date, and a date/time field plus or minus a number returns a date/time. • When calculating dates using fractions, Salesforce ignores any numbers beyond the decimal. For example: TODAY() + 0.7 is the same as TODAY() + 0, which is today’s date. TODAY() + 1.7 is the same asTODAY() + 1, which is tomorrow’s date. TODAY() + (-1.8) is the same as TODAY() + (-1), which is yesterday’s date.
• To calculate the value of two fractions first, group them within parentheses. For example: TODAY() + 0.5 + 0.5 is the same as TODAY() + 0 + 0, which is today’s date. TODAY() + (0.5+0.5) is the same as TODAY() + 1, which is tomorrow’s date.
• Years can’t be zero and must be between -4713 and 9999.
SEE ALSO: Tips for Building Formulas
418 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips for Working with Hyperlink Formula Fields
Use these tips to understand how links open from formula custom fields that contain a HYPERLINK EDITIONS function. If you have formula custom fields that contain a HYPERLINK function, the server generates an Available in: both Salesforce HTML anchor for the link. For example, this function: HYPERLINK("/apex/VF_TEST", Classic and Lightning "VFLINK",'_self') generates this HTML output: VFLINK HYPERLINK . If the function doesn't contain a target Available in: All Editions attribute, it defaults to a value of target="_blank" in the generated HTML. A value of "_blank" opens the link in a new window or tab, outside of Lightning Experience or the Lightning Console.
Note: The HYPERLINK function doesn’t support the biztel protocol on record home pages for custom objects in Lightning Experience. The Lightning Experience Honors Target Values for Hyperlinks in Formula Fields critical update ensures that the target value for hyperlinks is honored, whether it's explicitly configured or set by default. If you have enabled the critical update, you can keep the target page within Lightning navigation by adding a value of target="_self" to your formula field HYPERLINK functions. If you specify something other than target="_self", the link opens with standard browser navigation outside of Lightning Experience. If you haven’t enabled the critical update, relative links open in a new tab regardless of the target value.
Note: This critical update is automatically enabled in Summer ’20. Both before and after enabling the critical update, external links always open in a new tab, regardless of the target value.
Link Type Target Expected Behavior Example Relative Visualforce page or _self The Visualforce page or image HYPERLINK("/apex/VFPAGE", image opens in Lightning Experience "Visualforce Page", or Console inside the same tab. "_self")
Relative Visualforce page or _blank The Visualforce page or image HYPERLINK("/img/logo214", image opens outside of Lightning "Logo", "_blank") Experience or Console in a new tab.
Note: A critical update that is available in Winter ’19 and automatically enabled in Summer ’19 on May 17, 2019 controls this behavior. If you don’t enable the critical update, these links open inside Lightning Experience or Console in a new tab.
External website _self The website opens in a new tab. HYPERLINK("http://salesforce.com", "Salesforce", "_self")
419 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Link Type Target Expected Behavior Example
External website _blank The website opens in a new tab. HYPERLINK("http://salesforce.com", "Salesforce", "_blank")
Tips for Using Merge Fields in Formulas
• Delegated administrators need to have access to custom objects to access the objects’ merge EDITIONS fields from formulas. • In account formulas, all business account fields are available as merge fields. However, account Available in: both Salesforce fields exclusive to person accounts such as Birthdate and Email are not available. Classic and Lightning • You can’t use formula fields that include related object merge fields in roll-up summary fields. Experience • Formulas and roll-up summary fields can’t reference fields on external objects. Available in: All Editions • Using RecordType.Id can make your formula less readable; when you do use it, write in-line comments into the formula to clarify. • To determine if a record is a task or event, use the IsTask merge field. For example:
IF(IsTask, "This is a task", "This is an event")
• To reference the unique identifier for your Salesforce organization in a formula, insert the $Organization.Id merge field. This merge field can display anywhere formula fields can except in reports. • Some merge fields display as radio buttons but function like picklist fields when referenced in a formula. Use the values “Read,” “Edit,” and “None” in a formula when referencing: – $UserRole.CaseAccessForAccountOwner – $UserRole.OpportunityAccessForAccountOwner – CaseAccessLevel (on Territory) – OpportunityAccessLevel (on Territory) Use the values “Read,” “Edit,” and “All” in a formula when referencing: – AccountAccessLevel (on Territory)
• If you create a contacts formula field that references account merge fields, that field can be included in contact page layouts but should not be included in person accounts page layouts. The formula field will display a value of #Error on the person accounts page.
SEE ALSO: Tips for Building Formulas
420 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips for Working with Number Formula Fields
• Use the decimal version of a percent when working with percent fields in formulas. For example, EDITIONS IF(Probability =1...) for 100% probability or IF(Probability =0.9...) for 90% probability. Available in: both Salesforce • Reference auto-number fields as text fields in formulas. Classic and Lightning • The output of your formula must be less than 19 digits. Experience • Formulas can contain a mix of numbers, percents, and currencies as in this example: Available in: All Editions AnnualRevenue / NumberOfEmployees. • Salesforce uses the round half up tie-breaking rule for numbers in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35.
SEE ALSO: Tips for Building Formulas
Tips for Working with Picklist and Multi-Select Picklist Formula Fields
• You can use special picklist fields in your formulas, such as IsEscalated for cases and EDITIONS IsWon for opportunities. • Picklist fields can only be used in these functions: Available in: both Lightning – ISPICKVAL—Compares the value of a picklist to a single value. Experience and Salesforce Classic – CASE—Compares the value of a picklist to multiple values. – TEXT—Returns a picklist value’s API Name so that you can work with a reference to the Available in: All Editions value (even if the displayed value changes) in functions that support text values, such as CONTAINS. (Available in only flow formula resources, formula fields, validation rules, and workflow field updates.)
• Multi-select picklist fields can only be used in these functions: – CONTAINS (in Process Builder in which the criteria for executing actions is set to Conditions are met) – INCLUDES – ISBLANK – ISNULL – ISCHANGED (Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited) – PRIORVALUE (Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited)
SEE ALSO: Tips for Building Formulas
421 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Tips for Referencing Record Types in Formulas
Reference record types in formulas if you want different workflow rules, validation rules, and lookup EDITIONS filters to apply to different record types. For example, you can: Available in: both Salesforce Classic and Lightning • Create a workflow rule on accounts that emails different teams based on the account record Experience type the user selects when creating the account. • Create a validation rule on opportunities that allows only members of the North American sales Available in: All Editions team to save opportunities with the Domestic record type. Record types available in: When possible, use RecordTypeId instead of RecordType.Name to reference a specific Professional, Enterprise, record type. While RecordType.Name makes a formula more readable, you must update the Performance, Unlimited, formula if the name of the record type changes, whereas the ID of a record type never changes. and Developer Editions Also, RecordType.Name requires a cross-object reference to the record type, while RecordTypeId doesn’t. However, if you are deploying formulas across organizations (for example, between sandbox and production), use RecordType.Name because IDs are not the same across organizations. Avoid using $RecordType in formulas, except in default value formulas. Instead, use the RecordType merge field (for example, Account.RecordType.Name) or the RecordTypeId field on the object.
SEE ALSO: Tips for Building Formulas
Tips for Working with Text Formula Fields
• Before using the HYPERLINK function, consider the differences between hyperlinks and custom EDITIONS links. – Hyperlink formula fields are just like other custom fields that you can show in list views and Available in: both Salesforce reports. Classic and Lightning – Custom links appear on detail pages in a predefined section; hyperlink formula fields can Experience appear on a detail page wherever you specify. Available in: All Editions – Using custom links, you can specify display properties such as window position and opening in a separate popup position; hyperlink formula fields open in a new browser window by default or you can specify a different target window or frame. – Your formulas can reference custom links. Before deleting a custom link, make sure that it’s not referenced in a formula field. – Hyperlink formula fields that contain relative URLs to Salesforce pages, such as /rpt/reportwizard.jsp, can be added to list views, reports, and related lists. However, use a complete URL, including the server name and https://, in your hyperlink formula before adding it to a search layout.
• To insert text in your formula field, surround the text with quotation marks. For example, to display “CASE: 123,” use this formula "CASE: "& CaseNumber__c. • Use the backslash (\) character before a quote or backslash to insert it as a literal value in your output. For example, "Trouble\\Case \"Ticket\": " in your formula displays Trouble\Case "Ticket": on detail pages. • In Salesforce Classic, Knowledge articles show URLs from Formula (Text) fields as plain text. In Lightning Experience, Knowledge articles show such URLs as clickable links.
SEE ALSO: Tips for Building Formulas
422 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
What Is a Cross-Object Formula?
A Cross-object formula is a formula that spans two related objects and references merge fields on EDITIONS those objects. A cross-object formula can reference merge fields from a master (“parent”) object if an object is on the detail side of a master-detail relationship. A cross-object formula also works with Available in: both Salesforce lookup relationships. Classic and Lightning You can reference fields from objects that are up to 10 relationships away. A cross-object formula Experience is available anywhere formulas are used except when creating default values. Available in: all editions Note: If you create a formula that references a field on another object and display that formula in your page layout, users can see the field on the object even if they don’t have access to that object record. For example, if you create a formula field on the Case object that references an account field, and display that formula field in the case page layout, users can see this field even if they don’t have access to the account record. You can't include an object as the lookup field in a formula. To reference an object, reference the object's ID field or another field on the object. For example, Account.Owner is invalid because it references the object directly. Account.Owner.FirstName or Account.OwnerId are valid references for your formula.
Building Cross-Object Formulas in the Simple Formula Tab Build Cross-Object Formulas in the Advanced Formula Tab Tips for Building Cross-Object Formulas
SEE ALSO: Build a Formula Field
Building Cross-Object Formulas in the Simple Formula Tab
To create a cross-object formula when building a formula in the Simple Formula tab, enter the EDITIONS relationship names of the objects to which you are spanning followed by the field you want to reference. Separate the relationship names of each object and the field with periods. Available in: both Salesforce Example: For example, enter Contact.Account.Name to reference the Account Classic and Lightning Name for a contact associated with a case in a formula field on the Case object. Be sure to Experience use the relationship names of the objects, not the labels. Although the relationship name is Available in: All Editions often the same as the object name, it is technically the field name of the relationship field. To reference the parent account name from Account object, the syntax is Parent.Name, USER PERMISSIONS not Account.Name. When referencing a custom object, add two underscores and the letter r to its name. For example, Position__r.title__c references the Job Title To create or change field (title__c) on a Position custom object. cross-object formulas: • Customize Application Note: If you create a formula that references a field on another object and display that formula in your page layout, users can see the field on the object even if they don’t have access to that object record. For example, if you create a formula field on the Case
423 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
object that references an account field, and display that formula field in the case page layout, users can see this field even if they don’t have access to the account record.
SEE ALSO: Build Cross-Object Formulas in the Advanced Formula Tab What Is a Cross-Object Formula?
Build Cross-Object Formulas in the Advanced Formula Tab
To create a cross-object formula when building a formula in the Advanced Formula tab or for EDITIONS approvals or rules, such as workflow, validation, assignment, auto-response, or escalation rules, click Insert Field, then click the related object to list its fields. Related objects are denoted by a “>” sign. Available in: both Salesforce Note: If you create a formula that references a field on another object and display that Classic and Lightning formula in your page layout, users can see the field on the object even if they don’t have Experience access to that object record. For example, if you create a formula field on the Case object that Available in: All Editions references an account field, and display that formula field in the case page layout, users can see this field even if they don’t have access to the account record. USER PERMISSIONS Example: The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile To create or change cross-object formulas: name, as expected. In list views and reports, the value is the internal value of the associated • Customize Application profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example:
IF (OR (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name = "PT2"), "Standard", "Not Standard")
None of the above applies to profile names referenced by the $Profile global variable.
SEE ALSO: Building Cross-Object Formulas in the Simple Formula Tab What Is a Cross-Object Formula?
Tips for Building Cross-Object Formulas
• Cross-object formulas that reference currency fields convert the value to the currency of the EDITIONS record that contains the formula. If the referenced currency field is from a custom setting, the field value isn’t converted to the record’s currency. Available in: both Salesforce • Salesforce allows a maximum of 10 unique relationships per object in cross-object formulas. Classic and Lightning The limit is cumulative across all formula fields, rules, and lookup filters. For example, if two Experience different formulas on opportunities reference two different fields of an associated account, only Available in: All Editions one unique relationship exists (from opportunities to accounts). • You can’t reference cross-object formulas in roll-up summary fields.
424 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
• In cross-object formulas, you can’t reference merge fields for objects related to activities. For example, merge fields for contacts and accounts aren’t available in task and event formulas. • In cross-object formulas, you can’t reference fields from contacts through person accounts. For more information, see Using custom formula fields with person accounts.
Using the Owner Field Some objects support different object types for the Owner field, such as a User, Queue, or Calendar. On objects that support this behavior, when creating a cross-object formula using Owner, you must be explicit about the owner type you’re referencing. For example, if you need owner email and you don’t use queues, your formula would be Owner:User.Email. If you do use queues, your formula could be
IF( ISBLANK( Owner:User.Id ), Owner:Queue.QueueEmail, Owner:User.Email )
Here’s how you would select Owner object fields on a Lead in the Advanced formula tab:
Note: • Owner references aren’t supported in Visualforce pages. For example, on a page with Case as a controller, you can’t include {!Case.Owner:User.FirstName}. However, you can include an existing spanning formula on a Visualforce page. For example, if you have a custom text formula MyFormula__c on a Case with value Owner:User.FirstName, you can include {!Case.MyFormula__c} on your Visualforce page. • Owner references aren’t supported on the Queue object. For example, you can't reference Owner:Queue.Owner.Email. • If your formula has Owner:User.fieldname and Owner:Queue.fieldname, both of these count against the limit of 10 unique relationships per object in cross-object formulas. • On objects that don’t support Queues, User is implicit when referencing Owner. Your formula should be Owner.fieldname, not Owner:User.fieldname.
Using Profile.Name The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile name, as expected. In list views and reports, the value is the internal value of the associated profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example:
IF (OR (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name =
425 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
"PT2"), "Standard", "Not Standard")
None of the above applies to profile names referenced by the $Profile global variable.
SEE ALSO: Build Cross-Object Formulas in the Advanced Formula Tab What Is a Cross-Object Formula?
Formula Field Limits and Restrictions
Before you create formula fields, be aware of their limits and limitations. EDITIONS • Formula fields have these limits. – Character limit—Formula fields can contain up to 3,900 characters, including spaces, return Available in: both Salesforce Classic and Lightning characters, and comments. If your formula needs more characters, create separate formula Experience fields and reference them in another formula field. Available in: All Editions Note: The maximum number of displayed characters after an evaluation of a formula expression is 1,300.
– Save size limit—Formula fields can’t exceed 4,000 bytes when saved. The save size is different from the number of characters if you use multi-byte characters in your formula. – Compile size limit—Formula fields can’t exceed 5,000 bytes when compiled. The compile size is the size of the formula (in bytes) including all of the fields, values, and formulas it references. There is no direct correlation between the compile size and the character limit. Some functions, such as TEXT, DATEVALUE, DATETIMEVALUE, and DATE significantly increase the compile size.
Tip: For tips on how to rework your formulas to avoid these limits, see Tips for Reducing Formula Size
• Default value formulas for a record type can only reference fields for that record type. However, formula fields and formulas for approvals or rules for a record type can reference fields for that record type as well as any records that are related through a lookup or master-detail relationship. For example, a formula for a validation rule on opportunities can reference merge fields for accounts and campaigns as well as opportunities, and a formula field on accounts can reference fields for cases. • You can’t use long text area, encrypted, or Description fields in formulas. • The value of a field can’t depend on another formula that references it. • You can’t delete fields referenced in formulas. Remove the field from the formula before deleting it. • Campaign statistic fields can’t be referenced in formulas for field updates, approval processes, workflow rules, or validation rules, but can be referenced in custom formula fields. • The UI escapes HTML tags used in formula fields. To create an HTML element, replace your HTML with a function, like HYPERLINK or IMAGE. • Custom formula fields from contacts can’t be referenced through person accounts. For more information, see Using custom formula fields with person accounts.
SEE ALSO: Tips for Building Formulas Build a Formula Field
426 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Formula Best Practices
You can use the Formula Editor in Salesforce to construct a simple formula with a few clicks. But EDITIONS what if you want to build something more complex? Use these tips to help you map out formula logic and make it easier to troubleshoot errors. Available in: both Salesforce Thank you: Special thanks to Trailblazer Chris Emmett for contributing this content. Classic and Lightning Experience
Available in: All Editions Tip 1: Put Every Function on a Separate Line It’s easy to fall into the habit of keeping an entire formula on a single line, especially when the formula is small. Putting each function on its own line makes the formula easier to read and troubleshoot. These examples show the same formula, first with no line breaks, and then with each function on a separate line.
IF(AND(ISBLANK(myDate_c),active_c=true),"Missing Date","Not Applicable")
IF( AND( ISBLANK(myDate_c), active_c=true ), "Missing Date", "Not Applicable" )
Tip 2: Indent Sections Within Parentheses When your formula involves multiple functions, indentation helps visually isolate each function and makes it easier to identify errors, such as misplaced characters. In this example, with indentation, you see that the bulk of the formula sits within a single IF statement and that the AND statement contains two functions. Inside the AND statement, the function ISBLANK is enclosed in parentheses.
IF( AND( ISBLANK(myDate_c), active_c=true ), "Missing Date", "Not Applicable" )
Indentation can also help you zero in on mistakes. With a flat layout, it’s difficult to see that an extra “)” is included after the ISBLANK statement, and there are no visual clues about how the formula is structured.
IF( AND( ISBLANK(myDate_c) ), active_c=true ), "Missing Date", "Not Applicable" )
427 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
The indented layout makes it easy see the formula’s structure. You can quickly find and remove the extra character so that the AND statement is correctly formatted.
IF( AND( ISBLANK(myDate_c) ), active_c=true ), "Missing Date", "Not Applicable" )
Tip 3: Write Statement and Function Names in Uppercase All the examples here use uppercase letters for statement and function names, such as IF, AND, and ISBLANK. Using uppercase for these terms creates a clear distinction between functions and parameters and brings some visual clarity to a complex formula.
Tip 4: Handle Null and Required Input Field Values These examples reference a field called myDate__c and use the ISBLANK check to confirm that the field is populated. It’s important to verify the contents of any field in a formula. Without this verification, a formula can fail. For example, if you add a second date to the formula and perform a greater than operation, include the ISBLANK check for the second date to ensure that the formula executes correctly.
IF( AND( ISBLANK(myDate__c), ISBLANK(mySecondDate__c), active__c=true, mySecondDate__c > myDate__c ), "Missing Date", "Not Applicable" )
428 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Examples of Advanced Formula Fields
Review examples of formula fields for various types of apps that you can use and modify for your EDITIONS own purposes. This document contains custom formula samples for the following topics. For details about using Available in: both Salesforce the functions included in these samples, see Formula Operators and Functions on page 355. Classic and Lightning Experience
Sample Account Management Formulas Available in: All Editions Sample Account Media Service Formulas Sample Case Management Formulas USER PERMISSIONS
Sample Commission Calculations Formulas To view formula field details: Sample Contact Management Formulas • View Setup and Configuration Sample Data Categorization Formulas To create, change, or delete Sample Date Formulas formula fields: Sample Discounting Formulas • Customize Application Sample Employee Services Formulas Sample Expense Tracking Formulas Sample Financial Calculations Formulas Sample Image Link Formulas Sample Integration Link Formulas Sample Lead Management Formulas Sample Metric Formulas Sample Opportunity Management Formulas Sample Pricing Formulas Sample Scoring Calculations Formulas
SEE ALSO: Formulas: How Do I ... ? Tips for Building Formulas
Sample Account Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Classic and Lightning Experience
Available in: All Editions
429 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Account Rating This formula evaluates Annual Revenue, Billing Country, and Type, and assigns a value of “Hot,” “Warm,” or “Cold.”
IF (AND (AnnualRevenue > 10000000, CONTAINS (CASE (BillingCountry, "United States", "US", "America", "US", "USA", "US", "NA"), "US")), IF(ISPICKVAL(Type, "Manufacturing Partner"), "Hot", IF(OR (ISPICKVAL (Type, "Channel Partner/Reseller"), ISPICKVAL(Type, "Installation Partner")), "Warm", "Cold")), "Cold")
In addition, you can reference this Account Rating formula field from the contact object using cross-object formulas.
Account.Account_Rating__c
Account Region This formula returns a text value of “North,” “South,” “East,” “West,” or “Central” based on the Billing State/Province of the account.
IF(ISBLANK(BillingState), "None", IF(CONTAINS("AK:AZ:CA:HA:NV:NM:OR:UT:WA", BillingState), "West", IF(CONTAINS("CO:ID:MT:KS:OK:TX:WY", BillingState), "Central", IF(CONTAINS("CT:ME:MA:NH:NY:PA:RI:VT", BillingState), "East", IF(CONTAINS("AL:AR:DC:DE:FL:GA:KY:LA:MD:MS:NC:NJ:SC:TN:VA:WV", BillingState), "South", IF(CONTAINS("IL:IN:IA:MI:MN:MO:NE:ND:OH:SD:WI", BillingState), "North", "Other"))))))
Contract Aging This formula calculates the number of days since a contract with an account was activated. If the contract Status is not “Activated,” this field is blank.
IF(ISPICKVAL(Contract_Status__c, "Activated"), NOW() - Contract_Activated_Date__c, null)
Sample Account Media Service Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce BBC™ News Search Classic and Lightning Experience This formula creates a link to a BBC news search site based on the Account Name. Available in: All Editions
HYPERLINK( "http://www.bbc.co.uk/search/news/?q="&Name, "BBC News")
430 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Bloomberg™ News Search This formula creates a link to an account's ticker symbol on the Bloomberg website.
HYPERLINK( "http://www.bloomberg.com/markets/symbolsearch?query="&TickerSymbol, "Bloomberg News")
CNN™ News Search This formula creates a link to a CNN news search site using the Account Name.
HYPERLINK( "http://http://www.cnn.com/search/?query="&Name, "CNN News")
MarketWatch™ Search This formula creates a link to an account's ticker symbol on the Marketwatch.com website.
HYPERLINK( "http://www.marketwatch.com/investing/stock/"&TickerSymbol, "Marketwatch")
Google™ Search This formula creates a link to a Google search site using the Account Name.
HYPERLINK( "http://www.google.com/#q="&Name, "Google")
Google News Search This formula creates a link to a Google news search site using the Account Name.
HYPERLINK( "http://news.google.com/news/search?en&q="&Name, "Google News")
Yahoo!™ Search This formula creates a link to a Yahoo! search site using the Account Name.
HYPERLINK( "http://search.yahoo.com/search?p="&Name, "Yahoo Search")
431 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Yahoo! News Search This formula creates a link to a Yahoo! news search site using the Account Name.
HYPERLINK( "http://news.search.yahoo.com/search/news?p="&Name, "Yahoo News")
Sample Case Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: Salesforce Autodial Classic This formula creates a linkable phone number field that automatically dials the phone number Available in: All Editions when clicked. In this example, replace "servername" and "call" with the name of your dialing tool and the command it uses to dial. The merge field, Id, inserts the identifier for the contact, lead, or account record. The first Phone merge field tells the dialing tool what number to call and the last Phone merge field uses the value of the Phone field as the linkable text the user clicks to dial.
HYPERLINK("http://servername/call?id=" & Id & "&phone=" & Phone, Phone)
Case Categorization This formula displays a text value of “RED,” “YELLOW,” or “GREEN,” depending on the value of a case age custom text field.
IF(DaysOpen__c > 20, "RED", IF(DaysOpen__c > 10, "YELLOW", "GREEN") )
Case Data Completeness Tracking This formula calculates the percentage of specific custom fields that contain data. The formula checks the values of two custom number fields: Problem Num and Severity Num. If the fields are empty, the formula returns the value “0.” The formula returns a value of “1” for each field that contains a value and multiplies this total by fifty to give you the percentage of fields that contain data.
(IF(ISBLANK(Problem_Num__c), 0, 1) + IF(ISBLANK(Severity_Num__c ), 0,1)) * 50
Suggested Agent Prompts This formula prompts an agent with cross-sell offers based on past purchases.
CASE(Product_Purch__c, "Printer", "Extra toner cartridges", "Camera", "Memory cards", "Special of the day")
432 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Suggested Offers This formula suggests a product based on the support history for a computer reseller. When the Problem custom field matches a field, the formula field returns a suggestion.
CASE(Problem__c, "Memory", "Suggest new memory cards", "Hard Drive failure", "Suggest new hard drive with tape backup", "")
Sample Commission Calculations Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Commission Amounts for Opportunities Classic and Lightning Experience The following is a simple formula where commission is based on a flat 2% of the opportunity Amount. Available in: All Editions
IF(ISPICKVAL(StageName, "Closed Won"), ROUND(Amount *0.02, 2), 0)
This example calculates the commission amount for any opportunity that has a “Closed Won” stage. The value of this field will be the amount times 0.02 for any closed/won opportunity. Open or lost opportunities will have a zero commission value.
Commission Deal Size This formula calculates a commission rate based on deal size, returning a 9% commission rate for deals over 100,000 and an 8% commission rate for smaller deals.
IF(Amount > 100000, 0.09, 0.08 )
Commission Greater Than or Equal To This formula assigns the YES value with a commission greater than or equal to one million. Note, this is a text formula field that uses a custom currency field called Commission.
IF(Commission__c >= 1000000, "YES", "NO")
Commission Maximum This formula determines what commission to log for an asset based on which is greater: the user's commission percentage of the price, the price times the discount percent stored for the account or 100 dollars. This example assumes you have two custom percent fields on users and assets.
MAX($User.Commission_Percent__c * Price, Price * Account_Discount__c, 100)
433 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Contact Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Contact's Account Discount Percent Classic and Lightning Experience This percent formula displays the account's Discount Percent field on the contacts page. Available in: All Editions
Account.Discount_Percent__c
Contact's Account Name This formula displays the standard Account Name field on the contacts page.
Account.Name
Contact's Account Phone This formula displays the standard Account Phone field on the contacts page.
Account.Phone
Contact's Account Rating Use this formula to display the Account Rating field on the contacts page.
CASE(Account.Rating, "Hot", "Hot", "Warm", "Warm", "Cold", "Cold", "Not Rated")
Contact's Account Website This formula displays the standard Account Website field on the contacts page.
Account.Website
If the account website URL is long, use the HYPERLINK function to display a label such as “Click Here” instead of the URL. For example:
IF(Account.Website="", "", IF( OR(LEFT(Account.Website, 7) = "http://",LEFT(Account.Website, 8) = "https://"), HYPERLINK( Account.Website , "Click Here" ), HYPERLINK( "http://" & Account.Website , "Click Here" ) ) )
This formula also adds the necessary "http://" or "https://" before a URL if neither were included in the URL field.
Contact's LinkedIn™ Profile You can configure a link that appears on your contacts' profile page that sends you to their LinkedIn profile. To do so: 1. From the object management settings for contacts, go to Buttons, Links, and Actions.
434 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
2. Click New Button or Link. 3. Enter a Label for this link, like LinkedInLink. 4. Enter this formula in the content box:
http://www.linkedin.com/search/fpsearch?type=people&keywords ={!Contact.FirstName}+{!Contact.LastName}
5. Click Save. Remember to add this link to the Contact page layout in order for it to show up.
Contact Identification Numbering This formula displays the first five characters of a name and the last four characters of a social security number separated by a dash. Note that this example uses a text custom field called SSN.
TRIM(LEFT(LastName, 5)) & "-" & TRIM(RIGHT(SSN__c, 4))
Contact Preferred Phone This formula displays the contact’s preferred contact method in a contact related list—work phone, home phone, or mobile phone—based on a selected option in a Preferred Phone custom picklist.
CASE(Preferred_Phone__c, "Work", "w. " & Phone, "Home", "h. " & HomePhone, "Mobile", "m. " & MobilePhone, "No Preferred Phone")
Contact Priority This formula assesses the importance of a contact based on the account rating and the contact's title. If the account rating is Hot or the title starts with Executive, then the priority is high (P1). If the account rating is Warm or the title starts with VP then the priority is medium (P2), and if the account rating is Cold then the priority is low (P3).
IF(OR(ISPICKVAL(Account.Rating, "Hot"), CONTAINS(Title, "Executive")), "P1",
IF(OR(ISPICKVAL(Account.Rating, "Warm"), CONTAINS(Title, "VP")), "P2",
IF(ISPICKVAL(Account.Rating, "Cold"), "P3",
"P3") ) )
435 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Contact Yahoo! ID This formula displays a clickable Yahoo! Messenger icon indicating if the person is logged on to the service. Users can click the icon to launch a Yahoo! Messenger conversation with the person. This example uses a custom text field called Yahoo Name on contacts where you can store the contact's Yahoo! Messenger ID.
HYPERLINK("ymsgr:sendIM?" & Yahoo_Name__c, IMAGE("http://opi.yahoo.com/online?u=" & Yahoo_Name__c & "&m;=g&t;=0", "Yahoo"))
Dynamic Address Formatting This formula field displays a formatted mailing address for a contact in standard format, including spaces and line breaks where appropriate depending on the country.
CASE(ShippingCountry, "USA", ShippingStreet & BR() & ShippingCity & ", " & ShippingState & " " & ShippingPostalCode & BR() & ShippingCountry, "France", ShippingStreet & BR() & ShippingPostalCode & " " & ShippingCity & BR() & ShippingCountry, "etc")
Telephone Country Code This formula determines the telephone country code of a contact based on the Mailing Country of the mailing address.
CASE(MailingCountry, "USA", "1", "Canada", "1", "France", "33", "UK", "44", "Australia", "61", "Japan", "81", "?")
Unformatted Phone Number This formula removes the parentheses and dash characters from North American phone numbers. This is necessary for some auto-dialer software.
IF(Country_Code__c = "1", MID( Phone ,2, 3) & MID(Phone,7,3) & MID(Phone,11,4), Phone)
436 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Data Categorization Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Deal Size Large and Small Classic and Lightning Experience This formula displays “Large Deal” for deals over one million dollars or “Small Deal” for deals under one million dollars. Available in: All Editions
IF(Sales_Price__c > 1000000, "Large Deal", "Small Deal")
Deal Size Small This formula displays Small if the price and quantity are less than one. This field is blank if the asset has a price or quantity greater than one.
IF(AND(Price<1,Quantity<1),"Small", null)
Product Categorization This formula checks the content of a custom text field named Product_Type and returns Parts for any product with the word “part” in it. Otherwise, it returns Service. Note that the values are case-sensitive, so if a Product_Type field contains the text “Part” or “PART,” this formula returns Services.
IF(CONTAINS(Product_Type__c, "part"), "Parts", "Service")
Sample Date Formulas
EDITIONS Find the Day, Month, or Year from a Date Use the functions DAY( date ), MONTH( date ), and YEAR( date ) to return their Available in: both Salesforce numerical values. Replace date with a value of type Date (for example, TODAY()). Classic and Lightning Experience To use these functions with Date/Time values, first convert them to a date with the DATEVALUE() function. For example, DAY( DATEVALUE( date/time )). Available in: All Editions
Find Out If a Year Is a Leap Year This formula determines whether a year is a leap year. A year is only a leap year if it’s divisible by 400, or if it’s divisible by four but not by 100.
OR( MOD( YEAR( date ), 400 ) = 0, AND( MOD( YEAR( date ), 4 ) = 0, MOD( YEAR( date ), 100 ) != 0 ) )
437 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Find Which Quarter a Date Is In For standard quarters, you can determine which quarter a date falls in using this formula. This formula returns the number of the quarter that date falls in (1–4) by dividing the current month by three (the number of months in each quarter) and taking the ceiling.
CEILING( MONTH ( date ) / 3 )
The formula for shifted quarters is similar, but shifts the month of the date by the number of months between January and the first quarter of the fiscal year. The following example shows how to find a date’s quarter if Q1 starts in February instead of January.
CEILING( ( MONTH ( date ) - 1 ) / 3)
ITo check whether a date is in the current quarter, add a check to compare the date’s year and quarter with TODAY()’s year and quarter.
AND( CEILING( MONTH( date ) / 3 ) = CEILING( MONTH( TODAY() ) / 3 ), YEAR( date ) = YEAR( TODAY() ) )
Find the Week of the Year a Date Is In To find the number of a date’s week of the year, use this formula:
IF( CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7) > 52, 52, CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7) )
To find the current week number, determine the days to date in the current year and divide that value by 7. The IF() statement ensures that the week number the formula returns doesn’t exceed 52. So if the given date is December 31 of the given year, the formula returns 52, even though it’s more than 52 weeks after the first week of January.
Find Whether Two Dates Are in the Same Month To determine whether two Dates fall in the same month, say for a validation rule to determine whether an opportunity Close Date is in the current month, use this formula:
AND( MONTH( date_1 ) == MONTH( date_2 ), YEAR( date_1 ) == YEAR( date_2 ) )
Find the Last Day of the Month The easiest way to find the last day of a month is to find the first day of the next month and subtract a day.
IF( MONTH( date ) = 12, DATE( YEAR( date ), 12, 31 ), DATE( YEAR( date ), MONTH ( date ) + 1, 1 ) - 1 )
438 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Display the Month as a String Instead of a Number To return the month as a text string instead of a number, use:
CASE( MONTH( date ), 1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", 7, "July", 8, "August", 9, "September", 10, "October", 11, "November", "December" )
If your organization uses multiple languages, you can replace the names of the month with a custom label:
CASE( MONTH( date ), 1, $Label.Month_of_Year_1, 2, $Label.Month_of_Year_2, 3, $Label.Month_of_Year_3, 4, $Label.Month_of_Year_4, 5, $Label.Month_of_Year_5, 6, $Label.Month_of_Year_6, 7, $Label.Month_of_Year_7, 8, $Label.Month_of_Year_8, 9, $Label.Month_of_Year_9, 10, $Label.Month_of_Year_10, 11, $Label.Month_of_Year_11, $Label.Month_of_Year_12 )
Find and Display the Day of the Week from a Date To find the day of the week from a Date value, use a known Sunday, for example, January 7, 1900, and subtract it from the date, for example, TODAY(), to get the difference in days. The MOD() function finds the remainder of this result when divided by 7 to give the numerical value of the day of the week between 0 (Sunday) and 6 (Saturday). The formula below finds the result and then returns the text name of that day.
CASE( MOD( date - DATE( 1900, 1, 7 ), 7 ), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3, "Wednesday", 4, "Thursday", 5, "Friday", "Saturday" )
439 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This formula only works for dates after 01/07/1900. If you work with older dates, use the same process with any Sunday before to your earliest date, for example, 01/05/1800. You can adjust this formula if your week starts on a different day. For example, if your week starts on Monday, you can use January 8, 1900 in your condition. The new formula looks like this:
CASE( MOD( date - DATE( 1900, 1, 8 ), 7 ), 0, "Monday", 1, "Tuesday", 2, "Wednesday", 3, "Thursday", 4, "Friday", 5, "Saturday", "Sunday" )
Like the formula for getting the name of the month, if your organization uses multiple languages, you can replace the names of the day of the week with a variable like $Label.Day_of_Week_1, and so on.
Find the Next Day of the Week After a Date To find the date of the next occurrence of a particular day of the week following a given Date, get the difference in the number of days of the week between a date and a day_of_week, a number 0–6 where 0 = Sunday and 6 = Saturday. By adding this difference to the current date, you can find the date of the day_of_week. The IF() statement in this formula handles cases where the day_of_week is before the day of the week of the date value (for example date is a Thursday and day_of_week is a Monday) by adding 7 to the difference.
date + ( day_of_week - MOD( date - DATE( 1900, 1, 7 ), 7 ) ) + IF( MOD( date - DATE( 1900, 1, 7 ), 7 ) >= day_of_week, 7, 0 )
You can substitute either a constant or another field in for the day_of_week value based on your needs.
Find the Number of Days Between Two Dates To find the number of days between two dates, date_1 and date_2, subtract the earlier date from the later date: date_1 — date_2 You can alter this slightly if you want to determine a date that’s a certain number of days in the past. For example, to create a formula to return true if some date field is more than 30 days before the current date and false otherwise, use a formula such as the following:
TODAY() - 30 > date
Find the Number of Business Days Between Two Dates Calculating how many business days passed between two dates is slightly more complex than calculating total elapsed days. The basic strategy is to choose a reference Monday from the past and find out how many full weeks and any additional portion of a week have
440 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
passed between the reference date and your date. These values are multiplied by five for a five-day work week, and then the difference between them is taken to calculate business days.
(5 * ( FLOOR( ( date_1 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_1 - DATE( 1900, 1, 8), 7 ) ) ) - (5 * ( FLOOR( ( date_2 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_2 - DATE( 1900, 1, 8), 7 ) ) )
In this formula, date_1 is the more recent date and date_2 is the earlier date. If your work week runs shorter or longer than five days, replace all fives in the formula with the length of your week.
Find the Number of Months Between Two Dates To find the number of months between two dates, subtract the year of the earlier date from the year of the later date and multiply the difference by 12. Next, subtract the month of the earlier date from the month of the later date, and add that difference to the value of the first set of operations.
((YEAR(date_1) - YEAR(date_2))*12) + (MONTH(date_1) - MONTH(date_2))
Add Days, Months, and Years to a Date If you want to add a certain number of days to a date, add that number to the date directly. For example, to add five days to a date, the formula is date + 5. Adding years to a date is fairly simple, but do check that the future date is valid. That is, adding five years to February 29 (a leap year) results in an invalid date. The following formula adds num_years to date by checking if the date is February 29 and if the future date is not in a leap year. If these conditions hold true, the formula returns March 1 in the future year. Otherwise the formula sets the Date to the same month and day num_years in the future.
IF( AND( MONTH( date ) = 2, DAY( date ) = 29, NOT( OR( MOD( YEAR( date ) + num_years, 400 ) = 0, AND( MOD( YEAR( date ) + num_years, 4 ) = 0, MOD( YEAR( date ) + num_years, 100 ) != 0 ) ) ) ), DATE( YEAR( date ) + num_years, 3, 1), DATE( YEAR( date ) + num_years, MONTH( date ), DAY( date ) ) )
Adding months to a date is slightly more complicated because months vary in length and the cycle of months restart with each year. So a valid day in one month, January 31, might not be valid in another month, February 31. A simple solution is to approximate each month’s length as 365/12 days:
date + ( ( 365 / 12 ) * Number_months )
441 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
This formula is a good estimate but it doesn’t return an exact date. For example, if you add two months to April 30 using this method, the formula will return June 29 instead of June 30. Returning an exact date depends on your organization’s preference. For example, when you add one month to January 31, should it return February 28, the last day of the next month, or March 2, 30 days after January 31? This formula does the following: • Returns March 1 if the future month is a February and the day is greater than 28. This portion of the formula performs the same for both leap and non-leap years. • Returns the first day of the next month if the future month is April, June, September, or November and the day is greater than 30. • Otherwise, it returns the correct date in the future month. This example formula adds two months to a given date. You can modify the conditions on this formula if you prefer different behaviors for dates at the end of the month.
DATE( YEAR( date ) + FLOOR( ( MONTH ( date ) + 2 - 1 ) / 12 ), MOD( MONTH ( date ) + 2 - 1 + IF( DAY ( date ) > CASE( MOD( MONTH( date ) + 2 - 1, 12 ) + 1, 2, 28, 4, 30, 6, 30, 9, 30, 11, 30, 31 ), 1, 0 ), 12 ) + 1, IF( DAY( date ) > CASE( MOD( MONTH( date ) + 2 - 1, 12 ) + 1, 2, 28, 4, 30, 6, 30, 9, 30, 11, 30, 31 ), 1, DAY( date ) ) )
If you use these formulas for expiration dates, you can subtract a day from the return value to make sure that some action is completed before the calculated date.
Add Business Days to a Date This formula finds three business days from a given date.
CASE( MOD( date - DATE( 1900, 1, 7 ), 7 ), 3, date + 2 + 3, 4, date + 2 + 3, 5, date + 2 + 3, 6, date + 1 + 3, date + 3 )
This formula finds the day of the week of the date field value. If the date is a Wednesday, Thursday, or Friday, the formula adds five calendar days, two weekend days, three weekdays, to the date to account for the weekend. If date is a Saturday, you need four
442 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
additional calendar days. For any other day of the week Sunday Tuesday, simply add three days. You can easily modify this formula to add more or fewer business days. The tip for getting the day of the week is useful to use to adjust this formula.
Find the Hour, Minute, or Second from a Date/Time To get the hour, minute, and second from a Date/Time field as a numerical value, use the following formulas where TZoffset is the difference between the user’s time zone and GMT. For hour in 24–hour format:
VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) )
For hour in 12–hour format:
IF( OR( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 0, VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 12 ), 12, VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) - IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, 0, 12 ) )
For minutes:
VALUE( MID( TEXT( date/time - TZoffset ), 15, 2 ) )
For seconds:
VALUE( MID( TEXT( date/time - TZoffset ), 18, 2 ) )
And, to get “AM” or “PM” as a string, use:
IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, "AM", "PM" )
To return the time as a string in “HH:MM:SS A/PM” format, use the following formula:
IF( OR( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 0, VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 12 ), "12", TEXT( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) - IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, 0,
443 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
12 ) ) ) & ":" & MID( TEXT( date/time - TZoffset ), 15, 2 ) & ":" & MID( TEXT( date/time - TZoffset ), 18, 2 ) & " " & IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, "AM", "PM" )
When working with time in formula fields, always consider the time difference between your organization and GMT. See A Note About Date/Time and Time Zones on page 415 for more information about the time zone offset used in this formula.
Find the Elapsed Time Between Date/Times To find the difference between two Date values as a number, subtract one from the other like so: date_1 — date_2 to return the difference in days. Finding the elapsed time between two Date/Time values is slightly more complex. This formula converts the difference between two Date/Time values, datetime_1 and datetime_2, to days, hours, and minutes.
IF( datetime_1 - datetime_2 > 0 , TEXT( FLOOR( datetime_1 - datetime_2 ) ) & " days " & TEXT( FLOOR( MOD( (datetime_1 - datetime_2 ) * 24, 24 ) ) ) & " hours " & TEXT( ROUND( MOD( (datetime_1 - datetime_2 ) * 24 * 60, 60 ), 0 ) ) & " minutes", "" )
Find the Number of Business Hours Between Two Date/Times The formula to find business hours between two Date/Time values expands on the formula to find elapsed business days. It works on the same principle of using a reference Date/Time, in this case 1/8/1900 at 16:00 GMT, or 9:00 AM PDT, and then finding your Dates’ respective distances from that reference. The formula rounds the value it finds to the nearest hour and assumes an 8–hour, 9:00 AM5:00 PM work day.
ROUND( 8 * ( ( 5 * FLOOR( ( DATEVALUE( date/time_1 ) - DATE( 1900, 1, 8) ) / 7) + MIN(5, MOD( DATEVALUE( date/time_1 ) - DATE( 1900, 1, 8), 7) + MIN( 1, 24 / 8 * ( MOD( date/time_1 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1 ) ) ) ) ) - ( 5 * FLOOR( ( DATEVALUE( date/time_2 ) - DATE( 1900, 1, 8) ) / 7) + MIN( 5, MOD( DATEVALUE( date/time_2 ) - DATE( 1996, 1, 1), 7 ) +
444 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
MIN( 1, 24 / 8 * ( MOD( date/time_2 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1) ) ) ) ) ), 0 )
You can change the eights in the formula to account for a longer or shorter work day. If you live in a different time zone or your work day doesn’t start at 9:00 AM, change the reference time to the start of your work day in GMT. See A Note About Date/Time and Time Zones for more information.
SEE ALSO: Using Date, Date/Time, and Time Values in Formulas Examples of Advanced Formula Fields Tips for Building Formulas
Sample Discounting Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Maintenance and Services Discount Classic and Lightning Experience This formula field uses two custom currency fields: Maintenance Amount and Services Amount. It displays “Discounted” on an opportunity if its maintenance amount and services amount Available in: All Editions do not equal the opportunity Amount standard field value. Otherwise, it displays "Full Price."
IF(Maintenance_Amount__c + Services_Amount__c <> Amount, "Discounted", "Full Price")
Opportunity Discount Amount This formula calculates the difference of the product Amount less the Discount Amount. Discount Amount is a custom currency field.
Amount - Discount_Amount__c
Opportunity Discount Rounded Use this formula to calculate the discounted amount of an opportunity rounded off to two digits. This example is a number formula field on opportunities that uses a custom percent field called Discount Percent.
ROUND(Amount-Amount* Discount_Percent__c,2)
Opportunity Discount with Approval This formula adds a “Discount Approved” checkbox to an opportunity. It uses conditional logic to check the value of the approval flag before calculating the commission.
IF(Discount_Approved__c, ROUND(Amount – Amount * DiscountPercent__c, 2), Amount)
445 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Employee Services Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Bonus Calculation Classic and Lightning Experience This example determines an employee's bonus amount based on the smallest of two amounts: the employee's gross times bonus percent or an equally divided amount of the company's performance Available in: All Editions amount among all employees. It assumes you have custom number field for Number of Employees, a custom percent field for Bonus Percent, and currency custom fields for the employee's Gross and company's Performance.
MIN(Gross__c * Bonus_Percent__c, Performance__c / Number_of_Employees__c)
Employee 401K This example formula determines which amount to provide in employee 401K matching based on a matching program of half of the employee's contribution or $250, whichever is less. It assumes you have custom currency field for Contribution.
MIN(250, Contribution__c /2)
Hours Worked Per Week This formula uses a custom tab to enable time tracking of hours worked per day. It uses a formula field to sum the hours per week.
MonHours__c + TuesHours__c + WedsHours__c + ThursHours__c + FriHours__c
Total Pay Amount This formula determines total pay by calculating regular hours multiplied by a regular pay rate, plus overtime hours multiplied by an overtime pay rate.
Total Pay = IF(Total_Hours__c <= 40, Total_Hours__c * Hourly_Rate__c, 40 * Hourly_Rate__c + (Total_Hours__c - 40) * Overtime_Rate__c)
Sample Expense Tracking Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Expense Identifier Classic and Lightning Experience This formula displays the text Expense- followed by trip name and the expense number. This is a text formula field that uses an expense number custom field. Available in: All Editions
"Expense-" & Trip_Name__c & "-" & ExpenseNum__c
446 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Mileage Calculation This formula calculates mileage expenses for visiting a customer site at 35 cents a mile.
Miles_Driven__c * 0.35
Sample Financial Calculations Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Compound Interest Classic and Lightning Experience This formula calculates the interest, you will have after T years, compounded M times per year. Available in: All Editions
Principal__c * ( 1 + Rate__c / M ) ^ ( T * M) )
Compound Interest Continuous This formula calculates the interest that will have accumulated after T years, if continuously compounded.
Principal__c * EXP(Rate__c * T)
Consultant Cost This formula calculates the number of consulting days times 1200 given that this formula field is a currency data type and consulting charges a rate of $1200 per day. Consulting Days is a custom field.
Consulting_Days__c * 1200
Gross Margin This formula provides a simple calculation of gross margin. In this formula example, Total Sales and Cost of Goods Sold are custom currency fields.
Total_Sales__c - Cost_of_Goods_Sold__c
Gross Margin Percent This formula calculates the gross margin based on a margin percent.
Margin_percent__c * Items_Sold__c * Price_item__c
Payment Due Indicator This formula returns the date five days after the contract start date whenever Payment Due Date is blank. Payment Due Date is a custom date field.
(BLANKVALUE(Payment_Due_Date__c, StartDate +5)
447 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Payment Status This formula determines if the payment due date is past and the payment status is “UNPAID.” If so, it returns the text “PAYMENT OVERDUE” and if not, it leaves the field blank. This example uses a custom date field called Payment Due Date and a text custom field called Payment Status on contracts.
IF( AND(Payment_Due_Date__c < TODAY(), ISPICKVAL(Payment_Status__c, "UNPAID")), "PAYMENT OVERDUE", null )
Sample Image Link Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Yahoo! Instant Messenger™ Image Classic and Lightning Experience This formula displays an image that indicates whether a contact or user is currently logged in to Yahoo! Instant Messenger. Clicking the image launches the Yahoo! Instant Messenger window. This Available in: All Editions formula uses a custom text field called Yahoo Name to store the contact or user’s Yahoo! ID.
IF(ISBLANK(Yahoo_Name__c),"", HYPERLINK("ymsgr:sendIM?" & Yahoo_Name__c, IMAGE("http://opi.yahoo.com/online?u=" & Yahoo_Name__c & "&m=g&t=0", " ")))
Flags for Case Priority This formula displays a green, yellow, or red flag image to indicate case priority.
IMAGE( CASE( Priority, "Low", "/img/samples/flag_green.gif", "Medium", "/img/samples/flag_yellow.gif", "High", "/img/samples/flag_red.gif", "/s.gif"), "Priority Flag")
Color Squares for Case Age This formula displays a 30 x 30 pixel image of a red, yellow, or green, depending on the value of a Case Age custom number field.
IF( Case_Age__c > 20, IMAGE("/img/samples/color_red.gif", "red", 30, 30), IF( Case_Age__c > 10, IMAGE("/img/samples/color_yellow.gif", "yellow", 30, 30), IMAGE("/img/samples/color_green.gif", "green", 30, 30) ))
448 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Traffic Lights for Status This formula displays a green, yellow, or red traffic light images to indicate status, using a custom picklist field called Project Status. Use this formula in list views and reports to create a “Status Summary” dashboard view.
IMAGE( CASE(Project_Status__c, "Green", "/img/samples/light_green.gif", "Yellow", "/img/samples/light_yellow.gif", "Red", "/img/samples/light_red.gif", "/s.gif"), "status color")
Stars for Ratings This formula displays a set of one to five stars to indicate a rating or score.
IMAGE( CASE(Rating__c, "1", "/img/samples/stars_100.gif", "2", "/img/samples/stars_200.gif", "3", "/img/samples/stars_300.gif", "4", "/img/samples/stars_400.gif", "5", "/img/samples/stars_500.gif", "/img/samples/stars_000.gif"), "rating")
Consumer Reports™—Style Colored Circles for Ratings This formula displays a colored circle to indicate a rating on a scale of one to five, where solid red is one, half red is two, black outline is three, half black is four, and solid black is five.
IMAGE( CASE(Rating__c, "1", "/img/samples/rating1.gif", "2", "/img/samples/rating2.gif", "3", "/img/samples/rating3.gif", "4", "/img/samples/rating4.gif", "5", "/img/samples/rating5.gif", "/s.gif"), "rating")
Horizontal Bars to Indicate Scoring This formula displays a horizontal color bar (green on a white background) of a length that is proportional to a numeric score. In this example, the maximum length of the bar is 200 pixels.
IMAGE("/img/samples/color_green.gif", "green", 15, Industry_Score__c * 2) & IMAGE("/s.gif", "white", 15, 200 - (Industry_Score__c * 2))
449 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Integration Link Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Application API Link Classic (not available in all orgs) and Lightning This formula creates a link to an application outside Salesforce, passing the parameters so that it Experience can connect to Salesforce via the SOAP API and create the necessary event. Available in: All Editions
HYPERLINK ("https://www.myintegration.com?sId=" & GETSESSIONID() & "?&rowID=" & Name & "action=CreateTask","Create a Meeting Request")
Important: $Api.Session_ID and GETSESSIONID() return the same value, an identifier for the current session in the current context. This context varies depending on where the global variable or function is evaluated. For example, if you use either in a custom formula field, and that field is displayed on a standard page layout in Salesforce Classic, the referenced session is a basic Salesforce session. That same field (or the underlying variable or formula result), when used in a Visualforce page, references a Visualforce session instead. Session contexts are based on the domain of the request. That is, the session context changes whenever you cross a hostname boundary, such as from .salesforce.com to .vf.force.com or .lightning.force.com. Session identifiers from different contexts, and the sessions themselves, are different. When you transition between contexts, the old session is replaced by the new one, and the old session is no longer valid. The session ID also changes at this time. Normally Salesforce transparently handles session hand-off between contexts, but if you’re passing the session ID around yourself, you might need to re-access $Api.Session_ID or GETSESSIONID() from the new context to ensure a valid session ID. Not all sessions are created equal. In particular, sessions obtained in a Lightning Experience context have reduced privileges, and don't have API access. You can't use these session IDs to make API calls. {!$Api.Session_ID} isn’t generated for guest users.
Shipment Tracking Integration This formula creates a link to FedEx, UPS, or DHL shipment tracking websites, depending on the value of a Shipping Method custom picklist field. Note that the parameters shown in this example for FedEx, UPS, and DHL websites are illustrative and do not represent the correct parameters for all situations.
CASE(Shipping_Method__c, "Fedex", HYPERLINK("http://www.fedex.com/Tracking?ascend_header=1&clienttype =dotcom&cntry_code=us&language=english&tracknumbers= "& tracking_id__c,"Track"), "UPS", HYPERLINK("http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion =5.0&sort_by=status&loc=en_US&InquiryNumber1= "& tracking_id__c & "&track.x=32&track.y=7", "Track") , "DHL", HYPERLINK("http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber=" & tracking_id__c,"Track"), "")
450 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Skype™ Auto Dialer Integration This formula creates a linkable phone number field that automatically dials the phone number via the Skype VOIP phone application. It requires installation of the Skype application (a third-party product not provided by Salesforce) on your desktop.
HYPERLINK("callto://+" & Country_Code__c & Phone_Unformatted__c, Phone)
Sample Lead Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Lead Aging (for open leads) Classic and Lightning Experience This formula checks to see if a lead is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number Available in: All Editions of days open rounded to zero decimal places. If the lead is not open, this field is blank.
IF(ISPICKVAL(Status, "Open"), ROUND(NOW()-CreatedDate, 0), null)
Lead Data Completeness This formula calculates the percent of certain lead fields that your sales personnel enter. The formula field checks the values of two custom number fields: Phone and Email. If the fields are empty, the formula returns the value “0.” The formula returns a value of “1” for each field that contains a value and multiplies this total by fifty to give you the percentage of fields that contain data.
(IF(Phone = "", 0, 1) + IF(Email = "", 0, 1) ) * 50
Lead Numbering This formula returns a number value for the text value in the auto-number field Lead Number. This can be useful if you want to use the Lead Number field in a calculation, such as round-robin or other routing purposes. Note that auto-number fields are text fields and must be converted to a number for numeric calculations.
VALUE(Lead_Number__c)
Round-Robin Assignment of Cases or Leads The following formula example for leads assumes you have three lead queues and you want to assign an equal number of incoming leads to each queue. You can also assign cases using a similar formula.
MOD(VALUE(Lead_Number__c), 3)
This formula is for a custom formula field named Round_Robin_ID that assigns each lead a value of 0, 1, or 2. This formula uses a custom auto-number field called Lead Number that assigns each lead a unique number starting with 1. The MOD function divides the lead number by the number of lead queues available (three in this example) and returns a remainder of 0, 1, or 2. Use the value of this formula field in your lead assignment rules to assign lead records to different queues. For example: • Round_Robin_ID = 0 is assigned to Queue A • Round_Robin_ID = 1 is assigned to Queue B • Round_Robin_ID = 2 is assigned to Queue C
451 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Sample Metric Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Temperature Conversion Classic and Lightning Experience This formula converts Celsius degrees to Fahrenheit. Available in: All Editions
1.8 * degrees_celsius__c + 32
Unit of Measure Conversion This formula converts miles to kilometers.
Miles__c * 1.60934
Sample Opportunity Management Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Expected Product Revenue Classic and Lightning Experience This formula calculates total revenue from multiple products, each with a different probability of closing. Available in: All Editions
ProductA_probability__c * ProductA_revenue__c + ProductB_probability__c * ProductB_revenue__c
Maintenance Calculation This formula calculates maintenance fees as 20% of license fees per year. Maintenance Years is a custom field on opportunities.
Amount * Maint_Years__c * 0.2
Monthly Subscription-Based Calculated Amounts This formula calculates an opportunity amount based on a monthly subscription rate multiplied by the subscription period.
Monthly_Amount__c * Subscription_Months__c
Monthly Value This formula divides total yearly value by 12 months.
Total_value__c / 12
452 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Opportunity Additional Costs This formula calculates the sum of the product Amount, maintenance amount, and services fees. Maint amount and Service Fees are custom currency fields.
Amount + Maint_Amount__c + Services_Amount__c
Opportunity Categorization This formula uses conditional logic to populate an Opportunity category text field, based on the value of the Amount standard field. Opportunities with amounts less than $1500 are “Category 1,” those between $1500 and $10000 are “Category 2,” and the rest are “Category 3.” This example uses nested IF statements.
IF(Amount < 1500, "Category 1", IF(Amount > 10000, "Category 3", "Category 2"))
Opportunity Data Completeness This formula takes a group of fields and calculates what percent of them are being used by your personnel. This formula field checks five fields to see if they are blank. If so, a zero is counted for that field. A “1” is counted for any field that contains a value, and this total is divided by five (the number of fields evaluated). This formula requires you to select the Treat blank fields as blanks option under Blank Field Handling while the Advanced Formula subtab is showing.
(IF(ISBLANK(Maint_Amount__c), 0, 1) + IF(ISBLANK(Services_Amount__c), 0,1) + IF(ISBLANK(Discount_Percent__c), 0, 1) + IF(ISBLANK(Amount), 0, 1) + IF(ISBLANK(Timeline__c), 0, 1)) / 5
Opportunity Expected License Revenue This formula calculates expected revenue for licenses based on probability of closing.
Expected_rev_licenses__c * Probability
Opportunity Revenue Text Display This formula returns the expected revenue amount of an opportunity in text format without a dollar sign. For example, if the Expected Revenue of a campaign is “$200,000,” this formula field displays “200000.”
TEXT(ExpectedRevenue)
Opportunity Total Deal Size This formula calculates the sum of maintenance and services amounts.
Amount + Maint_Amount__c + Services_Amount__c
Opportunity Total Price Based on Units This formula generates proposal pricing based on unit price and total volume.
Unit_price__c * Volume__c * 20
453 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Professional Services Calculation This formula estimates professional service fees at an average loaded rate of $1200 per day. Consulting Days is a custom field on opportunities.
Consulting_Days__c * 1200
Stage-Based Sales Document Selection This formula Identifies a relevant document in the Documents tab based on opportunity Stage. Use document IDs in the form of “00l30000000j7AO.”
CASE(StageName, "Prospecting", "Insert 1st Document ID", "Qualification", "Insert 2nd Document ID", "Needs Analysis", "Insert 3rd Document ID", "Value Proposition", ... ) )
Sales Coach This formula creates a hyperlink that opens a stage-specific document stored in the Documents tab. It uses the previously defined custom formula field that identifies a document based on opportunity Stage. See Stage-Based Sales Document Selection on page 454.
HYPERLINK("/servlet/servlet.FileDownload?file=" & Relevant_Document__c, "View Document in New Window")
Shipping Cost by Weight This formula calculates postal charges based on weight.
package_weight__c * cost_lb__c
Shipping Cost Percentage This formula calculates shipping cost as a fraction of total amount.
Ship_cost__c / total_amount__c
Tiered Commission Rates This formula calculates the 2% commission amount of an opportunity that has a probability of 100%. All other opportunities will have a commission value of zero.
IF(Probability = 1, ROUND(Amount * 0.02, 2), 0)
454 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Total Contract Value from Recurring and Non-Recurring Revenue This formula calculates both recurring and non-recurring revenue streams over the lifetime of a contract.
Non_Recurring_Revenue__c + Contract_Length_Months__c * Recurring_Revenue__c
Sample Pricing Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Total Amount Classic and Lightning Experience This formula calculates a total amount based on unit pricing and total units. Available in: All Editions
Unit_price__c * Total_units__c
User Pricing This formula calculates a price per user license.
Total_license_rev__c / Number_user_licenses__c
Sample Scoring Calculations Formulas
For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Lead Scoring Classic and Lightning Experience This formula scores leads, providing a higher score for phone calls than website requests. Available in: All Editions
CASE(LeadSource, "Phone", 2, "Web", 1, 0)
Here's a formula that scores a lead based on his or her rating:
CASE(1, IF(ISPICKVAL(Rating, "Hot"), 1, 0), 3, IF(ISPICKVAL(Rating, "Warm"), 1, 0), 2, IF(ISPICKVAL(Rating, "Cold"), 1, 0), 1))
Customer Success Scoring This formula uses a simple scoring algorithm to rank customers a high score for positive survey results in Salesforce.
Survey_Question_1__c * 5 + Survey_Question_2__c *2
455 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Formulas: How Do I ... ?
EDITIONS Common Math Calculations • Add numbers? Available in: both Salesforce Classic and Lightning • Convert text into a number? Experience • Divide numbers? Available in: All Editions • Multiply numbers? Some How Do I's are not • Round numbers? relevant to Database.com • Subtract numbers?
Common Text Functions USER PERMISSIONS • Check if a field contains specified text? To view formula field details: • View Setup and • Check if a picklist field contains a specified value? Configuration • Combine first and last names? To create, change, or delete • Convert numbers into text? formula fields: • Create a hyperlink field? • Customize Application
Advanced Formulas • Calculate Commission Amounts for Opportunities? • Set Up Round-Robin Assignment of Cases or Leads? • Set Up Opportunity Discount Rounded?
Custom Summary Formulas for Reports • Calculate the sum of all leads that have Email Opt Out and Do Not Call fields selected? • Calculate the difference of all Amount fields and all Discounted Amount fields on opportunities? • Calculate the average age of all opportunities? • Calculate what percent of all opportunities are closed won? • Calculate the number of active Salesforce users to the 2nd power for administration? • Calculate the duration of all activities (minutes) times the number of records per 24 hours? • Calculate the average percent margin on a product-by-product level across many opportunities? • Calculate the percentage of one product compared to all products in closed opportunities? • Calculate the change in revenue from opportunities between months?
Cross-Object Formulas • Display a Percent field from a parent object? • Display a text field from a parent object? • Display a phone number field from a parent object? • Display a picklist field from a parent object? • Display a URL field from a parent object?
456 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas
Common Formula Errors
Review common errors that can occur with formulas and how to fix them. EDITIONS • “#Error!” displays for a formula field whenever an error occurs while calculating the value of a formula. To resolve the error, check your formula. Available in: both Salesforce Classic and Lightning – Is the formula dividing by zero? If so, check if the denominator of your expression is zero Experience and provide an alternative value. For example, the following campaign formula field is blank if the number of opportunities is zero: Available in: All Editions
IF(NumberOfOpportunities > 0, NumberOfWonOpportunities / NumberOfOpportunities, null)
– Is the formula calculating a value larger than the maximum value of the current type? If so, you can append L to numeric values to make them Long so the intermediate products will be Long and no overflow occurs. For example, the following example shows how to correctly compute the amount of milliseconds in a year by multiplying Long numeric values.
Long MillsPerYear = 365L * 24L * 60L * 60L * 1000L; Long ExpectedValue = 31536000000L;
System.assertEquals(MillsPerYear, ExpectedValue);
– Is the formula calculating the square root of a negative number? If so, use an IF function similar to the one above to check if the value is a positive number. – Is the formula calculating the LOG of a negative number? If so, use an IF function similar to the one above to make sure that the number is positive. – Is the formula using the VALUE function with text that contains special characters? For examples of special characters, see Formula Operators and Functions on page 355. – Make sure the formula does not contain a HYPERLINK function within a text function, such as LEFT( HYPERLINK("http://MYCOMPANY.ORG ", "MYCOMPANY ") , 5). – Is the formula disabled or referencing a disabled formula field? Salesforce disables formula fields when they are deleted and they remain disabled after they are restored. To enable disabled formula fields, edit and save the field. For more information on deleted custom fields and restoring them, see Manage Deleted Custom Fields on page 244.
• “#Too Big!” displays if your formula output is over 18 digits. When this happens, check your formula for calculations that could result in more than 18 digits. Avoid multiplying large numbers, raising a large number to a power, or dividing by a very small number. • CASE functions return an error whenever any of the expressions return an error, regardless of which one should be returned. For example, CASE(Field__c,"Partner", "P", "Customer", "C", LEFT(Field__c, -5)) returns an error even if the value of the field is “Partner” or “Customer” because the last statement is illogical. • Prevent division by zero errors by including an IF function that determines if the value of a field is zero. For example, IF(Field__c =0,0, 25/Field__c).
457 Extend Salesforce with Clicks, Not Code Generate Emails From Records
Generate Emails From Records
A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. For example, you can place a merge field in an email template so that the greeting includes the recipient’s name rather than a generic “Hello!”. Available in: both Salesforce You can use merge fields within custom formula fields, s-controls, custom links, custom buttons, Classic and Lightning Visualforce pages, and when you create email or mail merge templates. Experience Merge field names are determined when you create a new custom field or object. Field Name The available merge fields is automatically populated based on what you type into Field Label. You can customize this vary according to which field if you want, but keep in mind that the name must: Salesforce edition you have. • Only use underscores and alphanumeric characters • Begin with a letter and end with a letter • Not include spaces • Not contain two consecutive underscores
Important: Ensure that the custom field name and label are unique for that object. • If a standard and custom field have identical names or labels, the merge field displays the custom field value. • If two custom fields have identical names or labels, the merge fieldcan display an unexpected value. If you create a field label called Email and a standard field labeled Email exists, the merge field is unable to distinguish between the fields. Adding a character to the custom field name makes it unique. For example, Email2. To find the merge field name for an object or field in Salesforce, visit the object or field’s detail page and refer to Field Name. To incorporate merge fields, use the editor in the respective feature. Salesforce provides valid merge fields in each editor for all related standard and custom objects. If you’re using the Connect for Office Word add-in to create mail merge templates, you’ll see a complete list of valid merge fields to insert.
Merge Field Syntax A merge field’s syntax can vary depending on where you use the field. To make sure that you use the correct syntax, select merge fields from the dropdown list in the editor where you use the merge field. Merge Fields for Validation Rules Merge Fields for Formulas Merge Fields for Cross-Object Formulas A Cross-object formula is a formula that spans two related objects and references merge fields on those objects. Merge Field Tips Here are a few pointers for getting the most out of merge fields.
458 Extend Salesforce with Clicks, Not Code Generate Emails From Records
Merge Field Syntax
A merge field’s syntax can vary depending on where you use the field. To make sure that you use EDITIONS the correct syntax, select merge fields from the dropdown list in the editor where you use the merge field. Available in: both Salesforce Custom objects and fields are always appended with __c when referenced. The object precedes Classic and Lightning field labels, and all spaces convert to underscores. For example, Account.CreatedDate Experience Created Date references the standard field for the account object. The available merge fields In standard relationships, the name of the relationship is the master object. For example, you can vary according to which reference the account name from a contact validation rule using Account.Name. You can Salesforce edition you have. reference the phone number of the account creator from an opportunity product formula field using Opportunity.Account.CreatedBy.Phone. In custom relationships, the name of the relationship is the value specified in Field Name with __r appended to it. For example, you can reference contact email from a custom object validation rule using Contact__r.Email.
Merge Fields for Validation Rules
A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. Available in: both Salesforce Syntax and Formatting Classic and Lightning Experience When you insert a merge field in a validation rule, the syntax consists of the object, a period, and the field name. For example, $User.State corresponds with a user’s state or province. Available in: Essentials, Contact Manager, Group, A merge field’s syntax can vary depending on where you’re using the field. To make sure you’re Professional, Enterprise, using the correct syntax, select merge fields from the drop-down list in the editor where you’re Performance, Unlimited, using the merge field. The merge fields for validation rules correspond directly with the fields in Developer, and your app. Database.com Editions For a list of fields in an object, from the management settings for the object, go to the fields section.
Important: • If two or more custom objects have matching names or labels, only one of the objects appears when you select from available merge fields. Make sure that all custom objects have unique names and labels so that you can select merge fields from any of the objects.
Limitations Validation rules can’t reference merge fields for: • Auto number fields, such as Requisition Number • Compound fields, such as addresses, first and last names, dependent picklists, and dependent lookups
Note: Validation rules can reference merge fields individual address fields, such as Billing City.
• Campaign statistic fields, including statistics for individual campaigns and campaign hierarchies
Tips • Some merge fields display as radio buttons but function like picklist fields when referenced in a formula.
459 Extend Salesforce with Clicks, Not Code Generate Emails From Records
Use the values “Read,” “Edit,” and “None” in a formula when referencing: – $UserRole.CaseAccessForAccountOwner – $UserRole.OpportunityAccessForAccountOwner – CaseAccessLevel (on Territory) – OpportunityAccessLevel (on Territory) Use the values “Read,” “Edit,” and “All” in a formula when referencing: – AccountAccessLevel (on Territory)
• Use the RecordType.Id merge field in your formula to apply different validations for different record types.
SEE ALSO: Find Object Management Settings
Merge Fields for Formulas
A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. Available in: both Salesforce Syntax and Formatting Classic (not available in all orgs) and Lightning Merge fields for formulas aren’t enclosed in curly braces or preceded by an exclamation point, nor Experience are they preceded by the type of record. For example: AccountNumber. To ensure you’re using the correct syntax, use the Insert Field button or the drop-down list in the formula editor. Available in: All Editions
SEE ALSO: Tips for Using Merge Fields in Formulas Build a Formula Field
Merge Fields for Cross-Object Formulas
A Cross-object formula is a formula that spans two related objects and references merge fields on EDITIONS those objects. A merge field is a field you can put in an email template, mail merge template, custom link, or Available in: Salesforce formula to incorporate values from a record. Classic (not available in all orgs) A cross-object formula can reference merge fields from a master (“parent”) object if an object is on the detail side of a master-detail relationship. A cross-object formula also works with lookup Available in: All editions relationships. For example, you can write a cross-object formula that references the Account Name for a contact associated with a case. In this example, you would type Contact.Account.Name in a formula on the Case object.
Syntax and Formatting Merge fields for formulas aren’t enclosed in curly braces or preceded by an exclamation point. Use the relationship names of the objects, not the labels. Although the relationship name is often the same as the object name, it is technically the field name of the relationship field.
460 Extend Salesforce with Clicks, Not Code Manage Your Notifications with Notification Builder
To reference the parent account name from Account object, the syntax is Parent.Name, not Account.Name. When referencing a custom object, add two underscores and the letter r to its name. For example, Position__r.title__c references the Job Title field (title__c) on a Position custom object.
Limitations You can’t reference: • Merge fields for objects related to activities. For example, merge fields for contacts and accounts are not available in task and event formulas. • The $RecordType global variable—it only resolves to the record containing the formula, not the record to which the formula spans. Starting with the Spring ’13 release, when you create a new formula the $RecordType global variable is only available for default value formulas. The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile name, as expected. In list views and reports, the value is the internal value of the associated profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example:
IF (OR (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name = "PT2"), "Standard", "Not Standard")
None of the above applies to profile names referenced by the $Profile global variable.
Merge Field Tips
Here are a few pointers for getting the most out of merge fields. EDITIONS To make sure you’re using the correct syntax, select merge fields from the merge field picker. • To use a merge field as the destination of a link, insert the merge field after http://. Available in: both Salesforce Classic and Lightning • Salesforce rounds decimal values referenced in merge fields on email templates to three digits Experience regardless of locale. The available merge fields • You can store the name of an account, contact, or lead in your organization’s default language vary according to which (the local name), in addition to the account or user’s default language (the standard name). If Salesforce edition you have. the local name is blank, the standard merge field name is used. • To reference a stand-alone file, use $Resource., where is the name you specified when you uploaded the resource. • If you're using the Translation Workbench to translate custom field names, users can look up merge fields in their chosen language. • You can’t use a lookup field as a merge field in an email template. You can, however, create a hidden formula field on the page layout that pulls the value from the lookup field. Then include the hidden field in the email template.
Manage Your Notifications with Notification Builder
Keep your users in the know with timely notifications, whether they’re at their desks or on the go. Choose whether standard Salesforce notifications, like Chatter notifications, appear on desktop, mobile, or at all. Create custom notifications to give your users new information and reminders, or replace a standard notification.
461 Extend Salesforce with Clicks, Not Code Send Custom Notifications
Send Custom Notifications Send custom notifications when important events occur. Alert an account owner if a new support case is logged while trying to close a deal. Send a notification for a workflow built entirely with custom objects. Or replace a standard notification with a custom notification to include a message and recipients tailored to your needs. Manage Notification Delivery Settings Choose the desktop and mobile delivery channels for custom and standard notification types. The delivery channels for custom types can be edited for supported Salesforce-provided apps and apps installed from a managed package. The delivery channels for standard types can be edited for supported Salesforce-provided apps only. Considerations for Notification Builder Before you begin managing your desktop and mobile notifications, learn about the considerations specific to custom notifications and notification delivery settings.
SEE ALSO: Salesforce Mobile App Notification Types
Send Custom Notifications Send custom notifications when important events occur. Alert an account owner if a new support case is logged while trying to close a deal. Send a notification for a workflow built entirely with custom objects. Or replace a standard notification with a custom notification to include a message and recipients tailored to your needs. 1. Create a Notification Type Create notification types to send custom notifications via a process in Process Builder, a flow in Flow Builder, Apex code, or the invocable action API. You can create multiple custom notifications from a notification type.
Note: If you create a custom notification type with a mobile delivery channel in Winter ’20 or later, you must manually enable the Salesforce mobile app and any other supported apps in Notification Delivery Settings.
2. Send a Custom Notification from a Process Add the Send Custom Notification action to a process, then add recipients and content. or Learn about Other Ways to Send a Custom Notification We’ve made it easy to build notifications using clicks, not code. But if your business needs are more complex, we also support flows and programmatic solutions.
462 Extend Salesforce with Clicks, Not Code Send Custom Notifications
Create a Notification Type
Create notification types to send custom notifications via a process in Process Builder, a flow in Flow EDITIONS Builder, Apex code, or the invocable action API. You can create multiple custom notifications from a notification type. Available in: Lightning 1. Enter Notification Builder in the Quick Find box in Setup, then select Custom Experience Notifications. Available in: all editions, 2. Click New and add your Custom Notification Name and API Name, and supported channels. except Database.com Channel Description USER PERMISSIONS Desktop Sends a notification to the desktop notification tray.
Mobile Sends an in-app and push notification to enabled supported apps. To view notification types: • View Setup and Configuration Note: Mobile in-app notifications require the Enable in-app notifications setting. Mobile push notifications depend on a user’s device-level and, if available, app-level push To create and edit notification types: notification settings. Push notifications for the Salesforce mobile app require the Enable • Customize Application push notifications setting.
Note: If you created a custom notification type with a mobile delivery channel before Winter ’20, your notification is automatically delivered to the Salesforce mobile app. If you create a custom notification type with a mobile delivery channel in Winter ’20 or later, you must manually enable the Salesforce mobile app and any other supported apps in Notification Delivery Settings.
3. Save your notification type. 4. If you enable the mobile channel, you must enable the supported apps for your notification type. a. From Setup, enter Notification Builder in the Quick Find box, then select Notification Delivery Settings. b. Choose your custom notification type, and select Edit from the dropdown menu. c. Select the supported applications for your notification type and save.
463 Extend Salesforce with Clicks, Not Code Send Custom Notifications
Send a Custom Notification from a Process
Add the Send Custom Notification action to a process, then add recipients and content. EDITIONS • Before you begin, make sure that the custom notification type you want to call from your process exists. If not, create the notification type on page 463. Available in: both Salesforce • Before you can add an action to your process, you must define the process properties, configure Classic and Lightning the process trigger, and add process criteria. If you’re new to creating processes, learn more in Experience Process Builder help. Available in: Essentials, After you’ve created an action and selected Send Custom Notification for the type, fill in the Professional, Enterprise, relevant fields to add the action to your process. Performance, Unlimited, and Developer Editions 1. Enter an easily recognizable name for this action. The name appears on the canvas and helps you differentiate this action from others in your USER PERMISSIONS process. The name truncates to fit on the canvas.
2. Select a notification type. To create, edit, or view processes: 3. Select a recipient category, and designate or find a recipient ID. • Manage Flow • Current User — The user who initiated the record change, platform event, or process that AND triggered the process. This option is useful for confirmation notifications, such as a successful View All Data submission of a form. • Find User — The user who receives the notification each time this action is executed. • User Field from a Record — A user referenced via UserId on the record that initiated the process or on a related record. • Find Group — All users in the group that receives the notification each time this action is executed. • Find Queue — All users in the queue that receives the notification each time this action is executed. • Account Field from a Record — All users on the account team for an account referenced via AccountId on the record that initiated the process or on a related record. This option is available if you’ve enabled account teams for your org. • Opportunity Field from a Record — All users on the opportunity team for an opportunity referenced via OpportunityId on the record that initiated the process or a related record. This option is available if you’ve enabled team selling for your org. • Owner Field from a Record — An owner or queue referenced via OwnerId on the record that initiated the process or a related record. With this option, you can send a notification to all record owners, regardless of whether the owner is an individual owner or a queue.
4. Write a helpful notification title and body using text and merge fields.
Note: The content of custom push notifications depends on the Display full content push notifications setting. If full content push notifications are not enabled, only the notification title is sent.
5. Save the action.
Other Ways to Send a Custom Notification We’ve made it easy to build notifications using clicks, not code. But if your business needs are more complex, we also support flows and programmatic solutions.
Tip: To see how to specify the target using JSON, see pageReference.
464 Extend Salesforce with Clicks, Not Code Send Custom Notifications
Flow Builder Flow Core Action: Send Custom Notification The Send Custom Notification action is available in Flow Builder. Add it to your flow, then add recipients and content. Some tips specific to custom notifications: • To query for the Notification Type ID directly from a flow, add the Get Record element to your flow and filter by API name. If you’ve installed a notification type via a managed package, filter by the namespace prefix as well as the API name. • To add recipients, define Recipient ID as a resource. Then add values to your Recipient ID collection by adding the Assignment element to your flow. If you’re new to creating flows, learn even more in Flow help.
Apex CustomNotification Use the CustomNotification Apex class to create, configure, and send custom notifications from Apex code, such as a trigger. When possible, create and send custom notifications from Apex rather than via API call. It’s less code, and more efficient.
API CustomNotificationType Use the CustomNotificationType object to create notification types and query for your Custom Notification Type ID. It’s available for the following APIs: • Metadata • Tooling • Lightning Platform REST and SOAP customNotificationAction Invocable Action Use the customNotificationAction action to send custom notifications to desktop and delivery channels.
465 Extend Salesforce with Clicks, Not Code Manage Notification Delivery Settings
Manage Notification Delivery Settings
Choose the desktop and mobile delivery channels for custom and standard notification types. The EDITIONS delivery channels for custom types can be edited for supported Salesforce-provided apps and apps installed from a managed package. The delivery channels for standard types can be edited for Available in: Lightning supported Salesforce-provided apps only. Experience 1. From Setup, enter Notification Builder in the Quick Find box, then select Available in: all editions, Notification Delivery Settings. except Database.com 2. Choose the notification type, and select Edit from the dropdown menu. Notification Delivery Settings shows you only the notification types available for your org. USER PERMISSIONS 3. Select the channels and applications for your notification type, and save. To view notification delivery Only the delivery channels and mobile applications supported for the notification type are settings: listed. • View Setup and Configuration If a channel for a custom notification type created in your org is listed but unavailable, enable it in Custom Notifications in Setup. To edit notification delivery settings: Note: Mobile in-app notifications require the Enable in-app notifications setting. Mobile • Customize Application push notifications depend on a user’s device-level and, if available, app-level push notification settings. Push notifications for the Salesforce mobile app require the Enable push notifications setting.
SEE ALSO: Connect REST API Developer Guide: Notification Settings Resources Metadata API Developer Guide: NotificationTypeConfig
Considerations for Notification Builder Before you begin managing your desktop and mobile notifications, learn about the considerations specific to custom notifications and notification delivery settings.
Custom Notifications • In orgs created in Winter ’21 or later, the Send Custom Notifications user permission is required to trigger the Send Custom Notification action in flows that run in user context, REST API calls, and Apex callouts. The Send Custom Notifications user permission isn’t required to trigger the Send Custom Notification action in process or flows that run in system context. • If you created a custom notification type with a mobile delivery channel before Winter ’20, your notification is automatically delivered to the Salesforce mobile app. If you create a custom notification type with a mobile delivery channel in Winter ’20 or later, you must manually enable the Salesforce mobile app and any other supported apps in Notification Delivery Settings. • You can create up to 500 custom notification types. • Each notification can have up to 10,000 users as recipients. However, you can add an action to the same process within Process Builder or to the same flow in Flow Builder to have more recipients. • Your org saves your most recent 1 million custom notifications for view in notification trays. Your org can save up to 1.2 million custom notifications, but it trims the amount to the most recent 1 million notifications when you reach the 1.2 million limit. • An org can execute up to 10,000 notification actions per hour. When you exceed this limit, no more notifications are sent in that hour, and all unsent notifications are lost. Notification actions resume in the next hour.
466 Extend Salesforce with Clicks, Not Code Considerations for Notification Builder
For example, your notification action processes are triggered 10,250 times between 4:00 and 4:59. Salesforce executes the first 10,000 of those actions. The remaining 250 notifications aren’t sent and are lost. Salesforce begins executing notification actions again at 5:00.
• When you send a custom notification from a process, the Target ID for the notification is the record that started the process. However, target records that don't have their own detail page (for example, a case comment, which appears only in a Case Comment related list) don't support direct navigation. Use Flow Builder to send the notification from a flow and specify either a different Target ID or Target Page Reference.
Tip: To see how to specify the target using JSON, see pageReference.
• Custom notification title and body fields support plain text only. • The content of custom push notifications depends on the Display full content push notifications setting. If full content push notifications aren’t enabled, only the notification title is sent.
Notification Delivery Settings • When you disable a delivery channel for a standard or custom notification type, you pause the delivery of a notification. However, a notification is still created and stored whenever an existing notification type is triggered. If you enable a delivery channel for an existing notification type, the stored notifications become visible in the notification tray for that delivery channel. • Mobile in-app notifications require the Enable in-app notifications setting. Mobile push notifications depend on a user’s device-level and, if available, app-level push notification settings. • In the Salesforce mobile app: – Mobile push notifications require the Enable push notifications setting. – A push notification for an individual notification type depends on a user’s app-level Push Notification Settings. If the mobile channel is enabled for a notification type, but a user disables push notifications for that type, the user doesn’t receive a push notification. – If you enable the mobile delivery channel for a notification type after you’ve disabled it, users’ Push Notification Settings for that type default to enabled.
• A desktop notification can be delivered in real time to up to 1,000 concurrently logged-in recipients. Additional concurrently logged-in recipients must refresh their Salesforce page to see their latest notifications. Recipients who aren't logged in see their notifications as expected upon login.
SEE ALSO: Considerations for Salesforce Mobile App Notifications
467 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events
Define and Manage Platform Events
Use platform events to connect business processes in Salesforce and external sources through the EDITIONS exchange of real-time event data. Platform events are secure and scalable. Define fields to customize your platform event data. Available in both Salesforce By using platform events, publishers can send custom event data through Apex, a process, a flow, Classic and Lightning or an API. Subscribers can receive custom event messages from Salesforce or an external system Experience using Apex, CometD clients, processes, or flows. Based on the event message data, subscribers can Available in: Performance, process custom business logic, such as sending an email or logging a case. For example, a software Unlimited, Enterprise, and system monitoring a printer can make an API call to publish an event when the ink is low. The Developer Editions custom printer event can contain custom fields for the printer model, serial number, and ink level. The event is processed in Salesforce by an Apex trigger that places an order for a new cartridge. USER PERMISSIONS Platform events simplify the process of communicating changes and responding to them without writing complex logic. Publishers and subscribers communicate with each other through events. To create and edit platform Multiple subscribers can listen to the same event and carry out different actions. event definitions: • Customize Application Define Your Platform Event To define a platform event in Salesforce Classic or Lightning Experience: 1. From Setup, enter Platform Events in the Quick Find box, then select Platform Events. 2. On the Platform Events page, click New Platform Event. 3. Complete the standard fields, and optionally add a description. 4. For Publish Behavior, choose when the event message is published in a transaction. • Publish After Commit to have the event message published only after a transaction commits successfully. Select this option if subscribers rely on data that the publishing transaction commits. For example, a process publishes an event message and creates a task record. A second process that is subscribed to the event is fired and expects to find the task record. Another reason for choosing this behavior is when you don't want the event message to be published if the transaction fails. • Publish Immediately to have the event message published when the publish call executes. Select this option if you want the event message to be published regardless of whether the transaction succeeds. Also choose this option if the publisher and subscribers are independent, and subscribers don't rely on data committed by the publisher. For example, the immediate publishing behavior is suitable for an event used for logging purposes. With this option, a subscriber might receive the event message before data is committed by the publisher transaction.
5. Click Save. 6. To add a field, in the Custom Fields & Relationships related list, click New. 7. Follow the custom field wizard to set up the field properties.
Note: • If you change the publish behavior, expect up to a 5-minute delay for the change to take effect. • In Lightning Experience, platform events aren’t shown in the Object Manager’s list of standard and custom objects and aren’t available in Schema Builder.
A platform event is a special kind of Salesforce entity, similar in many ways to an sObject. An event message is an instance of a platform event, similar to how a record is an instance of a custom object. Unlike custom objects, you can’t update or delete event records. You
468 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events
also can’t view event records in the Salesforce user interface, and platform events don’t have page layouts. When you delete a platform event definition, it’s permanently deleted.
Standard Fields Platform events include standard fields. These fields appear on the New Platform Event page.
Field Description Label Name used to refer to your platform event in a user interface page.
Plural Label Plural name of the platform event.
Starts with a vowel sound If it’s appropriate for your org’s default language, indicate whether the label is preceded by “an” instead of “a.”
Object Name Unique name used to refer to the platform event when using the API. In managed packages, this name prevents naming conflicts with package installations. Use only alphanumeric characters and underscores. The name must begin with a letter and have no spaces. It cannot end with an underscore or have two consecutive underscores.
Description Optional description of the object. A meaningful description helps you remember the differences between your events when you view them in a list.
Deployment Status Indicates whether the platform event is visible to other users.
Custom Fields In addition to the standard fields, you can add custom fields to your custom event. Platform event custom fields support only these field types. • Checkbox • Date • Date/Time • Number • Text • Text Area (Long) The maximum number of fields that you can add to a platform event is the same as for a custom object. See Salesforce Features and Edition Allocations.
ReplayId System Field Each event message is assigned an opaque ID contained in the ReplayId field. The ReplayId field value, which is populated by the system when the event is delivered to subscribers, refers to the position of the event in the event stream. Replay ID values are not guaranteed to be contiguous for consecutive events. For example, the event following the event with ID 999 can have an ID of 1,025. A subscriber can store a replay ID value and use it on resubscription to retrieve events that are within the retention window. For example,
469 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events
a subscriber can retrieve missed events after a connection failure. Subscribers must not compute new replay IDs based on a stored replay ID to refer to other events in the stream.
EventUuid System Field A universally unique identifier (UUID) that identifies a platform event message. This field is available in API version 52.0 and later. The API version corresponds to the version that an Apex trigger is saved with, or the version specified in a CometD subscriber endpoint.
API Name Suffix for Custom Platform Events When you create a platform event, the system appends the __e suffix to create the API name of the event. For example, if you create an event with the object name Low Ink, the API name is Low_Ink__e. The API name is used whenever you refer to the event programmatically, for example, in Apex. API names of standard platform events, such as AssetTokenEvent, don’t include a suffix.
Event Subscribers The Subscriptions related list shows all triggers, processes, and platform event–triggered flows that are subscribed to a platform event. CometD subscribers, such as your own CometD client or the empApi Lightning component, aren't listed in this page. The list shows the replay ID of the event that the system last processed (Last Processed Id field) and the event last published (Last Published Id field). Knowing which replay ID was last processed is useful when there’s a gap in the events published and processed. For example, if a trigger contains complex logic that causes a delay in processing large batches of incoming events.
Note: For high-volume platform events, the Last Published Id value is not available and is always shown as Not Available.
Also, the Subscriptions list shows the state of each subscriber, which can be one of the following. • Running—The subscriber is actively listening to events. If you modify the subscriber, the subscription continues to process events. • Error— The subscriber was disconnected and stopped receiving published events. A trigger reaches this state when it exceeds the number of maximum retries with the EventBus.RetryableException. Trigger assertion failures and unhandled exceptions don’t cause the error state. We recommend limiting the retries to fewer than nine times to avoid reaching this state. When you fix and save the trigger, or for a managed package trigger, if you redeploy the package, the trigger resumes automatically from the tip, starting from new events. Also, you can resume a trigger subscription in the subscription detail page that you access from the platform event page. • Suspended—The subscriber is disconnected and can’t receive events because a Salesforce admin suspended it or due to an internal error. You can resume a trigger subscription in the subscription detail page that you access from the platform event page. To resume a process, deactivate it and then reactivate it. If you modify the subscriber, the subscription resumes automatically from the tip, starting from new events.
Note: Only one “Process” subscriber appears in the Subscriptions related list for all paused flow interviews that are subscribed to the platform event. Processes and platform event–triggered flows are listed individually. Also, information about event subscribers is exposed in the EventBusSubscriber object. You can query this object to obtain details about subscribers.
Suspend or Resume an Apex Trigger Subscription Resume a suspended trigger subscription where it left off, starting from the earliest available event message that is stored in the event bus. If you want to bypass event messages that are causing errors or are no longer needed, you can resume a subscription from the tip, starting from new event messages.
470 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events
To manage a trigger subscription: 1. In the Subscriptions related list, click Manage next to the Apex trigger. 2. In the subscription detail page, choose the appropriate action. • To suspend a running subscription, click Suspend. • To resume a suspended subscription, starting from the earliest event message that is available in the event bus, click Resume. • To resume a suspended subscription, starting from new event messages, click Resume from Tip.
You can’t manage subscriptions for flows and processes through the Subscriptions related list.
Note: • After you modify a subscriber, the subscription resumes automatically. For more information, see the Event Subscribers section. • If you click Resume for a trigger that is in the error state, the trigger skips the events that were retried with EventBus.RetryableException. The subscription starts with the unprocessed events sent after the error state and that are within the retention window.
Platform Event Considerations Field-Level Security All platform event fields are read only by default, and you can’t restrict access to a particular field. Field-level security permissions don’t apply and the event message contains all fields. Enforcement of Field Attributes Platform event records are validated to ensure that the attributes of their custom fields are enforced. Field attributes include the Required and Default attributes, the precision of number fields, and the maximum length of text fields. Permanent Deletion of Event Definitions When you delete an event definition, it’s permanently removed and can’t be restored. Before you delete the event definition, delete the associated triggers. Published events that use the definition are also deleted. Renaming Event Objects Before you rename an event, delete the associated triggers. If the event name is modified after clients have subscribed to this event, the subscribed clients must resubscribe to the updated topic. To resubscribe to the new event, add your trigger for the renamed event object. No Associated Tab Platform events don’t have an associated tab because you can’t view event records in the Salesforce user interface. No SOQL Support You can’t query event messages using SOQL. No Record Page Support in Lightning App Builder When creating a record page in Lightning App Builder, platform events that you defined show up in the list of objects for the page. However, you can’t create a Lightning record page for platform events because event records aren’t available in the user interface. Platform Events in Package Uninstall When uninstalling a package with the option Save a copy of this package's data for 48 hours after uninstall enabled, platform events aren’t exported. Event Volume in Package Installations and Upgrades Installing a managed or unmanaged package that contains a standard-volume platform event causes the event type to be saved as high volume in the subscriber org. Upgrading a managed package doesn't change the event volume in the subscriber org.
471 Extend Salesforce with Clicks, Not Code Manage Your Domains
No Support in Professional and Group Editions Platform events aren’t supported in Professional and Group Edition orgs. Installation of a package that contains platform event objects fails in those orgs.
SEE ALSO: Platform Events Developer Guide
Manage Your Domains
You can configure domains and their site associations to suit your organization’s unique needs. For EDITIONS example, you can set up a single domain to host your Experience Cloud, Lightning Platform, and Site.com sites. Or perhaps you want a single site on more than one domain. Available in: both Salesforce Sites and domains can have a many-to-many relationship. Each domain can have up to 200 sites, Classic and Lightning and each site can be associated with up to 500 domains. Each Experience Cloud site has two sites. Experience Hosting your Experience Cloud, Lightning Platform, and Site.com sites on one domain can simplify Available in: Professional, your domain requirements. For Site.com sites, consider hosting them on the same domain as your Enterprise, Performance, Salesforce Sites because you can access Visualforce pages and access Apex code more easily. and Unlimited Editions There are also reasons why you would have a site on more than one domain. For example, let’s say you have a parent company with two distinct brands. Each brand has its own registered domain, USER PERMISSIONS but you want them both to point to the parent website. Because you can have a site exist on more than one domain, you can point both brand domains to a single parent website. To manage domains: To host one or more sites on a domain, you must set up custom URLs for each site. Custom URLs • You must have Site.com, uniquely distinguish the sites within that domain. Let’s say you have a domain called Salesforce Sites, or Experience Cloud Sites www.ourdomain.com and you want to host two sites called siteone and sitetwo. You enabled. create custom URLs by associating ourdomain.com to each site using a custom path. This results in two custom URLs: http://www.ourdomain.com/siteone and http://www.ourdomain.com/sitetwo. When web users access the domain using one of the URLs, the custom path determines which site within the domain they see.
Add a Domain Add a domain and choose how it’s going to be served. Options to Serve a Custom Domain Salesforce supports multiple options to configure how your domain is served. Whether you serve content for your domain through one of Salesforce’s content delivery networks (CDNs), or an external provider, we strongly recommend using HTTPS. Enable External HTTPS on a Domain Enabling External HTTPS lets you tell Salesforce that a non-Salesforce host or service serves your domain. Use this option if you route your domain through your own server or content delivery network (CDN) account instead of routing it through Salesforce. Naked Domains A naked domain is a domain name server (DNS) name that can’t be a canonical name record (CNAME). An example is hello.com, without the “www” subdomain. You can set up a naked domain in a Salesforce org, but it can require work on your part to maintain and optimize it. Add a Custom URL Define your domain and site relationships by creating custom URLs, which consist of domains and custom path prefixes.
472 Extend Salesforce with Clicks, Not Code Add a Domain
Manage Domains and Custom URLs You can add a custom URL to an existing domain, rename a domain, update its HTTPS service option, activate changes to a domain, or delete a custom URL from a particular domain. Test Your Custom Domains in a Sandbox Develop and test your custom domains for Salesforce Sites and Experience Cloud sites within a sandbox before deploying them to production. Delete a Domain You can delete domains from your org, but you can’t delete a domain that is attached to a published site. Deleting Custom URLs You can delete custom URLs from your organization using the Domain Management page.
Add a Domain
Add a domain and choose how it’s going to be served. EDITIONS Before you add a domain in your org, we recommend evaluating the available domain configuration options. Available in: both Salesforce Classic and Lightning 1. From Setup, enter Domains in the Quick Find box, then select Domains. Experience 2. Click Add a Domain. Available in: Professional, 3. Enter the domain name. Enterprise, Performance, 4. Choose the HTTPS domain configuration option you want to serve this domain with. Optionally, and Unlimited Editions specify a CNAME value if you’re using a non-Salesforce provider to serve your domain.
Note: In Professional Edition orgs with Pardot, you must choose Salesforce serves the USER PERMISSIONS domain over HTTPS using a Salesforce content delivery network (CDN) partner. To view a domain: 5. To avoid vulnerabilities during HTTP redirects and to have supported web browsers always use • View Setup and secure HTTPS connections for your domain, select Allow HSTS preloading registration. This Configuration setting adds the preload directive to the HSTS header. After you enable this setting, you To add a domain: must submit your domain at https://hstspreload.org. • Customize Application OR View Setup and Note: This setting applies only to domains that are eligible for HSTS preloading. Domain Configuration plus either names can consist of a public suffix plus one additional label, For example, a Site.com Publisher example.com and example.co.uk are eligible, but www.example.com, license or Create and Set www.example.co.uk, and sub.example.com aren’t eligible. Up Experiences To edit or delete a domain: 6. Add a certificate if you have already set up a CA-signed certificate that supports this domain. • Customize Application 7. Click Save. To add another domain, click Save & New. Salesforce validates ownership based on the fully qualified domain name (FQDN) you use when adding a domain to your org. Salesforce has three different ways to validate an FQDN using the domain name system (DNS). Only one method is required to add the domain to your org. You can find the 18-character org ID at the top of the Domain Edit page. • Your FQDN in DNS is a canonical name (CNAME) record that points to [YourFQDN].[Your18charOrgId].live.siteforce.com. – For example, let’s say you’re adding www.example.com to your org and your 18-character org ID is 00dxx0000001ggceai. The CNAME record in DNS points to www.example.com.00dxx0000001ggceai.live.siteforce.com. – Your domain name must be a CNAME record for Salesforce to serve your domain, except for the special case of a naked domain.
473 Extend Salesforce with Clicks, Not Code Add a Domain
• Your FQDN in DNS has a TXT record that equals your 18-character org ID. – After the FQDN is added to your org, you can delete this TXT record because it’s needed only for adding the domain to your org. – This option is useful when setting up a custom domain for an FQDN that points to another service or server with A or AAAA records in DNS. This option allows the domain, its custom URLs, and its sites to be ready to take over the domain’s live service before you update your FQDN record in DNS to a CNAME pointing to [YourFQDN].[Your18charOrgId].live.siteforce.com.
• Your FQDN is a subdomain of another domain in your org. – This option is useful when setting up a custom domain for an FQDN that points to another service or server with a CNAME record in DNS. Updating the DNS CNAME to point to [YourFQDN].[Your18charOrgId].live.siteforce.com takes down the existing website until you have the domain fully set up in your org. Instead, you can add the parent domain to your org using the TXT record validation. Then add the FQDN as a subdomain, which automatically validates because it’s now a subdomain of another domain in your org. Your FQDN in DNS updates to point to [YourFQDN].[Your18charOrgId].live.siteforce.com only after you have the domain, its custom URLs, and its sites fully set up in your org. This process gives your web users a smoother transition.
With the exception of sandbox orgs, a single FQDN is meant to exist in only one org. In some circumstances, the Salesforce service allows adding an FQDN to more than one org, but that isn’t a supported capability. Before pointing your domain name’s CNAME to a new target name, ensure that the target name exists in the DNS by using dig or nslookup. The target of your CNAME depends on when you create your domain name. • To use HTTPS for domain names added before the Summer ’13 release, adjust your CNAME to point to the FQDN followed by .live.siteforce.com instead of to the org’s force.com subdomain. For example, if your pre-Summer ’13 domain is www.example.com, its CNAME target is www.example.com.live.siteforce.com instead of example.force.com. • Domain names added in Summer ’13 or earlier don’t have the 18-character org ID in the CNAME target. • Domain names added in Summer ’13 or later point to the location for setting up HTTPS in a custom domain. • Domain names added in Winter ’14 or later use a CNAME that points to the FQDN followed by your org’s 18-character ID and .live.siteforce.com. For example, if your domain name is www.example.com and your 18-character org ID is 00dxx0000001ggxeay, its CNAME target is www.example.com.00dxx0000001ggxeay.live.siteforce.com. Every custom domain that you want Salesforce to serve must exist in an org that you control. The FQDN must be a CNAME that points to its own unique [YourFQDN].[Your18charOrgId].live.siteforce.com target or alternative. Configuration errors can prevent your domain from functioning properly. For the changes to take effect, activate the domain after its provisioning status becomes Awaiting Activation. If you receive notice requiring you to enroll in CDN, activate your domain. When setting up HTTPS or renaming a domain, the domain’s live traffic doesn’t use the provisioned HTTPS option or new domain name until the domain is activated. Until activation occurs, the domain’s live traffic uses its previously provisioned HTTPS option and domain name.
Important: Salesforce is unable to serve a top-level domain, such as example.com, using the built-in CDN. We can only serve subdomains, such as www.example.com or parts.example.com. If your site needs a top-level domain served from CDN, host it on a CDN outside of Salesforce.
Note: Only orgs allowed to use the Salesforce CDN partner HTTPS option must activate changes to a domain.
SEE ALSO: Naked Domains
474 Extend Salesforce with Clicks, Not Code Options to Serve a Custom Domain
Options to Serve a Custom Domain
Salesforce supports multiple options to configure how your domain is served. Whether you serve EDITIONS content for your domain through one of Salesforce’s content delivery networks (CDNs), or an external provider, we strongly recommend using HTTPS. Available in: both Salesforce Each option represents a unique way to configure your domain. Dashed lines in the images represent Classic and Lightning DNS configurations, and solid lines represent user traffic flow through HTTP and HTTPS. Experience Salesforce serves the domain over HTTPS on Salesforce’s servers using your HTTPS Available in: Professional, certificate. Enterprise, Performance, This option requires a CA-signed certificate using Certificate and Key Management for your and Unlimited Editions domain. Use a wildcard or Subject Alternative Name certificate to support all domains hosted by sites in your org.
Note: This option is unavailable in Hyperforce orgs.
This image represents how user traffic is routed when you use Salesforce to serve your domain with your HTTPS certificate, where: 1. Your custom domain This is the custom domain you want to add to your org. You control the DNS configuration through your DNS vendor. The domain name is also referred to as the fully qualified domain name (FQDN). Point your domain to the Salesforce internal CNAME (2). 2. Salesforce’s internal CNAME When you add a custom domain to your org, Salesforce creates a CNAME for you, so you have a unique, consistent, and reliable DNS entry point to your org. The CNAME is in the format of:[YourFQDN].[Your18charOrgId].live.siteforce.com. [YourFQDN] is the name of your custom domain. [Your18charOrgId] is your unique 18-character org ID, which is found at the top of the Add Domain page. 3. Salesforce secure server This server hosts your HTTPS certificate and creates secure connections for users. 4. Salesforce content Content that Salesforce is hosting for you in Salesforce sites or Experience Cloud sites. Salesforce serves the domain over HTTPS using a Salesforce content delivery network (CDN) partner. This option allows only Experience Cloud sites to be linked to the domain. New custom domains selecting this option use a single certificate. Only one domain is displayed on the certificate. Ten single certificates are available with the purchase of an Experience Cloud license. Contact your account representative if more certificates are needed.
475 Extend Salesforce with Clicks, Not Code Options to Serve a Custom Domain
In Summer ’21 and earlier, you could choose to use a shared certificate. Shared certificates aren’t recommended. With Experience Cloud shared certificates for CDN, the certificate that your domain uses is shared with other customers. Also, the list of domains on the same certificate can change at any time and without notice.
Important: Professional Edition orgs with Pardot must use this option when serving a custom domain.
This image represents how Salesforce routes traffic for a custom domain over a partner CDN network, where: 1. Your custom domain that points to the Salesforce internal CNAME. 2. Salesforce’s internal CNAME that points to the Salesforce CDN partner 3. Salesforce’s content delivery network partner (CDN) User traffic is pointed to the CDN partner, which acts as an intermediary for your Salesforce content. 4. Salesforce content on Experience Cloud sites.
Note: If you enable the Experience Cloud CDN feature, this domain uses Akamai, a third-party CDN service, to optimize its content delivery. All information sent to or returned by this domain, which includes data submitted to the domain, web page content returned from the domain, data tables on those pages, images, files, JavaScript code, style sheets, and static resources, are stored and transmitted by Akamai. Akamai can offer different privacy and security protections for such data than that offered by Salesforce. Salesforce isn’t responsible for the privacy and security of the data that is shared with Akamai as a result of your decision to enable this feature. A non-Salesforce host or service serves this domain over HTTPS. This option allows you to serve the domain using a non-Salesforce host or service. Specify the hostname of the external server or host so Salesforce’s CNAME can point to it.
Note: Make sure your CDN setup honors origin caching headers.
476 Extend Salesforce with Clicks, Not Code Options to Serve a Custom Domain
This diagram represents how Salesforce routes traffic when you use a non-Salesforce host or service to serve your domain, where: 1. Your custom domain that points to the Salesforce internal CNAME. 2. Salesforce’s internal CNAME that points to the non-Salesforce service provider or host. 3. Non-Salesforce host or service Typically, the third-party CDN service or your external server has a hostname (external CNAME). Specify this hostname in the external hostname field on the domain configuration page. 4. Salesforce content on Salesforce sites or Experience Cloud sites. Temporary non-HTTPS domain Salesforce serves your domain using HTTP instead of HTTPS. Attempting to use HTTPS typically displays a certificate mismatch error in the user’s web browser and users can also experience a connection timeout.
Note: As a security best practice, we recommend that you select one of the HTTPS options. However, if you’re in the process of configuring DNS or adding a subdomain whose CNAME points to another service, you can select this option. Previously, this option was named Salesforce serves the domain over HTTP without support for HTTPS access.
This diagram represents how Salesforce serves your domain and content over HTTP, where: 1. Your custom domain that points to the Salesforce internal CNAME. 2. Salesforce’s internal CNAME that points to a secure Salesforce server.
477 Extend Salesforce with Clicks, Not Code Enable External HTTPS on a Domain
3. Salesforce server, which is secure but it doesn’t host an HTTPS certificate for your custom domain. We don’t recommend using this HTTPS configuration. 4. Salesforce content on Salesforce sites or Experience Cloud sites.
Enable External HTTPS on a Domain
Enabling External HTTPS lets you tell Salesforce that a non-Salesforce host or service serves your EDITIONS domain. Use this option if you route your domain through your own server or content delivery network (CDN) account instead of routing it through Salesforce. Available in: both Salesforce Note: Before enabling External HTTPS on a domain, note these important considerations. Classic and Lightning Experience • This option is only for domains that use your own server or CDN to serve HTTPS. You can’t set the HTTPS options on domains managed by Salesforce, such as subdomains of Available in: Professional, force.com, my.salesforce-sites.com, and my.site.com. Enterprise, Performance, and Unlimited Editions • To enable a custom domain for testing in a sandbox org and enable HTTPS on it, you must create the custom domain in Salesforce production. See Test Your Custom Domains in a Sandbox.
To enable External HTTPS on a domain, click Edit from the domain list page or from a domain’s detail page, and then select A non-Salesforce host or service serves this domain over HTTPS.
Dashed lines in diagrams represent DNS configurations, and solid lines represent user traffic flow through HTTP and HTTPS. In this image: 1. Your custom domain To use External HTTPS, configure your domain's CNAME to point to the internal CNAME that Salesforce creates for your domain. Work with your DNS vendor to update your domain’s CNAME. 2. Salesforce’s internal CNAME that points to the non-Salesforce service provider or host. When you add a custom domain to your org, Salesforce creates a CNAME for you, so that you have a unique, consistent, and reliable DNS entry point to your org. The CNAME is in the format of:[YourFQDN].[Your18charOrgId].live.siteforce.com. [YourFQDN] is the name of your custom domain. [Your18charOrgId] is your unique 18-character org ID, shown at the top of the Add Domain page. 3. Non-Salesforce host or service Typically, the third-party CDN service has a unique CNAME. Specify this hostname in the external hostname field in your domain configuration. If you’re hosting the domain yourself, then specify the public hostname of your host. 4. Salesforce content on Salesforce sites or Experience Cloud sites.
478 Extend Salesforce with Clicks, Not Code Enable External HTTPS on a Domain
If the domain for which you’re enabling External HTTPS has only Site.com custom URLs unrelated to Experience Cloud sites, manually publish the affected Site.com sites via the Site.com Studio to implement the changes. If at least one Experience Cloud site or a Salesforce site exists on the same domain as a Site.com site related to an Experience Cloud site, publishing the changes to enable External HTTPS is automatic on that domain. For more ways to configure custom domains, see Options to Serve a Custom Domain.
Note: To maximize the security of connections to your domain, we recommend that you submit your HTTPS domain for HTTP Strict Transport Security (HSTS) preloading. Enable the Allow HSTS preloading registration setting, then submit your domain at https://hstspreload.org.
Caching When caching responses, your CDN must honor the Salesforce Cache-Control response header. Specifically, make sure that your CDN follows these rules when it operates as a reverse-proxy server. • Your CDN must cache responses only when public exists in the Salesforce Cache-Control response header. • If private, no-store, or no-cache exists in the Salesforce Cache-Control response header, the CDN must not cache that response. • To determine the cache duration, the CDN must use s-maxage, if present in the Salesforce Cache-Control response header. If s-maxage isn’t present, then the CDN must use max-age. The CDN must never increase the cache duration, regardless of whether it’s derived from s-maxage or max-age.
Request Configuration To use the External HTTPS option, configure your proxy or CDN service so that the requests sent to Salesforce contain the originally requested Host HTTP header. This means that your custom domain name must be used as the Host HTTP header value, which is the domain that users see in their original web browser request. When processing an incoming request without a cached response, your proxy or CDN service must forward (proxy) the request to the Salesforce Host using HTTPS while passing through the incoming request's originally requested Host HTTP header value. If enhanced domains are enabled, forward your proxy or CDN requests to these hostnames, based on your configuration.
Hyperforce Target Hostname Yes Your Salesforce Site’s my.salesforce-sites.com subdomain. • Production org example: MyDomainName.my.salesforce-sites.com • Sandbox example: MyDomainName--SandboxName.sandbox.my.salesforce-sites.com
No Your org’s instanced URL, in the format InstanceName.force.com. • Production org example: na87.force.com • Sandbox example: cs34.force.com
If enhanced domains aren’t enabled, forward your proxy or CDN requests to these hostnames, based on your configuration.
Experience Salesforce Target Hostname Cloud sites Sites Yes Yes or no Your Experience Cloud site’s force.com subdomain. • Production org example: ExperienceCloudSitesSubdomain.force.com
479 Extend Salesforce with Clicks, Not Code Enable External HTTPS on a Domain
Experience Salesforce Target Hostname Cloud sites Sites
• Sandbox example: SandboxName-ExperienceCloudSitesSubdomainName.InstanceName.force.com
No Yes Your Salesforce Site’s secure.force.com subdomain or force.com subdomain. • Production org example: SalesforceSitesSubdomain.secure.force.com • Sandbox example: SandboxName-SalesforceSitesSubdomain.InstanceName.force.com
No No Your org’s instanced URL, in the format InstanceName.force.com. • Production org example: na87.force.com • Sandbox example: cs34.force.com
Tip: You can find your org’s instance name on the Company Information page in Setup.
As an example, let’s say you have a custom domain of www.example.com, which is served by an external host or CDN. When a web browser requests https://www.example.com/hello/world, your external host sends the request to Salesforce at https://MyDomainName.my.salesforce-sites.com/hello/world, while setting the Host header to www.example.com. Salesforce then processes the request at MyDomainName.my.salesforce-sites.com as a request for www.example.com with a path of /hello/world. If the Host header isn’t set to a known custom domain, such as if it's set to www.unknown-domain.com, then Salesforce doesn’t process the request properly.
SEE ALSO: Manage Domains and Custom URLs Manage Your Domains
480 Extend Salesforce with Clicks, Not Code Naked Domains
Naked Domains
A naked domain is a domain name server (DNS) name that can’t be a canonical name record EDITIONS (CNAME). An example is hello.com, without the “www” subdomain. You can set up a naked domain in a Salesforce org, but it can require work on your part to maintain and optimize it. Available in: both Salesforce You can’t set a CNAME record on a naked domain because of a DNS limitation. This limitation creates Classic and Lightning complications because normally you would configure your domain’s CNAME to point to your Experience internal Salesforce CNAME, Available in: Professional, [YourFQDN].[Your18CharOrgId].live.siteforce.com. Enterprise, Performance, To bypass this limitation, a few DNS vendors have implemented a CNAME behavior for naked and Unlimited Editions domains to mimic the standard CNAME behavior. If you want to use naked domains, we recommend that you use a DNS vendor that supports this workaround. It makes it easier to maintain your USER PERMISSIONS domain’s DNS configuration by eliminating the need to dynamically monitor and update your naked domain's “A” records. It also avoids unexpected downtime events related to certificate updates To view a domain: or infrastructure adjustments. Plus, this behavior allows each end user around the world to get • View Setup and directed automatically to an IP address that is geographically closest. Configuration This workaround is a relatively new feature. The industry hasn’t agreed what to call it yet, so each To add a domain: vendor has their own proprietary name for it. Here are some examples of vendors that provide this • Customize Application CNAME behavior for naked domains and how they refer to it. OR View Setup and Configuration plus either • Akamai: Zone Apex Mapping a Site.com Publisher • Amazon Route 53: Alias record license or Create and Set Up Experiences • Cloudflare: CNAME Flattening To edit or delete a domain: • Dyn: Alias record • Customize Application • NS1: ALIAS record • UltraDns: Apex Alias There are two different techniques for configuring naked domains based on the functionality provided by your DNS provider.
My DNS Provider Supports CNAME Behavior for Naked Domains If your DNS provider supports bypassing the DNS limitation, use their DNS configuration system to point your naked domain to your domain’s internal Salesforce CNAME. Use the format [YourFQDN].[Your18CharOrgId].live.siteforce.com.
My DNS Vendor Doesn’t Support CNAME Behavior for Naked Domains If your DNS vendor doesn’t support bypassing the DNS limitation, you must add “A” records for the fully qualified domain name (FQDN) to your DNS. You must also comply with the following requirements. • To add the naked domain to your Salesforce org as a custom domain, you must add a TXT record that contains the 18-character org ID to your DNS. • To use HTTPS with a naked domain, use one of the following options: Salesforce serves the domain over HTTPS, on Salesforce's servers, using your HTTPS certificate or A non-Salesforce host or service serves this domain over HTTPS. – If you use the Salesforce serves the domain over HTTPS, on Salesforce's servers, using your HTTPS certificate option, the IP addresses that you can use in “A” DNS records are enumerated in the Certificate IP Addresses related list on the domain’s certificate. If you change the domain to use another certificate, the IP addresses aren’t the same IP addresses that the previous certificate used.
481 Extend Salesforce with Clicks, Not Code Add a Custom URL
– Although the IP addresses of a certificate typically don’t change, they can change when Salesforce adjusts the infrastructure that handles custom HTTPS domains. Periodically monitor the list of IP addresses associated with your certificate and modify your DNS “A” records to stay synchronized with that list. – If you return all the IP addresses of a certificate during DNS lookups, some users of your naked domain probably don’t connect to their closest endpoint. Some DNS services support setting up a global server load balancer (GSLB) configuration with these IP addresses. A GSLB can maximize the performance of your naked domain around the world. If the GSLB includes monitoring, that can prevent or minimize regional outages when the active Salesforce endpoints serving your certificate go down, whether scheduled or unscheduled.
• If your naked domain doesn’t use HTTPS, you can use the IP addresses that your org’s Salesforce Sites MyDomainName.my.salesforce-sites.force.com DNS entry resolves to. You can also use the IP addresses that your org’s Experience Cloud sites MyDomainName.my.site.com DNS entry resolves to. These IP addresses change without notice, so monitor your website’s functionality. When changes occur, for example during maintenance, quickly update your naked domain’s DNS “A” records to the new IP addresses.
Note: If you’re not using enhanced domains, your org’s Salesforce Sites and Experience Cloud sites URLs are different. For details, see My Domain URL Formats in Salesforce Help. Except for sandbox orgs, a single FQDN is meant to exist in only one org. In some circumstances, the Salesforce service allows adding a single FQDN to more than one org, but that isn’t a supported capability.
SEE ALSO: My Domain URL Formats
Add a Custom URL
Define your domain and site relationships by creating custom URLs, which consist of domains and EDITIONS custom path prefixes. You can use the same path prefix for more than one domain, but not more than once within the Available in: both Salesforce same domain. When adding a custom URL, the first character of the path must be a slash (/) to Classic and Lightning indicate the root. You can extend the path after the slash. For example, if the domain name is Experience https://oursite.com and the path prefix is /products, the site URL is Available in: Professional, https://oursite.com/products. If you add the custom URL to the root, the URL is Enterprise, Performance, https://oursite.com. and Unlimited Editions If you want to set a preferred custom URL for authenticated pages and email that links to the Salesforce site or Experience Cloud site, select Site Primary Custom URL. This option is available USER PERMISSIONS for the root path for Lightning Platform and Experience Clouds sites, but not for Site.com sites. For Experience Cloud sites and Salesforce Sites, if you don’t select a primary URL, the first https To view custom URLs: custom URL in the site, determined alphabetically, is used for authenticated pages and email. If • View Setup and there’s no https custom URL, your Salesforce Sites domain is used. Configuration 1. From Setup, enter Custom URLs in the Quick Find box, then select Custom URLs. To add, edit, and delete custom URLs: 2. Click New Custom URL. • Customize Application 3. Enter a domain name. OR View Setup and Configuration plus either Important: Avoid entering personal information in your domain name. Instead, enter a Site.com Publisher only public information. license or Create and Set Up Experiences 4. Enter a site name.
482 Extend Salesforce with Clicks, Not Code Manage Domains and Custom URLs
5. Enter a unique path. 6. Click Save.
Example: In the Custom URLs table, even though the domain name and path are in separate columns, the URLs consist of the combination of the two.
Manage Domains and Custom URLs
You can add a custom URL to an existing domain, rename a domain, update its HTTPS service EDITIONS option, activate changes to a domain, or delete a custom URL from a particular domain. On the Domain Detail page, you can: Available in: both Salesforce Classic and Lightning • Edit the domain name, HTTPS service option, and certificate—Click Edit in the Domain Detail Experience section. • Delete the domain—Click Delete in the Domain Detail section. Available in: Professional, Enterprise, Performance, • Activate provisioned changes to the domain—Click Activate, if available, in the Domain Detail and Unlimited Editions section. • Add a custom URL—Click New Custom URL. USER PERMISSIONS • Edit a custom URL— Click Edit on a custom URL row. • Delete a custom URL— Click Del on a custom URL row. To view a domain: • View the site if it is published—Click View on a custom URL row. • View Setup and Configuration • Jump to a site—Click the site name below the site label. To add a domain: • Jump to an attached certificate—Click the certificate name next to Certificate and Key. • Customize Application • Check whether the domain has External HTTPS enabled. Only domains that don’t point to the OR View Setup and yourdomain.your18characterOrgId.live.siteforce.com CNAME target Configuration plus either have this option available. a Site.com Publisher license or Create and Set Note: You can’t edit a domain record whose name ends with .force.com, Up Experiences *.my.site.com, or *.salesforce-sites.com. To rename the domain, contact To edit or delete a domain: Salesforce Customer Support. • Customize Application To access the Domain Detail page: 1. From Setup, enter Domains in the Quick Find box, then select Domains. USER PERMISSIONS
2. In the Domain Name column, click the domain name. To view custom URLs: Note: If your domain is set to http and you edit the domain to use https instead, you • View Setup and Configuration must republish the Site.com sites that are attached to the domain and unrelated to Experience Cloud sites. To add, edit, and delete custom URLs: • Customize Application OR View Setup and Configuration plus either a Site.com Publisher license or Create and Set Up Experiences
483 Extend Salesforce with Clicks, Not Code Test Your Custom Domains in a Sandbox
Test Your Custom Domains in a Sandbox
Develop and test your custom domains for Salesforce Sites and Experience Cloud sites within a EDITIONS sandbox before deploying them to production.
Note: Government Cloud, Public Cloud, and Hyperforce orgs are currently excluded from Available in: both Salesforce Custom Domains in Sandbox. Classic (not available in all orgs) and Lightning Experience Set Up Your Sandbox Custom Domain Available in: Enterprise, Create a custom domain and use it for testing Salesforce Sites and Experience Cloud sites in Performance, Unlimited, your sandbox. and Developer Editions Activate Your Custom Domain in Production After developing and testing your custom domains for Salesforce Sites and Experience Cloud sites within a sandbox, deploy them to production. Considerations for Custom Domains in Sandboxes Review how to prevent errors when you refresh, clone, or delete a sandbox associated with a custom domain.
Set Up Your Sandbox Custom Domain
Create a custom domain and use it for testing Salesforce Sites and Experience Cloud sites in your EDITIONS sandbox.
Note: Government Cloud, Public Cloud, and Hyperforce orgs are currently excluded from Available in: both Salesforce Custom Domains in Sandbox. Classic (not available in all orgs) and Lightning Before setting up your custom domain in your sandbox, create the Salesforce Sites and Experience Experience Cloud sites that you want to access from the custom domain in your sandbox. Available in: Enterprise, 1. Create the custom domain in Salesforce production. Performance, Unlimited, a. From Setup in production, enter Domains in the Quick Find Box and select Domains. and Developer Editions b. To add a domain, click Add or, to edit an existing domain, click Edit next to the domain name. USER PERMISSIONS c. On the Domain screen, select an HTTPS option other than the Salesforce CDN. To add a domain: Note: See Enable External HTTPS on a Domain for configuration advice when selecting • View Setup and A non-Salesforce host or service that serves this domain over HTTPS as the Configuration HTTPS Option for your sandbox custom domain. To edit or delete a domain: • Customize Application d. Select your sandbox in the Associated Org field. To view custom URLs: e. Click Save. • View Setup and After you save your changes, the domain is provisioned. Once the provisioning process is Configuration complete, you receive an email and the domain status changes to Awaiting Activation. To add, edit, and delete custom URLs: 2. To finish adding your custom domain, activate the provisioned custom domain. • Customize Application a. From Setup in production, enter Domains in the Quick Find Box and select Domains. If OR View Setup and Configuration plus either the provisioning process is complete, your custom domain’s status is Awaiting Activation. a Site.com Publisher b. Click Activate next to your custom domain. license or Create and Set Up Experiences
484 Extend Salesforce with Clicks, Not Code Test Your Custom Domains in a Sandbox
3. Log in to the sandbox to finish updating the sandbox Saleforce Sites and Experience Cloud sites domains. a. From Setup in your sandbox org, enter Custom URLs in the Quick Find Box and select Custom URLs. b. Click New Custom URL. c. On the Custom URL screen, select your custom domain in the Domain field. d. Optional: specify a path in the Path field. e. Select your Salesforce Site or Experience Cloud site in the Sites field. f. Click Save.
Your custom domain is ready for testing. Once you complete your testing, you can activate the custom domain in production.
SEE ALSO: Enable External HTTPS on a Domain Setting Up Salesforce Sites Set Up an Experience Cloud Site Activate Your Custom Domain in Production
Activate Your Custom Domain in Production
After developing and testing your custom domains for Salesforce Sites and Experience Cloud sites EDITIONS within a sandbox, deploy them to production. Before activating your custom domain in production, Set Up Your Sandbox Custom Domain on Available in: both Salesforce page 484 and complete testing. Also, create the Salesforce Sites and Experience Cloud sites that Classic (not available in all you want to access from the custom domain in production. orgs) and Lightning Experience 1. Update the custom domain. a. From Setup in production, enter Domains in the Quick Find Box and select Domains. Available in: Enterprise, Performance, Unlimited, b. Select Add to add a domain or Edit to edit an existing domain. and Developer Editions c. On the Domain screen, select an HTTPS option other than the Salesforce CDN. d. Select your Production in the new Associated Org field. USER PERMISSIONS
e. Click Save. To add a domain: After you save your changes, the domain is provisioned. Once the provisioning process is • View Setup and complete, you receive an email and the domain status changes to Awaiting Activation. Configuration To edit or delete a domain: 2. Update your production Salesforce Sites and Experience Cloud sites domains. • Customize Application Custom URLs a. From Setup in your production org, enter in the Quick Find Box and select To view custom URLs: Custom URLs. • View Setup and b. Click New Custom URL. Configuration c. On the Custom URL screen, select your custom domain in the Domain field. To add, edit, and delete custom URLs: d. Optional: specify a path in the Path field. • Customize Application e. Select your Salesforce Site or Experience Cloud site in the Sites field. OR View Setup and Configuration plus either f. Click Save. a Site.com Publisher license or Create and Set Up Experiences
485 Extend Salesforce with Clicks, Not Code Test Your Custom Domains in a Sandbox
Note: To create Custom URLs with different paths for other Salesforce Sites and Experience Cloud sites, repeat this step.
3. Activate the provisioned custom domain. a. From Setup in production, enter Domains in the Quick Find Box and select Domains. If the provisioning process is complete, your custom domain’s status is Awaiting Activation. b. Click Activate next to your custom domain.
SEE ALSO: Setting Up Salesforce Sites Set Up an Experience Cloud Site
Considerations for Custom Domains in Sandboxes
Review how to prevent errors when you refresh, clone, or delete a sandbox associated with a custom EDITIONS domain. Available in: both Salesforce Feature Exclusions Classic (not available in all orgs) and Lightning Government Cloud, Public Cloud, and Hyperforce orgs are currently excluded from Custom Domains Experience in Sandbox. Available in: Enterprise, Performance, Unlimited, Sandbox Refreshes from Production and Developer Editions When you refresh a sandbox from its owning production Salesforce org, the custom domain remains associated with the sandbox in a provisioned but inactive state. After you activate the refreshed sandbox, log in and validate the sandbox Salesforce Sites and Experience Cloud sites domains from the Custom URLs Setup page.
Cloning a Sandbox You can create a sandbox by cloning an existing sandbox rather than using your production org as the source. When you activate a cloned sandbox, any custom domains associated with the sandbox remain associated with the inactive source sandbox. Until it’s reassociated with the cloned sandbox, any calls to the custom domain return an error. To associate your custom domain with the cloned sandbox, after the cloned sandbox is activated, log in to your production org. From the Domains Setup page, edit the custom domain and change the associated org to an org other than your sandbox. Save your changes and activate the domain. Then edit the custom domain again, and update the associated org to your sandbox. Save and activate your domain. After you reactivate the custom domain for your sandbox, log in to the sandbox and validate the sandbox Salesforce Sites and Experience Cloud sites domains from the Custom URLs Setup page.
Custom Domains Pointing to a Sandbox Experience Builder Site You must republish sandbox Experience Builder sites after refreshing or cloning a sandbox. Calls to a custom domain pointing to an Experience Builder site return an error until the site is published.
486 Extend Salesforce with Clicks, Not Code Delete a Domain
Deleting a Sandbox Before deleting a sandbox, log in to production and associate any custom domains for that sandbox with a different org. If you don’t update the domain in production, calls to the custom domain URL return an error.
SEE ALSO: Create, Clone, or Refresh a Sandbox
Delete a Domain
You can delete domains from your org, but you can’t delete a domain that is attached to a published EDITIONS site. Remove all custom URLs from the domain before you delete it. For Lightning Platform sites and Available in: both Salesforce Experience Cloud sites, the domain is deleted immediately, and users no longer have access to any Classic and Lightning site connected to that domain. For Site.com sites unrelated to Experience Cloud sites, the domain Experience remains active until you republish or unpublish the site. Available in: Professional, 1. From Setup, enter Domains in the Quick Find box, then select Domains. Enterprise, Performance, and Unlimited Editions 2. Next to the domain name, click Del. 3. Click OK. USER PERMISSIONS When you delete a domain with an unpublished site attached, it also deletes the custom URL associated with that site. To delete domains: • Customize Application SEE ALSO: Manage Your Domains
487 Extend Salesforce with Clicks, Not Code Deleting Custom URLs
Deleting Custom URLs
You can delete custom URLs from your organization using the Domain Management page. EDITIONS You can’t delete a URL that is attached to a published site. You’ll need to unpublish the site attached to the custom URL before you can delete it. For Lightning Platform sites, the URL is deleted Available in: both Salesforce immediately, and users no longer have access to any site connected to that URL. But with Site.com Classic and Lightning sites, the URL remains active until you republish the site. Experience To delete a URL from a domain: Available in: Professional, 1. From Setup, enter Custom URLs in the Quick Find box, then select Custom URLs. Enterprise, Performance, and Unlimited Editions 2. Click Del next to the URL name.
3. Click OK. USER PERMISSIONS
SEE ALSO: To view custom URLs: • View Setup and Manage Your Domains Configuration To add, edit, and delete custom URLs: • Customize Application OR View Setup and Configuration plus either a Site.com Publisher license or Create and Set Up Experiences
Build Your Own Web Site
You can use Experience Builder or Salesforce Sites to build out your Salesforce organization with custom pages and apps.
Site.com Site.com is a web content management system (CMS) that makes it easy to build dynamic, data-driven web pages quickly, edit content in real time, and manage your websites. Salesforce Sites Salesforce Sites enables you to create public websites and applications that are directly integrated with your Salesforce organization—without requiring users to log in with a username and password. You can publicly expose any information stored in your organization through a branded URL of your choice. And you can make the site's pages match the look and feel of your company’s brand.
488 Extend Salesforce with Clicks, Not Code Site.com
Site.com
Site.com is a web content management system (CMS) that makes it easy to build dynamic, EDITIONS data-driven web pages quickly, edit content in real time, and manage your websites.
Note: If you’re a new customer who’d like to create a site, portal, or community, Communities Available in: Salesforce are a great way to share information and collaborate with people outside your company, Classic (not available in all such as customers, partners, or employees. See Set Up and Manage Experience Cloud Sites orgs) to learn more. Available for purchase in: From the Site.com tab in the Site.com app, you can launch Site.com Studio, which provides a Enterprise, Performance, separate, dedicated environment for creating and editing pixel-perfect, custom websites. Site and Unlimited Editions administrators and designers can create and style web pages, and add features such as navigation Available (with limitations) menus, images, and text areas using drag-and-drop page elements, while ensuring the site's pages in: Developer Edition match the look and feel of the company's brand. And content contributors, such as marketing users, can browse and update website content directly in a simplified Site.com Studio environment. Additionally, websites built with Site.com benefit from running on Salesforce’s trusted global infrastructure.
Note: The features available in Site.com Studio vary depending on whether you're a site administrator, designer, or contributor.
The following examples illustrate a few ways to use Site.com: • Create an event site—Advertise upcoming events, such as grand openings, launches, or sales kick-offs on a public event site. • Promote new products—Launch new products into the market with a promotional website that helps drive sales. • Publish a support FAQ—Provide helpful information on a public website where customers can view solutions to their issues. • Create microsites and landing pages—Create temporary landing pages or targeted microsites for marketing campaigns. • Create a recruiting website—Post job openings to a public site and allow visitors to submit applications and resumes. • Publish a catalog of products—List all of your company's products on a public website, with model numbers and current prices pulled dynamically from your organization. • Post company press releases—Publish your company’s press releases and sort by publication date.
System Requirements To use Site.com Studio, we recommend: • Mozilla® Firefox® or Google® Chrome for best performance.
Note: Microsoft® Edge is supported, but it is strongly recommended that you do not use Internet Explorer®.
• Disabling the Firebug extension for Firefox, if installed, as it can impact performance. • A minimum browser resolution of 1024x768.
About Site.com Feature Licenses Planning and Implementing a Site.com Website Create a Site.com Community Creating a Site.com Site Importing and Managing Assets Editing Site.com Pages as a Designer or Site Administrator Site.com Page Elements
489 Extend Salesforce with Clicks, Not Code Site.com
Setting Up the Contributor’s Studio View Control what your contributors can do in Site.com Studio. Cascading Style Sheets Overview Site Branding Overview Branding provides a flexible way for you to define different aspects of your website’s brand. Once branding properties are defined, your editors can easily customize everything in one centralized place, the Branding Editor. When your website editors customize the properties, they get a preview of their branding changes immediately. Custom Site Properties Overview With custom site properties, you can define and store frequently occurring content on your site. For example, you can store your address and phone number as a custom property so that it can be reused by anyone who is editing your site. You can apply stored properties to pages, headers and footers, and widgets quickly by using expression language syntax. Site.com Data Services Overview Site.com data services combine many features that let you connect to standard and custom Salesforce objects. Retrieve data from your organization’s objects and dynamically display it on your site pages, or alternatively, gather and submit data from your customers. And when you update data in your Salesforce object, the changes are reflected automatically on the live site—no site updates required! Widgets Overview Widgets let you save time by building custom page elements that you and your team can reuse throughout the site. Multilingual Sites Overview Site.com Studio lets you to create different language versions of your site. And because all languages are maintained within the site, you don’t need to create and manage a separate site for each language. Content Lists and Categories Overview Events Overview Understanding the Contributor’s Page Editing View Previewing How Pages Appear on Mobile Devices With live mode, site administrators, designers, and contributors can preview how pages and templates appear on devices such as cell phones and tablets. Previewing Site.com Sites Site.comIP Restrictions Overview Managing Domains in Site.com Before you can publish your site to the Internet, you must set the site's domain information.
SEE ALSO: Setting Up Site.com Users Planning and Implementing a Site.com Website Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor
490 Extend Salesforce with Clicks, Not Code Site.com
About Site.com Feature Licenses
To access Site.com, each user in your organization must have a Site.com feature license. EDITIONS • The Site.com Publisher feature license allows the user to access Site.com Studio to create and style websites, control the layout and functionality of pages and page elements, and add and Available in: Salesforce edit content. Classic (not available in all • The Site.com Contributor feature license allows the user to access Site.com Studio to edit site orgs) content only. Available for purchase in: Consider what your users need to do in a site and purchase feature licenses accordingly. See the Enterprise, Performance, Site.com feature table for a complete list of the capabilities that come with each feature license. and Unlimited Editions After you purchase feature licenses, you can set up Site.com users. Available (with limitations) in: Developer Edition You can view the number of assigned feature licenses on your organization's profile.
Note: Organizations using Performance, Unlimited, or Enterprise Editions must purchase Site.com Publisher and Site.com Contributor feature licenses separately. Additionally, a Site.com Published Site license is required for each site that’s published to the Internet. For information on purchasing Site.com licenses, contact Salesforce. Developer Edition organizations contain two Site.com Publisher feature licenses and one Site.com Contributor feature license. Developer Edition organizations can’t publish sites. Communities users with the “Create and Set Up Communities” permission are assigned the role of site administrator in a community’s Site.com site. To let users who don’t have this permission edit the site, you must purchase and assign a Site.com Publisher or a Site.com Contributor feature license. Then you must assign a user role at the site level.
Setting Up Site.com Users About Site.com User Roles Managing Site.com Users and Roles About Site.com Features
SEE ALSO: About Site.com User Roles Managing Site.com Users and Roles
491 Extend Salesforce with Clicks, Not Code Site.com
Setting Up Site.com Users
Before users can access Site.com, you must allocate a Site.com feature license to each user and EDITIONS assign a user role at the site level. The features available when editing a site in Site.com Studio vary depending on these settings. Available in: Salesforce First, review the Site.com feature table for detailed information on the feature license, permissions, Classic (not available in all and role required for each user. orgs) After you’ve determined the appropriate access level required: Available for purchase in: 1. Allocate a feature license to the user by editing the user’s profile. To allocate: Enterprise, Performance, and Unlimited Editions • A Site.com Publisher feature license, select the Site.com Publisher User Available (with limitations) checkbox. in: Developer Edition • A Site.com Contributor feature license, select the Site.com Contributor User checkbox. After you allocate a feature license, users can access Site.com in the Lightning Platform app USER PERMISSIONS menu in the Salesforce header. To create or edit users: Note: If the checkboxes don't appear, verify that Site.com is enabled for your organization. • Manage Internal Users See About Site.com Feature Licenses on page 491.
2. Ensure the “View Setup and Configuration” permission is enabled. All users who create or edit websites in Site.com Studio need this permission. 3. Additionally, ensure that at least one user in your organization has both a Site.com feature license and the “Manage Users” permission. This way, someone can always reallocate user roles if a site’s users are accidentally deleted.
Warning: The “Manage Users” permission is powerful. It allows a user to manage all other users in your organization and not just Site.com.
4. Add users and assign user roles within a site. (When a user with the Site.com Publisher feature license creates a site, the user is automatically allocated the role of site administrator at the site level.) The feature license, permissions, and user role all determine what a user can do in each site. For example, to create an administrative user who can manage all sites in your organization, assign a Publisher feature license and assign the role of site administrator at the site level. For users who need only limited access to edit site content, but no administrative access, assign a Contributor feature license and a contributor role at the site level. Alternatively, to create a user who can manage roles in a site, but without the ability to publish, assign a Publisher feature license, the “Manage Users” permission, and the designer role at the site level.
Note: Any records created by unauthenticated guest users via a Site.com Site has the Site Guest User as the record's owner. Each site has one Site Guest User.
SEE ALSO: About Site.com User Roles
492 Extend Salesforce with Clicks, Not Code Site.com
About Site.com User Roles
Each Site.com user must have a user role assigned at the site level, which controls what each user EDITIONS can do in a site. Users can have only one role per site, but their roles can vary between sites. For example, a person can be a site administrator on one site and a contributor on another. Available in: Salesforce To manage user roles in a site, you must either be the site administrator for that site, or have a Classic (not available in all Site.com feature license and the “Manage Users” permission. orgs)
Note: Users with the “Create and Set Up Experiences” permission are assigned the role of Available for purchase in: site administrator in a community’s Site.com site. However, they don’t appear in the User Enterprise, Performance, Roles section on the Overview tab of Site.com Studio. and Unlimited Editions Users can have one of three roles at the site level: Available (with limitations) in: Developer Edition • Site administrator—Site administrators are users who can create and manage all site content. They can create sites, templates, style sheets, and pages, and also set up domains, publish sites, and assign user roles. This role requires the Site.com Publisher feature license. • Designer—Designers have the same control over site content as site administrators, but they can’t manage domains or publish sites. By default, they can’t assign roles unless they have the “Manage Users” permission. This role requires the Site.com Publisher feature license. • Contributor—Contributors have the most restricted access to content and can typically just edit page text and images. By default, they can’t assign roles unless they have the “Manage Users” permission. This role requires the Site.com Contributor feature license. See the Site.com feature table on page 495 for a detailed list each user role’s capabilities.
SEE ALSO: Managing Site.com Users and Roles Setting Up Site.com Users Setting Up the Contributor’s Studio View About Site.com Feature Licenses
493 Extend Salesforce with Clicks, Not Code Site.com
Managing Site.com Users and Roles
After you create a site, you can add other users and assign roles to them. If you haven’t assigned EDITIONS Site.com feature licenses to your users, you won’t be able to add them to a site.
Note: Communities users with the “Create and Set Up Communities” permission are assigned Available in: Salesforce the role of site administrator in a community’s Site.com site. However, they don’t appear in Classic (not available in all the User Roles section on the Overview tab of Site.com Studio. orgs) When assigning a user role, be sure to add one that’s compatible with the user’s Site.com license. Available for purchase in: When users log into Site.com, their licenses are checked against the role assigned to them at the Enterprise, Performance, site level. If the license doesn’t allow the permissions associated with the role, then the user is given and Unlimited Editions the permissions associated with the license. For example, if a user has a Site.com Contributor feature Available (with limitations) license, but is assigned a role of site administrator, they will only have Contributor permissions in: Developer Edition regardless of the assigned role.
To add users and assign roles: USER PERMISSIONS 1. On the Overview tab in Site.com Studio, click Site Configuration > User Roles. To manage Site.com users: 2. Click Add Users. • Site.com 3. In the Available Users section, highlight the user you want to add. Publisher User field enabled on the user 4. Select the role from the Add as drop-down list. detail page 5. Click the arrow to move the user to the Selected Users section. AND 6. Click Save. Site administrator role To delete users: assigned at the site level 1. In the User Roles view, select the user. 2. Click > Remove. 3. Click OK. To change a user’s role: 1. In the User Roles view, hover over the user’s role. 2. Click the arrow to display all the roles. 3. Select the new role. To delete or change the role of a group of users at the same time, use Bulk Actions. 1. In the User Roles view, select the check box beside each user’s name. 2. Click Bulk Actions. 3. Select the action. 4. Click Apply.
494 Extend Salesforce with Clicks, Not Code Site.com
Note: When updating the roles of several users at once, you can only assign the same role to all selected users.
SEE ALSO: Setting Up Site.com Users Setting Up the Contributor’s Studio View Planning and Implementing a Site.com Website About Site.com Features
About Site.com Features
The features available when editing a site in Site.com Studio vary depending on your Site.com EDITIONS feature license and also your user role for that particular site. This table lists the required feature licenses, permissions, and roles for many of the Site.com Studio Available in: Salesforce features. Classic (not available in all orgs) Note: Available for purchase in: • Communities users with the “Create and Set Up Communities” permission are assigned Enterprise, Performance, the role of site administrator in a community’s Site.com site. and Unlimited Editions • You can’t create, delete, or duplicate community sites in Site.com. Available (with limitations) in: Developer Edition Site.com Studio Feature Requirements Feature Feature Site.com Studio User Permissions License Role Assign feature license to user “Manage Internal profile Users”
Add users and roles at the site Publisher Site administrator Additionally, any level user with a Site.com feature license and the “Manage Users” permission.
Enable contributors to create Publisher Site administrator or pages, add content blocks and designer widgets, and edit content blocks and graphics
Create websites Publisher Users who create a site are automatically added to that site as a site administrator.
Delete websites Publisher Site administrator or designer
Import websites Publisher Users who import a site are automatically added to the
495 Extend Salesforce with Clicks, Not Code Site.com
Site.com Studio Feature Requirements Feature Feature License Site.com Studio User Role Permissions new site as a site administrator.
Export websites Publisher Site administrator or designer
Duplicate websites Publisher Site administrator or designer
Manage domains Publisher Site administrator (Unavailable for Developer Edition)
Add and edit IP restrictions Publisher Site administrator
Publish changes to the live website Publisher Site administrator (Unavailable for Developer Edition)
Create page templates Publisher Site administrator or designer
Create website pages Publisher or Site administrator or designer Contributor Contributor only if enabled by the site administrator or designer in the page template’s Properties pane.
Create and modify style sheets Publisher Site administrator or designer
Modify layout and design Publisher Site administrator or designer
Add page elements Publisher or Site administrator or designer Contributor Contributor can add content blocks and widgets only if enabled by the site administrator or designer.
Add data repeaters and other data-bound page Publisher Site administrator or designer elements
Modify the Guest User profile to set public Publisher Site administrator or designer “Manage Profiles and access permissions to Salesforce objects Permission Sets” and “Customize Application”
Import assets, such as images and files Publisher or Any assigned role Contributor
Edit content and images Publisher or Site administrator or designer Contributor Contributor only if enabled by the site administrator or designer in the page template’s Properties pane.
Preview website pages Publisher or Any assigned role Contributor
496 Extend Salesforce with Clicks, Not Code Site.com
Planning and Implementing a Site.com Website
There are many approaches to building a website. The process that best suits you depends on many EDITIONS factors, such as the size of your team and the tasks you're responsible for. If you're a site administrator or designer, you may be involved in every stage, including adding and Available in: Salesforce maintaining the site's content. Alternatively, you may have contributors who add, edit, and maintain Classic (not available in all this content. And if you're a contributor, you may be responsible for editing and updating all of the orgs) site's content, or you may work with other contributors, designers, and site administrators to bring Available for purchase in: the site to completion. Enterprise, Performance, This topic describes the various stages involved in creating a site with Site.com. and Unlimited Editions • Plan the Site Design and Page Layout (Site administrator or designer)—Before building the Available (with limitations) pages of the site, spend time planning the site design and basic layout. This stage is key to in: Developer Edition ensuring a consistent look and feel with the minimum amount of effort. From a hierarchical point of view, think about how many pages you need and whether they'll have subpages. Also consider how you want site visitors to navigate around your site. USER PERMISSIONS Next, plan the layout of the pages and identify the common elements that every page will have. To create or import Site.com In this example, the site has a header section that includes the company's logo and menu (1), sites: and a footer section (2). However, the main section of the home page (3) differs from the rest • Site.com of the site pages (4). Take note of these similarities and differences, because they will affect Publisher User how you create your site pages. field enabled on the user detail page To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
To edit only content in Site.com sites: • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level
497 Extend Salesforce with Clicks, Not Code Site.com
• Create the Site (Site administrator or designer)—Once you've completed the planning stage, you're ready to get started! Log into the Site.com app and go to the Site.com tab, where you can create your first site. Your new blank site opens in Site.com Studio, a powerful environment for building the pages of your site.
Note: Only users with the Site.com Publisher User field enabled on their user detail page can create and import sites.
• Import Assets (Site administrator or designer)—If you're working with a design agency, they may provide all of the files and assets you need, including a CSS style sheet. If you've created your own design, cut up the design and collect the assets, images, and files you plan to use in the site. Import the assets into Site.com Studio, where they appear in the Assets section of the Overview tab. • Create a Page Template (Site administrator or designer)—Once you've decided on the layout, the quickest and most effective method is to use page templates to build the basic layout and then base your site pages on it. Try to keep the design of your main page template simple to make it easier to modify in the future. For more complicated site designs, such as the example graphic, you can use the main page template as the basis for a child template to achieve maximum flexibility. When you create your page template, you can choose from predesigned layouts that include headers, footers, and columns, or you can create a blank page template. • Lay Out the Page (Site administrator or designer)—After you create the page template, you can modify the layout further to match the design of your site. • Create the Site Pages (Site administrator or designer)—Using the template as a base, you can quickly create the site pages, which automatically inherit all the elements of the page template. Or if you need a standalone page that doesn't follow the site's overall design, you can create a blank page instead. • Add Features and Page Elements (Site administrator or designer)—Use Site.com's prebuilt page elements to add features such as navigation menus, images, and data services, and include content blocks that contributors can edit. And add interactive, animated effects using events and actions. • Make Your Website Look Good (Site administrator or designer)—Take advantage of cascading style sheets (CSS) to develop the look and feel of your website. If you're not completely up to speed with CSS, the Style pane provides an easy, visual way to create and manage styles. Or if you're a CSS expert who likes to get straight into the code, you can hand-code the site's style sheets. • Add and Edit Content (Contributor)—At this stage, if you're a contributor, the site is usually ready for you to add and edit content such as text, images, videos, and hyperlinks. And as you work, you can upload any images or files you need. • Review and Test the Site (Contributor, designer, or site administrator)—Testing the changes to the pages of your site happens throughout the development cycle. As a contributor, designer, or site administrator, you should always preview your changes to ensure they display as expected in a browser. And if you're a site administrator or designer, you can send a preview link to the site's reviewers so they can review the finished product before it goes live. • Publish the Site (Site administrator only)—After testing is complete, you're ready to go live with your new site. Just set the site's domain information and then publish your changes to make your site live!
Site.com Tab Overview
498 Extend Salesforce with Clicks, Not Code Site.com
Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor Understanding the Site Administrator and Designer's Overview Tab Understanding the Contributors's Overview Tab
SEE ALSO: Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor Setting Up the Contributor’s Studio View
499 Extend Salesforce with Clicks, Not Code Site.com
Site.com Tab Overview
If you can't see the Site.com tab, go to the Site.com app. It's available in the Lightning Platform app EDITIONS menu in the Salesforce header. Then click the Site.com tab to view the list of your Site.com sites. From this page you can: Available in: Salesforce • Click New to create or import a site. Only users with the Site.com Publisher User Classic (not available in all field enabled on their user detail page can create and import sites. orgs) • Filter the sites you see by selecting a predefined list from the drop-down list. My Sites shows Available for purchase in: the sites you can access and your role. All Sites shows all the sites in your organization even if Enterprise, Performance, you don’t have access to some of them. and Unlimited Editions • Click Edit next to a site to open it in Site.com Studio. Available (with limitations) • Click Preview next to a site to see how it looks when rendered in a browser window. in: Developer Edition • Click next to a site to duplicate, export, or delete it. Only users with the Site.com Publisher User field enabled on their user detail page and the role of site administrator USER PERMISSIONS or designer can duplicate, export, and delete sites. If a site has been published, you can't delete it until you take it offline. To create or import Site.com • See the status of your site. sites: • Site.com – In Development—The site has never been published. Publisher User – Published—The site has been published at least once. field enabled on the user detail page • Click the title of any column to sort your site list. By default, sites are sorted by name. To build, edit, and manage Note: You can’t create, delete, or duplicate community sites in Site.com. Site.com sites: • Site.com Publisher User SEE ALSO: field enabled on the user detail page Using Site.com Studio as a Site Administrator or Designer AND Using Site.com Studio as a Contributor Site administrator or Planning and Implementing a Site.com Website designer role assigned at the site level
To edit only content in Site.com sites: • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level
500 Extend Salesforce with Clicks, Not Code Site.com
Using Site.com Studio as a Site Administrator or Designer
Site.com Studio provides a dedicated site-building environment for site administrators and designers. EDITIONS Using the many features available, you can: • Create page templates to base your site pages on. Available in: Salesforce • Create site pages. Classic (not available in all orgs) • Import assets, such as images and files. • Edit the site’s style sheet or create new style sheets. Available for purchase in: Enterprise, Performance, • View and edit a page or template. and Unlimited Editions • Add page elements to your site pages to provide features and functionality. Available (with limitations) • Use data services to connect to Salesforce objects to retrieve and display, or to submit data. in: Developer Edition • Create custom widgets that you and other users can reuse throughout the site. • Create a multilingual site that lets site visitors choose their preferred language. USER PERMISSIONS • Create events to add interactive and animated effects to your website. • Add IP restrictions to control site visitors’ access to the pages, page templates, folders, and To build, edit, and manage sites Site.com sites: assets in your site. • Site.com • Add URL redirects to inform users and search engines if site content has moved. Publisher User • Create folders to organize your site content. field enabled on the user detail page • Preview your site or generate an anonymous preview link to send to other users. AND • Manage the domain information for your site. Site administrator or • Publish your recent changes to the live site. designer role assigned • Duplicate, import, and export sites. at the site level
Note: To manage domains and • Designers can’t manage domains or publish content. publish Site.com sites: • Site.com • You can’t create, delete, or duplicate community sites in Site.com. Publisher User field enabled on the user detail page SEE ALSO: AND Understanding the Site Administrator and Designer's Overview Tab Site administrator role Planning and Implementing a Site.com Website assigned at the site level Setting Up the Contributor’s Studio View Site.com Tab Overview
501 Extend Salesforce with Clicks, Not Code Site.com
Using Site.com Studio as a Contributor
Site.com Studio provides a dedicated content-editing environment for contributors, where you EDITIONS can: • Open a page to edit it. Available in: Salesforce • Create site pages, if your site administrator or designer has enabled page creation. Classic (not available in all orgs) • Edit the page text. • Add images and hyperlinks to pages. Available for purchase in: Enterprise, Performance, • Add page elements to pages. and Unlimited Editions • Import assets, such as images and files. Available (with limitations) • Preview the site in a browser window. in: Developer Edition
SEE ALSO: USER PERMISSIONS Understanding the Contributors's Overview Tab Planning and Implementing a Site.com Website To edit only content in Site.com sites: Site.com Tab Overview • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level
502 Extend Salesforce with Clicks, Not Code Site.com
Understanding the Site Administrator and Designer's Overview Tab
As a site administrator or designer, when you open a site in Site.com Studio, it opens on the Overview EDITIONS tab. Here you can access and manage the site’s components and configure the site’s properties. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
To manage domains and publish Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator role assigned at the site level
To manage user roles: • Site.com Publisher User field enabled on the user detail page AND Site administrator role assigned at the site level OR Manage Users
503 Extend Salesforce with Clicks, Not Code Site.com
• Select a view (1) on the Overview tab to view its contents (2). – All Site Content—Create folders to organize your site content. In this view, you can also create pages, templates, and style sheets, and import assets. – Site Pages—Create site pages, open and edit pages, access page options, create site map links, and organize the site map. You can also switch between the default site map view ( ) and the list view ( ). – Page Templates—Create page templates to base your site pages on, open and edit existing templates, and access template options. – Style Sheets—Edit the site’s style sheet or create new style sheets. – Assets—Import and manage assets, such as images and files. – Widgets—Build custom widgets that can you and your team can reuse throughout the site. – Trash Can—Retrieve deleted items. When you delete a page, template, style sheet, or asset, it goes into the trash can. Deleted items remain in the trash can indefinitely. Retrieved items are restored to their original location. If the original location no longer exists, they are restored to the top-level root directory. – Change History—View information about recently published files. – Site Configuration—Configure site properties, add IP restrictions, create URL redirects, manage domain information, manage user roles, and add and manage site languages.
• Use the toolbar (3) to: – Import assets, such as images and files. – Publish recent changes. – Preview your site or generate an anonymous preview link to send to other users. – Duplicate or export the site, overwrite the site with a version from sandbox, or create a new site ( ).
• Use the site's pull-down menu (4) to:
504 Extend Salesforce with Clicks, Not Code Site.com
– Open recently accessed sites. – View Site.com Studio as your contributors see it to ensure that you set up the view correctly. – Exit Site.com Studio and return to Salesforce. – Create a new site. – Duplicate the site.
Note: You can’t create, delete, or duplicate community sites in Site.com.
SEE ALSO: Using Site.com Studio as a Site Administrator or Designer Planning and Implementing a Site.com Website Site.com
Understanding the Contributors's Overview Tab
As a contributor, when you open a site in Site.com Studio, it opens on the Overview tab. Here you EDITIONS can access and edit the site’s pages and content, and import images and files. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To edit only content in Site.com sites: • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level
505 Extend Salesforce with Clicks, Not Code Site.com
• Select a view (1) on the Overview tab to view its contents (2). – All Site Content—View all of the site’s pages, images, and files. – Site Pages—View and edit pages or create site pages, if available. – Assets—Import assets, such as images and files. – Site Configuration—Manage user roles in the site. This is available only if you have the “Manage Users” perm.
• Use the toolbar (3) to: – Import assets, such as images and files. – Preview the site in a browser window.
• Use the site's pull-down menu (4) to: – Open recently accessed sites. – Exit Site.com Studio and return to Salesforce.
SEE ALSO: Using Site.com Studio as a Contributor Site.com
Create a Site.com Community Each community has one associated Site.com site that lets you add custom, branded pages to your community. By default, Site.com pages are publicly available and don’t require login, but you can also create private pages that only community members can access.
Note: As of Spring ’15, the Community Template is no longer available for creating communities. If you already have a Site.com community that’s based on the Community Template, it will continue to work. For information on creating a community with a new Lightning Community template, see Create an Experience Cloud Site.
506 Extend Salesforce with Clicks, Not Code Site.com
Before You Begin Communities users with the “Create and Set Up Communities” permission automatically have full site administrator access to a community’s Site.com site. To let users who don’t have the permission edit the site, you must purchase and assign a Site.com Publisher or a Site.com Contributor feature license. And then you must assign a user role at the site level. See About Site.com User Roles on page 493.
Tips and Considerations • Users with the “Create and Set Up Experiences” permission are assigned the role of site administrator in a community’s Site.com site. However, they don’t appear in the User Roles section on the Overview tab of Site.com Studio. • You can’t create, delete, or duplicate community sites in Site.com. • When working with data-bound components, such as data repeaters and forms, keep in mind that the objects listed may not be available to site visitors. For authenticated visitors, their user profiles control object access on public and private pages. For unauthenticated visitors, the site’s guest user profile controls object access on public pages. • When adding forms to authenticated community pages in Site.com, set the current user for Salesforce objects that require the Owner ID field. Setting the current user (as opposed to the default guest user) lets you identify the authenticated user when the form is submitted. To set the current user for the Owner ID field, select the field in the form, and click Configure. Under Field Properties in the Properties pane, select Global Property as the source, and select Current userID as the value. • The home page, 404 page, login page, and self-registration page that you specify for Site.com Community sites in Site Configuration set the default pages for the Site.com Community site. These default URLs are used unless you specify different URLs in Community Management under Administration Pages and Administration Login & Registration . Community error pages are specified in Lightning Platform Setup, under Error Pages. • When your Site.com Community site is inactive, users are redirected to the Service Not Available page defined in Community Management under Pages. • The contributor’s view is not available by default for Site.com Community sites. However, you can use a Site.com Contributor license to grant contributor access to a specific user. See About Feature Licenses in the Site.com help for details. Alternatively, a user can preview the Site.com Community site as a contributor by appending ?iscontrib to the site’s URL. For example: MyDomainName.builder.salesforce-experience.com/?iscontrib
Use Site.com to Customize Your Community Create Branded Pages Overview When you create a Community site, Salesforce automatically creates a new Site.com site and associates it with your community. Site.com Authorization Overview Display Current Community User Information Site.com designers creating authenticated pages for a community site can display the current user’s information by accessing CurrentUser namespace expressions. Expressions Available for Displaying Current User Information Determine the URL of a Site.com Page Add Authenticated Site.com Pages to Community Tabs After you create a private Site.com page, you can add the page to a tab in your community. Add Chatter News or Group Feeds to Community Site.com Pages Use the Chatter News Feed to display a Chatter feed on your site pages, or display the feeds of a particular group using the Chatter Group Feed.
507 Extend Salesforce with Clicks, Not Code Site.com
Improve Performance with HTML Page Caching for Communities in Site.com HTML caching lets you improve the performance and page rendering of your community’s Site.com site by controlling how often the generated markup of the page is reloaded.
SEE ALSO: Use Site.com to Customize Your Community Set Up and Manage Experience Cloud Sites
Use Site.com to Customize Your Community
Communities users can use Site.com to build custom, branded pages for a community. There are EDITIONS many approaches to building custom pages for your community, but these are some of the typical stages involved: Available in: Salesforce • Import Assets—Collect the assets, images, and files you plan to use on your custom page. Classic (not available in all Import the assets into Site.com Studio, where they appear in the Assets section of the Overview orgs) tab. Available for purchase in: • Create Branded Pages—The quickest and easiest way to create branded pages is to use the Enterprise, Performance, Community Template, which is automatically included with all Site.com community sites. When and Unlimited Editions you create a new page based on the Community Template, the page includes all of the branded Available (with limitations) styles in your community, including the community’s header and footer. If you want even more in: Developer Edition control over the look and feel of your community page, you can create your own page template, drag community headers and footers to it from the Widgets section of the Page Elements pane, and add other community styles. USER PERMISSIONS
Note: As of Spring ’15, the Community Template is no longer available for creating To build, edit, and manage communities. If you already have a Site.com that’s based on the Communities Template, a community’s Site.com it will continue to work. For information on creating a community with a new Lightning custom pages: Community template, see Create an Experience Cloud Site. • Create and Set Up Communities • Use Branded CommunityStyles—Develop the look and feel of your custom pages by using OR the CommunityBranding style sheet, or by creating branded community styles in your own cascading style sheets (CSS). If you're not completely up to speed with CSS, the Style pane Site.com Publisher User provides an easy, visual way to create and manage styles. Or if you're a CSS expert who likes to field enabled on the user get straight into the code, you can hand-code community styles right in your own style sheets. detail page • Create Public Pages—Using the template as a base, you can quickly create pages, which AND automatically inherit all the elements of the page template. Or if you need a standalone page that doesn't follow the overall design, you can create a blank page instead. Site administrator or designer role assigned • Make Pages Private—By default, any page you create in Site.com Studio is publicly available. at the site level However, you can make pages private so that only logged-in Communities users can access them. • Add Features, Page Elements, and Community Widgets—Use Site.com's prebuilt page elements to add features such as navigation menus, images, content blocks, and community widgets. Retrieve data from your organization’s objects and dynamically display it on your site pages using data repeaters and data tables. Alternatively, gather and submit data from visitors using forms. • Add and Edit Content—At this stage, the page is usually ready for you to add and edit content such as text, images, videos, and hyperlinks. And as you work, you can upload any images or files you need.
508 Extend Salesforce with Clicks, Not Code Site.com
• Review and Test the Page—Testing the changes to your page happens throughout the development cycle. You should always preview your changes to ensure they display as expected in a browser. You can also send a preview link to reviewers so they can review the finished product before it goes live. • Publish the Page—After testing is complete, you're ready to make the page available to your community by publishing your changes. • Add Authenticated Pages to Your Community’s Tab—Now that the page is tested and published, if you’re working with authenticated pages, the final step is to add the page to a tab in your community. • Use Site.com in Sandbox—Site.com is now available on sandbox. When you create a sandbox copy from a production organization, you can include your Site.com sites. You can also copy your sandbox site back to production using the overwrite feature.
SEE ALSO: Create a Site.com Community Set Up and Manage Experience Cloud Sites Brand Your Salesforce Tabs + Visualforce Site
Create Branded Pages Overview
When you create a Community site, Salesforce automatically creates a new Site.com site and EDITIONS associates it with your community. With Site.com Community sites you can: Available in: Salesforce Classic (not available in all • Use the branded Community template to create Site.com pages for your community. orgs) Note: As of Spring ’15, the Community Template is no longer available for creating Available for purchase in: communities. If you already have a Site.com that’s based on the Communities Template, Enterprise, Performance, it will continue to work. For information on creating a community with a new Lightning and Unlimited Editions Community template, see Create an Experience Cloud Site. Available (with limitations) • Use the CommunityBranding style sheet to style Site.com pages by using CSS. in: Developer Edition • Create your own community CSS styles using a number of available Network namespace expressions.
Create Branded Pages from the Community Template Site.com Community sites include a branded template that you can use to create new community site pages. Apply Community Styles from the CommunityBranding Style Sheet The CommunityBranding style sheet contains a set of CSS styles created from Network namespace expressions. Create Styles in a CSS Style Sheet Branded styles are available in Site.com sites through Network namespace expressions. Expressions Available for Community Branding View the CommunityBranding Style Sheet The CommunityBranding style sheet contains a set of branded styles from your community.
509 Extend Salesforce with Clicks, Not Code Site.com
Create Branded Pages from the Community Template
Site.com Community sites include a branded template that you can use to create new community EDITIONS site pages.
Note: As of Spring ’15, the Community Template is no longer available for creating Available in: Salesforce communities. If you already have a Site.com community that’s based on the Community Classic (not available in all Template, it will continue to work. For information on creating a community with a new orgs) Lightning Community template, see Create an Experience Cloud Site. Available for purchase in: The styles for the Community Template come from the CommunityBranding style Enterprise, Performance, sheet, which is automatically included for all new Site.com Community sites. and Unlimited Editions To create branded pages from the Community Template: Available (with limitations) in: Developer Edition 1. On the Site.com Overview tab, hover over Site Pages and click New. 2. Type the new community page name. Page names can’t include spaces or special characters, such as #, ?, or @. USER PERMISSIONS 3. Make sure Community Template is selected for the page template. To build, edit, and manage a community’s Site.com 4. Click Create. custom pages: Note: • Create and Set Up Communities • Community branding options, such as headers, footers, and page colors, are set from the OR Administration > Branding section on the Experience Management page. Site.com • Empty community headers and footers, or headers that contain only images, won’t work Publisher User in Site.com. Be sure to specify customized HTML blocks for your community headers and field enabled on the user footers if you’re creating Site.com pages from the Community Template, or creating detail page community headers and footers using Network namespace expressions. AND • Community headers and footers are available as widgets in Site.com community pages. Site administrator or To add a community header or footer to a blank page, drag it to the page from the Widgets designer role assigned section of the Page Elements pane. at the site level
SEE ALSO: Create Branded Pages Overview View the CommunityBranding Style Sheet Site.com Page Templates Overview Creating Site.com Page Templates
510 Extend Salesforce with Clicks, Not Code Site.com
Apply Community Styles from the CommunityBranding Style Sheet
The CommunityBranding style sheet contains a set of CSS styles created from Network EDITIONS namespace expressions.
Note: As of Spring ’15, the Community Template is no longer available for creating Available in: Salesforce communities. If you already have a Site.com community that’s based on the Community Classic (not available in all Template, it will continue to work. For information on creating a community with a new orgs) Lightning Community template, see Create an Experience Cloud Site. Available for purchase in: The CommunityBranding style sheet is attached to the Community Template, and is Enterprise, Performance, responsible for the template’s branded look and feel. You can access the styles in the and Unlimited Editions CommunityBranding style sheet and apply them directly to elements on any page. Available (with limitations) in: Developer Edition To apply community styles using the CommunityBranding style sheet: 1. Make sure the CommunityBranding style sheet is attached to the Site.com page you want to brand. USER PERMISSIONS
Note: All Site.com pages based on the Community Template automatically have To build, edit, and manage the CommunityBranding style sheet attached to them. a community’s Site.com custom pages: 2. Select the element on the page you want to style. • Create and Set Up 3. Open the Style pane. Communities OR 4. Select Class. Site.com 5. Start typing “brand”. Publisher User A list of all of the available styles in the CommunityBranding styles sheet appears. field enabled on the user 6. Select the style you want to apply. detail page AND SEE ALSO: Site administrator or designer role assigned Create Branded Pages Overview at the site level Create Branded Pages from the Community Template View the CommunityBranding Style Sheet Creating and Using CSS Style Sheets
511 Extend Salesforce with Clicks, Not Code Site.com
Create Styles in a CSS Style Sheet
Branded styles are available in Site.com sites through Network namespace expressions. EDITIONS You can access a full list of available Network namespace expressions to create new community styles in any CSS style sheet. When you add an expression to a CSS rule, Site.com “pulls in” the style Available in: Salesforce as it’s defined in the community, and displays it on your page. Classic (not available in all orgs) To create community styles in a CSS style sheet: 1. Open an existing style sheet or create a new style sheet. (See Creating and Using CSS Style Available for purchase in: Sheets on page 584.) Enterprise, Performance, and Unlimited Editions 2. Click Edit Style Sheet Code. Available (with limitations) 3. Add a new community style rule by using any of the available Network expressions. You can in: Developer Edition create both ID styles and class styles. For example:
USER PERMISSIONS
To build, edit, and manage a community’s Site.com custom pages: • Create and Set Up Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
#main_content_block { background-color: {!Network.primaryColor}; color: {!Network.primaryComplementColor}; } .secondary_content_blocks{ background-color: {!Network.zeronaryColor}; color: {!Network.zeronaryComplementColor}; }
4. Apply the new styles to elements on other pages.
512 Extend Salesforce with Clicks, Not Code Site.com
Note: Remember, the style sheet that contains your community styles must be attached to the page containing your styled elements.
SEE ALSO: Create Branded Pages Overview Expressions Available for Community Branding Creating and Using CSS Style Sheets
Expressions Available for Community Branding
You can use the Network namespace expressions listed on this page to create your own EDITIONS Community styles. Community branding options, such as headers, footers, and page colors, are set from the Available in: Salesforce Administration > Branding section on the Experience Management page. Classic (not available in all orgs) Note: Available for purchase in: • Empty community headers and footers, or headers that contain only images, won’t work Enterprise, Performance, in Site.com. Be sure to specify customized HTML blocks for your community headers and and Unlimited Editions footers if you’re creating Site.com pages from the Community Template, or creating community headers and footers using Network namespace expressions. Available (with limitations) in: Developer Edition • Community headers and footers are available as widgets in Site.com community pages. To add a community header or footer to a blank page, drag it to the page from the Widgets section of the Page Elements pane.
Network Expression Corresponding Community Branding Page Element {!Network.header} Custom content of the community header.
{!Network.footer} Custom content of the community footer.
{!Network.zeronaryColor} The background color for the community header.
{!Network.zeronaryComplementColor} The font color used with zeronaryColor.
{!Network.primaryColor} The color used for active tabs in the community.
{!Network.primaryComplementColor} The font color used with primaryColor.
{!Network.secondaryColor} The color used for the top border of lists and tables in the community.
{!Network.tertiaryColor} The background color for section headers on edit and detail pages in the community.
{!Network.tertiaryComplementColor} The font color used with tertiaryColor.
{!Network.quaternaryColor} The background color for pages in the community.
513 Extend Salesforce with Clicks, Not Code Site.com
Network Expression Corresponding Community Branding Page Element {!Network.quaternaryComplementColor} The font color used with quaternaryColor.
SEE ALSO: Create Branded Pages Overview Create Styles in a CSS Style Sheet
View the CommunityBranding Style Sheet
The CommunityBranding style sheet contains a set of branded styles from your community. EDITIONS Community branding options, such as headers, footers, and page colors, are set from the Administration > Branding section on the Experience Management page. Available in: Salesforce Classic (not available in all To see the Community styles in the CommunityBranding style sheet, on the Site.com Overview orgs) tab, click Style Sheets, and click the CommunityBranding style sheet. The Community styles are listed on the left. To see the code for the style sheet, click Edit Style Sheet Code. Available for purchase in: Enterprise, Performance, A total of fourteen Community class styles are provided. These are the default contents of the style and Unlimited Editions sheet: Available (with limitations) in: Developer Edition
.brandZeronaryBgr { background-color: {!Network.zeronaryColor} !important; } .brandZeronaryFgr { color: {!Network.zeronaryComplementColor} !important; } .brandPrimaryBgr { background-color: {!Network.primaryColor} !important; } .brandPrimaryFgr { color: {!Network.primaryComplementColor} !important; } .brandPrimaryBrd2 { border-color: {!Network.primaryComplementColor} !important; } .brandPrimaryFgrBrdTop { border-top-color: {!Network.primaryComplementColor} !important; } .brandPrimaryBrd { border-top-color: {!Network.primaryColor} !important; } .brandSecondaryBrd { border-color: {!Network.secondaryColor} !important; } .brandSecondaryBgr { background-color: {!Network.secondaryColor} !important; } .brandTertiaryFgr {
514 Extend Salesforce with Clicks, Not Code Site.com
color: {!Network.tertiaryComplementColor} !important; } .brandTertiaryBgr { background-color: {!Network.tertiaryColor} !important; color: {!Network.tertiaryComplementColor} !important; background-image: none !important; } .brandTertiaryBrd { border-top-color: {!Network.tertiaryColor} !important; } .brandQuaternaryFgr { color: {!Network.quaternaryComplementColor} !important; } .brandQuaternaryBgr { background-color: {!Network.quaternaryColor} !important; }
SEE ALSO: Create Branded Pages Overview Create Branded Pages from the Community Template
Site.com Authorization Overview
As part of your site design, you might want to control what content is public and private to your EDITIONS site visitors. New sites are initially set so that all site resources, such as folders and pages, are public. You can change the default setting from the Authorization view found under Site Configuration. Available in: Salesforce The global site authorization options are: Classic • No Authorization (default)—All resources are public. Available in: Enterprise, • Requires Authorization—All resources are private. Performance, Unlimited, and Developer Editions • Custom—All resources are public by default, but can be made private. The No Authorization and Requires Authorization options let you quickly make your site either all public or all private. But, if you want to control access to individual pages, folders, and other resources, use the Custom option. Selecting Custom enables a Requires Authorization checkbox on the Actions menu for all resources throughout the site. You can define authorization at the site, folder, page, and individual resource level. As you mark items for authorization, a lock icon appears on them. After a resource, like a page, is marked as private, users who aren’t logged into Salesforce are asked to log in when they try to access it. Resources can inherit their privacy setting from folders. For example, when a resource, such as a site folder, is marked for authorization, anything placed in that folder inherits the folder’s authorization setting and becomes private. If you drag that resource into a public folder, it becomes public again. But, if you explicitly mark a resource as private using the Actions menu, and then drag it into a public folder, it still remains private because the privacy setting at the resource level dominates. When you use the Custom option, an authorization table appears in the Authorization view that lets you manage your private resources/items marked as private. You can remove authorization from a resource by either deleting it from the authorization table, or by deselecting the Requires Authorization box on the item itself.
Setting Custom Authorization
515 Extend Salesforce with Clicks, Not Code Site.com
Removing Site.com Authorization
SEE ALSO: Setting Custom Authorization Removing Site.com Authorization
Setting Custom Authorization
When you select Custom authorization, you get a great deal of flexibility in controlling access to EDITIONS your site. Not only can you control who has access to top level resources, like folders and pages, but you can also set access at the individual resource level. Available in: Salesforce Using Custom authorization at the folder level is a great way to make a large number of resources Classic private without having to mark them individually. Let’s say you periodically run sale offers for your Available in: Enterprise, paid users. If you drag all the sale pages into a special folder you mark for authorization, they instantly Performance, Unlimited, inherit the folder’s setting. Users will need to log in to access them. Plus, if you decide to make one and Developer Editions of the sale pages available to everyone, you can simply drag it back into a public folder, or to the root of the All Site Content area. USER PERMISSIONS 1. Open you site for editing. 2. Click Site Configuration > Authorization. To manage authorization: • You must be an 3. Select Custom. administrative user on 4. Click All Site Content. the site 5. Create a folder to hold the private pages if it doesn’t already exist. 6. From the folder’s Actions menu, select Requires Authorization. You’ll see the lock appear on the folder. It is now private. 7. Drag any pages you want to make private into the folder. A lock appears on them too.
Example: Let’s take another example. If you have a page that you’d like to keep private no matter where it resides, you can set its authorization using the Actions menu. After you set it at the individual resource level, it remains private even if you drag it into a folder that isn’t set to private. In other words, an resource marked private is always private until you deselect Requires Authorization on the Actions menu. If you check the Authorization page, you’ll see all folders and resources marked private are listed in the authorization table where you can view and delete them.
SEE ALSO: Removing Site.com Authorization
516 Extend Salesforce with Clicks, Not Code Site.com
Removing Site.com Authorization
You can remove authorization for a resource by either deleting it from the authorization table under EDITIONS Site Configuration, or by deselecting Requires Authorization from the menu. 1. Open your site for editing. Available in: Salesforce Classic 2. Click Site Configuration > Authorization. 3. From the authorization table, click Delete next to the item you want to remove. Alternatively, Available in: Enterprise, Performance, Unlimited, navigate to the All Site Content view. Select the resource. From the Actions menu, deselect and Developer Editions Requires Authorization.
Example: If a resource is explicitly marked as private using the Actions menu, then you must USER PERMISSIONS remove authorization from it using the Actions menu. For example, if a page marked private is dragged into a folder that’s public, it remains private. Likewise, if you drag it into a folder To manage authorization: that’s already private, and remove the authorization on that folder, the page will still be private. • You must be an administrative user on the site SEE ALSO: Setting Custom Authorization
Display Current Community User Information
Site.com designers creating authenticated pages for a community site can display the current user’s EDITIONS information by accessing CurrentUser namespace expressions. 1. Open the page on which you want to display the current community user's information. Available in: Salesforce Classic (not available in all 2. From the Page Elements pane, drag a Content Block or Custom Code page element onto orgs) the page. 3. Type {!CurrentUser. and the value that you want to display. Available for purchase in: For example, {!CurrentUser.firstName}. Enterprise, Performance, and Unlimited Editions Check the list of available expressions for displaying current user information. Available (with limitations) 4. Add any additional text you require. in: Developer Edition For example, Welcome back {!CurrentUser.firstName}!. 5. If you’re in a Content Block, click Save. If you’re in a Custom Code element, click Save and USER PERMISSIONS Close. To build, edit, and manage Note: If an unauthenticated user views a page that contains CurrentUser expressions, a community’s Site.com the current user information does not appear. For example, if an unauthenticated user viewed custom pages: a page that contained the above example, the user would see “Welcome back !” as the • Create and Set Up welcome message. Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
517 Extend Salesforce with Clicks, Not Code Site.com
Expressions Available for Displaying Current User Information
Use these CurrentUser namespace expressions to display authenticated user information on EDITIONS a Site.com community page. Available in: Salesforce CurrentUser Expression Displays Classic (not available in all {!CurrentUser.name} Combined first and last name of the user, as orgs) displayed on the user detail page. Available for purchase in: Enterprise, Performance, {!CurrentUser.firstName} First name of the user, as displayed on the user and Unlimited Editions edit page. Available (with limitations) {!CurrentUser.lastName} Last name of the user, as displayed on the user in: Developer Edition edit page.
{!CurrentUser.userName} Administrative field that defines the user’s login.
{!CurrentUser.email} Email address of the user.
{!CurrentUser.communityNickname} Name used to identify the user in a community.
{!CurrentUser.accountId} The account Id associated with the user. It shows a valid account id for Partner and Customer users. For all others, it is empty '000000000000000'.
{!CurrentUser.effectiveAccountId} The account Id associated with the effective account. It shows a valid account id for Partner and Customer users. For all others, it is empty '000000000000000'.
518 Extend Salesforce with Clicks, Not Code Site.com
Determine the URL of a Site.com Page
After you create a Site.com page, you can determine the page’s URL to: EDITIONS • Provide your users with a URL that lets them access a public page directly. • Create a link to the page from other pages, including Salesforce Sites and Visualforce pages. Available in: Salesforce Classic (not available in all • Make it the home page for your community using a URL redirect in Salesforce Sites. orgs) and Lightning • Add a private page to a web tab in your community. Experience
1. To determine the correct URL for the page: Available in: Enterprise, • From the Create Community wizard, click Customize. Performance, Unlimited, and Developer Editions • If you navigated away from the Create Community wizard, click Customize > Communities > All Communities, then click the Manage button next to the community name. USER PERMISSIONS
2. Click Administration Settings. To build, edit, and manage 3. Copy the URL displayed on the page and paste it into a text editor. a community’s Site.com custom pages: 4. To create a URL that points to: • Create and Set Up • The Site.com site’s home page, append /s/ to the URL. For example, Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
https://MyDomainName.my.site.com/ExperienceCloudSiteName/s/. • A specific Site.com page, append /s/, where is the name of the Site.com page. For example, https://MyDomainName.my.site.com/ExperienceCloudSiteName/s/promotion. The URL is case-sensitive and “s” must be lowercase.
Note: If you’re not using enhanced domains, your org’s Experience Cloud sites URL is different. For details, see My Domain URL Formats in Salesforce Help.
SEE ALSO: Add Authenticated Site.com Pages to Community Tabs Salesforce Sites URL Redirects
519 Extend Salesforce with Clicks, Not Code Site.com
Add Authenticated Site.com Pages to Community Tabs
After you create a private Site.com page, you can add the page to a tab in your community. EDITIONS In this case, you need to create a Web tab that points to your Site.com page. 1. In the Properties pane for your page, select Show Salesforce Header. Available in: Salesforce Classic (not available in all Selecting this option ensures that you see tabs in your community. orgs) and Lightning 2. Enter the tab name as it should appear on the tab in your community. Experience The web tab you create must have the same name. Available in: Enterprise, Performance, Unlimited, 3. Determine the correct URL for the page. and Developer Editions The URL must be in the following format https://MyDomainName.my.site.com/mycommunity/s/, USER PERMISSIONS where pagename matches the name of your page. To build, edit, and manage Note: If you’re not using enhanced domains, your org’s Experience Cloud sites URL is a community’s Site.com different. For details, see My Domain URL Formats in Salesforce Help. custom pages: 4. From Setup, enter Tabs in the Quick Find box, then select Tabs. • Create and Set Up Communities 5. In Web Tabs, click New and enter the name of the tab as it appears in the Tab Name field in OR your page properties. Site.com 6. On the Step 3 screen, paste the URL you created in the Button or Link URL text box. Publisher User 7. Return to the Create Community wizard and add the new tab to your community. field enabled on the user detail page To preview the private page in your community, you must publish your Site.com site. AND Note: You can’t publish your site from sandbox. Site administrator or designer role assigned at the site level SEE ALSO: Set Up and Manage Experience Cloud Sites Create Web Tabs My Domain URL Formats
520 Extend Salesforce with Clicks, Not Code Site.com
Add Chatter News or Group Feeds to Community Site.com Pages
Use the Chatter News Feed to display a Chatter feed on your site pages, or display the feeds of a EDITIONS particular group using the Chatter Group Feed. 1. Drag the News Feed or Group Feed from the Widgets section of the Page Elements pane Available in: Salesforce onto the page. Classic (not available in all When you add a widget to a page, it creates a copy or instance of the widget. You can’t edit orgs) and Lightning the content of a widget, but you can edit the properties. Experience 2. If you’re adding a group feed, enter the Group ID in the Properties pane. Available in: Enterprise, The Group ID determines which group feed is displayed on your page. You can include more Performance, Unlimited, than one group feed on a page if you want to show the feeds for multiple groups. and Developer Editions
3. Preview the page to test the feed, or use Live Mode to see how the feed renders in different USER PERMISSIONS mobile devices. Consider the following limitations when using a news or group feed in your community Site.com To build, edit, and manage sites: a community’s Site.com custom pages: • Chatter news and group feeds only appear if a user is logged in to the community. They don’t • Create and Set Up appear to guest users or in anonymous preview mode. Communities • Chatter news and group feeds may not render appropriately on pages less than 700px wide. OR We recommend a minimum page width of 700px to view full content. We also recommend Site.com using a white background. Publisher User • Chatter news and group feeds only inherit some page branding elements. field enabled on the user detail page AND Site administrator or designer role assigned at the site level
521 Extend Salesforce with Clicks, Not Code Site.com
Improve Performance with HTML Page Caching for Communities in Site.com
HTML caching lets you improve the performance and page rendering of your community’s Site.com EDITIONS site by controlling how often the generated markup of the page is reloaded. Lets say 100 people visit the page at the same time. Without caching, the page makes 100 separate Available in: Salesforce requests for the same markup, slowing performance considerably. However, with caching enabled, Classic (not available in all the page markup is requested and retrieved only once—the first time someone visits the page. orgs) Any subsequent page requests during a set time period are returned from the cache. When the Available for purchase in: specified time period expires, the cache is refreshed. Enterprise, Performance, Note: The caching duration applies only to community pages that are accessed by guest and Unlimited Editions users. When a user logs in to access the page, caching is disabled. Available (with limitations) in: Developer Edition 1. In Site.com Studio, open the page. 2. In the Cache Duration (Minutes) field of the Cache section of the Properties tab, specify the length of time to cache the page. USER PERMISSIONS By default, the caching duration of a page is set to 30 minutes. To build, edit, and manage To disable caching, set the page’s caching duration to 0. a community’s Site.com custom pages: • Create and Set Up Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
522 Extend Salesforce with Clicks, Not Code Site.com
Creating a Site.com Site
To get started with Site.com, create a new blank site: EDITIONS 1. On the Site.com tab in the Site.com app, click New. Alternatively, in Site.com Studio, click Create a New Site in the site's drop-down menu. Available in: Salesforce Classic (not available in all 2. Click Create a Blank Website. orgs) 3. Enter the site name. Available for purchase in: 4. Click Create. Your new website opens in Site.com Studio, where you can create page templates Enterprise, Performance, and site pages, and add functionality to it. and Unlimited Editions Note: You can’t create, delete, or duplicate community sites in Site.com. Available (with limitations) in: Developer Edition
Deleting a Site.com Site Duplicating a Site.com Site USER PERMISSIONS Exporting a Site.com Site To create or import Site.com sites: Importing a Site.com Site • Site.com Configuring Site Properties Publisher User Enable Clickjack Protection in Site.com field enabled on the user detail page Clickjacking is a type of attack that tricks users to click something, such as a button or link, because they perceive they are clicking something safe. Instead, the button or link performs malicious actions on your site, leading to data intrusion, unauthorized emails, changed credentials, or other site-specific results. Site.com Versioning Overview Each time you publish your site, it’s tracked as a version. You can restore your site back to one of the previously published versions. You can’t select individual components when restoring; you must restore the complete site. Creating URL Redirects in Site.com If you move or reorganize pages in your site, search engines may have trouble finding the new page locations. To avoid this, set up URL redirects to inform users and search engines that site content has moved. Importing External Websites into Site.com With Site.com Studio, you can import your existing website and recreate it automatically as a Site.com site. This saves you the time of having to re-code existing HTML pages. Copying and Overwriting a Site Sometimes, you might want to copy and replace your current production Site.com or Site.com community site with another site. Using the Metadata API to Deploy a Site As a user, you can migrate a site from sandbox to production. You can use the Metadata API to create a deployable package for Site.com sites and Site.com Communities sites.
SEE ALSO: Creating Site.com Page Templates Creating Site.com Pages Editing Site.com Pages as a Designer or Site Administrator
523 Extend Salesforce with Clicks, Not Code Site.com
Deleting a Site.com Site
You can delete any site that isn’t published. If the site is published, you must first unpublish it before EDITIONS you can delete it. See Taking a Site Offline on page 669. 1. On the Site.com tab in the Site.com app, select the site and click > Delete. Available in: Salesforce Classic (not available in all 2. Click OK. orgs) Note: You can’t create, delete, or duplicate community sites in Site.com. Available for purchase in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Exporting a Site.com Site Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
524 Extend Salesforce with Clicks, Not Code Site.com
Duplicating a Site.com Site
To create a copy of a site: EDITIONS 1. On the Site.com tab in the Site.com app, select the site and click > Duplicate. Alternatively, Available in: Salesforce on the Overview tab in Site.com Studio, click > Duplicate This Site. Classic (not available in all 2. Enter a name for the site. orgs) 3. Click Create. Available for purchase in: Enterprise, Performance, Note: and Unlimited Editions • If you’re creating a copy of a site that uses data services, you must set the data access Available (with limitations) permissions in the new site’s guest user profile. in: Developer Edition • You can’t create, delete, or duplicate community sites in Site.com.
USER PERMISSIONS SEE ALSO: To build, edit, and manage Creating a Site.com Site Site.com sites: Exporting a Site.com Site • Site.com Importing a Site.com Site Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
525 Extend Salesforce with Clicks, Not Code Site.com
Exporting a Site.com Site
You can export your site from Site.com to your hard drive. The site is exported in a packaged format EDITIONS with a .site extension, which you can import into another Salesforce organization. The maximum site size you can import is 2 GB. Available in: Salesforce 1. On the Site.com tab in the Site.com application, select the site and click > Export. Classic (not available in all orgs) Alternatively, on the Overview tab in Site.com Studio, click > Export This Site. Available for purchase in: 2. If the site is: Enterprise, Performance, • Smaller than 100 MB, select a location to save the exported .site file on your hard drive and and Unlimited Editions click Save. Available (with limitations) • Larger than 100 MB, you’ll receive an email when the export process has completed. Click in: Developer Edition the link in the email to download the exported .site file.
Note: USER PERMISSIONS
• Exporting a site doesn’t remove it from the current organization. To build, edit, and manage Site.com sites: • Site.com SEE ALSO: Publisher User Creating a Site.com Site field enabled on the user detail page Importing a Site.com Site AND Site administrator or designer role assigned at the site level
Importing a Site.com Site
You can import an exported Site.com site into your organization. The maximum site size you can EDITIONS import is 2 GB. When you import a site, you are given the site administrator role in the site. 1. On the Site.com tab in the Site.com app, click New. Alternatively, in Site.com Studio, click Create Available in: Salesforce a New Site in the site's drop-down menu. Classic (not available in all orgs) 2. Select Import a Site or Template. 3. Enter the site name. Available for purchase in: Enterprise, Performance, 4. Click Browse to locate the exported site on your hard drive. Exported sites have a .site extension. and Unlimited Editions 5. Click Create. Available (with limitations) in: Developer Edition Note: • If you’re importing a site that uses data services, you must set the data access permissions in the imported site’s guest user profile. Additionally, any data repeaters, data tables, data USER PERMISSIONS functions, or forms may need to be reconfigured. To create or import Site.com sites: • Site.com Publisher User field enabled on the user detail page
526 Extend Salesforce with Clicks, Not Code Site.com
• You can’t create, delete, or duplicate community sites in Site.com.
SEE ALSO: Creating a Site.com Site Exporting a Site.com Site
Configuring Site Properties
Set properties for the site, such as the home page, site name, and error page, and create an EDITIONS anonymous preview URL that allows other users to review the site before it goes live. The URL is always valid (unless you disable it) and shows the latest work in progress. It’s only available to the Available in: Salesforce people you send it to, and can’t be found by search engines. Classic (not available in all 1. On the Overview tab, click Site Configuration. orgs) 2. Click Edit. Available for purchase in: 3. In the Site Configuration view, you can: Enterprise, Performance, and Unlimited Editions • Replace the name in the Site Name field to rename the site. Available (with limitations) • See the Developer Name of the site. This read-only field may differ from the Site in: Developer Edition Name. The Developer Name is used by the Metadata API. • Select Enable Anonymous Preview to create a URL that allows other users to preview the site before it goes live. (Click the View Anonymous Preview option that appears in USER PERMISSIONS the Preview menu to access the preview URL, which you can copy and send to other users To build, edit, and manage to review and test your changes.) Enable Anonymous Preview is also available from the Site.com sites: Preview menu on the Overview tab. • Site.com • Access the site’s guest user profile. Publisher User • Set the clickjack protection level. field enabled on the user detail page • Determine whether guest users can view features available only in Lightning. If you disable Lightning Features for Guest Users, Lightning features don’t load. AND Site administrator or • Enable Content Sniffing Protection to force the browser to use the Content-Type header designer role assigned only. at the site level • Enable Browser Cross Site Scripting Protection to protect against reflected cross-site scripting attacks. • Select Referrer URL Protection to have the referrer header shows only Salesforce.com rather than the entire URL when loading pages. • Select the home page for your website in the Home Page drop-down list. • Site.com Community sites only: – Select the login page for your Site.com Community site in the Login Page drop-down list. – Select the page that you’ve set up for Site.com Community site users who don’t have accounts yet from the Registration Page drop-down list. – Select the Forgot Password page you’ve set up for your community using Site.com.
• Select a user-friendly error page in the 404 Page drop-down list to display when a page can't be found. It's a good idea to create a user-friendly error page to assist site visitors if they encounter a broken link.
4. Click Save.
527 Extend Salesforce with Clicks, Not Code Site.com
Note: • The home page, 404 page, login page, and self-registration page that you specify for Site.com Community sites in Site Configuration set the default pages for the Site.com Community site. These default URLs are used unless you specify different URLs in Community Management under Administration Pages and Administration Login & Registration . Community error pages are specified in Lightning Platform Setup, under Error Pages. • When your Site.com Community site is inactive, users are redirected to the Service Not Available page defined in Community Management under Pages.
SEE ALSO: Creating a Site.com Site Using Site.com Studio as a Site Administrator or Designer Enable Clickjack Protection in Site.com
Enable Clickjack Protection in Site.com
Clickjacking is a type of attack that tricks users to click something, such as a button or link, because EDITIONS they perceive they are clicking something safe. Instead, the button or link performs malicious actions on your site, leading to data intrusion, unauthorized emails, changed credentials, or other site-specific Available in: Salesforce results. Classic (not available in all Hidden iframes can be placed maliciously on site pages and entice users to click a button or link orgs) that appears below the hidden iframe. With clickjack protection, you can configure whether your Available for purchase in: browser allows frames over your site pages. The default clickjack level for Site.com is set to Allow Enterprise, Performance, framing by the same origin only. and Unlimited Editions You can set the clickjack protection for a site to one of these levels: Available (with limitations) • Allow framing by any page (no protection): The least secure level. in: Developer Edition • Allow framing of site pages on external domains (good protection): Allows framing of your site pages by pages on external domains that are added to the Trusted Domains for Inline USER PERMISSIONS Frames list. • Allow framing by the same origin only (recommended): The default level for sites. Allows To build, edit, and manage framing of site pages by pages with the same domain name and protocol security. Site.com sites: • Site.com • Don’t allow framing by any page (most protection): The most secure level, but it can cause Publisher User certain pages to appear as blank pages. To avoid this issue, use the default setting instead. field enabled on the user 1. In Site.com Studio, click Site Configuration > Edit. detail page 2. Select your preferred level of clickjack protection and save your changes. AND 3. If you chose to allow framing of your site pages on your external domains, specify the domains Site administrator or designer role assigned that you want to allow. at the site level a. From Setup in Salesforce Classic, enter Sites in the Quick Find box, and then select Sites. b. Click the site label to open the Site Details page. c. Click Add Domain in the Trusted Domains for Inline Frames section and enter the domain you want to allow iframes on. You can add up to 512 domains.
Tip: Added domains take effect only when Allow framing of site pages on external domains is selected.
528 Extend Salesforce with Clicks, Not Code Site.com
Note: Internet Explorer supports clickjack protection through the legacy X-Frame-Options HTTP Header only. This header supports sameorigin, deny (none), allowall, and allow-from uri. In particular, allow-from uri supports only one URI. To support a list for IE users, the framing site must identify itself to the site domain by passing in a query parameter in the iframe tag. For example, if you add https://example.com as a trusted external domain and your site URL is https://MyDomainName.my.site.com, then the page on https://example.com must make its iframe as follows:
You can also set the trusted external domain in the iframeDomain cookie. This method allows iframes if the _iframeDomain URL variable isn’t saved when navigating between pages in IE.
Cookie iframeDomainCookie = ApexPages.currentPage().getCookies().get('iframeDomain');
if (iframeDomainCookie == null) { iframeDomainCookie = new Cookie('iframeDomain','www.example.com');
// Set the new cookie for the page ApexPages.currentPage().setCookies(new Cookie[]{iframeDomainCookie}); }
SEE ALSO: Configuring Site Properties Enable Clickjack Protection in Experience Cloud Sites Create and Edit Salesforce Sites
Site.com Versioning Overview
Each time you publish your site, it’s tracked as a version. You can restore your site back to one of EDITIONS the previously published versions. You can’t select individual components when restoring; you must restore the complete site. Available in: Salesforce When working in Site.com Studio, you’re always working on an unpublished version of your site. Classic (not available in all It’s your working copy. When you restore a version, you overwrite your working copy, not your live orgs) site. You must publish the restored version before you see the change on your live site. Available for purchase in: In Site.com Studio, you’ll find your site versions in the Change History view on the Overview tab. Enterprise, Performance, Not all items in a site are reverted when you restore a version. Some things, like user roles, remain and Unlimited Editions unchanged even when you restore from a previous version. Everything in a site is under version Available (with limitations) control except: in: Developer Edition • Site name • Anonymous preview setting • Guest User Profile settings • Clickjack protection level • Domains and path prefixes • User role settings
529 Extend Salesforce with Clicks, Not Code Site.com
Restoring to a Previous Site Version The Change History list in Site.com Studio tracks all published versions of your site. You can select any previously published version and restore it. You can only restore an entire site, not parts of a site.
SEE ALSO: Restoring to a Previous Site Version
Restoring to a Previous Site Version
The Change History list in Site.com Studio tracks all published versions of your site. You can select EDITIONS any previously published version and restore it. You can only restore an entire site, not parts of a site. Available in: Salesforce Note: The restore version feature is not available in Communities. Classic (not available in all orgs) When working in Site.com Studio, you’re always working on an unpublished version of your site. Available for purchase in: It’s your working copy. When you restore a version, you overwrite your working copy, not your live Enterprise, Performance, site. You must publish the restored version before you see the change on your live site. and Unlimited Editions Warning: You can’t restore the working copy of your site after you revert to a previous Available (with limitations) version. Therefore, it’s a good idea to back up the working copy of the site before reverting in: Developer Edition to ensure you don’t lose any unpublished changes. To revert to a previously published site version: USER PERMISSIONS 1. Select the Overview tab. To build, edit, and manage 2. From the Change History view, select the version you want to restore. Site.com sites: 3. Click > Restore Version. • Site.com Publisher User 4. Click OK at the confirmation message. field enabled on the user After you restored your working site to a previous version, you can continue to make additional detail page changes until you’re ready to publish the site. AND Site administrator or designer role assigned at the site level
530 Extend Salesforce with Clicks, Not Code Site.com
Creating URL Redirects in Site.com
If you move or reorganize pages in your site, search engines may have trouble finding the new EDITIONS page locations. To avoid this, set up URL redirects to inform users and search engines that site content has moved. Available in: Salesforce You can use URL redirects to: Classic (not available in all orgs) • Maintain search engine ranking. For example, if you change a page’s name from “Gadgets” to “Widgets,” creating a redirect rule from /Gadgets to /Widgets lets you restructure the Available for purchase in: site without affecting your page ranking. Enterprise, Performance, • Make URLs more readable and memorable. For example, site visitors will find long or numeric and Unlimited Editions page names, such as /widget65AD890004ab9923, difficult to remember. Instead, you Available (with limitations) can provide them with a short, friendly URL, such as /widget, and create an alias that redirects in: Developer Edition to the correct page when the user uses the short URL alias. • Assist with migration from another system to Site.com if you’re still using the same domain. USER PERMISSIONS For example, if your old site ran on PHP, you can create a redirection rule from an old page, such as /index.php, to a new page in Site.com, such as /myNewPage. To build, edit, and manage To assign a redirect to a site page: Site.com sites: • Site.com 1. On the Overview tab, click Site Configuration > URL Redirects. Publisher User 2. Click Create a Redirect. field enabled on the user detail page 3. Specify the Redirect type: AND Option Description Site administrator or designer role assigned Permanent (301) Select this option if you want users and search at the site level engines to update the URL in their systems when visiting the page. Users visiting a page redirected with this type are sent seamlessly to the new page. Using a permanent redirect ensures that your URLs retain their search engine popularity ratings, and that search engines index the new page and remove the obsolete source URL from their indexes.
Temporary (302) Select this option if you want users and search engines to keep using the original URL for the page. Search engines interpret a 302 redirect as one that could change again at any time, and though they index and serve up the content on the new target page, they also keep the source URL in their indexes.
Alias Select this option if you don’t want the URL to change in the user’s browser, but you want to redirect to a different page. Search engines won’t be aware of the change or update their records.
531 Extend Salesforce with Clicks, Not Code Site.com
Option Description Alias redirects only work when you redirect from one Site.com page to another. You can’t create an alias to an external address.
4. Specify the former page location in the Redirect from field. • The page location must be a relative URL. • The page can have any valid extension type, such as .html or .php, and can contain parameters. Parameter order is irrelevant. • The URL can’t contain anchors, such as /siteprefix/page.html#target. • You can create just one redirection rule from a particular URL. If you create a new rule with the same Redirect From information, the old rule is overwritten.
5. Specify the new page location in the Redirect to field. This can be a relative URL or a fully-qualified URL with an http:// or https:// prefix. Unlike pages you’re redirecting from, pages you’re redirecting to can contain anchors. 6. To immediately enable the redirection rule, ensure Active is selected. To enable it at a later stage, deselect the property. 7. Click Save. The URL Redirects section displays all URL redirection rules you've created for your site. • Edit an assigned redirect rule by clicking > Edit Redirect. • Delete a redirect rule by clicking > Delete Redirect.
Importing External Websites into Site.com
With Site.com Studio, you can import your existing website and recreate it automatically as a EDITIONS Site.com site. This saves you the time of having to re-code existing HTML pages. Create a zipped file of your website and the content with the desired folder structure. Create a new Available in: Salesforce Site.com site and then import your zipped file. Classic (not available in all orgs) During the creation of the new Site.com site, all your HTML pages and assets are copied into the new site in the same locations they are in the zipped file. Here are some guidelines for importing Available for purchase in: assets. Enterprise, Performance, and Unlimited Editions • Some code in style sheets may not convert properly to the Site.com format. If this happens, you’ll receive a warning message. You can continue to import the zipped file or stop the import. Available (with limitations) If you continue, the style sheet imports and you can then manually attach it to your pages. in: Developer Edition • You can edit the
section of a page using Edit Head Markup in scripts section on the properties pane. This is useful for manually editing the HTML. • The maximum file size you can import is 50 MB unless you import and unzip a .zip file. In that case, you can import a .zip file of up to 200 MB if you select Unzip files during the import process. If your site is larger than 200MB when zipped, you can create more than one zipped file and import them individually. • Site.com attempts to format links correctly when importing a page. Links are checked in content blocks, custom code, and head script markup. You can check for any links that might still be broken on your page using the link checker. Open the page, select > Find Broken Links. A dialog displays showing any broken links. To fix the link, click Edit. The link opens in the HTML editor.SEE ALSO: Importing a Site.com Site
532 Extend Salesforce with Clicks, Not Code Site.com
Copying and Overwriting a Site
Sometimes, you might want to copy and replace your current production Site.com or Site.com EDITIONS community site with another site. You’ll first need to export a copy of your site from your . Once you have an exported .site file, Available in: Salesforce import that file into your production organization using the overwrite feature. Overwrite replaces Classic (not available in all your production site with the imported site. You can only overwrite sites that are the same type. orgs) For example, you can’t overwrite a Site.com site with a Site.com community site. Available for purchase in: 1. Create your .site file using the export feature in Site.com Studio. Enterprise, Performance, and Unlimited Editions 2. From Site.com Studio in your production site, click Site Actions > Overwrite This Site. Alternatively, if you have access to the Site.com tab in your organization, you can click next Available (with limitations) to the site name to find Overwrite. in: Developer Edition 3. Click Browse to find the .site file you exported. 4. Click OK at the overwrite warning. USER PERMISSIONS
Warning: You can’t revert once you have overwritten a site. To overwrite sites: • Site administrator or Here are a few tips when using overwrite. designer role assigned at the site level • You’ll need to publish the site you overwrote before changes take effect. • When copying a site, the production site is overwritten. So, be sure to backup your production site by exporting a .site file. • Overwrite does not copy data changes. For example, if you created a custom object to use in a repeater in the site you are copying from, that repeater won’t work in the production site until you create the same custom object. • If there are assets that exist in the production site that do not exist in the site you are copying from, they are moved to the trash can during the overwrite process so you can restore them if needed. • If your copied site has a different name than your production site, the production name is preserved and only the contents are changed. For example, if your site is called Site One and you overwrite your production site called Site Two, the production site is still called Site Two.
SEE ALSO: Exporting a Site.com Site Using the Metadata API to Deploy a Site
Using the Metadata API to Deploy a Site
As a user, you can migrate a site from sandbox to production. You can use the Metadata API to EDITIONS create a deployable package for Site.com sites and Site.com Communities sites.
Note: For information on deploying a Lightning community or a Salesforce Tabs + Visualforce Available in: Salesforce community, see Deploy a Community from Sandbox to Production. Classic (not available in all orgs) There are several tools that you can use to create a package: Available for purchase in: • Change sets (for Site.com and Site.com Communities sites only). The component type is called Enterprise, Performance, Site.com . and Unlimited Editions • Workbench, which works for creating all site types. The metadata type is called SiteDotCom. Available (with limitations) • Lightning Platform Migration Tool for Ant, which works for creating all site types. The metadata in: Developer Edition type is called SiteDotCom.
533 Extend Salesforce with Clicks, Not Code Site.com
If using change sets, select Site.com from the list and follow the prompts to create your package. If using Workbench or Lightning Platform as your tool, you must create a package.xml file. That file is submitted to the Metadata API to create a package.
Note: You can include a Guest User Profile in your package.xml file. If you do so, that Guest User Profile is linked to the site during deployment. The packaging process generates a folder that contains a content file and a metadata xml file. The content file name is [sitename].site. The metadata .xml file name is [sitename].site-meta.xml. If you deploy a package that doesn’t include a .site file, an empty site is created. If the package contains a site file, and the organization already contains a site with the same name, the site is updated.
Note: There is a file size limitation when using the Metadata API to deploy a site from sandbox to production. The assets in the .site file can’t be larger than 40 MB. The site gets created, but the assets show in the new site as broken. To fix the assets, export the assets from the sandbox environment separately and then import them into your new site. For help with the Metadata API, see the Metadata API Developer Guide. You can find help for change sets in the online help and for the Migration Tool Guide at https://developer.salesforce.com/page/Migration_Tool_Guide.
Sample Package.xml Files Here are some sample Site.com package.xml files.
SEE ALSO: Change Sets Sample Package.xml Files
Sample Package.xml Files
Here are some sample Site.com package.xml files. EDITIONS Here is a sample package.xml file for a Site.com site. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
xyzsite SiteDotCom 30.0
534 Extend Salesforce with Clicks, Not Code Site.com
Here is an example of a package.xml for a Salesforce Communities site. The package also includes a Guest User Profile.
xyzsite CustomSite xyzsite Network xyzsite1 SiteDotCom xyzsite Profile Profile 30.0
535 Extend Salesforce with Clicks, Not Code Site.com
Importing and Managing Assets
Contributors, publishers, and site administrators can import a variety of assets, such as images, EDITIONS HTML pages, and PDFs, to use in a website. You can import assets and files individually, or use a zipped file. When importing entire websites or large numbers of assets, it’s easier to create a zipped Available in: Salesforce file of the content with the desired folder structure. When importing the zipped file for a website, Classic (not available in all Site.com recreates your website and places everything in the same folder structure. orgs)
Note: Available for purchase in: • The maximum file size you can import is 50 MB unless you import and unzip a .zip file. In Enterprise, Performance, that case, you can import a .zip file of up to 200 MB if you select Unzip files during the and Unlimited Editions import process. Available (with limitations) in: Developer Edition The quickest way to import one or more files is to: 1. Select the files from your computer and drag them directly onto the Studio interface. This is supported for Mozilla® Firefox® and Google® Chrome only. You can drag individual files, or a USER PERMISSIONS zipped file. To build, edit, and manage 2. Depending on the types of files you’re importing, a dialog box may appear that lets you: Site.com sites: • Site.com • Select Unzip files to extract the contents of a .zip file. If the .zip file includes folders, this Publisher User structure is maintained in your site. field enabled on the user • Select Overwrite existing files to replace a file that already exists in the site. detail page • Select Convert CSS files into style sheets, if you're a site administrator or designer, to AND convert a CSS file into a style sheet that you can use to style your website. Site administrator or designer role assigned Note: If you import a .zip file that includes CSS files, and they fail to convert, they at the site level may not be valid. Try unchecking this option and then re-importing the .zip file. To edit only content in • Select Convert HTML files into pages to import HTML pages into your website. The Site.com sites: structure of the HTML page is maintained in your site, but the HTML is not validated during • Site.com import. Contributor User Alternatively, to import a single file: AND 1. Click Import.... Contributor role assigned at the site level 2. Click Browse... to locate the file. 3. Select the file and click Open. 4. Depending on the type of file you’re importing, you can: • Select Unzip files to extract the contents of a .zip file. If the .zip file includes folders, this structure is maintained in your site. • Select Overwrite existing files to replace a file that already exists in the site. • Select Convert CSS files into style sheets, if you're a site administrator or designer, to convert a CSS file into a style sheet that you can use to style your website.
Note: If you import a .zip file that includes CSS files, and they fail to convert, they may not be valid. Try unchecking this option and then re-importing the .zip file.
• Select Convert HTML files into pages to import HTML pages into your website. The structure of the HTML page is maintained in your site, but the HTML is not validated during import.
5. Click Import. A message appears indicating whether the file was imported successfully.
536 Extend Salesforce with Clicks, Not Code Site.com
6. Click . You can add images and videos to the text areas of your site pages, or create a hyperlink to any imported asset. If you're a site administrator or designer, you can add also add images directly to the page. View the list of imported assets in the Assets view on the Overview tab. You can also access assets in the All Site Content view, which displays the folder hierarchy of your site. • To view a thumbnail of an imported image, hover over it. • To save an asset to your computer, hover over or select it and click > Download. • To remove an asset from your site if you're a site administrator or designer, hover over or select it and click > Delete. If the asset is being used in your site, you see a confirmation message with a list of locations where that asset is in use. After an asset file is deleted, it exists in the Salesforce cache for up to 24 hours. After this it is permanently deleted from our systems.
Note: An asset may still be accessible if it's cached locally by a browser, or cached by an external system.
• To rename an asset on your site if you're a site administrator or designer, hover over the asset and click > Rename.
Exporting Assets Designers and site administrators can export all site assets separately from the .site file. You can export assets together or individually. Creating and Managing Folders As a site administrator or designer, you can create folders to manage your pages, style sheets, templates, and assets.
SEE ALSO: Adding Site.com Page Elements Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor Exporting Assets
537 Extend Salesforce with Clicks, Not Code Site.com
Exporting Assets
Designers and site administrators can export all site assets separately from the .site file. You EDITIONS can export assets together or individually. When you export all assets, the assets are exported to a zipped file that is named after the site Available in: Salesforce name—for example, sitename-Assets.zip. Classic (not available in all orgs) Export your assets from the Overview tab by clicking > Export Site Assets. Available for purchase in: To export a single asset, hover over the asset and select Download from the Actions menu. Enterprise, Performance, and Unlimited Editions Note: There is a file size limitation when using the Metadata API to deploy a site from sandbox to production. The assets in the .site file can’t be larger than 40 MB. The site gets created, Available (with limitations) in: Developer Edition but the assets show in the new site as broken. To fix the assets, export the assets from the sandbox environment separately and then import them into your new site. USER PERMISSIONS SEE ALSO: To build, edit, and manage Importing and Managing Assets Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
538 Extend Salesforce with Clicks, Not Code Site.com
Creating and Managing Folders
As a site administrator or designer, you can create folders to manage your pages, style sheets, EDITIONS templates, and assets. To create new folders: Available in: Salesforce Classic (not available in all 1. In the All Site Content view on the Overview tab, click New Folder. orgs) 2. Type in the folder name. Available for purchase in: 3. Click Create. Enterprise, Performance, Folders are created at the top level of the folder tree. Once created, you can drag them anywhere and Unlimited Editions in the tree structure. Likewise, you can drag and drop files into the folders you create. To rename, Available (with limitations) delete, and create sub-folders, right-click the folder or use the Actions menu ( ). in: Developer Edition Note: The site map remains the same regardless of how you arrange folders in the All Site Content view. USER PERMISSIONS
SEE ALSO: To build, edit, and manage Site.com sites: Understanding the Site Administrator and Designer's Overview Tab • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
539 Extend Salesforce with Clicks, Not Code Site.com
Editing Site.com Pages as a Designer or Site Administrator
When working with page templates and site pages, you can add content, structure, and style, all EDITIONS in one place. Open a page or template on the Overview tab by double-clicking it or hovering over it and clicking > Edit. The page opens as a new tab. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
• Using the Page Elements and Page Structure panes (1), you can search for and add page elements to a page, and reorder the page element hierarchy.
540 Extend Salesforce with Clicks, Not Code Site.com
• Using the Properties, Style, and Events panes (2), you can set properties, add style, and create events for a selected page or element. • Using the toolbar (3), you can: – Undo and redo your actions. – Cut, copy, or paste page elements. – Import assets, such as images and files. – Preview pages to see how they’ll appear when live on different devices. – Preview your site or generate an anonymous preview link to send to other users. – Publish your recent changes. – Access other page actions ( ), such as renaming or deleting the page.
• On the page canvas (4), you can lay out the page and select, edit, and move page elements.
Tip: • Hide the side panes to increase the canvas size by clicking and . To reopen a pane, click its icon. • As you edit a page, your changes are saved and the status icon ( ) on the page tab is updated automatically. • If the site page or page template is based on another template, editable page elements are highlighted with a blue border on the page.
Site.com Page Templates Overview Creating Site.com Page Templates Creating Editable Template Areas As the template creator, you specify which elements users can edit in pages based on the template. About Editable Page Elements When you mark a page element as Editable on a page template, that page element becomes editable in any child pages or templates derived from the parent template. Creating Site.com Pages Identifying Which Template a Site.com Page Uses Renaming, Duplicating, and Converting Pages Changing a Page’s Doctype Property The Document Type Definition (DTD) or doctype of a page defines which version of HTML it’s using. This information is used by some browsers to trigger a standard rendering mode. By default, each page’s doctype is set to HTML5, which is the latest version, but you can change it to XHTML 1.0.
SEE ALSO: Using Site.com Studio as a Site Administrator or Designer
541 Extend Salesforce with Clicks, Not Code Site.com
Site.com Page Templates Overview
Before you begin building the pages of your website, take some time to plan the pages you need, EDITIONS and in particular, which pages will have a similar layout. Once you've decided on the layout, the quickest method is to use a page template to build the basic layout. Available in: Salesforce Classic (not available in all About Page Templates orgs) A page template lets you define the layout and functionality of site pages in one location. By adding Available for purchase in: common page elements to the template and then basing site pages on it, you can achieve a Enterprise, Performance, consistent look and feel throughout your site. Page templates don't appear on your public site. and Unlimited Editions As the template creator, you specify which elements users can edit in pages based on the template. Available (with limitations) By default, a page element in a template is “locked,” so users can't edit its contents in any in: Developer Edition template-based page unless you mark the page element as “editable.” Conversely, when users edit an editable page element in a template-based page, their changes are specific to that page and don't affect your template. For example, this main page template contains a non-editable header and navigation menu that are common to all the pages in the site (1). The main template also has an editable center panel (2) to house the page-specific content of each page that's based on it.
Note: • Page templates must contain at least one editable page element. Otherwise, users can't edit site pages that are based on the template. • Panels are ideal for adding editable areas to page templates.
You can use page templates to: • Save time and effort by laying out the page structure and using it as a starting point when you create site pages. For example, you could design a template with a fixed header panel and side menu, and an editable center panel, to which you add page-specific page elements and content. • Quickly make global updates to the layout or style of your website, as any changes you make to the template's design are reflected immediately in all the pages that use it. • Control how other users (such as contributors or other site administrators and designers) can modify site pages. For example, you may allow contributors to edit specific content blocks only. • Ensure your template design remains pixel-perfect. When users edit a page that's based on a template, their changes don't affect your template. • Reuse common design elements by creating child templates. • Allow contributors to create site pages that are based on the template.
542 Extend Salesforce with Clicks, Not Code Site.com
About Child Templates Child templates are a useful way to reuse common design elements for more complicated page layouts. For example, your website will probably have elements that are the same on every page in your site, such as a navigation menu. However, several pages may have elements that are common only to them, such as pages in a subsection of your site that include a subsection header. By using a child template, which is a template that's based on another template, you can reuse the main template design. Using our main page template as a base, the child template inherits the non-editable header and navigation menu (1), and an editable center panel (2) where we add the non-editable subsection header (3). We also need to add a new editable center panel (4) because the center panel of the main template is editable only in pages directly based on the main template.
Now, any page based on the child template includes the non-editable main header, navigation menu, and subsection header, and an editable center panel (5) for that page's content.
Best Practices • Plan your site structure and the layout of your pages. Taking the time to plan your website first saves time when you build your site. • Identify which elements are common to all the pages of your site, such as navigation menus or headers, as these are the elements you can add to the page template. • Use page templates wherever possible to promote content reuse and save time. • Try to keep the design of your main page template as simple as possible to make it easier to modify in the future. For more complicated site designs, use child templates to achieve maximum flexibility.
SEE ALSO: Creating Site.com Page Templates Creating Site.com Pages Setting Up the Contributor’s Studio View Identifying Which Template a Site.com Page Uses
543 Extend Salesforce with Clicks, Not Code Site.com
Creating Site.com Page Templates
A page template lets you define the layout and functionality of site pages in one location. By adding EDITIONS common page elements to the template and then basing site pages on it, you can achieve a consistent look and feel throughout your site. And because a template-based page inherits the Available in: Salesforce template's elements, you can make site-wide changes from one location. Classic (not available in all You can create a page template from a layout, or if you've already created a template, you can use orgs) it as a base to create a child template, which lets you reuse the design of the main template. Available for purchase in: Enterprise, Performance, Creating a Page Template from a Layout and Unlimited Editions To start from scratch with a completely blank template or use a basic page layout: Available (with limitations) in: Developer Edition 1. Hover over Page Templates on the Overview tab and click New, or click New Page Template in the Page Templates view. 2. Enter the page template name. Template names can’t include special characters, such as #, ?, USER PERMISSIONS or @. To build, edit, and manage 3. Click Layouts and select either a blank page or a predefined page layout, such as a page with Site.com sites: a header and footer. • Site.com Publisher User Note: Predefined page layouts use panels to create columns, headers, and footers. These field enabled on the user panels use inline CSS to set their position, so you can easily modify the layout after the detail page page is created. However, if you're familiar with CSS and prefer using CSS rules, you can AND remove the inline style by selecting the panel, deleting the code from the Code tab in Site administrator or the Style pane ( ), and clicking Apply. designer role assigned at the site level 4. Choose a layout mode: • To expand the page to fill the width of the browser window, click Full width. • To set the page width, click Fixed width and enter the width.
5. Click Create. The page template opens. Next, you must complete the template.
Tip: • By default, any template you create is only available to other site administrators and designers in your organization. To let contributors create pages based on the template, select Available to Contributor in the Properties pane ( ). • You can also create templates by converting or duplicating other pages.
Creating a Child Template To use an existing template as a base for a child template: • The quickest option is to: 1. Select the template in the Page Templates view on the Overview tab and click > Create Child Template. Alternatively, click Page Actions > Create Child Template if the template is open. 2. Enter the page template name. Template names can’t include special characters, such as #, ?, or @. 3. Click Create. The child template opens.
• Alternatively:
544 Extend Salesforce with Clicks, Not Code Site.com
1. Hover over Page Templates on the Overview tab and click New, or click New Page Template in the Page Templates view. 2. Enter the page template name. Template names can’t include special characters, such as #, ?, or @. 3. Click Page templates and select the page template. 4. Click Create. The child page template opens.
Completing Your Template Once you've created a template, you must take the next steps to complete it: • Lay out the page template • Add other page elements to the template • Create editable areas • Create template-based site pages
SEE ALSO: Creating Editable Template Areas Identifying Which Template a Site.com Page Uses Site.com Page Templates Overview Setting Up the Contributor’s Studio View
Creating Editable Template Areas
As the template creator, you specify which elements users can edit in pages based on the template. EDITIONS To make a page element editable in derived pages or child templates, select it on the page template or in the Page Structure pane ( ) and click > Make Editable, or select Editable in the Available in: Salesforce Classic (not available in all Properties pane ( ). orgs)
When the page template is open, editable page elements are highlighted with a blue border on Available for purchase in: the page. They also display a pencil icon ( ) in the Page Structure pane and in the information Enterprise, Performance, popup that appears when you hover over the element on the page. and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage SEE ALSO: Site.com sites: About Editable Page Elements • Site.com Setting Up the Contributor’s Studio View Publisher User field enabled on the user Creating Site.com Page Templates detail page AND Site administrator or designer role assigned at the site level
545 Extend Salesforce with Clicks, Not Code Site.com
About Editable Page Elements
When you mark a page element as Editable on a page template, that page element becomes EDITIONS editable in any child pages or templates derived from the parent template. Consider these tips when creating editable page elements. Available in: Salesforce Classic (not available in all • Editable page elements are highlighted with a blue border in child pages and templates. orgs) • If you make a page element within a panel editable, you can’t also make the container panel editable. Available for purchase in: Enterprise, Performance, • Users can't alter the events, style, or properties of an editable page element in pages based on and Unlimited Editions the template. Available (with limitations) • Users can't resize, reposition, or delete editable page elements in pages based on the template. in: Developer Edition However, if the element's Auto Height property is enabled in the template, its height will adjust to fit the content of the template-based page. • Deleting an editable element from a page template removes it from all child pages and templates. • When you enable the Editable property of a page element, any pages or child templates based on the template also inherit the enabled status. In turn, the enabled status in the child template cascades to any of its children, and so on. If you don’t want its editability to cascade to any lower levels, disable the Editable property of a page element in a child template.
Editable Page Elements for Contributors • Contributors can modify editable content blocks in site pages based on the template. They can also edit content blocks that you place in an editable panel in template-based site pages.
Tip: To add a content block that only other site administrators or designers can edit, use custom code instead.
• Contributors can add content blocks to editable panels in site pages based on the template. If you make widgets available to contributors, they can also add them to editable panels. • Site administrators and designers can edit any page element you make editable.
Default Content in Editable Page Elements The content of all editable page elements on a child page or template is linked to the content of the editable elements on its parent page template. When you update the content of an editable page element on the parent template, the changes are pushed down to any child pages or page templates. However, if you modify the content of an editable page element at the child page or template level, you break the link between the elements, and any subsequent changes made to the page element on the parent template won't trickle down to its children. (To return control of the content to the parent template, select the editable page element on the page or in the Page Structure pane and click > Revert to Parent Content. When you do this, any custom content in the editable page element is lost.) Disabling the Editable property of a panel in a parent template overrides any changes made to that panel in child pages or templates. Changes to the panel at the child level disappear, and the panel reflects only the content from the parent template. However, the changes
546 Extend Salesforce with Clicks, Not Code Site.com
at the child level aren’t lost. Re-enabling the Editable property of the panel in the parent template restores the custom content previously added to its children. Any changes made to the element at the parent level will no longer show up.
SEE ALSO: Creating Editable Template Areas Setting Up the Contributor’s Studio View Creating Site.com Page Templates Editing and Working With Site.com Page Elements
Creating Site.com Pages
As a site administrator or designer, when you create a site page, you can choose to base it on a EDITIONS page template. If you're creating several site pages that have common page elements, such as a navigation menu, you can save time and effort and achieve a consistent look and feel by creating Available in: Salesforce a page template first and then basing your site pages on it. Alternatively, if none of your site pages Classic (not available in all have a similar structure or if you need to create a one-off site page that doesn't follow the overall orgs) site design, such as a home page, you can create a page based on a basic layout. Available for purchase in: Enterprise, Performance, Creating Site Pages from a Layout and Unlimited Editions Start from scratch with a completely blank page or use a basic page layout. Available (with limitations) 1. Hover over Site Pages on the Overview tab and click New, or click New > Site Page when in: Developer Edition the Site Pages view is open. 2. Enter the site page name. Page names can’t include spaces or special characters, such as #, ?, USER PERMISSIONS or @. To build, edit, and manage 3. Click Layouts and select either a blank page or a predefined page layout, such as a page with Site.com sites: a header and footer. • Site.com Note: Predefined page layouts use panels to create columns, headers, and footers. These Publisher User panels use inline CSS to set their position, so you can easily modify the layout after the field enabled on the user detail page page is created. However, if you're familiar with CSS and prefer using CSS rules, you can remove the inline style by selecting the panel, deleting the code from the Code tab in AND the Style pane ( ), and clicking Apply. Site administrator or designer role assigned 4. Choose a layout mode: at the site level • To expand the page to fill the width of the browser window, click Full width. • To set the page width, click Fixed width and enter the width.
5. Click Create. The site page opens.
Creating Site Pages from a Page Template If you created a page template, you can base your site pages on it. The quickest option is to: 1. Select the template in the Page Templates view and click > Create Page from Template. Alternatively, click Page Actions > Create Page from Template if the template is open.
547 Extend Salesforce with Clicks, Not Code Site.com
2. Enter the site page name. Page names can’t include spaces or special characters, such as #, ?, or @. 3. Click Create. The site page opens. Alternatively: 1. Hover over Site Pages on the Overview tab and click New, or click New > Site Page when the Site Pages view is open. 2. Enter the site page name. Page names can’t include spaces or special characters, such as #, ?, or @. 3. Click Page templates and select the page template. 4. Click Create. The site page opens.
Tip: You can also create pages by converting or duplicating other pages.
SEE ALSO: Editing Site.com Pages as a Designer or Site Administrator Adding Site.com Page Elements
Identifying Which Template a Site.com Page Uses
When you edit a template-based page, you can't modify its non-editable page elements. You also EDITIONS can't reposition, resize, or delete editable page elements, or alter the events, properties, or style associated with them. To update these elements or properties, you must edit them in the template Available in: Salesforce the page is based on. Classic (not available in all To identify which page template a site page is based on: orgs) • Hover over the site page in the Sites Pages view on the Overview tab. An information popup Available for purchase in: appears that displays the page template's name. Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user • Examine the Page Structure pane when the page is open. The template's name is displayed as detail page a link that you can click to open the template. AND Site administrator or designer role assigned at the site level
548 Extend Salesforce with Clicks, Not Code Site.com
Tip: To view and open the site pages associated with a particular page template, select or hover over the page template in the Page Templates view of the Overview tab and click > Edit Pages Based on Template. Click a listed site page to open it.
SEE ALSO: Creating Site.com Page Templates Site.com Page Templates Overview
Renaming, Duplicating, and Converting Pages
When working with pages and templates, you can perform common tasks, such as renaming, EDITIONS deleting, or duplicating pages. To access more page options, select or hover over a page on the Site Pages view of the Overview Available in: Salesforce tab and click . Classic (not available in all orgs) To access more template options, select or hover over a template in the Page Templates view of the Overview tab and click . Available for purchase in: Enterprise, Performance, Alternatively, if the page or template is open, click on the toolbar. and Unlimited Editions The available options vary for pages and templates: Available (with limitations) in: Developer Edition Select To... Edit Open the page or template for editing. Alternatively, double-click the USER PERMISSIONS page or template. To build, edit, and manage Rename Change the page or template name. Site.com sites: • Site.com Preview View the page in a browser window. Publisher User Duplicate Create a copy of the page or template. field enabled on the user detail page Duplicating a page template doesn’t duplicate the pages or templates AND based on it. Site administrator or Delete Remove a page or template. You can't delete a template that has designer role assigned at the site level pages based on it.
549 Extend Salesforce with Clicks, Not Code Site.com
Select To... Create Child Template Create a child template based on the selected template.
Create Page from Template Create a page based on the template.
Convert Site Page to Template Change the page into a template.
Convert Template to Site Page Change the template into a page. You can't convert a template that has pages based on it.
Edit Pages Based on Template View and open the site pages that are based on the selected page template.
Add IP Restrictions Control access to the page or template by restricting the range of permitted IP addresses. When you create a page that’s based on a template with IP restrictions, the page inherits the IP restrictions.
SEE ALSO: Editing Site.com Pages as a Designer or Site Administrator Using Site.com Studio as a Site Administrator or Designer
Changing a Page’s Doctype Property
The Document Type Definition (DTD) or doctype of a page defines which version of HTML it’s using. EDITIONS This information is used by some browsers to trigger a standard rendering mode. By default, each page’s doctype is set to HTML5, which is the latest version, but you can change it to XHTML 1.0. Available in: Salesforce When the page is open: Classic (not available in all orgs) 1. Select the page in the Page Structure pane. 2. In the Properties pane, select an option in the Doctype drop-down list. Available for purchase in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Available (with limitations) Changing a Page Element’s HTML Tag in: Developer Edition Adding Custom HTML Attributes HTML5 Semantic Page-Layout Tags USER PERMISSIONS
To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
550 Extend Salesforce with Clicks, Not Code Site.com
Site.com Page Elements
Page elements are the building blocks of your site pages and page templates. Combined, they EDITIONS provide the page's structure and content. When a site page or page template is open in Site.com Studio, these page elements are available Available in: Salesforce to site administrators and designers. Classic (not available in all orgs)
Page Element Description Available for purchase in: Content Block Contains the page text, and can also house Enterprise, Performance, images, media, and hyperlinks. Also available to and Unlimited Editions contributors if the page has editable areas. Available (with limitations) in: Developer Edition Custom Code Lets you customize your site by adding markup, such as HTML and JavaScript for elements that aren't provided in Site.com Studio.
Image Adds images directly to the page.
Breadcrumb Adds a breadcrumb navigation element to the page.
Menu Creates a menu that lets users navigate through the pages of your site.
Panel Adds structure to the page and lets you group other page elements together.
Button Adds a button to the page. You can use the actions in the Events pane to add functionality to the button.
Form Lets you create web-to-lead forms or gather customer feedback, and submit the data to Salesforce objects.
Input Fields Provides several field types to add to forms or pages. When added to a form, binds to fields in the form’s object. See Input Field Types.
Data Element Must be contained in a data repeater. Binds to a field in the data repeater’s object and acts as a placeholder that shows the content of a specified field for the current record.
Data Function Connects to a standard or custom Salesforce object, performs calculations on the returned results, and displays the calculation on the page.
Data Repeater Connects to a Salesforce object and returns a dataset based on filters that you specify. Combines with data elements or custom code page elements to display the results on the page.
551 Extend Salesforce with Clicks, Not Code Site.com
Page Element Description Data Table Connects to a standard or custom Salesforce object, retrieves a data set based on the filter criteria that you specify, and displays one or more record as rows in the table.
Adding Site.com Page Elements Editing and Working With Site.com Page Elements Laying Out Site.com Pages Using Panels Positioning Panels Using CSS Adding Images Directly to the Page Adding Content Blocks to Pages Content blocks contain the text of your website pages, and can also house images, videos, and hyperlinks. Designers and site administrators can add content blocks to pages when in Design Mode. Adding Custom Code to Pages Custom code lets you customize your site using markup, such as HTML and JavaScript. About the Site Map and Page Hierarchy Adding Custom HTML Attributes You can add custom HTML attributes to pages and page elements, which are rendered on the HTML tag of the page element. For example, this is useful when working with third-party frameworks that render page elements differently based on certain attributes. Changing a Page Element’s HTML Tag By default, panels, data repeaters, data elements, custom code, and content blocks are each defined as a div, but you can change this to any other HTML tag using the HTML Tag property. This gives you greater flexibility and control over how the page element is displayed on the page. HTML5 Semantic Page-Layout Tags
SEE ALSO: Adding Site.com Page Elements Editing and Working With Site.com Page Elements
552 Extend Salesforce with Clicks, Not Code Site.com
Adding Site.com Page Elements
Page elements are the building blocks of your site pages and page templates. Panel elements add EDITIONS structure to your pages. You can think of both pages and panels as “containers” for the page elements that you add to them. Available in: Salesforce If a site page or page template is based on another page template, you can only add page elements Classic (not available in all to editable panels, which are highlighted with a blue border on the page. orgs) Pages, panels, data repeaters, and forms are “container” page elements, so you can add other page Available for purchase in: elements to them when the page is open. Enterprise, Performance, and Unlimited Editions • In the Page Elements pane ( ), either: Available (with limitations) – Drag the page element onto the page canvas or container page element. in: Developer Edition – Click the page element, select where to place it in the popup that appears, and click Apply.
• In the Page Structure pane ( ), hover over a container page element and click > Add USER PERMISSIONS Page Elements. Click the item you want to add or drag it onto the container page element. To build, edit, and manage • Select a container page element on the page and click > Add Page Elements. Click the Site.com sites: item you want to add or drag it into the container page element. • Site.com When you drag a page element into an editable panel, the page element displays a permitted icon Publisher User and a green border shows where you're placing the element. field enabled on the user detail page AND Site administrator or designer role assigned at the site level
If you try dragging a page element into a panel that isn't editable, the page element displays a not-permitted icon.
SEE ALSO: Editing and Working With Site.com Page Elements Adding Images Directly to the Page Adding Content Blocks to Pages Adding Custom Code to Pages Adding a Navigation Menu
553 Extend Salesforce with Clicks, Not Code Site.com
Editing and Working With Site.com Page Elements
The Page Structure pane ( ) displays the hierarchy of all elements on the page and is a very EDITIONS useful way of selecting, moving, and reordering elements, particularly for more complicated page designs. Available in: Salesforce Classic (not available in all • To select a page element, either click it on the page, or select it in the Page Structure pane. This orgs) highlights the element on the page and displays the item's selector bar and Actions menu ( ). Available for purchase in: • To edit a page element, such as a content block, image, or custom code, either: Enterprise, Performance, and Unlimited Editions – Double-click the element on the page. Available (with limitations) – Select the element on the page and click > Edit on its selector bar. in: Developer Edition – Select or hover over the element in the Page Structure pane and click > Edit. – Click Edit Content on the toolbar (for content blocks only). USER PERMISSIONS • To move a page element, either: To build, edit, and manage – Select the element on the page and drag it to the correct position, or click > Move Site.com sites: on its selector bar. • Site.com – Drag the item to your preferred location in the Page Structure pane, or select it and click Publisher User > Move > Direction. You can also drag all page elements other than panels to field enabled on the user your preferred location in the Page Structure pane. detail page AND • To resize a page element, select it and drag the resize handles to the correct size. If the corner Site administrator or resize handles are grayed out, it means the item's Auto Height property is enabled, which adjusts designer role assigned the height depending on its contents. To resize it to a set height, disable the property by either at the site level deselecting Auto Height in the Properties pane ( ), or by clicking one of the bottom resize handles and clicking Disable Auto Height in the popup message that appears.
Tip: If you disable the Auto Height property on an image, but you want it to retain its aspect ratio—the relationship of height to width—press and hold down the SHIFT key while you drag to resize it. Alternatively, if you're using CSS to style the page element, adjust the style of the class or ID that styles it.
• To delete an element, select it and either: – Click > Delete on the item's selector bar. – Press DELETE. – Click on the toolbar. – In the Page Structure pane, click > Delete.
If a site page or page template is based on another page template: • The content of all editable page elements on a child page or template is linked to the content of the editable elements on its parent page template. When you update the content of an editable page element on the parent template, the changes are pushed down to any child pages or page templates. However, if you modify the content of an editable page element at the child page or template level, you break the link between the elements, and any subsequent changes made to the page element on the parent template won't trickle down to its children. • You can't reposition or resize its page elements. However, if the element's Auto Height property is enabled in the template, the height will adjust to fit the content in the template-based page. To edit the page element, you must edit it in the page template. • You can't delete its page elements. To delete the page element, you must delete it from the page template.
554 Extend Salesforce with Clicks, Not Code Site.com
• You can't alter the events, properties, or style of an editable page element, such as its color, position, and size.
SEE ALSO: Site.com Page Elements Adding Site.com Page Elements Adding Content Blocks to Pages Laying Out Site.com Pages Using Panels About Editable Page Elements
Laying Out Site.com Pages Using Panels
A panel is a useful layout tool that defines the logical divisions of your page and lets you group EDITIONS page elements together for easy movement and positioning. Think of it as a container for other page elements, including other panels, or as a div that wraps around the content placed within Available in: Salesforce it. Panels are ideal for adding editable areas to page templates. Classic (not available in all When you create a page template or site page, you can use predefined page layouts that include orgs) headers, footers, and columns, which are created using panels. Once created, you can then further Available for purchase in: modify the layout to match your site's design. Enterprise, Performance, If you need to add more divisions to the page and you're not familiar with CSS, the easiest method and Unlimited Editions is to use row and column panels. This feature adds panels with predefined CSS positioning to ensure Available (with limitations) they align correctly on the page. in: Developer Edition Note: Predefined page layouts, and row and column panels use inline CSS to set their position. If you're familiar with CSS and are using CSS rules to style your site, you can remove the inline USER PERMISSIONS CSS by deleting it from the Code tab in the Style pane ( ) and clicking Apply. To build, edit, and manage To add row and column panels to a page: Site.com sites: • Site.com 1. Select the page (the top folder icon) in the Page Structure pane ( ). Publisher User 2. Click > Add Rows and Column Panels. field enabled on the user detail page 3. Select the number of row or column panels you require. If the page already contains content, it is placed in the first new panel. AND To add a row panel: Site administrator or designer role assigned • Above a panel, select the panel on the page or in the Page Structure pane and click > at the site level Add Rows and Column Panels > Insert Row Above • Below a panel, select the panel on the page or in the Page Structure pane and click > Add Rows and Column Panels > Insert Row Below To add row and column panels to another panel: 1. Select the panel on the page or in the Page Structure pane. 2. Click > Add Rows and Column Panels. 3. Select the number of row or column panels you require. If the page already contains content, it is placed in the first new panel.
To add a single panel, drag a Panel from the Page Elements pane ( ) onto the page.
555 Extend Salesforce with Clicks, Not Code Site.com
By default, the height of a panel automatically adjusts when you add content to it because its Auto Height property is enabled. You can disable the property to resize and reposition panels. If you hover over a panel on the page, an information popup appears that displays the width and height of the panel.
When you drag a page element onto a panel, the edges change color, indicating that the element is now grouped within it. To remove the element from the group, drag it outside the panel.
SEE ALSO: Adding Site.com Page Elements Positioning Panels Using CSS Changing a Page Element’s HTML Tag
Positioning Panels Using CSS
A panel is a useful layout tool that defines the logical divisions of your page. Using CSS, you can EDITIONS position panels and improve the layout of the page. Available in: Salesforce Adding Padding and Margins to Panels Classic (not available in all orgs) Two CSS properties—margins and padding—can help with your page layout by creating space between the rows and columns, and the content within. The margin property controls the space Available for purchase in: outside the panel between its border and outer edge, while the padding property controls the Enterprise, Performance, space between the panel's content and border. and Unlimited Editions To add margins and padding: Available (with limitations) in: Developer Edition 1. Select the panel. 2. Open the Dimensions section of the Style pane. USER PERMISSIONS 3. In the Margins section, either: • Set the margin width for all four sides by entering a value in the All text box and selecting To build, edit, and manage the unit of measurement. Site.com sites: • Site.com • Set the margin widths for the top, right, bottom, or left sides independently by entering a Publisher User value in the appropriate text box and selecting the unit of measurement. field enabled on the user detail page 4. Similarly, in the Padding section, set the padding widths as required. Adding padding increases the total width of the panel. For example, if you have a panel with a width of 500px and you AND add padding of 20px to all sides, the total width of the panel will be 540px. Site administrator or designer role assigned Tip: You can center a panel or block page element using the margin property. Enter 0 in at the site level the All text box and select Auto in the drop-down list.
Creating Column Panels Using the Float Property If you need to add more divisions to the page and you're not familiar with CSS, the easiest method is to use row and column panels. Alternatively, using the CSS float property, you can position panels to the left or right to create columns. (When you add panels using
556 Extend Salesforce with Clicks, Not Code Site.com
the row and column panels feature, they're automatically positioned using the float property.) For example, you could add two single panels to a container panel and set both panel's float and width properties to create a two-column page layout. To create a column panel: 1. Select the panel. 2. Open the Layout section of the Style pane. 3. Click to float the panel to the left, or click to float the panel to the right. If you're creating a two-column layout, for example, ensure you set the float property of both panels. 4. Adjust the width of the panel to ensure the panels align correctly by either setting the width in the Dimensions section or dragging the panel's border on the page. For example, if you're creating two columns of equal width, set the width of both panels to 50%.
Tip: When you use the float property, remember to set the overflow property of the container panel to “hidden.” This allows the container panel to grow as the height of the column panels increase. Select the container panel and in the Layout section of the Style pane, select Hidden in the Overflow drop-down list.
SEE ALSO: Cascading Style Sheets Overview Laying Out Site.com Pages Using Panels
Adding Images Directly to the Page
As a site administrator or designer, you can add images directly to your site pages and page templates EDITIONS or you can add images to content blocks. To add an image directly to the page: Available in: Salesforce Classic (not available in all 1. Open the site page or page template. orgs) 2. Drag an Image from the Page Elements pane onto the page. Available for purchase in: 3. In the Add an Image dialog box, either: Enterprise, Performance, • Find an existing image by typing its name in the Search Image text box and selecting and Unlimited Editions it from the list. Available (with limitations) • Upload an image from your computer in the Upload tab by browsing to the image, clicking in: Developer Edition Upload, and selecting it from the list.
4. Click Apply. The image is added to the page. USER PERMISSIONS 5. Enter a brief description of the image in the Alternative Text field in the Properties To build, edit, and manage pane. The description is used by screen reader users or as a substitute if the browser can’t display Site.com sites: the image. It can also help with search engine optimization (SEO). • Site.com Publisher User SEE ALSO: field enabled on the user detail page Adding Site.com Page Elements AND Editing and Working With Site.com Page Elements Site administrator or designer role assigned at the site level
557 Extend Salesforce with Clicks, Not Code Site.com
Adding Content Blocks to Pages
Content blocks contain the text of your website pages, and can also house images, videos, and EDITIONS hyperlinks. Designers and site administrators can add content blocks to pages when in Design Mode. Available in: Salesforce To add a content block when the page is open, either drag it from the Page Elements pane onto Classic (not available in all the page or target a container page element. orgs) To edit a content block, double-click it. For greater control over the text, you can edit the HTML Available for purchase in: directly by selecting the content block and clicking > Edit HTML. Enterprise, Performance, and Unlimited Editions If you make a content block in a page template editable, contributors can edit the content block in any page based on the template. To add a content block that only other site administrators or Available (with limitations) designers can edit, use custom code instead. in: Developer Edition
Understanding the Content Editing Toolbar USER PERMISSIONS Editing Content Blocks in Design Mode To build, edit, and manage Designers and site administrators can edit content blocks on the page. Content blocks contain Site.com sites: the text for site pages, and can also house images, videos, and hyperlinks. • Site.com Adding Images to Content Blocks in Design Mode Publisher User field enabled on the user Adding Video to Content Blocks in Design Mode detail page Attaching Hyperlinks to Text and Images in Design Mode AND Adding Anchors to Pages in Design Mode Site administrator or designer role assigned at the site level SEE ALSO: Adding Images to Content Blocks in Design Mode Attaching Hyperlinks to Text and Images in Design Mode
Understanding the Content Editing Toolbar
Designers and site administrators can edit content blocks when in Design mode. Content blocks EDITIONS contain the site page's text, along with images, videos, and hyperlinks. Available in: Salesforce Classic (not available in all orgs)
Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition
558 Extend Salesforce with Clicks, Not Code Site.com
When in Design Mode, you can use the content editing toolbar to: • Undo and redo your edits, and remove the formatting of text copied and pasted from Microsoft® Office, which can often include hidden formatting (1). • Cut, copy, and paste text (2). • Apply direct formatting (3), such as: – Font family and size – Bold, italic, underline, subscript, superscript, and strikethrough – Font and highlight color
• Control the text style and layout (4) by: – Applying paragraph and heading styles – Setting paragraph indentation – Left-aligning, centering, right-aligning, or justifying text – Inserting numbered or bulleted lists
• Insert a table, and add rows, columns, and spacing (5). • Add images, videos, and special characters (6). • Add and remove hyperlinks and anchors (7).
Tip: Avoid applying formatting, such as different fonts or highlighting, directly to text whenever possible. Instead, it’s best practice to use the paragraph and heading styles to quickly apply consistent formatting throughout the site. This also ensures that all page text is updated automatically if a site administrator or designer modifies the site's paragraph and heading styles.
559 Extend Salesforce with Clicks, Not Code Site.com
Editing Content Blocks in Design Mode
Designers and site administrators can edit content blocks on the page. Content blocks contain the EDITIONS text for site pages, and can also house images, videos, and hyperlinks. When the page is open in Design Mode: Available in: Salesforce Classic (not available in all 1. Double-click the content block on the page. orgs) 2. Add or edit text and format it using the content editing toolbar. Available for purchase in: Tip: Enterprise, Performance, and Unlimited Editions • If you copy and paste text from Microsoft® Office, highlight the text and click to remove any hidden formatting, which can adversely affect how the text appears on Available (with limitations) the page. in: Developer Edition • Avoid applying formatting, such as different fonts or highlighting, directly to text whenever possible. Instead, it’s best practice to use the paragraph and heading styles USER PERMISSIONS to quickly apply consistent formatting throughout the site. This also ensures that all page text is updated automatically if a site administrator or designer modifies the To build, edit, and manage site's paragraph and heading styles. Site.com sites: • Site.com 3. Add images, videos, hyperlinks, or anchors as required. Publisher User field enabled on the user 4. Click Save. detail page Note: The content of all editable page elements on a child page or template is linked to the AND content of the editable elements on its parent page template. When you update the content Site administrator or of an editable page element on the parent template, the changes are pushed down to any designer role assigned child pages or page templates. However, if you modify the content of an editable page at the site level element at the child page or template level, you break the link between the elements, and any subsequent changes made to the page element on the parent template won't trickle down to its children.
560 Extend Salesforce with Clicks, Not Code Site.com
Adding Images to Content Blocks in Design Mode
Designers and site administrators can add images to content blocks when viewing a page in Design EDITIONS Mode. When the page is open: Available in: Salesforce Classic (not available in all 1. Double-click the content block on the page. orgs) 2. Position your cursor where you want to insert the image and click . Available for purchase in: 3. In the Image Properties dialog box, either: Enterprise, Performance, • Enter a URL to an image in the Image URL field. and Unlimited Editions • Select an image from your website by clicking From Website and selecting the image in Available (with limitations) the list that appears. in: Developer Edition • Upload an image from your computer by opening the Upload tab, browsing to the image, and clicking Upload. USER PERMISSIONS
4. Enter a brief description of the image in the Alternative text field. The description is To build, edit, and manage used by screen reader users or as a substitute if the browser can’t display the image. It can also Site.com sites: help with search engine optimization (SEO). • Site.com Publisher User 5. Optionally, preview how the image appears in relation to the text on the page and set: field enabled on the user • The width and height of the image detail page • How much space surrounds the image (which is controlled by the HSpace and VSpace AND properties) Site administrator or • How it aligns with the text on the page designer role assigned at the site level • The image border (for example, to set a dotted green border that's 10 pixels wide, you enter 10px dotted green in the Border field) To edit only content in Site.com sites: 6. Click Apply. • Site.com 7. Click Save. Contributor User AND SEE ALSO: Contributor role Editing Content Blocks in Design Mode assigned at the site level Understanding the Content Editing Toolbar Importing and Managing Assets
561 Extend Salesforce with Clicks, Not Code Site.com
Adding Video to Content Blocks in Design Mode ® ® ® ® ® Designers and site administrators can add YouTube , Google , Adobe Flash , Windows Media , EDITIONS and Apple QuickTime® videos to content blocks when viewing a page in Design Mode. When the page is open: Available in: Salesforce Classic (not available in all 1. Double-click the content block on the page. orgs) 2. Position your cursor where you want to insert the video and click . Available for purchase in: 3. In the Video Properties dialog box, select the video type and either: Enterprise, Performance, • Enter the URL to the video in the Video URL text box—for example, and Unlimited Editions http://www.youtube.com/watch?v=123abc. Available (with limitations) • Select a video from your website by clicking From Website and selecting the video in the in: Developer Edition list that appears. • Upload a video from your computer by opening the Upload tab, browsing to the image, USER PERMISSIONS and clicking Upload. To build, edit, and manage Note: You can only select or upload Flash, Windows Media, and QuickTime videos. Site.com sites: • Site.com 4. To specify how the video is displayed on the page, you can set: Publisher User field enabled on the user • The width and height of the video detail page • How much space surrounds the video (which is controlled by the HSpace and VSpace AND properties) Site administrator or • How it aligns with the text on the page designer role assigned at the site level You can also preview the video. 5. Click Apply. The video appears as an icon in the content block. To edit only content in Site.com sites: 6. Click Save. • Site.com Note: You can view all video types, other than Windows Media videos, when you preview Contributor User a page. AND Contributor role SEE ALSO: assigned at the site level Editing Content Blocks in Design Mode Understanding the Content Editing Toolbar
562 Extend Salesforce with Clicks, Not Code Site.com
Attaching Hyperlinks to Text and Images in Design Mode
When viewing a page in Design Mode, designers and site administrators can create hyperlinks to: EDITIONS • External Web pages or websites • Pages and assets in the site Available in: Salesforce Classic (not available in all • Email messages orgs) • Anchors on the page Available for purchase in: When the page is open: Enterprise, Performance, 1. Double-click the content block on the page. and Unlimited Editions Available (with limitations) 2. Select the text or image that you want to attach a hyperlink to and click . in: Developer Edition 3. Select the link type in the Link to drop-down list. To link to: • A Web page: USER PERMISSIONS a. Select A URL. To build, edit, and manage b. Type the address in the URL field—for example, Site.com sites: http://www.externalsite.com. • Site.com c. Go to step 4. Publisher User field enabled on the user • A page or item in your site: detail page a. Select An item in your site. AND b. Select the item type, such as a page or image. Site administrator or designer role assigned URL c. Select the item. (If you can’t see the list of items, place your cursor in the field and at the site level press the DOWN key on your keyboard.) d. Go to step 4.
• An anchor that you previously added to the page: a. Select An anchor on the page. b. Select the anchor in the drop-down list. Alternatively, enter a new anchor name and create the anchor afterwards. c. Go to step 5.
• An email message: a. Select An email. b. Enter the recipient's email address and the message information. c. Go to step 5.
Note: For content blocks in a data repeater, you can use expressions to add a custom link, such as a URL query string, to an item in your site or to a Web page.
4. To select which window the item should open in, select an option in the Target drop-down list: • Popup window loads the item into a popup window. When you select this option, you can set the title for the popup and control its appearance and size with the options that appear. • New window (_blank) loads the item into a new, unnamed browser window. • Same window (_self) loads the item into the same frame or window as the link. This is the default setting. • Topmost window (_top) loads the item into the topmost parent frameset or window of the frame that contains the link.
563 Extend Salesforce with Clicks, Not Code Site.com
• Parent window (_parent) loads the item into the parent frameset or window of the frame that contains the link.
5. Optionally, enter a tooltip description for the link. The tooltip displays as a pop-up when the user hovers over the link. 6. Click Apply. 7. Click Save.
To delete a hyperlink, select it and click .
SEE ALSO: Editing Content Blocks in Design Mode Understanding the Content Editing Toolbar
Adding Anchors to Pages in Design Mode
An anchor is an invisible marker that identifies a particular location on a page. If you’re a designer EDITIONS or site administrator, you can add an anchor to the page and then create a hyperlink that jumps to that specific location. This can be useful if a page is particularly long; for example, if your page has Available in: Salesforce several sections, you could add links to each section at the top of the page to aid navigation. Classic (not available in all When the page is open in Design Mode: orgs) 1. Double-click the content block on the page. Available for purchase in: 2. Enterprise, Performance, Place your cursor at the beginning of the line where you want to link to and click . and Unlimited Editions 3. Enter a name for the anchor and click Apply. Ideally, use a name that helps identify the anchor’s Available (with limitations) location on the page—for example, top. in: Developer Edition 4. Now create a hyperlink that links to the anchor. USER PERMISSIONS SEE ALSO: Attaching Hyperlinks to Text and Images in Design Mode To build, edit, and manage Site.com sites: Editing Content Blocks in Design Mode • Site.com Understanding the Content Editing Toolbar Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level
To edit only content in Site.com sites: • Site.com Contributor User AND Contributor role assigned at the site level
564 Extend Salesforce with Clicks, Not Code Site.com
Adding Custom Code to Pages
Custom code lets you customize your site using markup, such as HTML and JavaScript. EDITIONS • Add markup to a specific location on a page using the Custom Code page element. JavaScript added using the Custom Code page element loads when that part of the page loads. Available in: Salesforce • Add markup to the page head. JavaScript in the page head loads first. Classic (not available in all orgs) • Add JavaScript to the page body. JavaScript added to the page body is positioned at the end of the body tag and only loads when the DOM is ready. Available for purchase in: Enterprise, Performance, • Add a reference to a JavaScript file or library in the page head or body. and Unlimited Editions Tip: Available (with limitations) • Scripts can't execute while you're editing a page in Site.com Studio. To test your code, in: Developer Edition preview the page. • If you are building a Site.com site from an existing HTML site, avoid using the Custom USER PERMISSIONS Code page element to paste large chunks HTML from the original site. Instead, use the available page elements, such as panels, content blocks, and data tables. This will let you To build, edit, and manage make future updates and design changes much more easily. Site.com sites: • Site.com Publisher User Adding Markup Directly to the Page field enabled on the user detail page 1. Drag a Custom Code page element from the Page Element pane onto the page. AND 2. Enter the code in the Edit Code dialog box. Site administrator or 3. Click Save and Close to add the code directly to the page. designer role assigned at the site level Adding Markup to the Page Head 1. In the Scripts section of the Properties pane, click Configure in the Edit Head Markup section. 2. Enter the markup in the Edit HTML Code dialog box. 3. Click Save and Close to insert the markup into the page head.
Adding JavaScript to the Page Body 1. In the Scripts section of the Properties pane, click Configure in the Edit Body Scripts section. 2. Enter the code in the Edit JavaScript Code dialog box. Don't add
oncomplete="refreshFeed();"/> Account: Contact: Status: Priority: Case Origin:
Note: When you redirect to a URL internal to your org, the action dialog closes upon completion or programmatically navigating away. If you set up the redirect to point to an external URL, the behavior can vary because an external URL opens in a new browser tab.
732 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Requirements for Refreshing Host Pages If you want an object-specific or global custom action to refresh the feed on the page that hosts it, the Visualforce page you create to use as that action must: • Reference the publisher JavaScript file: . (Creating custom Visualforce actions doesn’t require the Canvas SDK.) • Include this JavaScript call: Sfdc.canvas.publisher.publish({name : 'publisher.refresh', payload : {feed:true}});.
Visualforce Pages as Global Custom Actions Visualforce pages used as global actions can be invoked in many different places and don’t have a specific record associated with them. They have complete “freedom of action,” which means it’s up to you to write the code. Hide the Action Header for Visualforce Custom Actions When creating a Visualforce page to use as a custom action, you can choose to hide the action’s header. Hiding the action header helps prevent user confusion, especially if you have your own buttons specified in the Visualforce page.
SEE ALSO: Visualforce Pages as Global Custom Actions Create Object-Specific Quick Actions Quick Actions
Visualforce Pages as Global Custom Actions
Visualforce pages used as global actions can be invoked in many different places and don’t have a EDITIONS specific record associated with them. They have complete “freedom of action,” which means it’s up to you to write the code. Available in: both Salesforce Visualforce pages you create to use as global actions can’t use a standard object controller. You Classic (not available in all must write a custom controller to handle the page. orgs) and Lightning Experience When a global action completes, the user should be either redirected to a parent record created as part of the action or returned to where they started. Available in: Group, Professional, Enterprise, This code sample shows a Visualforce page designed to be used as a custom action on any object Performance, Unlimited, that supports actions. This action lets users create cases from record detail pages, Chatter, Chatter Contact Manager, groups (except customer groups), or the home page. It has a different user interface from standard Database.com, and create actions. As with all global actions, the records created through this action aren’t associated Developer Editions with other records.
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();
733 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
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(); } } }
Subject: Account: Contact: 734 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
style="width:500px;height:92px;margin-top:4px;" />
Status: Priority: Case Origin: {!lastError}
Requirements for Refreshing Host Pages To have an object-specific or global custom action refresh the feed on the page that hosts it, the Visualforce page you create to use as that action must: • Reference the publisher JavaScript file: . (Creating custom Visualforce actions doesn’t require the Canvas SDK.) • Include this JavaScript call: Sfdc.canvas.publisher.publish({name : 'publisher.refresh', payload : {feed:true}});.
SEE ALSO: Visualforce Pages as Object-Specific Custom Actions Create Global Quick Actions Quick Actions
Hide the Action Header for Visualforce Custom Actions
When creating a Visualforce page to use as a custom action, you can choose to hide the action’s EDITIONS header. Hiding the action header helps prevent user confusion, especially if you have your own buttons specified in the Visualforce page. Available in: both Salesforce To hide the header, add showQuickActionVfHeader=“false” to the Classic (not available in all tag of the custom action’s Visualforce page. When the Visualforce custom action renders in the orgs) and Lightning Salesforce mobile app, the header and the Cancel and Save buttons are hidden. Using this attribute Experience doesn’t affect how the action displays in the full Salesforce site. Available in: Group, If you don’t specify showQuickActionVfHeader, its value defaults to true. Professional, Enterprise, Performance, Unlimited, Contact Manager, Database.com, and Developer Editions
735 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
The showQuickActionVfHeader attribute isn’t supported in Experience Cloud sites.
SEE ALSO: Visualforce Pages as Object-Specific Custom Actions Visualforce Pages as Global Custom Actions
Prerequisites for Using Canvas Apps as Custom Actions
Using canvas apps as custom actions makes it easy to give users access to the functionality of your EDITIONS apps in Chatter and elsewhere in Salesforce. You can use as a custom action any canvas app that uses Publisher as a location. For example, you Available in: both Salesforce might use an expense report app as a custom action to make it easy for salespeople to submit Classic (not available in all expense reports directly from feeds. A custom action that includes a video conferencing canvas orgs) and Lightning app could help support agents communicate with customers visually for easier troubleshooting of Experience technical issues. Quick actions available in: Before creating a custom action with a canvas app, be sure the app uses Publisher as a location, Group, Professional, and be sure to give the users you want to be able to use the action access to the app. Enterprise, Performance, Unlimited, Contact SEE ALSO: Manager, Database.com, and Developer Editions Visualforce Pages as Object-Specific Custom Actions Custom canvas actions Quick Actions available in: Professional (with Canvas enabled), Enterprise, Performance, Unlimited, and Developer Editions
Enable Actions in the Chatter Publisher
Enabling actions in the publisher lets you add actions that you’ve created to the Chatter publisher. USER PERMISSIONS Actions appear on the Home page, on the Chatter tab, in Chatter groups, and on record detail pages. To enable actions in the Chatter publisher: Available in: Salesforce Classic (not available in all orgs) • Customize Application
Available in: Group, Professional, Enterprise, Performance, Unlimited, Contact Manager, Database.com, and Developer Editions
By default, the Salesforce Classic Chatter publisher includes the standard actions Post, File, Link, Poll, Question, and Thanks. With the actions in the publisher setting enabled, you can include nonstandard actions in the Chatter publisher too. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. In organizations created after the Winter ‘14 release, actions in the publisher is enabled automatically. 1. From Setup, enter Chatter Settings in the Quick Find box, then select Chatter Settings. 2. Click Edit. 3. Select Enable Actions in the Publisher.
736 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Although the Enable Actions setting appears in Lightning Experience, it has no effect there.
4. Click Save.
Note: You aren’t required to enable actions in the publisher to use them in the Salesforce app or in third-party apps. See Actions With and Without Chatter for more information.
Set Up Actions with Chatter Enabled Global and object-specific actions enhance the Chatter experience for your users in Salesforce Classic and in the Salesforce app. Set Up Actions Without Chatter Enabled You can set up object-specific and global actions for the Salesforce mobile app or third-party apps, even if your org doesn’t have Chatter enabled. Actions With and Without Chatter Use actions regardless of whether Chatter or actions in the publisher are enabled.
Set Up Actions with Chatter Enabled
Global and object-specific actions enhance the Chatter experience for your users in Salesforce EDITIONS Classic and in the Salesforce app. Chatter must be enabled for your organization. Available in: both Salesforce Classic (not available in all By default, the Chatter publisher in Salesforce Classic includes the standard actions Post, File, Link, orgs) and Lightning Poll, Question, and Thanks. To set up more actions in Chatter: Experience 1. Enable feed tracking for the objects for which you want to make actions available. Available in: Group, 2. Enable actions in the publisher if you want to see both standard actions and non-standard Professional, Enterprise, actions in the Chatter publisher. Performance, Unlimited, 3. Optionally, enable feed updates for related records to display feed items on a record detail page Contact Manager, when related records are created. Database.com, and Developer Editions 4. Create object-specific actions or global actions. 5. Customize the action layout with the fields that you want users to see when they use the action. USER PERMISSIONS 6. Add the actions to page layouts or global publisher layouts. Salesforce automatically adds default actions to the page layouts for account, case, contact, To set up actions: • Customize Application lead, and opportunity, and to the global publisher layout in organizations that were created after Winter ‘14.
SEE ALSO: Enable Actions in the Chatter Publisher Create Object-Specific Quick Actions
737 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Set Up Actions Without Chatter Enabled
You can set up object-specific and global actions for the Salesforce mobile app or third-party apps, EDITIONS even if your org doesn’t have Chatter enabled. When Chatter is disabled in an org, only the nonstandard actions appear in the action bar in the Available in: both Salesforce Salesforce mobile app or in third-party apps that use action lists. Nonstandard actions include Classic (not available in all Create, Update, Log a Call, custom actions, and Mobile Smart Actions. orgs) and Lightning Experience Note: You can create actions in Salesforce Classic when Chatter is disabled. Those actions don’t appear in Salesforce Classic, but can appear in Lightning Experience and the Salesforce Available in: Group, mobile app if you don’t customize the Salesforce Mobile and Lightning Experience Actions Professional, Enterprise, section of the page layout editor. Performance, Unlimited, Contact Manager, Follow these steps to set up actions for use in the Salesforce mobile app or third-party apps. Database.com, and 1. Create object-specific actions or global actions. Developer Editions 2. Customize the action layout with the fields that you want users to see when they use the action. USER PERMISSIONS 3. Add the actions to page layouts or global publisher layouts. Salesforce automatically adds default actions to the page layouts for account, case, contact, To set up actions: lead, and opportunity, and to the global publisher layout in organizations that were created • Customize Application after Winter ‘14.
SEE ALSO: Create Object-Specific Quick Actions Create Global Quick Actions Customize Actions with the Enhanced Page Layout Editor
Actions With and Without Chatter
Use actions regardless of whether Chatter or actions in the publisher are enabled. EDITIONS The actions that are available in the full Salesforce site (Salesforce Classic and Lightning Experience) or in the Salesforce mobile app depend on your org’s settings. To enable or disable Chatter for your Available in: both Salesforce organization, from Setup, enter Chatter Settings in the Quick Find box, then select Classic (not available in all Chatter Settings. If Chatter is enabled, the Enable Actions in the Publisher option orgs) and Lightning controls whether the actions that you create display in the Chatter publisher. Experience
Chatter Off, Chatter On, Chatter On, Quick actions available in: Actions Off Actions Off Actions On Group, Professional, Enterprise, Performance, You can create global actions Yes Yes Yes Unlimited, Contact and customize global action Manager, Database.com, lists and Developer Editions
You can create Yes Yes Yes Custom canvas actions object-specific actions and available in: Professional (with Canvas enabled), customize object-specific Enterprise, Performance, action lists Unlimited, and Developer Actions appear on the Home No Yes1 Yes Editions page and Chatter home
738 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Chatter Off, Actions Off Chatter On, Actions Off Chatter On, Actions On page in the full Salesforce site
Actions appear in object feeds in the full No Yes1,2 Yes2 Salesforce site
The action bar is available in the No3 Yes4 Yes Salesforce mobile app feed
The action bar is available on the record Yes5 Yes6 Yes6 view in the Salesforce mobile app
The action bar is available on Lightning Yes5 Yes Yes pages in the Salesforce mobile app
Footnotes: 1. If actions in the publisher aren’t enabled, only standard Chatter actions (Post, File, Link, Poll, and Thanks) appear in the Chatter publisher in the full Salesforce site. 2. The Chatter feed appears on an object’s detail page in the full Salesforce site only for objects that have feed tracking enabled. 3. When Chatter is disabled, the Feed item isn’t available in the Salesforce mobile app. 4. When Chatter is enabled but actions in the publisher aren’t, standard Chatter actions and nonstandard actions appear in the Salesforce mobile app action bar and in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. 5. When Chatter and actions in the publisher are disabled, only nonstandard actions appear in the action bar in the Salesforce mobile app or in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. 6. If feed tracking isn’t enabled on an object, only nonstandard actions appear in the Salesforce mobile app action bar and in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions.
SEE ALSO: Set Up Actions with Chatter Enabled Set Up Actions Without Chatter Enabled Quick Actions
739 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Layout Editor
Just as object record pages have page layouts that can be customized, actions have action layouts EDITIONS that can be customized. When you create an action, Salesforce populates its layout with a default set of fields. You can add, remove, or reorder fields on the action layout to present only the essential Available in: both Salesforce items your users need when they’re taking the action. Classic (not available in all For example, a Post action needs just one large text area for user input. By contrast, an object-related orgs) and Lightning Create action must include multiple fields; otherwise, Salesforce can’t create the record. Experience The first time you view the layout for an action you’ve created, certain fields are prepopulated: Available in: Group, target object default fields, standard required fields, and any custom universally required fields. Professional, Enterprise, Default actions (available in organizations created after Winter ’14) have predefined sets of fields. Performance, Unlimited, Contact Manager, The upper part of the action layout editor is the palette, and below the palette is the action layout. Database.com, and The palette contains fields from the action’s target object that you can add to the action layout, Developer Editions except for the following unsupported field types: • Record type fields • Read-only field types such as roll-up summary, formula, and auto-number fields • Read-only system fields such as Created By or Last Modified By Inactive Fields Fields that are already on the action layout still appear on the palette but are inactive. When you select an inactive field on the palette, Salesforce highlights the field on the action layout. Field Type Conversion If you convert a field’s type from one that is supported for actions to a type that isn’t supported, Salesforce removes the field from the action layout. If you convert the field back to a supported type without changing the action layout, Salesforce automatically adds the field back to the layout. If you edit the layout, and then convert the field back to a supported type, add the field back to the layout manually. Layouts Used for Log a Call Actions A Log a Call action takes the active task page layout except under the following conditions: • Suppose that your organization has a custom Log a Call action for an object. The custom action takes the custom action layout defined for it. • Now suppose that your organization has a custom Log a Call global action. That action takes the custom layout defined for it, unless you also have a custom Log a Call action for an object. (A custom action on an object overrides a custom global action.) To display the simpler New Task form to Salesforce mobile app users, enable the form in Activity Settings and ensure that the layout used includes a subject field. Layout Auditing Salesforce tracks action layout customization in the setup audit trail history. To view and edit the layouts for global actions in Setup, enter Actions in the Quick Find box, then select Global Actions and then click Layout next to the action’s name. To view and edit the layouts for object-specific actions, find the object in Setup, then go to Buttons, Links, and Actions.
740 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Layout Editor Considerations When you create an action, Salesforce populates its layout with a default set of fields. You can add, remove, or reorder fields on the action layout to present only the essential items your users need when they’re taking the action.
SEE ALSO: Quick Actions
Action Layout Editor Considerations
When you create an action, Salesforce populates its layout with a default set of fields. You can add, EDITIONS remove, or reorder fields on the action layout to present only the essential items your users need when they’re taking the action. Available in: both Salesforce • There is no hard limit to the number of fields you can add to an action layout. However, for Classic (not available in all optimum usability, we recommend a maximum of 8 fields. Adding more than 20 fields can orgs) and Lightning severely impact user efficiency. To reduce the number of fields in your layout, you can create Experience predefined values for the required fields, and then remove those fields from your layout. You Available in: Group, can set predefined field values from the action detail page. Professional, Enterprise, • By default, the Call productivity action in the Salesforce mobile app action bar uses the global Performance, Unlimited, Log A Call action layout. If you create one Log a Call action on an object, users see that custom Contact Manager, Log a Call action’s layout when they tap Call from the action bar for that object. If you create Database.com, and more than one Log a Call action for the same object, the Call action on that object doesn’t know Developer Editions which layout to use, so it uses the global Log a Call action layout. • Mobile smart actions are populated with all your org’s required fields on the relevant object, regardless of how many fields there are. For example, the New Case action in the mobile smart action bundle includes all required case fields. You can’t edit the fields on mobile smart actions. The fields that appear change only if you change which fields on an object are required. • You can remove a required field from the action layout, but make sure that the field has a predefined value. Otherwise, users can’t create records. • Rich text area fields are supported only when you add them to one-column layouts, or as fields that span both columns in two-column layouts. If you add a rich text area field to only one column in a two-column layout, it appears as a plain text area, because there’s not enough space to display the full rich text editor.
Custom Success Messages for Quick Actions
For Create a Record, Update a Record, and Log a Call action types, you can create a custom message EDITIONS that displays when the action executes successfully. Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience
Available in: Group, Professional, Enterprise, Performance, Unlimited, Contact Manager, Database.com, and Developer Editions
741 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
In the Salesforce mobile app and Lightning Experience, when a create, update, or Log a Call action is completed, a default success message displays, regardless of whether the action created a feed item. If you add a custom success message to one of these actions, your custom success message displays instead of the default message. In Salesforce Classic, custom success messages have slightly different behavior. If you select Create Feed Item for a Create a Record or Log a Call action, no success message displays in Salesforce Classic. The feed item itself is the confirmation that the action executed successfully. You can configure translations for custom success messages through the Translation Workbench. From Setup, enter Translate in the Quick Find box, and then select Translate. Choose Action for the Setup Component, and choose Informational Message for the Aspect.
Note: If you have All Related Objects selected under feed tracking for a particular object, when a quick action creates related objects, a feed item is always created, regardless of the status of Create Feed Item.
SEE ALSO: Create Object-Specific Quick Actions Create Global Quick Actions
742 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Customize Actions with the Enhanced Page Layout Editor
Use the page layout editor to customize which actions show up in Salesforce and in the Salesforce EDITIONS mobile app.
Tip: To manage the actions for global pages, such as Home, Chatter Home, and Chatter Available in: both Salesforce groups, see Global Publisher Layouts. Classic (not available in all orgs) and Lightning From the management settings for the object whose actions you want to manage, go to Page Experience Layouts. Available in: Group, You can add actions to two sections on a page layout: Professional, Enterprise, Quick Actions in the Salesforce Classic Publisher Performance, Unlimited, This section can contain actions only from the Quick Actions category in the palette. Actions Contact Manager, in this section appear in the Chatter publisher in Salesforce Classic. Database.com, and Developer Editions Salesforce Mobile and Lightning Experience Actions This section can contain actions only from the Mobile & Lightning Actions category in the palette. On object page layouts, the Mobile & Lightning Actions category contains all available USER PERMISSIONS types of actions for the object, including quick actions, productivity actions, Lightning component actions, and standard and custom buttons. Actions in this section appear in the action bar and To create actions: action menu in the Salesforce mobile app and in various areas of Lightning Experience. • Customize Application To customize action layouts Tip: Hover over an action in the palette to see its label, API name, and action type. and page layouts: • Customize Application • To override the action defaults for an action section that you haven’t customized, either click the override text or hover over the section and click . To view page layouts: • View Setup If you haven’t customized the Quick Actions in the Salesforce Classic Publisher section of a page layout, the actions that appear in the publisher for that object default to the actions that are assigned to the global publisher layout. Upon overriding, the actions default to the standard actions—Post, File, Link, Poll, Question, and Thanks—regardless of what actions were assigned to the global publisher layout. If you haven’t customized the Salesforce Mobile and Lightning Experience Actions section of a page layout, the actions for that object default to a set of predefined actions. If you have customized actions in the Quick Actions in the Salesforce Classic Publisher section, and have saved the layout, the Salesforce Mobile and Lightning Experience Actions section inherits the actions from the Quick Actions in the Salesforce Classic Publisher section, plus any standard or custom buttons present on the layout, when you click to override.
• To revert the actions in either section to the defaults for that section, hover over the section and click .
SEE ALSO: Set Up Actions with Chatter Enabled Actions in Lightning Experience Send Email Action Considerations for Cases Mobile Smart Actions Customize Page Layouts with the Enhanced Page Layout Editor Find Object Management Settings
743 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Set Predefined Field Values for Quick Action Fields
When you create actions, use predefined field values to set a value for a field. Predefined values can EDITIONS help ensure consistency and make it faster and easier for users to create records. When you configure action layouts, it’s better to use fewer fields. Most users, especially mobile Available in: both Salesforce users, don’t like to fill in a lot of required fields. They want to get things done and move on to their Classic (not available in all next task. A good way to use fewer fields in action layouts is to set predefined values for as many orgs) and Lightning fields as possible. The more fields you can set predefined values for, the more you can remove from Experience the layout and make the action easier and quicker to use. Balance ease of use with the need for Available in: Group, required information. However, don’t remove required fields from an action layout without setting Professional, Enterprise, a predefined value for those fields, or when a user applies that action, the record won’t save properly. Performance, Unlimited, If you set predefined values for fields on object records created through an action, you don’t need Contact Manager, to add those fields to the action layout. For example, when you configure an action that lets users Database.com, and create opportunities, set Prospecting as the predefined value for the Stage field. All new opportunities Developer Editions users create through that action are automatically assigned to the prospecting stage. You can remove the Stage field from the action’s layout, because the field is going to be assigned a value USER PERMISSIONS automatically. To set predefined field Tip: Predefined values for fields on actions are different from default values that you can set values: for fields on records. If a field is included in an action, it can have both a predefined value set • Customize Applications for the action and a default value set. 1. Click the name of an action in the Buttons, Links, and Actions list or the Global Actions list. 2. On the action detail page, click New in the Predefined Field Values list. 3. Select the field you want to predefine a value for. 4. Specify the value for the field. For single-select picklists, you can specify both a specific value and a formula value. If you set both, the formula value takes precedence over the specific value.
5. Click Save.
Tip: On object-specific actions, the predefined value can include references to the source object and its related objects.
Notes on Predefined Field Values for Quick Actions
SEE ALSO: Notes on Predefined Field Values for Quick Actions
744 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Notes on Predefined Field Values for Quick Actions
Setting predefined field values for quick actions is especially important if you remove required or EDITIONS Always on Layout fields from the action layout. • You can set predefined values for any field available in the action layout editor, with these Available in: both Salesforce exceptions. Classic (not available in all orgs) and Lightning – Dependent picklists Experience – Multi-select picklists Available in: Group, – Read-only field types like auto-number, formula, and roll-up summary fields Professional, Enterprise, – Lookup fields Performance, Unlimited, Contact Manager, • You can’t use a dependent picklist to set a predefined value. Database.com, and • If a field on an action has both a predefined value and a default value set, the action uses the Developer Editions predefined value, not the default value. • If a picklist field on a quick action has both a predefined specific value and predefined formula value, the formula value takes precedence over the specific value. • If you set a predefined value for a field and leave it on the action layout, that value displays as the default value for the field. • If you use a rich text field as a predefined field value, any text formatting that was applied in the rich text field is removed in the new field. • When you have a required field with a predefined value and remove the field from the action layout, you must add the required field back to the action layout if you later delete the field’s predefined value. Otherwise, users can’t save the record. • Formulas can’t reference fields on external objects, so you can’t reference an external object field to set a predefined field value for a quick action. • You can use a TEXT(picklist) value in a predefined value field. • To set the value for an email action’s recipient, predefine the To, CC, or BCC fields. You can use ID fields, such as Contact.Id, or string fields, such as Contact.custom_email_field to predefine the value. – Contact, lead, and person account IDs are supported. – Use an ID field if you want to log the email on the recipient’s record. – Use a string field to predefine an email recipient for a custom object or custom field. – If you use a string field, the email isn’t logged on the recipient’s record.
SEE ALSO: Set Predefined Field Values for Quick Action Fields
745 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Global Publisher Layouts
Global publisher layouts determine the global actions that appear in the various Salesforce interfaces. EDITIONS In Salesforce Classic and Lightning Experience, these layouts customize the actions on global pages (like the Home page) and on the Chatter page. Lightning Experience also uses these layouts to Available in: both Salesforce populate the Global Actions menu. And in the Salesforce mobile app, these layouts drive the actions Classic (not available in all that appear in the action bar on the Feed and People pages. Global publisher layouts can include orgs) and Lightning global actions only. Experience
In Salesforce for Outlook, global publisher layouts drive the actions that Group, Contact Manager, Available in: Group, and Professional Edition users see when they click the Salesforce Side Panel Publisher. Professional, Enterprise, Salesforce for Outlook users working in all other editions can set up their side panel publishers using Performance, Unlimited, Outlook Side Panel Publisher Layouts. Contact Manager, Database.com, and Note: Chatter groups without customers display the global publisher layout by default, Developer Editions unless you override it with a customized group publisher layout. In Chatter groups that allow customers, the publisher displays standard actions only, such as Post, File, Link, and Poll. You can assign different global publisher layouts to different user profiles to customize which actions USER PERMISSIONS users see by default on global pages. To create actions: Note: Changes to user layouts override the global publisher layout on user profile pages • Customize Application and the Chatter home page. To customize action layouts and page layouts: These are the steps involved in working with global publisher layouts. • Customize Application To view page layouts: 1. Create Global Publisher Layouts • View Setup Global publisher layouts determine the global actions that appear in the various Salesforce interfaces. In Salesforce Classic and Lightning Experience, these layouts customize the actions on global pages (like the Home page) and on the Chatter page. Lightning Experience also uses these layouts to populate the Global Actions menu. And in the Salesforce mobile app, these layouts drive the actions that appear in the action bar on the Feed and People pages. Global publisher layouts can include global actions only. 2. Add Actions to Global Publisher Layouts Actions you add to the global publisher layouts appear on pages such as the Home and Chatter pages. They also appear on the action bar and action menu on the Feed and People pages in the Salesforce mobile app. 3. Assign Global Publisher Layouts to User Profiles Once you finish creating a global publisher layout, you can assign it to different user profiles. For example, a Marketing User and a Standard User might need different actions in the Chatter publisher or in the Salesforce mobile app. Create multiple global publisher layouts and assign them to different user profiles to customize the actions for each profile.
SEE ALSO: Create Global Quick Actions
746 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Create Global Publisher Layouts
Global publisher layouts determine the global actions that appear in the various Salesforce interfaces. EDITIONS In Salesforce Classic and Lightning Experience, these layouts customize the actions on global pages (like the Home page) and on the Chatter page. Lightning Experience also uses these layouts to Available in: both Salesforce populate the Global Actions menu. And in the Salesforce mobile app, these layouts drive the actions Classic and Lightning that appear in the action bar on the Feed and People pages. Global publisher layouts can include Experience global actions only. Available in: Enterprise, Publisher Layouts Quick Find 1. From Setup, enter in the box, then select Publisher Performance, Unlimited, Layouts. Database.com, and 2. To create a new global publisher layout, click New. Developer Editions 3. To clone a publisher layout, select one from the Existing Global Publisher Layout drop-down list. USER PERMISSIONS
4. Enter a name for the new global publisher layout. To create actions: 5. Click Save. • Customize Application To customize action layouts SEE ALSO: and page layouts: • Customize Application Assign Global Publisher Layouts to User Profiles To view page layouts: Global Publisher Layouts • View Setup
Add Actions to Global Publisher Layouts
Actions you add to the global publisher layouts appear on pages such as the Home and Chatter EDITIONS pages. They also appear on the action bar and action menu on the Feed and People pages in the Salesforce mobile app. Available in: both Salesforce Arrange the actions so that the frequently used actions appear first in each list. Classic (not available in all orgs) and Lightning You can add actions to two sections on a page layout: Experience Quick Actions in the Salesforce Classic Publisher This section can contain actions only from the Quick Actions category in the palette. Actions Available in: Group, Professional, Enterprise, in this section appear in the Chatter publisher in Salesforce Classic. Performance, Unlimited, Salesforce Mobile and Lightning Experience Actions Contact Manager, This section can contain actions only from the Mobile & Lightning Actions category in the Database.com, and palette. On object page layouts, the Mobile & Lightning Actions category contains all available Developer Editions types of actions for the object, including quick actions, productivity actions, Lightning component actions, and standard and custom buttons. Actions in this section appear in the action bar and USER PERMISSIONS action menu in the Salesforce mobile app and in various areas of Lightning Experience.
Note: Changes to user layouts override the global publisher layout on user profile pages To create actions: and the Chatter home page. Actions on the user profile page come from the Quick Actions • Customize Application in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter To customize action layouts actions appear on the user profile page, regardless of which actions are present in the User and page layouts: Page Layout or the global publisher layout. • Customize Application 1. From Setup, enter Publisher Layouts in the Quick Find box, then select Publisher To view page layouts: Layouts. • View Setup
747 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
2. To add or remove actions, drag them to and from the palette. To reorder actions, select an action and drag it to a new position. 3. Click Save when you’re done, or click Quick Save to save your changes and continue working on the layout. If you navigate away without saving, you lose your changes.
Note: Before using the personal email setting When you click an email address to compose an email, which email editor do you want to use?, confirm that the Global Publisher Layout has the email action in the Salesforce Mobile and Lightning Experience Action section.
Example: Let’s add the New Account action to the publisher on the Home and Chatter pages in Salesforce Classic. The New Account action lets users create an account directly from the publisher. Drag the New Account action to the Quick Actions in the Salesforce Classic Publisher section and save your changes.
Go to the Chatter tab in Salesforce Classic. Now the New Account action shows up in the publisher.
Note: The Chatter page in Lightning Experience supports only the standard Chatter actions Post, Poll, and Question, and if you have Groups, the Announcement action.
SEE ALSO: Actions in Lightning Experience Send Email Action Considerations for Cases Assign Global Publisher Layouts to User Profiles Email Application Publisher Layouts
748 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Assign Global Publisher Layouts to User Profiles
Once you finish creating a global publisher layout, you can assign it to different user profiles. For EDITIONS example, a Marketing User and a Standard User might need different actions in the Chatter publisher or in the Salesforce mobile app. Create multiple global publisher layouts and assign them to different Available in: both Salesforce user profiles to customize the actions for each profile. Classic (not available in all 1. From Setup, enter Publisher Layouts in the Quick Find box, then select Publisher orgs) and Lightning Layouts. Experience 2. Click Publisher Layout Assignment. Available in: Group, Professional, Enterprise, 3. Click Edit Assignment. Performance, Unlimited, 4. Select a user profile by clicking anywhere on its row in the table. Contact Manager, 5. From the Publisher Layout to Use drop-down, select the global publisher layout that you want Database.com, and to assign to the highlighted profile. Developer Editions 6. Save the layout. USER PERMISSIONS
SEE ALSO: To create actions: Add Actions to Global Publisher Layouts • Customize Application Global Publisher Layouts To customize action layouts and page layouts: • Customize Application To view page layouts: • View Setup
Quick Actions and Record Types
Using record types in your organization can affect the availability of quick actions for your users. EDITIONS If users don’t have access to a particular record type, actions that are assigned to that record type aren’t available to them. For example, let’s say that you have a page layout that contains a mix of Available in: both Salesforce actions—some have no record type assigned and some are assigned to Record Type A. Users Classic (not available in all without access to Record Type A see only the nonassigned actions when they visit the page. orgs) and Lightning Experience Important: Don’t assign actions to the Master record type. The Master record type is a placeholder record type that’s assigned when your organization is created. Quick actions available in: Group, Professional, Enterprise, Performance, Default Global Actions: A Special Case Unlimited, Contact If you have default global actions in your organization and you’re using record types, your users Manager, Database.com, might not be able to see all the default actions that are assigned to a page layout. and Developer Editions Default global actions are assigned to the Master record type, which isn’t accessible to most profiles. Custom canvas actions As a result, default global actions with the Master record type that are associated with target objects available in: Professional that have record types configured aren’t available for most users. To fix this issue, edit the default (with Canvas enabled), global actions associated with those objects and reassign them to a different record type. Enterprise, Performance, Unlimited, and Developer For example, the New Contact default global action has Contact as its target object. Let’s say you Editions have record types set up for the Contact object, and you add the New Contact default global object to a page layout. Users who visit records based on that page layout don’t see the New Contact action because the action is assigned to the Master record type by default. Editing the New Contact
749 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
default global action and assigning it to a record type other than Master makes it available for all users who have access to its assigned record type.
Actions Best Practices
Use these tips as you set up actions. EDITIONS
Tips for Creating Actions Actions available in: both Salesforce Classic and • Action labels longer than approximately 12–14 characters are shortened when they’re displayed Lightning Experience in the Chatter publisher. Keep names short and descriptive. • Give your actions task-oriented names that tell your users what they do. Use terms such as New, Publisher available in: Create, Share, Update, or Import. Salesforce Classic • Use the Description field to create notes for yourself about each action. Notes are especially Available in: Essentials, useful if you’re creating several similar actions for different record types, for example. The Group, Professional, description appears in the list of buttons, links, and actions for object-specific actions, or in the Enterprise, Performance, list of global actions, as well as on the detail page for the action. Your notes aren’t visible to Unlimited, Contact users. Manager, Database.com, and Developer Editions • 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.
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 necessary for them and for whomever handles 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, when you configure an action that lets users create opportunities, set Prospecting as the predefined value for the Stage field. All new opportunities users create through that action are automatically assigned to the prospecting stage. You can remove the Stage field from the action’s layout, because the field is going to be assigned a value automatically. If you set 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 appears to different user profiles.
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 Salesforce Classic, if you include five or more actions in the actions section of a page layout, 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 the Salesforce mobile app, the first three actions show up in the action bar, and the full set of actions are accessed by tapping .
SEE ALSO: Quick Action Considerations Troubleshooting Actions Set Up Actions with Chatter Enabled
750 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Quick Action Considerations
Keep these considerations in mind when working with quick actions. EDITIONS • If you’re using record types in your org, sometimes quick actions aren't visible to your users. For more information, see Quick Actions and Record Types on page 749. Actions available in: both • To see an object-specific action on a page layout, a user must have both Read and Edit Salesforce Classic and permissions on the action’s relationship field. The relationship field is the field that’s automatically Lightning Experience populated on the target object when a user creates a record using an action. For example, for Available in: Essentials, an action on a case that lets users create child cases, the default relationship field is Parent Group, Professional, Case. To be sure that users can see the Create Child Case action, check that they have both Enterprise, Performance, Read and Edit permissions on the Parent Case field. Unlimited, Contact Manager, Database.com, Field-level security sets the Account parent field on the Case object to read-only by default, and Developer Editions which means it’s not visible to non-system administrator users. Therefore, actions on accounts that have Case as the target object are also not visible to users without the System Administrator profile. To let users see actions on accounts that have Case as the target object, remove the Read Only setting.
• In quick action layouts: – A blank space inserted on the same line as another field in the quick action layout causes that field to stretch to the full page width. The field is left justified on the page, regardless of its position in the quick action layout editor. – Two blank spaces inserted on the same row in the quick action layout editor don't create a blank line on the page. The two blank spaces are ignored. – If there's an uneven number of fields on the quick action layout, the final field stretches to the full page width and is left justified. The behavior is the same if a blank space is inserted on the same row as the final field.
• Custom actions can be defined for person accounts but with these exceptions. – Person account-specific fields, including Email and Mobile, aren’t available in action layouts when using object-specific custom actions to update accounts. – To set up object-specific custom quick actions that create person account records, define a custom lookup field for Account on the Account or Contact object. Global custom quick actions can be used without defining this field. – Actions that create business account records from a person account detail page must be global, not object-specific.
• If you delete an action, the action is removed from all layouts that it’s assigned to. • Automatic triggers that change record ownership can affect what object details are visible to users. In some cases, a user can enter information that is then immediately hidden from them if an automatic trigger changes the object's owner. For example, if you use a global create quick action to create an object and an automatic trigger changes the object ownership, some information about the object isn't visible to you. • My Domain must be deployed in your org for Lightning component actions to work properly. • Chatter groups without customers display the global publisher layout by default, unless you override it with a customized group publisher layout. In Chatter groups that allow customers, the publisher displays standard actions only, such as Post, File, Link, and Poll.
Actions and Master-Detail Object Relationships • Actions to create records for an object that is the detail object in a master-detail relationship must be object-specific, not global. • If you create an action on a detail object in a master-detail relationship, the action’s target object can’t be a different detail object of the same master.
751 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
For example, master object A has two detail objects, B and C. You can create actions on object A with B or C as the target object. However, when creating an action on object B, the target object can’t be object C because B and C have the same master. To create an action on B with C as the target, you can do one of the following: – Change the relationship between B and C to master-detail so that A is the master of B, and B is the master of C. – Change the relationship between C and A to a lookup relationship. Note that A is still the master of B with this option, so you can’t create a quick action on B with a target object of A.
Troubleshooting Actions
EDITIONS I don’t see feeds on record detail pages for a certain object. Feeds appear only for objects for which you’ve enabled feed tracking. Available in: both Salesforce Classic (not available in all orgs) and Lightning I see the feed on a record detail page, but I don’t see a publisher. Experience
If there are no actions in the Quick Actions in the Salesforce Classic Publisher section on a page Available in: Group, layout, the publisher in Salesforce Classic doesn't appear. Add at least one action to the page layout Professional, Enterprise, for the publisher to appear. Performance, Unlimited, Contact Manager, I can create actions, but I can’t add them to publishers. Database.com, and Developer Editions Enable actions in the publisher to add nonstandard actions to publishers in Salesforce Classic.
I’m using Internet Explorer 10 and all the actions I’ve created appear in the publisher with the same icon, even though the actions are for different types of objects. Internet Explorer version 10 doesn’t support the techniques Salesforce uses to show icons that correspond to the type of object an action is associated with. Consider using Chrome, Firefox, Safari, or an earlier version of Internet Explorer.
I’ve added an action to a page layout, but a user assigned to the profile that uses that page layout can’t see the action. Be sure that the user has both Read and Edit permissions on the action’s relationship field. The relationship field is the field that’s automatically populated on the target object when a user creates a record using an action. For example, for an action on a case that lets users create child cases, the default relationship field is Parent Case. To be sure that users can see the Create Child Case action, check that they have both Read and Edit permissions on the Parent Case field.
I don’t see a relationship field on my global create actions. Relationship fields apply only to object-specific create actions, not to global actions.
I don’t see some of the actions in my Chatter groups. Which actions you see depends on your role in the group, the type of group, and how your administrator has configured the publisher layout for groups. Chatter groups without customers display the global publisher layout by default, unless you override it with a customized group publisher layout. In Chatter groups that allow customers, the publisher displays standard actions only, such as Post, File, Link, and Poll.
752 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
I see an error when I select a custom create account action from a person account. Although your administrator can add the custom create account action to the page layout, this action isn’t supported for person accounts.
SEE ALSO: Actions Best Practices Set Up Actions with Chatter Enabled
Action Limits and Limitations
Actions can work differently than you expect in certain situations and for different objects. Keep EDITIONS these limits and limitations in mind when working with actions. • Custom actions aren’t available in Experience Builder sites. Available in: Essentials, • You can display up to 10 actions in Lightning view. Group, Professional, Enterprise, Performance, • Custom images used for action icons must be less than 1 MB in size. Unlimited, Contact • Custom actions can be defined for person accounts but with these exceptions. Manager, Database.com, – Person account-specific fields, including Email and Mobile, aren’t available in action and Developer Editions layouts when using object-specific custom actions to update accounts. – To set up object-specific custom quick actions that create person account records, define a custom lookup field for Account on the Account or Contact object. Global custom quick actions can be used without defining this field. – Actions that create business account records from a person account detail page must be global, not object-specific.
• Actions associated with objects that aren’t supported in Lightning Experience don’t appear in the Global Actions menu. Also, the Global Actions menu doesn’t support standard Chatter actions. • Mobile smart actions don’t appear in the full Salesforce site, regardless of which page layouts you add them to. They appear only to users in the Salesforce mobile app. • The Chatter page in Lightning Experience supports only the standard Chatter actions Post, Poll, and Question, and if you have Groups, the Announcement action. • The palette in the action layout editor doesn’t support: – Record type fields – Read-only field types such as roll-up summary, formula, and auto-number fields – Read-only system fields such as Created By or Last Modified By
• Actions on the user profile page come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on the user profile page, regardless of which actions are assigned to the User Page Layout or the global publisher layout. • Actions on reports come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on reports, regardless of which other actions are assigned to the global publisher layout. • Chatter groups with customers don’t support global create, log a call, or custom actions and display only standard Chatter actions, such as Post, File, Link, and Poll. • External objects support quick actions, except when the actions involve features or functionality that are incompatible with external objects. For example: – Formulas can’t reference fields on external objects, so you can’t reference an external object field to set a predefined field value for a quick action. – Log a Call actions create tasks, which aren’t available for external objects.
753 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• When you create an object-specific action, you can choose as a target object an event, a task, or any object that has a parent-child or lookup relationship to the host object. You can’t choose Quote as a target object from Opportunity. However, you can still create quotes from an opportunity by going to the opportunity’s Quotes related list and clicking New. • The Account Contact Relationship object supports custom actions, but with limitations. – Custom actions must be specific to the Account Contact Relationship object. Global actions aren’t supported. – You can create actions that update records or invoke Lightning components or Visualforce pages. But you can’t create actions that create records. – You can’t create actions that send emails or log calls because you can't associate activities to the Account Contact Relationship object. – You can’t override the default actions on the Account Contact Relationship object. – Only custom actions that are created on the Contact object can use the Account Contact Relationship object as a target object. – Chatter standard actions aren’t supported because the Account Contact Relationship object doesn’t have a Chatter feed.
Actions in Lightning Experience
In Lightning Experience, actions appear in the Global Actions menu in the header, on related lists, EDITIONS and on list view items. Actions also appear on a record page, in one of several places depending on the action’s type. Available in: both Salesforce Note: Quick actions aren’t the only action type covered here. Standard and custom buttons Classic (not available in all are also considered actions. orgs) and Lightning Experience
Actions in the Global Actions Menu Quick actions available in: Group, Professional, The Global Actions menu displays a subset of global actions from the Salesforce Mobile and Lightning Enterprise, Performance, Experience Actions section of the global publisher layout. Unlimited, Contact Manager, Database.com, and Developer Editions Custom canvas actions available in: Professional (with Canvas enabled), Enterprise, Performance, Unlimited, and Developer Editions
The items in the menu appear in the order that they’re listed in the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout. Actions associated with objects that aren’t supported in Lightning Experience don’t appear in the Global Actions menu. Also, the Global Actions menu doesn’t support standard Chatter actions.
754 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Actions on List Views and List View Items Custom buttons, list view actions, and certain standard buttons are supported on all list views, except Recently Viewed. To have a custom button appear on a list view, add the button to the object’s List View search layout. In the Kanban view, only the standard New action is supported. List view items support only specific standard actions, like Edit, Delete, or Change Owner.
For Tasks, table format list views and the Kanban view support only standard buttons. Tasks list view items in table view and the task item detail pane in split view contain the complete list of available actions for tasks.
Actions on the Home Page On the Home page, you can find actions on recommendations in the Assistant. For example, imagine that a sales rep receives an update that an opportunity doesn’t have any open activity. The rep can create a task or event directly from the recommendation.
The actions that appear depend on the type of recommendation. To appear in the Assistant, actions must be added to the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout. Supported actions include: • New Task • New Event • Edit • Email After you complete an action, the related recommendation disappears from the Assistant.
755 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Actions on the Chatter Page The Chatter page, like the Chatter tab on record pages, contains only standard Chatter actions. By default, only the Post, Poll, and Question actions are supported, and if you have Groups, the Announcement action. You can add, remove, or reorder the actions on the Chatter page from the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout.
Actions on Record Pages Here’s a sample contact page in Lightning Experience.
Note: The opportunity and leads workspaces have different structures, but actions appear in the same way on those pages.
The page-level action menu in the record’s highlights panel (1) contains: • Productivity actions • Global and object-specific quick actions, except for those actions related to creating tasks, creating events, and logging calls • Standard buttons • Custom object-specific Lightning component quick actions • Custom flow actions • Custom Visualforce quick actions • Custom Visualforce buttons
756 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• Canvas actions The actions that appear in the page-level action menu are listed in the order that they appear in the Salesforce Mobile and Lightning Experience Actions section of the page layout.
Note: You can enable dynamic actions in the highlights panel on an object’s record page using the Lightning App Builder. Dynamic actions for custom objects on desktop and mobile and for the standard objects Account, Case, Contact, Lead, and Opportunity on desktop are generally available. Dynamic actions for other standard objects on desktop are beta. Add, remove, and reorder actions directly in the Lightning App Builder and control action visibility based on filters that you apply. When you enable dynamic actions in the Lightning App Builder, highlights panel actions for the record page no longer come from the object’s page layout. The Activity tab (2) contains Create a Record quick actions that point to the Event and Task objects. It also contains Log A Call and Send Email actions. The Chatter tab (3) contains standard Chatter actions. By default, only the Post, Poll, and Question actions are supported, and if you have Groups, the Announcement action. Some objects support other standard Chatter actions predefined by Salesforce.
Note: Actions on user profiles, cases, and work orders can appear in a different way than on other records. • Actions on the user profile page come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on the user profile page, regardless of which actions are assigned to the User Page Layout or the global publisher layout. • When feed tracking is enabled for cases or work orders, the page-level action menu on those records contains only custom buttons and supported standard buttons. Quick actions appear on the Chatter tab. On Experience Builder sites, quick actions for work orders appear on the page-level action menu.
Actions on Related Lists Related lists in Lightning Experience (4) show custom list buttons and supported standard buttons assigned to the related list. Not all related list standard buttons are supported in Lightning Experience.
Actions on Reports Actions on reports come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on reports, regardless of which other actions are assigned to the global publisher layout.
Example: Let’s say you have these actions on your Contact page layout in the Salesforce Mobile and Lightning Experience Actions section.
You have quick actions (New Account, New Event, New Task), a productivity action (Call), standard buttons (Edit, Delete, Clone, Send an Email), and Chatter actions (Poll, Post). Here’s how those actions appear on a contact record page in Lightning Experience. • The actions in the page-level action menu are a combination of the quick actions, productivity actions, and standard buttons. These actions appear in the order that they’re listed on the page layout. Although they’re quick actions, New Event and New Task don’t show up here.
757 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• The Chatter actions from the front of the action list are on the Chatter tab.
• The Activities-related actions—Email, New Event, New Task—display on the Activity tab.
How Actions Are Ordered in Lightning Experience In Lightning Experience, the actions on record pages are derived from the list of actions in the Salesforce Mobile and Lightning Experience Actions section of the page layout for that object. The same section on global publisher layouts determines the global actions that appear in the Global Actions menu.
SEE ALSO: Quick Actions Quick Action Considerations Set Up Cases for Lightning Experience
758 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
How Actions Are Ordered in Lightning Experience
In Lightning Experience, the actions on record pages are derived from the list of actions in the EDITIONS Salesforce Mobile and Lightning Experience Actions section of the page layout for that object. The same section on global publisher layouts determines the global actions that appear in the Global Available in: both Salesforce Actions menu. Classic (not available in all If you haven’t customized the Salesforce Mobile and Lightning Experience Actions section of an orgs) and Lightning object’s page layout, the quick actions that appear on the object’s record pages are derived from: Experience
• The actions on the global publisher layout Quick actions available in: • Standard and custom buttons in the buttons section of the object page layout Group, Professional, However, the order of the actions from the global page layout aren’t respected on those record Enterprise, Performance, Unlimited, Contact pages. Manager, Database.com, When you click to override the predefined actions in the Salesforce Mobile and Lightning Experience and Developer Editions Actions section, the custom buttons in the buttons section of the page layout aren’t automatically Custom canvas actions included in the action list. You must add the custom buttons as actions from the Mobile & Lightning available in: Professional Actions category in the palette. (with Canvas enabled), After you customize the Salesforce Mobile and Lightning Experience Actions section of an object’s Enterprise, Performance, page layout, the actions in each section of the record page respect the ordering of its types of Unlimited, and Developer actions on the page layout. For example, actions in the page-level actions menu appear in the order Editions that you configure them in the Salesforce Mobile and Lightning Experience Actions section on the page layout. And actions in the Chatter and Activity tabs reflect the order of the actions supported for those tabs on the page layout.
The Global Actions menu ( ) in the Lightning Experience header displays all global quick actions from the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout, except the standard Chatter actions Post, File, Poll, Link, Question, and Thanks.
SEE ALSO: Actions in Lightning Experience Send Email Action Considerations for Cases Quick Actions
Salesforce Mobile App Action Bar Salesforce mobile app users have a one-stop place to find actions, so there’s no confusion about where to go to do something. The action bar and its associated action menu collect actions from different places in the app into a single, unified home. The productivity actions, standard and custom record buttons, and quick actions appear in the action bar and the action menu ( ). The action bar and action menu show all the available actions for a given page.
759 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Salesforce Mobile App Actions in the Action Bar and Action Menu
The action bar appears in most places in the mobile app, including the feed, groups, user profiles, dashboards and reports, standard and custom object record views, related lists, and search results. The actions that are available depend on where a user is in the app and on how you’ve configured page layouts and publisher layouts for your organization. Users may see some or all of these kinds of actions in the action bar (including the action menu). • Productivity actions—The Send Email, Call, Map, View Website, and Read News actions are available on accounts, contacts, leads, and person accounts. The Quick Message, Join Conference Call, and Map actions are available on mobile calendar events in Salesforce Today.
Tip: In most cases, a productivity action displays only if a record includes the information that the action is keyed to. For example, the Send Email action depends on the record including an email address. The View Website action requires the record to include a website URL.
• Custom and standard buttons—Buttons (such as Edit, Delete, or Clone) that are included in the Buttons section on an object’s page layout are available in the mobile app as actions in the action bar on record pages. If you haven’t customized the action order, the button order in the button section of the page layout is used. However, the Edit button is in a fixed position.
Note: Custom links, custom buttons that are added to list views, and custom buttons that define the content source as OnClick JavaScript aren’t supported and don’t appear in the Salesforce mobile app.
• Quick actions—If you add, remove, or reorder actions in the action bar in the global publisher layout or an object’s page layout, the changes are reflected in the Salesforce mobile app. • Standard Chatter actions—Actions unique to Chatter, such as Post, File, Link, or Poll.
What are the exceptions? • On accounts, the Call action appears even when there isn’t a phone number on the record. • On record feeds, the Follow/Unfollow button remain in the highlights area on the page.
760 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• On public and private group feeds, the Join Group and Ask to Join buttons remain in the highlights area, but the Leave Group button is in the action bar.
What does this mean for custom branding? There can be only one version of a custom icon. Custom action icons that you created before Winter ’15 are still supported, but they are truncated in the action bar. To optimize your custom action icons for display in the action bar, use these guidelines. • The icon should be 72 x 72 pixels. Use the full pixel area for the image—don’t leave spacing around the image like before. • Make the image a PNG with a transparent background, with a file size that is less than 10k. • Have a resolution of 72 dpi. • Make the icon graphic white or lighter than the background color. • Avoid heavy inner or outer shadows. • Use simple and flat styling resembling the Salesforce mobile app icon family.
How Actions Are Ordered in the Salesforce Mobile App Action Bar The Salesforce Mobile and Lightning Experience Actions section of a page layout and global publisher layout drives which actions appear in the Salesforce mobile app action bar. It also enables you to customize the order of quick actions, productivity actions, and standard and custom buttons that are available as actions. List Item Actions in the Salesforce Mobile App List item actions give you access to your actions in list views, task lists, and related record lists. You can use list item actions to update records directly from lists. How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions Your org’s page layouts and publisher layouts control the order in which actions appear in the Salesforce mobile app action bar and list item actions. If you don’t customize the actions in the action bar on a page layout or global publisher layout, Salesforce predefines the location of key actions. Considerations for Actions in the Salesforce Mobile App
How Actions Are Ordered in the Salesforce Mobile App Action Bar
The Salesforce Mobile and Lightning Experience Actions section of a page layout and global publisher EDITIONS layout drives which actions appear in the Salesforce mobile app action bar. It also enables you to customize the order of quick actions, productivity actions, and standard and custom buttons that Available in: both Salesforce are available as actions. Classic (not available in all If you customize the Salesforce Mobile and Lightning Experience Actions section of a layout, the orgs) and Lightning mobile app reflects your customizations. Experience If you customize the Quick Actions in the Salesforce Classic Publisher section but not the Salesforce Available in: Group, mobile app section, the actions in the mobile app action bar are a combination of those in the Professional, Enterprise, Quick Actions in the Salesforce Classic Publisher section plus any standard or custom buttons present Performance, Unlimited, on the page layout. Contact Manager, Database.com, and When you click to override the predefined actions in the Salesforce Mobile and Lightning Experience Developer Editions Actions section, the custom buttons in the buttons section of the page layout aren’t automatically included in the action list. You must add the custom buttons as actions from the Mobile & Lightning Actions category in the palette. If neither section is customized, the action bar inherits a default set of actions predefined by Salesforce. The sets of actions differ between objects based on the most common or typical activities required for each object.
761 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: You can enable dynamic actions for custom object record pages for the Salesforce mobile app. When you enable dynamic actions, you assign actions in the Lightning App Builder instead of the page layout and apply filters to control when and where actions appear for users. You can assign the same dynamic actions for desktop and mobile, or assign a different set of dynamic actions for mobile.
SEE ALSO: How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions Salesforce Mobile App Action Bar Considerations for Actions in the Salesforce Mobile App
List Item Actions in the Salesforce Mobile App List item actions give you access to your actions in list views, task lists, and related record lists. You can use list item actions to update records directly from lists. To access list item actions, navigate to a list view or task list or open a related list from an object’s related information page. Then swipe left on the desired record. Hide list item actions by swiping the list item back to the right or by tapping another item in the list.
List Views List item actions in list views don’t have the same actions that are available in the action bar when viewing an object’s record. For example, when a user visits an opportunity record in the Salesforce mobile app, the actions in its action bar reflect the actions in the Salesforce Mobile and Lightning Experience Actions section of the Opportunity page layout. However, when the user swipes left on an opportunity from a list view, as you can see below, the actions that display come from the list of predefined actions for opportunities. See How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions for the breakdown of predefined actions for each object.
Swipe a list item to the left to reveal list item Tap to show the action menu, with the Here’s the All Opportunities list view. actions. full list of actions available for the list item.
762 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Related Lists List item actions on related lists in the app reflect the same actions as the related list in Lightning Experience. Usually, these are the standard actions Edit and Delete, but can vary by object. For example, in Lightning Experience, the actions available in the dropdown menu on an Opportunity related list item are the same set of actions that Salesforce mobile app users see when swiping left on the same record in the related list.
Note: Even if your org doesn’t have Lightning Experience enabled, the actions on related lists that you see in the Salesforce mobile app still match the actions that would appear on the related list items in Lightning Experience if it was enabled.
763 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: Task and event list items are different than other objects when they display in related lists. In the mobile app, when you tap the Tasks item from the menu, you can swipe left on an item in the My Tasks list view and see the predefined actions for tasks. However, tasks and events in the Open Activities or Activity History related lists in the mobile app have no actions and aren’t swipe-able.
How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions Your org’s page layouts and publisher layouts control the order in which actions appear in the Salesforce mobile app action bar and list item actions. If you don’t customize the actions in the action bar on a page layout or global publisher layout, Salesforce predefines the location of key actions.
Important: Predefined actions apply to the Salesforce mobile app action bar only if you haven’t customized the Salesforce Mobile and Lightning Experience Actions section of an object’s page layout or a global publisher layout. Predefined actions are derived from the Quick Actions in the Salesforce Classic Publisher section of the object page layout or global publisher layout. On object page layouts, when the Salesforce mobile app section isn’t customized: If you customized the Quick Actions in the Salesforce Classic Publisher section, the quick actions in the action bar reflect those customizations. If you didn’t customize either section, the quick actions in the action bar come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
764 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
On global publisher layouts, when the Salesforce mobile app section isn’t customized: If you customized the Quick Actions in the Salesforce Classic Publisher section, the quick actions in the action bar reflect those customizations. If you didn’t customize either section, the quick actions in the action bar for global pages default to a Salesforce predefined set. Here’s the breakdown of which actions are contained in each group for each object or page. Keep in mind these considerations: • The predefined actions in the action bar, list item actions, and associated action menus are divided into groups. The arrangement of these groups is fixed. • Unless they’re in an ordered list, the order of actions within the groups can vary based on the object and the actions present on the global publisher layout or on an object’s page layout. • Some actions are in fixed positions. For actions in a numbered list, this is the fixed order that they appear in the action bar, list item actions, and in the respective action menus. – For example, for the Account object, the standard Chatter Post action is in the fourth position. This position is fixed. Regardless of where you put the Post action in the account page layout, Post always displays in the fourth position. – However, deletion of actions is respected. So in our example, if you delete the Post action from the account page layout, the remaining actions move up and you see Edit in the fourth position.
• Some action groups aren’t supported for every object or page.
Note: Actions on list view items reflect only the predefined set of actions for that object. For example, let’s say you’re viewing the All Accounts list in the Salesforce mobile app. If you swipe left on an account item in the list, you see a set of actions. Those actions come from the predefined list of actions for accounts in this chart. You always see Call, Edit, and Delete. The other actions on the list view item follow the order and rules defined for the action groups in the chart.
Table 2: Account Object Action Predefined Actions Group 1 1. Call, 2. New Task, 3. New Event, 4. Post
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Account page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Send Text (if the Phone field is populated), View Website (if the Website field is populated)
Table 3: Case Object Action Predefined Actions Group 1 Actions from the Quick Actions in the Salesforce Classic Publisher section of the Case page layout. If that section isn’t customized, quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout
765 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Predefined Actions Group
2 Edit
3 Action group 3 isn’t supported for the Case object.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Productivity actions aren’t supported for this object.
Table 4: Contact Object Action Predefined Actions Group 1 1. Call, 2. Send Email, 3. New Task, 4. New Event
2 Edit
3 Remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Contact page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.*
5 Remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Send Text
Table 5: Custom Objects Action Predefined Actions Group 1 The first four actions in the order defined on the page layout. If the Quick Actions in the Salesforce Classic Publisher section of the page layout isn’t customized, then the first four actions in the order defined on the global publisher layout.
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the page layout. If that section isn’t customized, remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.*
5 Remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Action group 6 isn’t supported for custom objects.
766 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Table 6: Event Object Action Predefined Actions Group 1 Quick actions in the order defined on the layout. Standard Chatter actions aren’t supported.
2 Edit, Delete
3–6 Action groups 3 to 6 aren’t supported for the Event object.
Table 7: Feed Object Action Predefined Actions Group 1 Quick actions in the order defined on the global publisher layout
2–6 Action groups 2 to 6 aren’t supported for the Feed object.
Table 8: Group Object Action Predefined Actions Group 1 Actions from the Quick Actions in the Salesforce Classic Publisher section of the Group page layout. If that section isn’t customized, quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
2–4 Action groups 2 to 4 aren’t supported for the Group object.
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Action group 6 isn’t supported for the Group object.
Table 9: Lead Object Action Predefined Actions Group 1 1. Log a Call, 2. New Task, 3. Convert (if enabled), 4. Post
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Lead page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Lead page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the Lead page layout.
6 In order: Call, Send Text, Send Email
767 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Table 10: “App Page” Lightning Page Action Predefined Actions Group 1 Global actions in the order defined in the Lightning page.
2–6 Action groups 2 to 6 aren’t supported for “App Page” Lightning pages.
Table 11: List View Action Predefined Actions Group 1 New
2–6 Action groups 2 to 6 aren’t supported for list views.
Table 12: Object Home Page (Tablet Only) Action Predefined Actions Group 1 1. New, 2. Sort
2–6 Action groups 2 to 6 aren’t supported for object home pages.
Table 13: Opportunity Object Action Predefined Actions Group 1 1. Log a Call, 2. New Task, 3. New Event, 4. Post
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Opportunity page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Opportunity page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the Opportunity page layout.
6 Action group 6 isn’t supported for the Opportunity object.
Table 14: Person Object Action Predefined Actions Group 1 1. Call, 2. Send Email, 3. Post
2 Action group 2 isn’t supported for the Person object.
768 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Predefined Actions Group 3 The remaining actions in the order defined on the global publisher layout
4–6 Action groups 4 to 6 aren’t supported for the Person object.
Table 15: Person Account Object Action Predefined Actions Group 1 1. Call, 2. Send Email, 3. New Task, 4. New Event
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Person Account page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Person Account page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.
6 Read News, Send Text, View Website
Table 16: Related List (for Standard Objects) Action Predefined Actions Group 1 New
2–6 Action groups 2 to 6 aren’t supported for related lists.
Table 17: Salesforce Today—Main Page Action Predefined Actions Group 1 Quick actions in the order defined on the global publisher layout
2–6 Action groups 2 to 6 aren’t supported for the Salesforce Today main page.
Table 18: Salesforce Today—Mobile Calendar Event Action Predefined Actions Group 1 1. Quick Message, 2. Join Conference Call, 3. Map
2 Action group 2 isn’t supported for Salesforce Today mobile calendar events.
769 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Action Predefined Actions Group 3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Event page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout.
4–6 Action groups 4 to 6 aren’t supported for Salesforce Today mobile calendar events.
Table 19: Task Object Action Predefined Actions Group 1 1. Edit Comments, 2. Change Date, 3. Change Status, 4. Change Priority
2 Edit
3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Task page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Standard Chatter actions aren’t supported.
4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Task page layout.*
5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the Task page layout.
6 Action group 6 isn’t supported for the Task object.
* Custom buttons that are added to the Button section of a page layout and that define the content source as URL or Visualforce are supported in the Salesforce mobile app. Remember that Visualforce pages must be enabled for use in the Salesforce mobile app. Custom links, custom buttons that are added to list views, and custom buttons that define the content source as OnClick JavaScript aren’t available in the Salesforce mobile app.
SEE ALSO: How Actions Are Ordered in the Salesforce Mobile App Action Bar Salesforce Mobile App Action Bar Considerations for Actions in the Salesforce Mobile App
770 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Considerations for Actions in the Salesforce Mobile App
• Most actions, including quick actions, productivity actions, and standard and custom buttons, EDITIONS are displayed in the action bar in the Salesforce mobile app. • The Save & New action button isn’t available in the Salesforce mobile app. Available in: both Salesforce • The Delete action is available on record pages only, not record detail pages. Classic (not available in all orgs) and Lightning • In most cases, a productivity action appears only if a record includes the information that the Experience action is keyed to. For example, the Send Email action depends on the record including an email address. The View Website action requires the record to include a website URL. On Available in: Group, accounts, the Call action appears even when there isn’t a phone number on the record. Professional, Enterprise, • By default, the Call productivity action in the mobile app action bar uses the global Log A Call Performance, Unlimited, Contact Manager, action layout. If you create one Log a Call action on an object, users see that custom Log a Call Database.com, and action’s layout when they tap Call from the object's action bar. If you create more than one Developer Editions Log a Call action for the same object, the Call action on that object uses the global Log a Call action layout. • There are a few differences between the Send Email quick action in Salesforce and the standard Email action in Case Feed: – Users can’t switch between the rich text editor and the plain text editor in a Send Email action. – Templates aren’t supported in the Send Email action. – Quick Text isn’t available in the Send Email action. – The Send Email action doesn’t support attachments. – Users can’t save messages as drafts when using the Send Email action. – Users can’t edit or view the From field in the Send Email action.
• If feed tracking isn’t enabled on an object, only nonstandard actions appear in the Salesforce mobile app action bar and in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. • If you’re using record types in your org, sometimes quick actions aren't visible to your users. For more information, see Quick Actions and Record Types on page 749. • The Mobile Smart Actions element appears as a single action element in the page layout editor, but it expands to several actions when it appears in the Salesforce mobile app. If the Mobile Smart Actions element is in Quick Actions in the Salesforce Classic Publisher section when you customize the action bar section, the actions in the app use your action bar customizations. In this case, the Mobile Smart Actions element in the Quick Actions in the Salesforce Classic Publisher section becomes irrelevant. • To customize the actions in the Salesforce mobile app action bar for standard and custom objects, first override the predefined actions. You can then add or remove actions from the Salesforce Mobile and Lightning Experience Actions section. For instance, to move the Join Group, Edit Group, or Leave Group actions on groups in the Salesforce mobile app, override the predefined actions in the Groups page layout.
• Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. • If you add a custom button to the Salesforce Mobile and Lightning Experience Actions section of a page layout, it has a lightning bolt icon in the Salesforce mobile app action bar. If the Salesforce Mobile and Lightning Experience Actions section isn't customized, the icon in the app action bar is a wrench.
SEE ALSO: How Actions Are Ordered in the Salesforce Mobile App Action Bar How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions
771 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Set Up a Mass Quick Action
A mass quick action is a quick action that gets added to an object’s search layout. After a mass quick EDITIONS action is set up, you can select up to 100 records in a list view and perform mass updates. You can use a mass quick action with cases, leads, accounts, campaigns, contacts, opportunities, work orders, Available in: Lightning and custom objects that support quick actions and have a search layout in Lightning Experience. Experience You can’t perform mass quick actions on a Recently Viewed list. Available in: Essentials, Important: You can perform a mass quick action on only the following quick action types: Group, Professional, • Create a Record Enterprise, Performance, Unlimited, and Developer • Update a Record Editions Before setting up a mass quick action: • Set up quick actions for your objects. These actions are the ones that you want users to perform USER PERMISSIONS on multiple records in a list view. To set up mass quick actions • Review Mass Quick Action Considerations. for Lightning Experience: To set up mass quick actions, customize an object’s search layout. • Customize Application 1. From Setup, click the Object Manager tab. 2. Select the object you want to allow mass quick actions on. 3. Select Search Layout. 4. Edit the List View layout. 5. In the List View Actions in Lightning Experience section, add the actions that you want your users to be able to perform on list views for multiple records. Here’s an example of the List View Actions for the case object.
6. Click Save. The list view for the object you updated now displays buttons for the actions you added. Users can select multiple records in the list view and use the mass quick action button to perform bulk updates. To help users understand the changes they’re making, a “Fields to update” section is included in the quick action layout.
772 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Mass Quick Action Considerations Review these guidelines and considerations before setting up and using mass quick actions in list views.
SEE ALSO: Mass Quick Action Considerations
Mass Quick Action Considerations
Review these guidelines and considerations before setting up and using mass quick actions in list EDITIONS views. Setting Up a Mass Quick Action Available in: Lightning Experience • Mass quick actions are available only in Lightning Experience apps, including apps with standard and console navigation. Available in: Essentials, • You can’t perform mass quick actions in Experience Cloud sites, or on notes or users. Personal, Group, Enterprise, Performance, • You can’t use the Tooling API, AppExchange, and Changesets to add mass quick actions to Unlimited, Developer, and an object’s search layout. Professional Editions • If you want to set up predefined field values for a quick action, we recommend not including those fields on the quick action’s layout. If a predefined field value is included in the quick action’s layout, it’s only updated if the user manually selects it. If a predefined field value isn’t included in the quick action’s layout, the predefined value is updated, but the user isn't notified of the change. The “Fields to update” section includes only predefined field values that are specified in the layout.
Using a Mass Quick Action • When using a mass quick action, only the fields you manually modify are changed. Some fields show a default value, but changes aren’t made unless you manually select them. The “Fields to update” section shows the changes you’re making. • You can’t perform a mass quick action on a Recently Viewed list view. • You can’t undo changes performed by a mass quick action—so be careful when making your changes. • Mass actions in split view use the same logic as mass actions in table view. • If you use a mass quick action on only one record, the “Fields to update” section isn’t displayed.
Example: This mass quick action updates the owner on cases. The Case Owner field displays Awesome Admin because the user modified this field. The Status field displays New because that was the value of all the selected records. The changes to make are listed in the “Fields to update” section.
773 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: If the selected records had different statuses, such as one was set to New and one was set to Escalated, the Status field would display None.
SEE ALSO: Set Up a Mass Quick Action
Custom Buttons and Links
Custom buttons and links help you integrate Salesforce data with external URLs, applications, your EDITIONS company’s intranet, or other back-end office systems. Salesforce supports these custom links and custom buttons. Available in: Salesforce Classic Type of Custom Link or Custom Button Setup Page Where It’s Configured Available in: All Editions Bookmark-style links defined in the standard Home Page Components except Database.com custom links home page component
Full-featured custom links included in custom Custom Links USER PERMISSIONS home page components To create or change custom Full-featured custom links or custom buttons Buttons, Links, and Actions (in the object’s buttons or links: on objects management settings) • Customize Application
Custom links can link to an external URL, such as www.google.com, a Visualforce page, or your company’s intranet. Custom links can also link to a custom s-control in the custom s-control library, such as a Java applet or Active-X control. Custom buttons can: • Connect users to external applications, such as a web page that displays a map to a contact’s address. • Run an s-control from the s-control library, such as an s-control that escalates a case from the case detail page. • Launch custom links. You can choose the display window properties that determine how the target of a link or button is displayed to your users. Custom links and s-controls can include Salesforce fields as tokens within the URL or custom s-control. For example, you can include an account name in a URL that searches Yahoo: http://search.yahoo.com/bin/search?p={!Account_Name}. You can override the default action of some standard buttons and customize the behavior of tab home pages to suit your org’s needs.
Define Custom Buttons and Links Define the action that occurs when a user clicks a custom button or link. Custom buttons and links can streamline actions within Salesforce or integrate Salesforce data with external URLs, applications, or systems. Override Standard Buttons and Tab Home Pages You can override the behavior of standard buttons—like New, View, or Edit—in Salesforce Classic, Lightning Experience, and mobile independently. You can also override the tab home page that displays when a user clicks a standard, custom, or external object tab. Custom Button and Link Samples Use samples of custom Salesforce buttons and links to determine whether they can work for you. Custom Button and Link Considerations Keep these considerations in mind when working with custom buttons and links.
774 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Viewing References to Salesforce Components
SEE ALSO: Define Custom Buttons and Links Adding Default Custom Links Customize Salesforce Classic Home Tab Page Layouts
Define Custom Buttons and Links
Define the action that occurs when a user clicks a custom button or link. Custom buttons and links EDITIONS can streamline actions within Salesforce or integrate Salesforce data with external URLs, applications, or systems. Available in: Salesforce Watch a Demo (English only) Classic (not available in all orgs) If you want the button or link to launch a custom page or other code, consider a Visualforce page. 1. From the management settings for the object that you want to edit, go to Buttons, Links, and Custom buttons and links are available in: All Editions Actions. Visualforce pages and Note: Custom buttons aren’t available on the User object or custom home pages. Custom s-controls are available in: buttons and links are available for activities under the individual object management Contact Manager, Group, settings for tasks and events. To override a standard button that applies to both tasks and Professional, Enterprise, events, go to the object management settings for activities. Performance, Unlimited, and Developer Editions 2. Click New Button or Link. Alternatively, click Default Custom Links to add a predefined custom link. 3. For Display Type, select Detail Page Link, Detail Page Button, or List Button. USER PERMISSIONS
Note: If you select List Button, and your list button requires users to select individual To create or change custom records in a list, then select Display Checkboxes (for Multi-Record Selection). When buttons or links: you select this option, a checkbox appears next to each list item to let users select records, • Customize Application and the list button action is applied to those records. Don’t select Display Checkboxes (for Multi-Record Selection) if your list button doesn’t require users to select individual records in the list. For example, your list button links to a URL that doesn’t support POST operations, such as a URL that links to a Lightning component. In Lightning Experience, when you select Display Checkboxes (for Multi-Record Selection), the related list type must be set to Enhanced List. You can set the related list type for a related list on a record page in the Lightning App Builder.
4. Enter the button or link attributes. Here’s an example of the attributes for a button that performs a web search for an account’s name.
775 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
5. To validate all Salesforce merge fields and functions, click Check Syntax. 6. Click Save when you’re finished, or click Quick Save to save and continue editing. Saving validates the URL you defined if you set the content source to URL. 7. To open a button or link using settings other than the user’s default browser settings, click Window Open Properties on the button or link’s detail page. 8. To view all references to the new button or link, click Where is this used? on its detail page. Custom links for users are automatically added to the Custom Links section of the user detail page. You can add page buttons only to the Button section of a page layout.
Note: A link URL can be up to 2,048 bytes. When data is substituted for the tokens in the URL, the link can exceed 3,000 bytes. Some browsers enforce limits on the maximum URL length. Before you can use your custom buttons and links, add them to an object’s page layout. You can then see and use the button or link on a record detail page.
Custom Button and Link Fields This table defines the fields that are available when you create a custom button or link. Constructing Effective Custom URL Buttons and Links Use these methods to construct effective custom URL buttons and links. Editing Window Open Properties
776 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Merge Fields for Custom Buttons and Links Adding Default Custom Links Custom Link Best Practices Custom buttons and links can streamline actions within Salesforce, or integrate Salesforce data with external URLs, applications, or systems. Use these best practices to get the most out of your custom links.
SEE ALSO: Find Object Management Settings Custom Button and Link Considerations Custom Button and Link Samples
Custom Button and Link Fields
This table defines the fields that are available when you create a custom button or link. EDITIONS
Attribute Name Description Available in: Salesforce Label Enter the text that displays in the user interface for the custom button or Classic link. Custom buttons and links are available in: All Editions Name Accept or enter the unique name to use for the button or link when it’s except Database.com referenced from a merge field. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must Visualforce pages and begin with a letter, not include spaces, not end with an underscore, and s-controls are available in: not contain two consecutive underscores. Contact Manager, Group, Professional, Enterprise, Namespace Enter the prefix that uniquely identifies your package. In a packaging Performance, Unlimited, Prefix context, a namespace prefix is a one to 15-character alphanumeric identifier and Developer Editions that distinguishes your package and its contents from packages of other developers on AppExchange. Namespace prefixes are case-insensitive. For example, ABC and abc are not recognized as unique. Your namespace prefix must be globally unique across all Salesforce organizations. It keeps your managed package under your control exclusively.
Protected Optionally limit use in a subscriber org. Protected components can’t be Component linked to or referenced by components created in a subscriber org. A developer can delete a protected component in a future release without worrying about failing installations. However, once a component is marked as unprotected and is released globally, the developer can’t delete it.
Description Enter text that distinguishes the button or link from others. This text displays only to administrators when setting up buttons and links.
Display Type Determine where the button or link appears on page layouts. Detail Page Link Adds the link to the Custom Links section of your page layouts. Detail Page Button Adds the custom button to a record’s detail page. You can add detail page buttons to the Button section of a page layout.
777 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Attribute Name Description
List Button Adds the custom button to a list view, search result layout, or related list. You can add list buttons to the Related List section of a page layout or the List View and Search Result layouts. For list buttons, Salesforce selects the Display Checkboxes (for Multi-Record Selection) option to include a checkbox next to each record in the list. Users can select the records they want applied to the action on the list button. If your custom button doesn’t require the user to select records, deselect this option.
Behavior Choose the outcome of clicking the button or link. When applicable, some settings have default values. For example, if you choose Display in new window, the default height of a new window is 600 pixels. See Editing Window Open Properties.
Note: Custom button links open in a new tab in Experience Builder sites, even if any of the Display in existing window options is selected.
Content Source Choose whether to use a URL, s-control, JavaScript action, or Visualforce page as the content of the button or link. Salesforce checks the correctness of URLs in custom links and custom buttons. When you create or edit custom links or buttons that contain invalid URL markup, such as scripts, Salesforce blocks the links from rendering. Instead, an error message is shown on hover. Reconfigure the URLs to be valid and well formed. The URL can be a relative URL or an absolute http://, https://, file://, ftp://, or mailto:// address. Invalid URLs in custom links or custom buttons created before Spring ’13 aren’t checked for correctness until you edit them.
Content Enter the content of the button or link for buttons and links of type URL or OnClick JavaScript. • To insert a field, choose the field type from Select Field Type and choose a field from Insert Field. • To insert activity merge fields, select Event or Task from Select Field Type. • To insert an operator, choose the appropriate operator icon from the Insert Operator drop-down list. • To insert a function, double-click its name in the list, or select it and click Insert Selected Function. To filter the list of functions, choose a category from the Functions drop-down list. Select a function and click Help on this function to view a description and examples of formulas using that function.
Tip: Internet standards require special encoding for URLs. Salesforce encodes the text from any merge field you insert into a link. Encode extra text in your link manually. For example, to generate the following URL:
http://www.google.com/search?q={!user.name} Steve Mark 50%
Use this content:
http://www.google.com/search?q={!user.name}+Steve+Mark+50%25
Salesforce strips double quotes from URLs when the content source is a URL. If you must use double quotes, encode them manually. For example, to generate the URL http://www.google.com/search?q="salesforce+foundation", use this
778 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Attribute Name Description
content: http://www.google.com/search?q=%22salesforce+foundation%22
Link Encoding Choose the encoding setting. Encoding defaults to Unicode (UTF-8). Change the default encoding setting if the target of a link requires data in a different format. Encoding is available if your Content Source is URL.
Constructing Effective Custom URL Buttons and Links
Use these methods to construct effective custom URL buttons and links. EDITIONS Use merge fields to pass Salesforce data. You can add merge fields to a custom link to pass data from your Salesforce records, user Available in: Salesforce information, or company information to another website or application. Classic (not available in all orgs) For example, you can create custom links that search Google for an account name or look up an address on a map. Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
http://google.com/search?q={!Account.Name}
http://maps.google.com?q={!Account.ShippingStreet} {!Account.ShippingCity} {!Account.ShippingState} {!Account.ShippingPostalCode}
Note: Custom links don’t support data type conversion. When creating custom links to pass data from one Salesforce field to another, the data must match the data type of the fields in which you are placing it. For example, if you have numeric data, you must pass it to a numeric field. Substitute symbols for certain characters or use URLENCODE(). Due to URL encoding standards set forth by the World Wide Web Consortium (W3C), certain “unsafe” characters, such as spaces and punctuation marks, can’t be passed through a URL. Custom buttons and links escape these characters, so you don’t have to URL-encode them. If you need to encode your URL, use the URLENCODE() function in the merge field like so: {!URLENCODE(text)} and replace text with the merge field or text string that you want to encode. For example: If the merge field foo__c contains Mark's page, {!URLENCODE(foo_c)} results in: %3CB%3EMark%27s%20page%3C%2Fb%3E.
779 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Use URLFOR() to link to Visualforce pages. To link to a Visualforce page, use URLFOR() with the relative path to the page, which is /apex/PageName. For example, to link to a Visualforce page called MissionList that isn’t associated with a record, use the following syntax.
{! URLFOR( “/apex/MissionList” ) }
When you use URLFOR() with a Visualforce page, and you want to pass a record ID into the page, you must pass the ID in as a parameter.
{! URLFOR( “/apex/Mission”, null, [id=Mission__c.Id] ) }
Use the $Action global variable and URLFOR() to point to Salesforce pages. When creating a custom button or link that points to a page in Salesforce, use the $Action global variable to construct the link, instead of pasting in the path to the page. Then, if your organization is moved to another server or the URL to the page changes, the link still points to the right place. To construct the link, use the URLFOR() formula function with the $Action variable.
{!URLFOR( $Action.Case.NewCase, Account.Id )}
This custom link on the Account object opens the New Case form, creating the case as a child of the account record. You can use this process for any object that has a lookup to the Account object. To create a record that isn’t a child of another record, or if two objects have no relationship, you can use $ObjectType.ObjectName as the second argument. For example:
{!URLFOR( $Action.Case.NewCase, $ObjectType.Case )}
$Action global variables expect either a record ID or the $ObjectType. For example, these formulas create links to the tab and detail page for an account, respectively.
{!URLFOR( $Action.Account.Tab, $ObjectType.Account )}
{!URLFOR( $Action.Account.View, Some_Account_Lookup__c.Id )}
The URLFOR() function takes additional optional arguments that get passed into the destination as query string parameters. You can use these arguments when overriding a standard action with a Visualforce page to pass in the additional parameters needed by the Visualforce page or its controller. For example, if when closing a case you want to change the value of a custom field on the case called Actual Delivery Date to today, you could use:
{!URLFOR($Action.Case.CloseCase, Case.Id, [ actualDeliveryDate=TODAY()] )}
You can then override the Close Case action with a Visualforce page and handle setting the value of the Actual Delivery Date field either in that Visualforce page or its controller. See Using Query String Parameters in a Visualforce Page for more information. Use these Lightning-friendly URL button and link methods to point to other pages in Lightning Experience.
Custom URL Button or Link Lightning Experience Behavior External URL URL opens in new tab
www.google.com
Relative Salesforce URL, View Record home page opens in existing tab
/{!Account.Id}
Relative Salesforce URL, Edit Edit overlay pops up on the existing page
780 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Custom URL Button or Link Lightning Experience Behavior
/{!Account.Id}/e
Relative Salesforce URL, List Object home page opens in existing tab
/001/o
$Action URL, View Record home page opens in existing tab
{!URLFOR($Action.Account.View, Account.Id)}
$Action URL, Edit Edit overlay pops up on the existing page
{!URLFOR($Action.Account.Edit, Account.Id)}
Note: Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app.
SEE ALSO: Custom Link Example: Link to Documents Custom Link Example: Link to Files in Chatter Custom Link Example: Link to Reports
Editing Window Open Properties
Custom buttons and links can open in different types of windows. If you have selected a custom EDITIONS button or link to open in a popup window, set the window properties. If you leave the window properties blank, the custom button or link will use the default settings of the user’s browser. Available in: Salesforce To edit the window open properties: Classic 1. From the management settings for the object whose button or link you want to edit, go to Available in: All Editions Buttons, Links, and Actions, and then click the button or link name. Custom buttons are not except Database.com available on the user object. S-controls are available in: 2. Click Window Open Properties. Contact Manager, Group, Professional, Enterprise, 3. Edit the following properties. Performance, Unlimited, and Developer Editions Window Property Description Width The width (in pixels) of the popup. USER PERMISSIONS Height The height (in pixels) of the popup. To edit custom button or link Window Position The location on the screen where the popup properties: should open. • Customize Application Resizeable Allow users to resize the popup window.
781 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Window Property Description Show Address Bar Show the browser’s address bar which contains the URL.
Show Scrollbars Show browser scrollbars for the popup.
Show Toolbars Show the browser toolbars. Toolbars normally contain navigation buttons like Back, Forward, and Print.
Show Menu Bar Show the browser menus. The menus typically contain option like File and Edit.
Show Status Bar Show the status bar at the bottom of the browser.
Note: Some properties may not be available depending on the behavior of the custom button or link. For example, if you chose Execute JavaScript, no window open properties are available.
4. Save your changes.
SEE ALSO: Define Custom Buttons and Links
Merge Fields for Custom Buttons and Links
A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. Available in: Salesforce Syntax and Formatting Classic When you insert a merge field in a custom button or link, the syntax consists of an open curly brace Custom buttons and links and exclamation point, followed by the object name, a period, the field name, and a closing curly are available in: All Editions brace. except Database.com Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
{!Object_Name.Field_Name}
To ensure that you’re using the correct syntax, select merge fields from the dropdown list in the editor for custom buttons and links.
Note: Custom objects named “Org”, can’t be used in a merge field. Objects named “org’ are explicitly filtered from the Select Field Type list for a custom button.
Tips • To insert activity merge fields, select Event or Task from the Select Field Type dropdown list.
782 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• You can add links quickly to the sidebar by using the standard home page’s Custom Links component.
Warning: The standard home page’s Custom Links component doesn’t support – Merge fields – Functions, such as URLFOR – JavaScript execution – Customizable window opening properties
SEE ALSO: Generate Emails From Records Custom Button and Link Considerations
Adding Default Custom Links
1. From the management settings for the appropriate object, go to Buttons, Links, and Actions EDITIONS or to Buttons and Links. 2. Click Default Custom Links. Available in: Salesforce Classic 3. Next to a sample link you want to add, click Add Now!. 4. Change the default data for the link, as necessary. Available in: All Editions except Database.com 5. Choose Save. 6. Edit the page layout for the appropriate tab to display the new link. USER PERMISSIONS
SEE ALSO: To create or change custom links: Define Custom Buttons and Links • Customize Application
Custom Link Best Practices
Custom buttons and links can streamline actions within Salesforce, or integrate Salesforce data with EDITIONS external URLs, applications, or systems. Use these best practices to get the most out of your custom links. Available in: Salesforce Note: Salesforce checks the correctness of URLs in custom links and custom buttons. When Classic (not available in all you create or edit custom links or buttons that contain invalid URL markup, such as scripts, orgs) Salesforce blocks the links from rendering. Instead, an error message is shown on hover. Custom buttons and links Reconfigure the URLs to be valid and well formed. The URL can be a relative URL or an absolute are available in: All Editions http://, https://, file://, ftp://, or mailto:// address. Invalid URLs in Visualforce pages and custom links or custom buttons created before Spring ’13 aren’t checked for correctness until s-controls are available in: you edit them. Contact Manager, Group, Professional, Enterprise, Best Practices for Advanced Users Performance, Unlimited, and Developer Editions Salesforce has no plans to change field names; however, that doesn’t guarantee that field names won’t change in the future. Therefore, custom links that include Salesforce fields may change how they are mapped.
783 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Pass Session IDs with SSL Never pass session IDs to an “http” URL. Instead, pass session IDs with a secure sockets layer (SSL) “https” URL. Any data that is passed to other applications hosted on the Internet should always use SSL since the URL may contain sensitive customer information. Single Sign-On Use custom links to pass a session ID to support Single Sign-On (SSO), so users can avoid multiple logins to web applications that your organization hosts to manage Salesforce data. Construct your custom link to pass the {!User_Session_ID} merge field, which allows users to access all authorized resources during a single authentication. External systems can access Salesforce resources using a web service, which allows organizations to communicate data without intimate knowledge of each other's IT systems behind a firewall. Send the Server Date in the URL Some integration projects need custom links to include a server date to know the Salesforce initiation date. The Salesforce server date can be passed to external systems using custom links. For example, http://someurl.com/somepath?current_date={!Today}. Dates use the Pacific time zone. Avoid Double Sets of Tabs in a Browser Unlimited Edition and Enterprise Edition users can build a custom link to perform an action that keeps users in the same browser window and doesn’t display a double set of tabs. Create a Visualforce page that contains the following code, replacing with your regular or existing custom link.
784 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Override Standard Buttons and Tab Home Pages
You can override the behavior of standard buttons—like New, View, or Edit—in Salesforce Classic, EDITIONS Lightning Experience, and mobile independently. You can also override the tab home page that displays when a user clicks a standard, custom, or external object tab. Available in: Salesforce Button overrides are global. For example, if you override the New button on opportunities, your Classic (not available in all replacement action takes effect wherever that action is available, such as: orgs) and Lightning Experience • Opportunities home page • Any opportunities related lists on other objects, such as accounts Available in: Enterprise, Performance, Unlimited, • Create New dropdown list in the Salesforce Classic sidebar and Developer Editions • Any browser bookmarks for this Salesforce page Visualforce overrides also 1. From the object management settings for the object you want to set an override for, go to available in: Contact Buttons, Links, and Actions. Manager, Group, and 2. Click Edit next to the button or tab home page you want to override. Professional Editions Record types available in: 3. For each experience—Salesforce Classic, Lightning Experience, or mobile—click the type of Professional, Enterprise, override you want associated with the action. Performance, Unlimited, • No override (use default)—Use a custom override provided by an installed package. If and Developer Editions there isn't one installed, the standard Salesforce behavior is used. • Standard page—This option is available only for subscribers who are overriding the actions on an installed custom object. If selected, the standard Salesforce behavior is used. USER PERMISSIONS • Custom s-control—Use the behavior from an s-control. This option isn’t supported for To override standard buttons mobile. and tab home pages: • Customize Application Important: Visualforce pages supersede s-controls. Organizations that haven’t previously used s-controls can’t create them. Existing s-controls are unaffected, and To reset button and tab home page overrides: can still be edited. • Customize Application • Lightning component—Use the behavior from a Lightning component. Supported only for the Edit, New, New Event, Tab and View actions. This option isn’t supported for Salesforce Classic. • Lightning page—Use the behavior from the Lightning record page assigned as the org default for the object. This option is available only for the View action in Lightning Experience. • Visualforce page—Use the behavior from a Visualforce page. • Use the Salesforce Classic override—Inherits the behavior from the Salesforce Classic Override setting.
Important: Before you override a standard button with a Lightning component or Visualforce page, review implementation details in the respective developer guides.
4. Select the name of the s-control, Lightning component, Lightning page, or Visualforce page you want to run when users click the button or tab. When overriding the New button with a Visualforce page, you can choose to skip the record type selection page. If you do, new records you create aren’t forwarded to the record type selection page. Salesforce assumes that your Visualforce page is already handling record types.
Important: When a Salesforce mobile app user clicks New to create a product, the user must select a record type even if the Skip record type selection page option is selected in Setup.
5. Click Save.
785 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: A standard button (New, Edit, View, Delete, and Clone) overridden with a Visualforce page doesn’t show up in the Salesforce mobile app unless the Visualforce page is enabled for Salesforce mobile apps. Overriding standard list and tab controls isn’t supported in mobile.
Standard Action Overrides For standard actions, such as Delete, Edit, List, New, Tab, and View, you can provide a custom user interface for the action, called an action override. Use action overrides when your business model requires a more customized user experience than the Salesforce standard page provides. Considerations for Overriding Standard Buttons Before you override a standard button, review these considerations. Remove Overrides for Standard Buttons and Tab Home Pages
SEE ALSO: Considerations for Overriding Standard Buttons Remove Overrides for Standard Buttons and Tab Home Pages Visualforce Developer Guide : Overriding Buttons, Links, and Tabs with Visualforce Lightning Aura Components Developer Guide : Standard Actions and Overrides Basics
Standard Action Overrides
For standard actions, such as Delete, Edit, List, New, Tab, and View, you can provide a custom user EDITIONS interface for the action, called an action override. Use action overrides when your business model requires a more customized user experience than the Salesforce standard page provides. Available in: Salesforce You can specify a different override for each user experience, with the following guidelines. Classic (not available in all orgs) and Lightning • Salesforce Classic—Use a Visualforce page as the action override. Experience • Lightning Experience and the Salesforce mobile app —You can override the Edit, New, Tab, and View standard actions on most standard and all custom objects. Available in: Enterprise, Performance, Unlimited, • Lightning Experience—Use a Lightning component as the action override for the Edit, New, and Developer Editions and Tab actions. Use a Lightning page or a Lightning component as the action override for the View action. Visualforce overrides also available in: Contact • Experience Builder sites—Use a custom Lightning component to replace standard forms when Manager, Group, and users click the New or Edit button. The action you choose in Lightning Experience is the same Professional Editions action that you use to override actions in Experience Builder sites. Record types available in: • Salesforce app—Use a Lightning component as the action override. Professional, Enterprise, • Managed packages—Developers can include action overrides as package defaults, and managed Performance, Unlimited, package subscribers can specify local overrides as alternatives to the default overrides. and Developer Editions
Note: For Salesforce Classic, usually a Visualforce page is the only supported override option. Under certain conditions, you can use existing s-controls as overrides for Salesforce Classic. USER PERMISSIONS However, s-controls have been deprecated since the Spring ’09 release. We recommend using Visualforce pages instead. To override standard buttons: • Customize Application
786 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Assign Action Overrides To assign a Visualforce page or Lightning component as an override, first create the page or component (or use one created by a Salesforce developer in your org). It’s important to understand the action override options for each user experience and how your selections for each one can affect the others. Assign a Lightning Record Page Override for the View Action When you create an override for the View action for Lightning Experience, you can use either a Lightning record page or a Lightning component. To use a Lightning record page as an override, you must activate the page as the org default in the Lightning App Builder. Action Overrides in Managed Packages In a managed package, overrides specified by the package developer are included as default overrides. The package subscriber can specify local overrides for each user experience to use instead of the package default overrides. Package default overrides impact the options and behaviors of local overrides. Action Overrides in Experience Builder Sites Personalize your Experience Builder site users’ experience by adding a custom Lightning component to replace standard forms when users click the New or Edit button. Use action overrides when your site and portal users require a more customized user experience than the Salesforce standard page provides.
SEE ALSO: Trailhead: Introduction to Creating Visualforce Pages Trailhead: Build a Lightning Component to Override a Standard Action
Assign Action Overrides
To assign a Visualforce page or Lightning component as an override, first create the page or EDITIONS component (or use one created by a Salesforce developer in your org). It’s important to understand the action override options for each user experience and how your selections for each one can Available in: Salesforce affect the others. Classic (not available in all When assigning overrides, keep in mind the following requirements. orgs) and Lightning Experience • Salesforce Classic—To use a Visualforce page to override an action, the Visualforce page must use the standard controller for the object on which the action appears. To use a Visualforce Available in: Enterprise, page to override a tab, the Visualforce page must use the standard list controller for that tab’s Performance, Unlimited, associated object. and Developer Editions • Lightning Experience and the Salesforce mobile app—To make a Visualforce page available Visualforce overrides also for use as an override, select Available for Lightning Experience, Experience Builder sites, available in: Contact and the mobile app in the Visualforce Pages setup panel. Manager, Group, and Professional Editions 1. Click Setup, select Object Manager, and select the object that you want to modify. Record types available in: 2. In the Object Manager settings list, select Buttons, Links, and Actions. Professional, Enterprise, 3. In the row for the action you want to modify, select Edit from the dropdown menu. Performance, Unlimited, and Developer Editions 4. Specify the override option for each user experience.
USER PERMISSIONS
To override standard buttons: • Customize Application
787 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Example: This Override Properties panel specifies a Visualforce page for Salesforce Classic and a Lightning component for Lightning Experience. The mobile override specifies the Salesforce Classic override, so mobile users see the Visualforce page.
SEE ALSO: Trailhead: Introduction to Creating Visualforce Pages Trailhead: Build a Lightning Component to Override a Standard Action
Assign a Lightning Record Page Override for the View Action
When you create an override for the View action for Lightning Experience, you can use either a EDITIONS Lightning record page or a Lightning component. To use a Lightning record page as an override, you must activate the page as the org default in the Lightning App Builder. Available in: Salesforce 1. Click Setup, enter Lightning App in the Quick Find box, and select Lightning App Classic (not available in all Builder. orgs) and Lightning Experience 2. In the Setup panel for the Lightning App Builder, click Edit next to the Lightning page that you want to use as an override. Available in: Enterprise, Performance, Unlimited, 3. In the Lightning App Builder, click Activation. and Developer Editions 4. On the Activation page, select Org Default and click Close. After you activate the Lightning Visualforce overrides also page as the org default, the page is selected as the Lightning Experience override for the View available in: Contact action in the Override Properties panel. Manager, Group, and 5. To remove the Lightning page as the override, return to the Activation page in the Lightning Professional Editions App Builder, click Remove as Org Default, and click Close.. Record types available in: Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To override standard buttons: • Customize Application
788 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Example: In this Override Properties panel, the Lightning page Account_Lightning_Page_Test is the specified Lightning Experience override for the View action.
SEE ALSO: Create and Configure Lightning Experience Record Pages
Action Overrides in Managed Packages
In a managed package, overrides specified by the package developer are included as default EDITIONS overrides. The package subscriber can specify local overrides for each user experience to use instead of the package default overrides. Package default overrides impact the options and behaviors of Available in: Salesforce local overrides. Classic (not available in all Several rules determine local override behaviors in a managed package. orgs) and Lightning Experience • For each user experience—When a package subscriber specifies a local override, the local override takes precedence over the package default override. If no local override is specified Available in: Enterprise, for a user experience, the package default override for that user experience is used. Performance, Unlimited, • For Lightning Experience and the Salesforce mobile app—If no local override is specified and and Developer Editions no package default override is specified, the local override inherits from Salesforce Classic. Either Visualforce overrides also the Salesforce Classic local override (if it is specified) is used, or the Salesforce Classic package available in: Contact default override (if no Salesforce Classic local override is specified) is used. Manager, Group, and Professional Editions • A package developer can remove or replace the default overrides when updating a managed package. The new default overrides are available for package subscribers when they install the Record types available in: updated package. Professional, Enterprise, Performance, Unlimited, Example: The Override Properties panel for a managed package identifies the override and Developer Editions defaults and the local override options for each user experience. The available local override options vary based on the override defaults. • No override (use default)—Uses either the override default Visualforce page or the USER PERMISSIONS Salesforce standard page if no Visualforce page is specified. To override standard • Standard page—Available for package subscribers only if the package default override buttons: for the given user experience is a Visualforce page or Lightning component. • Customize Application • Lightning component—The specified component takes precedence over the package default override for the given user experience.
789 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• Use the package default override—Available for package subscribers only if the package default override for the given user experience is a Lightning component. • Use the Salesforce Classic override—Available for package subscribers only if the package default override for the given user experience is the Salesforce standard page. Option inherits from the local Salesforce Classic override.
Action Overrides in Experience Builder Sites
Personalize your Experience Builder site users’ experience by adding a custom Lightning component EDITIONS to replace standard forms when users click the New or Edit button. Use action overrides when your site and portal users require a more customized user experience than the Salesforce standard page Available in: Salesforce provides. Classic (not available in all To override actions in an Experience Builder site: orgs) and Lightning Experience 1. In Salesforce Setup, enter Digital Experiences in the Quick Find box and select All Sites. Available in: Essentials,Enterprise, 2. Next to the site that you want to override, click Workspaces. Performance, Unlimited, 3. Click Administration. and Developer Editions 4. Select Override standard actions with the Lightning component. 5. Click Save. USER PERMISSIONS
Note: The action you choose in Lightning Experience is the same action that you use to To override standard override actions in Experience Builder sites. buttons: • Customize Application
790 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Considerations for Overriding Standard Buttons
Before you override a standard button, review these considerations. EDITIONS
Implementation Tips Available in: Salesforce Classic (not available in all Important: Before you override a standard button with a Lightning component or Visualforce orgs) and Lightning page, review implementation details in the respective developer guides. Experience
• If you override a standard button in Salesforce, that button is still available in Connect Offline, Available in: Enterprise, but it retains its original behavior. Performance, Unlimited, • The View standard button refers to all links in Salesforce that display the detail page for a record. and Developer Editions Overriding the View standard button reroutes all these links. Visualforce overrides also • The View action is the only one that supports overrides with a Lightning record page. To make available in: Contact a Lightning record page available for a View action override, assign the page as the org default Manager, Group, and for its associated object by activating it in the Lightning App Builder. Professional Editions • If you have the View action overridden with a Visualforce page in Salesforce Classic, the Setup Record types available in: menu on that object record page in Lightning Experience displays the Edit Page option. Selecting Professional, Enterprise, Edit Page in Lightning Experience on an object page that’s overridden with a Visualforce page Performance, Unlimited, in Salesforce Classic lets you create a custom Lightning Experience record page for that object and Developer Editions in the Lightning App Builder. • If a button isn’t available for overrides, you can still hide it on the page layout. USER PERMISSIONS • Button overrides affect everywhere that action or behavior is available. For example, overriding the New button on an account also overrides the account option in the Create New drop-down To override standard list in the Salesforce Classic sidebar. buttons: • Customize Application • Person Account records use any standard button overrides you make for accounts. Person Account records also use any overrides for the View Self-Service and Enable Self-Service buttons you make for contacts. • If your organization uses the Console tab, overrides for the Edit and View buttons for an object don’t affect the Edit and View buttons in the mini page layouts. Pages that display due to overrides display in the console without the header or sidebar. • To replace a standard button with a custom button, first define the custom button, then customize the page layout to hide the standard button and display the custom one in its place. • When you override the Edit button with a Visualforce page, you’re also overriding default logic that checks whether the record has been locked for approval. However, you can perform the same check by implementing the Approval.lock Apex method.
Limitations • You can override buttons on the detail page but not the edit page of a record. • You can only override these standard buttons: New, View, Edit, and Delete. • For tasks and events in Salesforce Classic, you can only override standard buttons and links, with the exception of the New Event button. Overrides for that button aren’t supported in Salesforce Classic. In Lightning Experience, you can override the New Event button on the Calendar page with a Lightning component for a custom object, but clicking a timeslot always creates a standard event. • You can’t change buttons on lookup dialogs, reports, or tabs. However, you can change the buttons on list view and search result layouts under search layouts. • Action overrides on the New standard button don't work on New Object links in lookup searches.
791 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
• Action overrides on the New standard button for objects with multiple record types aren’t supported in the Outlook and Gmail integrations unless you choose to skip the record type selection page. • You can’t relabel or relocate standard buttons on a record detail page. • When overriding tabs or buttons with a Lightning component, you can select only Lightning components that implement the lightning:actionOverride interface. • A standard button (New, Edit, View, Delete, and Clone) overridden with a Visualforce page doesn’t show up in the Salesforce mobile app unless the Visualforce page is enabled for Salesforce mobile apps. Overriding standard list and tab controls isn’t supported in mobile. • When overriding tabs with a Visualforce page, you can select only Visualforce pages that use the standard list controller for that tab’s associated object, pages with a custom controller, or pages with no controller. • When overriding lists with a Visualforce page, you can select only Visualforce pages that use a standard list controller. • When overriding buttons with a Visualforce page, you can select only Visualforce pages that use the standard controller for the object on which the button appears. For example, if you want to use a page to override the Edit button on accounts, the page markup must include the standardController="Account" attribute on the tag:
... page content here ...
SEE ALSO: Override Standard Buttons and Tab Home Pages Visualforce Developer Guide : Overriding Buttons, Links, and Tabs with Visualforce Lightning Aura Components Developer Guide : Standard Actions and Overrides Basics
792 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Remove Overrides for Standard Buttons and Tab Home Pages
To remove overrides for actions that support overrides for Classic, Lightning, and mobile web: EDITIONS 1. From the management settings for the object whose button you want to edit, go to Buttons, Links, and Actions. Available in: Salesforce Classic (not available in all 2. Click Edit next to the overridden button or tab link. orgs) and Lightning 3. Select No override (use default) for the Salesforce Classic override Experience
4. To also remove overrides for Lightning Experience or Mobile, select Use the Salesforce Classic Available in: Enterprise, override. Performance, Unlimited, 5. Click Save and Developer Editions Visualforce overrides also available in: Contact Manager, Group, and Professional Editions Record types available in: Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To override standard buttons and tab home pages: • Customize Application To reset button and tab home page overrides: • Customize Application
To remove overrides for actions that support only Classic: 1. From the management settings for the object whose button you want to edit, go to Buttons, Links, and Actions. 2. Click Edit next to the overridden button or tab link. 3. Select No override (use default) for Salesforce Classic Override. 4. Click Save
793 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Custom Button and Link Samples
Use samples of custom Salesforce buttons and links to determine whether they can work for you. USER PERMISSIONS
Custom Link Example: Link to Documents To create or change custom buttons or links: Use custom links to reference documents from a Salesforce record detail page. • Customize Application Custom Link Example: Link to Files in Chatter Use custom links to reference files from Chatter. EDITIONS Custom Link Example: Link to Reports Use custom links to run reports with filtered results from a Salesforce record detail page. For Available in: Salesforce example, let’s say you frequently run a mailing list report for the contacts related to an account. Classic (not available in all You can create a custom link for accounts that links directly to a report that is automatically orgs) filtered to the account you are viewing. In this case, your custom link must pass the account’s Custom buttons and links unique record ID to the report. are available in: All Editions Create a Custom Button for Performing Mass Deletes Visualforce pages and This example creates a JavaScript custom button for Salesforce Classic that can be added to s-controls are available in: activity-related lists and list views and allows users to delete selected records at the same time. Contact Manager, Group, Displaying Alerts Professional, Enterprise, Performance, Unlimited, This example creates a button that opens a popup dialog with a welcome message containing and Developer Editions the user's first name. Getting Record IDs This example creates a button that opens a popup window listing record IDs for user selected records. This is useful when testing to ensure you have the correct record IDs before processing them further. Passing Record IDs to an External System You can use Salesforce record IDs as unique identifiers for integrating with an external system. This example creates a button that calls a Visualforce page to determine the record IDs of selected records and passes them in a URL query parameter to an external Web page called “www.yourwebsitehere.com.” Launching Record Create Page with Default Field Values Construct custom buttons and links that pass default field values to a record create page. This feature applies to Lightning Experience in all editions. This feature doesn’t apply to Lightning Out, Experience Builder sites, or the Salesforce mobile app. Reopening Cases This example creates a button that can be added to cases related lists so users can reopen several cases on an opportunity at once.
794 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
International Maps This example creates a link that displays a country-specific Google map.
SEE ALSO: Define Custom Buttons and Links
Custom Link Example: Link to Documents
Use custom links to reference documents from a Salesforce record detail page. EDITIONS 1. Create a folder on the Documents tab to which all users have access. 2. Upload the document to that folder. Available in: Salesforce Classic (not available in all 3. From the Documents tab, choose the folder and click Go. orgs)
4. Click View next to the document. Custom buttons and links 5. Copy the document’s URL from the browser. For example, are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create or change custom buttons or links: • Customize Application
https://MyDomainName.my.salesforce.com/servlet/servlet.FileDownload?file=015300000000xvU. 6. Use everything after the domain portion of the URL to create your custom link. Using the example in the previous step, your link would point to /servlet/servlet.FileDownload?file=015300000000xvU.
SEE ALSO: Constructing Effective Custom URL Buttons and Links Custom Link Example: Link to Files in Chatter Custom Link Example: Link to Reports
795 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Custom Link Example: Link to Files in Chatter
Use custom links to reference files from Chatter. EDITIONS 1. Upload a file to the Files tab. 2. When the upload is finished, from the Upload dialog box, click Share settings. Available in: Salesforce Classic (not available in all 3. Click Anyone with link. orgs)
4. Copy the document’s URL from the Share via Link dialog box. For example, Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create or change custom buttons or links: • Customize Application
https://MyDomainName.my.salesforce.com/sfc/p/D0000000JsES/a/D000000001dd/aiq8UPJ5q5i6Fs4Sz.IQLKUERsWYdbAm320cjqWnkfk=. 5. Use everything after the domain portion of the URL to create your custom link. Using the example in the previous step, your link would point to /sfc/p/D0000000JsES/a/D000000001dd/aiq8UPJ5q5i6Fs4Sz.IQLKUERsWYdbAm320cjqWnkfk=.
SEE ALSO: Constructing Effective Custom URL Buttons and Links Custom Link Example: Link to Documents Custom Link Example: Link to Reports
796 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Custom Link Example: Link to Reports
Use custom links to run reports with filtered results from a Salesforce record detail page. For example, EDITIONS let’s say you frequently run a mailing list report for the contacts related to an account. You can create a custom link for accounts that links directly to a report that is automatically filtered to the Available in: Salesforce account you are viewing. In this case, your custom link must pass the account’s unique record ID Classic (not available in all to the report. orgs) 1. Copy the ID for the type of record by which you want to filter your report (in this example, an Custom buttons and links account). To do so, view the record and copy the 15-character ID from the last part of the URL. are available in: All Editions For example, https://MyDomainName.my.salesforce.com/001200030012j3J. Visualforce pages and s-controls are available in: 2. From the Reports tab, create the report you want by either customizing a standard report or Contact Manager, Group, creating a custom report. Professional, Enterprise, 3. Filter the report by the record ID you copied. For example, “Account ID equals 001200030012j3J”. Performance, Unlimited, and Developer Editions 4. Run the report to verify that it contains the data you expect. 5. Click Customize. USER PERMISSIONS 6. Click Save or Save As to save the report to a public folder accessible by the appropriate users. Save doesn’t create a custom report, whereas Save As does. To create or change custom 7. Run the report and copy the report’s URL from the browser. buttons or links: • Customize Application 8. Begin creating your custom link. Set the Content Source field to URL. In the large formula text area, paste the report URL you copied. Remember to omit the domain portion https://MyDomainName.my.salesforce.com. 9. Add the custom link to the appropriate page layouts. 10. Verify that the new custom link works correctly.
Tip: When creating a report for use in a custom link, set date ranges and report options generically so that report results include data that can be useful for multiple users. For example, if you set a date range using the “Created Date” of a record, set the Start Date far enough in the past to not exclude any relevant records and leave the End Date blank. If you scope the report to just “My” records, the report might not include all records that a user can see. Try setting the report options to “All visible” records.
SEE ALSO: Constructing Effective Custom URL Buttons and Links Custom Link Example: Link to Documents Custom Link Example: Link to Files in Chatter
797 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Create a Custom Button for Performing Mass Deletes
This example creates a JavaScript custom button for Salesforce Classic that can be added to USER PERMISSIONS activity-related lists and list views and allows users to delete selected records at the same time. To create or change custom Note: JavaScript custom buttons are supported in all editions, in Salesforce Classic only. The buttons or links: mass delete function described here doesn’t work in editions where the API isn’t enabled. • Customize Application 1. Define a button for events with the following attributes. • Display Type List Button EDITIONS Note: Select Display Checkboxes (for Multi-Record Selection) so users can select Available in: Salesforce multiple records in the list before clicking the button. Classic (not available in all • Behavior Execute JavaScript orgs) • Content Source OnClick JavaScript Custom buttons and links • Use the following sample code. are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
{!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")}
var records = {!GETRECORDIDS( $ObjectType.Event )}; var taskRecords = {!GETRECORDIDS( $ObjectType.Task)}; records = records.concat(taskRecords);
if (records[0] == null) { alert("Please select at least one record.") } else {
var errors = []; var result = sforce.connection.deleteIds(records); if (result && result.length){ var numFailed = 0; var numSucceeded = 0; for (var i = 0; i < result.length; i++){ var res = result[i]; if (res && res.success == 'true'){ numSucceeded++; } else { var es = res.getArray("errors"); if (es.length > 0) { errors.push(es[0].message); } numFailed++; } }
798 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
if (numFailed > 0){ alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n")); } else { alert("Number of records deleted: " + numSucceeded); } } window.location.reload(); }
2. Add the button to your activity list views. 3. Add the button to any page layout that contains an activity-related list. The button deletes any selected task or event in the list. You can install custom buttons from the Mass Delete app at http://sites.force.com/appexchange.
SEE ALSO: Custom Button and Link Samples
Displaying Alerts
This example creates a button that opens a popup dialog with a welcome message containing the USER PERMISSIONS user's first name. 1. Define a button with the following attributes. To create or change custom buttons or links: • Display Type Detail Page Button • Customize Application • Behavior Execute JavaScript • Content Source OnClick JavaScript EDITIONS • Use the following sample code. Available in: Salesforce Classic (not available in all orgs)
Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
alert ("Hello {!$User.FirstName}");
2. Add the button to the appropriate page layout.
SEE ALSO: Custom Button and Link Samples
799 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Getting Record IDs
This example creates a button that opens a popup window listing record IDs for user selected USER PERMISSIONS records. This is useful when testing to ensure you have the correct record IDs before processing them further. To create or change custom 1. Define a button with the following attributes. buttons or links: • Customize Application • Display Type List Button
Note: Select Display Checkboxes (for Multi-Record Selection) so users can select EDITIONS multiple records in the list before clicking the button. Available in: Salesforce • Behavior Execute JavaScript Classic (not available in all • Content Source OnClick JavaScript orgs) • Use the following sample code. Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
idArray = {!GETRECORDIDS($ObjectType.Contact)}; alert("The Ids you have selected are: "+idArray);
Note: This example is for contacts. Change the object type for a different type of record.
2. Add the button to the appropriate related list on a page layout or list view layout.
SEE ALSO: Custom Button and Link Samples
800 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Passing Record IDs to an External System
You can use Salesforce record IDs as unique identifiers for integrating with an external system. This USER PERMISSIONS example creates a button that calls a Visualforce page to determine the record IDs of selected records and passes them in a URL query parameter to an external Web page called To create or change custom “www.yourwebsitehere.com.” buttons or links: • Customize Application 1. Create a Visualforce page that uses the GETRECORDIDS function to retrieve a list of selected records: EDITIONS
Available in: Salesforce Classic (not available in all orgs)
Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
idArray = {!GETRECORDIDS($ObjectType.Account)};
window.location.href="http://www.yourwebsitehere.com?array="+idArray;
Note: Replace www.yourwebsitehere.com with your own URL.
2. Define a button for accounts with the following attributes. • Display Type List Button
Note: Select Display Checkboxes (for Multi-Record Selection) so users can select multiple records in the list before clicking the button.
• Behavior Display in existing window with sidebar • Content Source Visualforce Page • Select the Visualforce page you created in the first step.
3. Add the button to the appropriate page layout or list view layout.
SEE ALSO: Custom Button and Link Samples
801 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Launching Record Create Page with Default Field Values Construct custom buttons and links that pass default field values to a record create page. This feature applies to Lightning Experience in all editions. This feature doesn’t apply to Lightning Out, Experience Builder sites, or the Salesforce mobile app. To construct a custom button or link, encode any field that is read from a record and contains special characters, like commas. Use this sample formula:
/lightning/o/Account/new?defaultFieldValues= Name={!URLENCODE(Account.Name)}, OwnerId={!Account.OwnerId}, AccountNumber={!URLENCODE(Account.AccountNumber)}, NumberOfEmployees=35000, CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)}
Important: The URLENCODE function works only when creating custom buttons and links. You can’t use it for custom fields. The TEXT function is supported for custom number fields, but it returns only the numbers without any separators, like commas.
Note: Passing the RecordTypeId to defaultFieldValues isn’t yet supported. The recordTypeId influences routing behavior, layout assignment, and page assignment, so you can see unexpected results if you try to use it.
Reopening Cases
This example creates a button that can be added to cases related lists so users can reopen several USER PERMISSIONS cases on an opportunity at once. 1. Define a button for cases with the following attributes. To create or change custom buttons or links: • Display Type List Button • Customize Application Note: Select Display Checkboxes (for Multi-Record Selection) so users can select multiple records in the list before clicking the button. EDITIONS • Behavior Execute JavaScript Available in: Salesforce • Content Source OnClick JavaScript Classic (not available in all • Use the following sample code. orgs) Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
{!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")} var records = {!GETRECORDIDS($ObjectType.Sample)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one row") } else { for (var n=0; n802 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
Note: This example references the AJAX Toolkit, which is available if API access is enabled. See https://developer.salesforce.com/page/Integration.
2. Add the button to your opportunity page layouts by editing the Cases related list.
Tip: Use this button on any page layout that contains the cases related list, such as account or contact page layouts.
Note: Notice the check for records[0] == null, which displays a message to users when they don’t select at least one record in the list.
SEE ALSO: Custom Button and Link Samples
International Maps
This example creates a link that displays a country-specific Google map. USER PERMISSIONS 1. Define a link for accounts with the following attributes. To create or change custom • Display Type Detail Page Link buttons or links: • Behavior Display in new window • Customize Application • Content Source URL • Use the following sample code. EDITIONS
Available in: Salesforce Classic (not available in all orgs)
Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
{! IF(Sample.BillingCountry = "US", "http://maps.google.com/maps?q="&Sample.BillingStreet& "+"&Sample.BillingCity&"+"&Sample.BillingState&"+"&Sample.BillingCountry, (IF(Sample.BillingCountry = "UK", "http://maps.google.co.uk/maps?q="&Sample.BillingStreet &"+"&Sample.BillingCity&"+"&Sample.BillingCountry, "http://maps.google.com"))) }
803 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
2. Add the link to your account page layout.
SEE ALSO: Custom Button and Link Samples
Custom Button and Link Considerations
Keep these considerations in mind when working with custom buttons and links. EDITIONS
Implementation Tips Available in: Salesforce Classic (not available in all • Custom buttons display at the top and bottom of the detail page to the right of all standard orgs) buttons. • Custom buttons aren't distinguished from standard buttons in any graphical way. However, Custom buttons and links you can recognize them by their location on the right of all standard buttons. are available in: All Editions • If the button bar gets too wide on the detail page layout, the browser displays a horizontal Visualforce pages and scroll bar. If the button bar gets too wide on the list view, search result, tagging result, or related s-controls are available in: Contact Manager, Group, list layouts, the buttons wrap. Professional, Enterprise, • Custom buttons are available for activities under the individual setup links for tasks and events. Performance, Unlimited, To add a custom button to an activity list view or search layout, first create a custom list button and Developer Editions in tasks or events. Next, add it to your activity list view or search result layouts. You can override a button that applies to both tasks and events. • Person Account records use the custom buttons and links you have made for accounts. USER PERMISSIONS
• If your organization uses the Console tab, list buttons are available in Mass Action. List To create or change custom buttons don’t display in the mini page layouts. Pages that display due to custom buttons and buttons or links: links display in the console without the header or sidebar. • Customize Application • If you get an error message when overriding a button that appears in a list, try calling the s-control using the URLFOR function. • When creating custom buttons, be aware of any validation rules your organization has for records on that object. For example, some custom list buttons that change case status conflict with a case validation rule. In this scenario, Salesforce displays the error message for the validation rule when users click the custom button. • To replace a standard button with a custom button, first define the custom button, then customize the page layout to hide the standard button and display the custom one in its place. • Visualforce pages used as custom links on the home page can’t specify a controller. • Visualforce pages used as custom buttons or links on detail pages must specify a standard controller of the same object. • Visualforce pages used as custom list buttons must use a standard list controller of the same object. • A Web tab or custom link could display a blank page if the embedded site: – Has been set to deny the loading of its content in a frame. – Has been set to allow the loading of its content in a frame only if the same site is delivering the content. – Contains a mix of secure and unsecure content, and the user’s browser has been configured to block mixed active content. To resolve this issue, try these workarounds. – Set your custom link to either open in a new window or display in the existing window without the sidebar or header. – Move the URL from a Web tab into a custom link instead, and set the URL to either open in a new window or display in the existing window without the sidebar or header.
804 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links
– If the site you’re embedding has an HTTP prefix and mixed active content, try changing the prefix to HTTPS. If the embedded site has a valid security certificate and it hasn’t blocked itself from being displayed in frames, using HTTPS as the prefix allows the site to display.
Best Practices • Use formula functions in custom buttons with caution. Because functions run on the server before your HTML or JavaScript is passed to the browser, they can only evaluate information that exists at that time. Don't use functions like IF to evaluate conditions that only exist when the code reaches the browser, such as the value of a JavaScript variable that your code returns. • To prevent a user from performing a particular action, such as creating or editing, change the user's permissions rather than hiding the standard button. Hiding a standard button removes it from a page layout, but the link is still available and users can navigate to the new or edit page manually. • Use global variables to access special merge fields for components like custom buttons, links, and s-controls. For example, the $Request global variable allows you to access query parameters inside a snippet, s-control, or custom button. • When you create a custom list button, select Display Checkboxes (for Multi-Record Selection) only if your list button requires users to select individual records in a list. If your list button doesn’t require users to select individual records, don’t select this option. Don’t select Display Checkboxes (for Multi-Record Selection) if your list button links to a URL that doesn’t support POST operations, such as a URL that links to a Lightning component. • In Lightning Experience, when you select Display Checkboxes (for Multi-Record Selection), the related list type must be set to Enhanced List. You can set the related list type for a related list on a record page in the Lightning App Builder. • If you create multiple custom list buttons on a list and select Display Checkboxes (for Multi-Record Selection) for at least one of the list buttons, checkboxes appear next to records in the list. But those checkboxes aren’t activated for custom list buttons without Display Checkboxes (for Multi-Record Selection) selected.
Limitations • A custom link's label can't exceed 1,024 characters. • A link URL can be up to 2,048 bytes. When data is substituted for the tokens in the URL, the link can exceed 3,000 bytes. Some browsers enforce limits on the maximum URL length. • Custom buttons that call JavaScript aren’t supported in Lightning Experience. • Custom buttons with a content source of OnClick JavaScript aren’t supported in the Salesforce app. • Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. • On record detail pages for external objects that are associated with high-data-volume external data sources, custom buttons, and links that call JavaScript aren’t supported. • Custom buttons aren’t available for Web-to-Lead, Web-to-Case, the Case Teams related list, or the user object. • Custom buttons on search results pages aren’t supported in Lightning Experience. • When you redirect to an external website with merge fields, use the Text Field data type field. If you use the URL data type field, the link breaks because symbols in the link are converted to hexadecimal code.
Considerations for the Salesforce Mobile App • Custom buttons that are added to the Button section of a page layout and that define the content source as URL or Visualforce are supported in the Salesforce mobile app. Remember that Visualforce pages must be enabled for use in the Salesforce mobile app. Custom links, custom buttons that are added to list views, and custom buttons that define the content source as OnClick JavaScript aren’t available in the Salesforce mobile app.
805 Extend Salesforce with Clicks, Not Code External Services
• Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. • Custom images used for action icons must be less than 1 MB in size.
SEE ALSO: Define Custom Buttons and Links Custom Button and Link Samples
Viewing References to Salesforce Components
You can view a list of all the areas in Salesforce that reference a component. For example, view the EDITIONS custom links, custom buttons, or page layouts that reference another component, such as a Visualforce page or static resource. To do this, click Where is this used? from the detail page of Available in: Salesforce the component. Salesforce lists the type of component that references the component and the Classic label for that component. Click any item in the list to view it directly. Custom buttons and links are available in: All Editions SEE ALSO: Visualforce pages and Define Custom Buttons and Links custom components available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create or change custom buttons or links: • Customize Application To create, edit, and delete Visualforce pages and custom components: • Customize Application To clone, edit, or delete static resources: • Customize Application
External Services Connect your Salesforce org to an external API using zero lines of code. Use declarative tools and OpenAPI specifications to describe the external API functionality, and External Services creates invocable actions within Salesforce. Use the invocable actions to create a flow that interacts with the external API source.
What Can I Do with External Services? To illustrate how External Services work, let’s say you want to connect Salesforce to an external credit service that determines if credit is extended to a Salesforce account. You also want to know the payment terms.
806 Extend Salesforce with Clicks, Not Code External Services
Current and Legacy Versions The current version of External Services became generally available in Spring ’20 release and has replaced the legacy version. Compared to the legacy version, this version provides significant improvements and adds a broader feature set, including support for larger and more complex schemas, and offers better error messaging and error recovery. External Services Registration To register and use External Services, provide an API spec that describes the services and methods for tools such as Flow Builder or Einstein Bots to consume. The API spec’s schema generates the External Service flow actions with corresponding input and output parameters. Import MuleSoft APIs Import your MuleSoft Anypoint Platform APIs in a few clicks with External Services for MuleSoft. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. Create a Flow with External Services Design and test the automation that sends a user’s information from Salesforce to the external employee banking system. Create the variables for user phone numbers, and combine different phone numbers into one piece of data. Then use the external service action to create the user. Add Actions to an Einstein Bot Integrating your Einstein bot with a registered external service is now as easy as adding an action to a dialog. You can add an external service action to your bot from Einstein’s Bot Builder. Edit, Delete, Save As, and View an External Service Find services that you already registered, view actions for a previously defined service, edit, clone, and delete a service. You can’t edit or delete an external service that is in use by a flow. Recreate an External Service Recreate your external service, and update the related flows. External Services and Packaging You can install or create packages containing an external service. Read these tips before you begin. Testing External Service Actions in Flow Test the example flow MyAtmFlow with a flow external service action MyAtmExternalService by implementing the HttpCalloutMock interface that provides a test response without performing the callout to the external service endpoint.
What Can I Do with External Services?
To illustrate how External Services work, let’s say you want to connect Salesforce to an external EDITIONS credit service that determines if credit is extended to a Salesforce account. You also want to know the payment terms. Available in: Lightning Example: First, you create a Named Credential by supplying a URL and authentication Experience settings for the credit service. Salesforce uses these items to make callouts to the external Available in: Enterprise, service. With the External Services wizard, you then select whether you will get your API spec Performance, Unlimited, from Mulesoft Anypoint Platform, or from an API spec provided elsewhere. To register an API and Developer Editions spec: 1. Enter a URL (or endpoint) to the location of the hosted OpenAPI specification (”API spec”) for the external service, or provide (paste in) the complete schema from the API spec. For Mulesoft, provide your credentials and select the ASPI spec. 2. Select the operations from the schema you want to make available in Salesforce as invocable actions, and complete the registration.
807 Extend Salesforce with Clicks, Not Code External Services
The External Services wizard walks you through it so that you don’t directly touch the API. You can also skip writing Apex code to make the callout. Once you have registered your new external service, use a Salesforce point-and-click automation tool, such as Flow Builder or Einstein Bots. Create a flow using the External Service type for flow actions automatically generated from your External Services registration. When the flow runs, the output contains the credit decision and, if applicable, payment terms.
Example: Another use case involves saving time when you add new users to an org. For instance, you want new users to automatically become collaborators for all external org-related applications. Create a flow using inputs such as user ID, which you can define in your API spec’s schema. Then you add triggers in your flow. When a user is created, the triggers engage and add the new user as a collaborator to your other applications.
Current and Legacy Versions
The current version of External Services became generally available in Spring ’20 release and has EDITIONS replaced the legacy version. Compared to the legacy version, this version provides significant improvements and adds a broader feature set, including support for larger and more complex Available in: Lightning schemas, and offers better error messaging and error recovery. Experience External Services (Current version) Available in: Enterprise, Here are some of the key enhancements and additions for OpenAPI support: Performance, Unlimited, • More complex OpenAPI 2.0 schema. and Developer Editions – Nested parameters - rendered as Dynamic Apex-defined data type in Flow Builder – Header parameters in HTTP request.
• Named arrays, anonymous arrays, or inline arrays, supported as collection type in Flow Builder • Access to the latest product enhancements. • Normal packaging support. • Shows up as External Service type for flow actions. • External Services operations show up as External Service action type in Flow builder.
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
SEE ALSO: Register an External Service Edit, Delete, Save As, and View an External Service External Services Considerations
808 Extend Salesforce with Clicks, Not Code External Services
External Services Registration
To register and use External Services, provide an API spec that describes the services and methods EDITIONS for tools such as Flow Builder or Einstein Bots to consume. The API spec’s schema generates the External Service flow actions with corresponding input and output parameters. Available in: Lightning When you create your API spec, keep the following in mind. Experience • An API spec can include up to 4,000,000 characters (4.0MB). Available in: Enterprise, • You can use the GET, PATCH, PUT, POST, and DELETE methods in a schema. Performance, Unlimited, and Developer Editions • A property must include a value. • Each parameter must have a name. • Request headers are supported. • Response headers aren’t supported. • Form parameters are supported. • Security settings defined in the API spec are ignored and defer to security settings in the Named Credential. Supported data types: • boolean • date • datetime • double • float • integer • long • string • any type (as Apex Object) • object: top level named and nested anonymous objects • anonymous and top level named lists (can nest both named and anonymous arrays) • additionalProperties as maps • allOf as an object composition
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
Register an External Service Registering an external service takes only a few steps and no code. External Services Considerations Here are the semantic, service, and usage constraints to keep in mind when integrating your services into External Services. Examples: External Services Schema These API spec examples highlight various scenarios with JSON schemas supported by External Services and can help you avoid common mistakes with syntax and code placement. The API spec examples also cover schema elements like HTTP header as input parameters.
809 Extend Salesforce with Clicks, Not Code External Services
MIME Type Mapping in External Service Registrations You can register OpenAPI specifications with non-permitted consumes or produces MIME types directives by mapping the MIME types to permitted MIME types.
SEE ALSO: Register an External Service External Services Named Credentials
Register an External Service
Registering an external service takes only a few steps and no code. EDITIONS Before you begin, ensure that you have the OpenAPI version 2.0 endpoint information for the service that you’re registering. Then set up a named credential. A named credential specifies the URL of a Available in: Lightning callout endpoint (the service you want to access) and its authentication parameters. For example, Experience https://my_endpoint.example.com. Available in: Enterprise, Note: If you use OpenAPI 2.0, your endpoint is relative to the base URL. So if your named Performance, Unlimited, credential URL is https://my_endpoint.example.com and the basePath is and Developer Editions /basepath, they combine as the final endpoint of https://my_endpoint.example.com/basepath. USER PERMISSIONS External Services supports all named credential authoring schemes. To manage connections: Note: OpenAPI 2.0 security schemes are ignored. • Customize Application
1. From Setup in Lightning Experience, enter External Services in the Quick Find box, and select External Services. 2. Click New External Service. 3. On the Select an API Source screen, select whether you are importing an API spec From Mulesoft Anypoint Platform, or From API Specification. 4. Enter a service name and an optional description. 5. Choose a named credential. 6. If your schema includes operations that are not supported, you can filter them out by toggling on Only include supported operations (default). To learn why operations can't be included, disable this toggle. If you aren’t sure, leave this toggle on. 7. Enter a schema URL path (or endpoint), or provide a complete schema. If you enter a schema URL path, it must begin with “/” and be a relative path. For example, /accountSchema.json. If you provide a schema, it must be complete, valid OpenAPI 2.0, and JSON-compliant. 8. Click Save & Next. 9. Select the operations you want to import into your external service registration. Note that you can select up to 625 operations per org, and up to 625 active objects per org. If you exceed either of these limits, divide the operations in your schema across separate registrations. For information about limits, see External Services Considerations on page 811. For information about “objects” in Open API schemas, see https://swagger.io/docs/specification/2-0/basic-structure/ 10. Click Next.
810 Extend Salesforce with Clicks, Not Code External Services
11. Click Done.
SEE ALSO: External Services Define a Named Credential Choose an Authentication Protocol
External Services Considerations Here are the semantic, service, and usage constraints to keep in mind when integrating your services into External Services.
OpenAPI 2.0 Support • The following MIME types are permitted: – application/json — Structured data in JSON format – application/x-www-form-urlencoded -- URL encoded form – text/plain -- Unstructured data as plain text
• Non-permitted MIME types can be mapped to permitted MIME types for request and response content serialization. To do this, see MIME Type Mapping in External Service Registrations. • Form data parameters are supported. • Supports all Java runtime supported character set encodings. UTF-8 is the default encoding. • Server and operation level consumes and produces directives.
Supported Schema Format • OpenAPI 2.0, JSON schema format • UTF-8, with full character set for names and identifiers
Unsupported Schema Formats • Interagent hyper-schema format • OpenAPI 2.0 schema, YAML format • OpenAPI 3.0
Unsupported OpenAPI 2.0 Schema Constructs • The combined schema keywords: oneOf, anyOf, not • Media types such as xml, png, and pdf
OpenAPI 2.0 Schema Definitions • A schema can have up to 4,000,000 characters (4.0 MB). • You can use up to 25 External Services registrations per org. • You can have up to 625 active operations per org. The sum of active (selected) and inactive operations can’t exceed 5,000 per org.
811 Extend Salesforce with Clicks, Not Code External Services
• You can have up to 625 active, unique, Apex-defined objects per org. Apex-defined objects are derived from the object schemas in the OAS. The sum of active and inactive objects can’t exceed 5,000 per org. • You can have up to 200,000 properties per org. • You can use the GET, PATCH, PUT, POST, and DELETE methods in a schema. • The following MIME types are permitted: – application/json — Structured data in JSON format. – text/plain -- Unstructured data as plain text. – application/x-www-form-urlencoded -- URL encoded form.
• The following OpenAPI schema components are ignored: – security requirement objects and security definitions – tag objects – external documentation objects – For allOf, the schema object property discriminator is ignored. The discriminator property determines the schema referenced by its type name. The discriminator property must be set in your flow to the appropriate schema property name. Only properties from the base schema are accessible, not the composition properties from the schema designated by the discriminator schema type value. For more information, see the Swagger 2.0 Specification OpenAPI Specification.
• The operation name is derived from the schema's path operationId. If missing, it's derived from the HTTP method and resource path. • Use case consistently for object name definitions, property names, parameter names, and field names in a schema. • The derived Apex class name for an OpenAPI schema input or output parameter object can be a maximum of 255 characters. Ensure that class names are the correct length by choosing a short service name, or edit the schema object name definition to create a shorter name if errors are encountered during registration. The operation or object developer name is derived from the registered API specification. The name must fit within a maximum of 80 characters. If the individual objects or operations in the nested data structure don't themselves exceed 80 characters, then nested data structures can go up to 255 characters. • The derived Apex class name and Apex object property names require valid Apex identifier characters. Ensure that the object name in the schema object definition section matches the naming convention and the object property names. • External Services can handle up to 1,333 characters for any optional description string used to describe operations and parameters in your JSON schema definition. If the description string exceeds this limit, External Services stores only the first 1,333 characters of the description. Truncating the operation or parameter description doesn’t affect the integrity of your schema definition. • consumes/produces directives: – Unsupported consumes/produces directives invalidate the API spec registration. – consumes/produces directives that are incompatible with a request body or response entity schema declaration cause errors during callout. – Missing consumes/produces directives are defaulted to: • application/json—if the request body or the response body schema is either an object or an array • text/plain—if the request or response schema body is a primitive type such as a string or an integer number
– If no request body parameter is defined for methods POST, PUT, and PATCH, form data request parameters are sent in the request body as application/x-www-form-urlencoded. – The applicable media type in the produces list or a default (json or text/plain) is set as the HTTP Accept header.
• Character set encodings:
812 Extend Salesforce with Clicks, Not Code External Services
– The request body is encoded by the character set in the operation’s resolved consumes directive. For example, application/json; charset=ISO-8859-1 encodes the HTTP request in Latin-1 before sending it to the server – The response body is encoded by the character set in the operation’s resolved produces directive. For example, application/x-www-form-urlencoded; charset=SHIFT_JIS decodes the percent URL encoded form with the Shift JIS character set. – The default character set for encoding request bodies is UTF-8 – The default character set for decoding server response entities is defined by the server response’s Content-Type header or UTF-8 if it’s missing. – Reserved HTTP request header characters aren’t escaped and are encoded by the request body’s character set – The supported encoding set is as defined by the Java JDK. For example, for version 11, supported encoding is documented here (replace the “11” in this URL with your Java SE Platform version number): https://docs.oracle.com/en/java/javase/11/intl/supported-encodings.html - and it’s recommended to use the standard character set encoding name as described by the IANA Charset Registry.
• Considerations for properties and additionalProperties – In OpenAPI 2.0, the named properties are accessible as Apex properties with matching property type. additionalProperties allow for free form map or dictionary properties with a common property value type that are accessible in Apex as a Map property. – properties and additionalProperties under an OpenAPI 2 schema directive show as formal object properties and as a dictionary property. If declared under a property or additionalProperties type, then the OpenAPI 2 parser ignores one or the other. The registration process doesn't throw an error – OpenAPI 2.0 named properties are properties in Apex with the same name and property type. – OpenAPI 2.0 additionalProperties are grouped in the Apex property with name properties and type Map, where Type is the declared additionalProperties type. – OpenAPI 2.0 additionalProperties are always declared as an Apex object map property, even if it could be declared as a standalone Apex Map type. The result is consistently handled named object properties defined together with additionalProperties. – OpenAPI 2.0 properties and additionalProperties can both be declared under an OpenAPI parameter schema or schema in the definitions section. The OpenAPI 2.0 parser ignores either properties or additionalProperties if declared as an object property type. An object property type must only define named properties or additionalProperties, but not both. To work around, place the object property definition as a named schema under definitions and reference it by name. – The OpenAPI 2.0 parser doesn't differentiate between literal declarations or untyped schemas. Declarations like additionalProperties: true, additionalProperties: false or additionalProperties: {} are interpreted as untyped. Untyped additionalProperties are ignored. There isn't a workaround to define additionalProperties that can be of any type. – Flow doesn't allow access or manipulation of Apex object types with Map properties, but transparently preserves the content when assigned to variables of the same Apex object type. To manipulate map data structure in flow, call an Apex invocable action that can access the map data structure. For an example with External Service maps in action, see the “External Services Schema Example 9” section of Examples: External Services Schema.
External Service support for Apex reserved keywords Although not a best practice, External Services doesn’t prohibit schema entities with the same name as the Apex reserved keywords. If your schema name conflicts with an Apex reserved keyword, External Services creates a unique name by encoding it to be compatible with Apex identifier rules.
813 Extend Salesforce with Clicks, Not Code External Services
For example, you have an account object with property name type. Because the property name type conflicts with the Apex reserved keyword type, External Services encodes the property name type as z0type to make it Apex compliant. During callout, the property name type is used according to the original OpenAPI schema. Special characters that aren’t valid Apex identifiers are UTF-8 encoded. For example, 5getOpen-bankingV2.2Atms is encoded as x35getOpenx2dbankingV2x2e2Atms for a valid Apex identifier. Flow • You can’t edit an external service used in a flow. • External service callouts aren’t allowed when there are pending, uncommitted transactions. Close your transaction, and resume Flow using the flow element Pause. Array definition in OpenAPI 2.0 External Services supports inline array definitions and referenceable named arrays. List types in External Services are identified by their object element type. Supported Inline Array Definition with Reference to Array Items Definition
{ "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "type": "array", "items": { "$ref": "#definitions/MyObject" } } ... "definitions": { "MyObject": { "type": "object", "properties": {...} } } }
In Flow Builder, declare a variable for the myObjects parameter by marking the variable as a collection and picking its Apex element type ExternalService__RegistrationName_MyObject. Inline Array Definition with Inline Array Items Definition
{ "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "type": "array", "items": { "type": "object", "properties": {...} } }
814 Extend Salesforce with Clicks, Not Code External Services
... "definitions": { ... } }
In Flow Builder, declare a collection variable for the myObjects parameter and Apex element type ExternalService__RegistrationName_OperationName_IN_myObjects. Referenceable Array Definition with Reference to Array Item Definitions
{ "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "$ref": "#definitions/MyObjectList" } ... "definitions": { "MyObjectList": { "type": "array", "items": { "$ref": "#definitions/MyObject" } } "MyObject": { "type": "object", "properties": {...} } } }
In Flow Builder, declare a collection variable for the myObjects parameter and Apex element type ExternalService__RegistrationName_MyObject. Referenceable Array Definition with Inline Array Items Definition
{ "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "$ref": "#definitions/MyObjectList" } ... "definitions": { "MyObjectList": { "type": "array", "items": { "type": "object", "properties": {...} } }
815 Extend Salesforce with Clicks, Not Code External Services
} }
In Flow Builder, declare a collection variable for the myObjects parameter and Apex element type ExternalService__RegistrationName_MyObjectList.
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
Examples: External Services Schema
These API spec examples highlight various scenarios with JSON schemas supported by External EDITIONS Services and can help you avoid common mistakes with syntax and code placement. The API spec examples also cover schema elements like HTTP header as input parameters. Available in: Lightning External Services API Spec Example 1 Experience Here’s an example of a an API spec that contains a supported JSON schema for OpenAPI 2.0. The Available in: Enterprise, parameters (in bold) contain the definition for the accountId input. The responses (also in bold) Performance, Unlimited, contain the definition for the output, which is creditRating. Parameters and responses and Developer Editions translate to inputs and outputs, respectively, for your flow actions.
{ "swagger":"2.0", "info":{ "description":"A service for checking credit for an account.", "version":"1.0.0", "title":"Credit Decision", "termsOfService":"http://swagger.io/terms/", "contact":{ "email":"[email protected]" }, "license":{ "name":"Apache 2.0", "url":"http://www.apache.org/licenses/LICENSE-2.0.html" } }, "host":"", "paths":{ "/account/lastCreditRating":{ "get":{ "summary":"Evaluates credit rating and decides what payment terms to offer.",
"description":"", "consumes":[ "application/json", "application/xml" ], "produces":[ "application/xml", "application/json" ], "parameters":[{ "in":"body",
816 Extend Salesforce with Clicks, Not Code External Services
"name":"body", "description":"Specifies input parameters to calculate payment term", "required":true, "schema":{ "$ref":"#/definitions/accountId" } }], "responses":{ "200":{ "description":"success", "schema":{ "$ref":"#/definitions/creditRating" } }, "405":{ "description":"Invalid input" } } } } }, "definitions":{ "accountId":{ "type":"object", "properties":{ "accountIdString":{ "type":"string" } }, "xml":{ "name":"accountId" } }, "creditRating":{ "type":"object", "properties":{ "creditRatingString":{ "type":"string" } }, "xml":{ "name":"creditRating" } } } }
External Services API Spec Example 2 Basic Setup • For the named credential that your org uses to access the banking system, assign the Bank label and the https://api.example.com URL. The named credential URL corresponds to the declared host of the JSON schema and one of its schemes or URL protocols. The URL can point to a different endpoint as long as it hosts the same external service. The base path is added to the named credential URL on callout.
817 Extend Salesforce with Clicks, Not Code External Services
• Register the employee banking system’s external service. Use the Bank name and the Bank named credential, and then copy one of the following schemas provided. • The banking system's external service shows two ways to define parameters with object types: a named object type under a “definitions” block or an anonymously declared object type inline.
Note: The defined or derived parameter object type name, or a property with an object type, must be fewer than 255 characters to be used in Flow Builder.
Here’s a schema with the named object type defined under the “definitions” block. The phone object type's name is ExternalService__Bank_Phone in Flow Builder.
{ "swagger": "2.0", "info": { "title": "bankService", "description": "API description in Markdown.", "version": "1.0.0" }, "host": "api.example.com", "basePath": "/v1", "schemes": [ "https" ], "definitions": { "User": { "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones":{ "type":"array", "items":{ "type": "object", "$ref": "#/definitions/Phone" } } } }, "Phone":{ "properties":{ "typeofphone":{ "type":"string" }, "phone":{ "type":"string" } } } }, "paths": { "/users/{userId}": {
818 Extend Salesforce with Clicks, Not Code External Services
"get": { "summary": "Returns a user by ID.", "parameters": [{ "in": "path", "name": "userId", "required": true, "type": "integer" }], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/User" } } } } }, "/users": { "post": { "summary": "Creates a new user.", "parameters": [{ "in": "body", "name": "user", "schema": { "$ref": "#/definitions/User" } }], "responses": { "200": { "description": "OK" } } } } } }
External Services API Spec Example 3 Here’s an API spec with a JSON schema with anonymous object types defined inline. The derived phone object type's name is ExternalService__Bank_getUsers_OUT_200_phones.
Note: For anonymous object types, Salesforce automatically derives object type names based on the external service, parent operation, operation parameter, parent object, and object property names. The derived name must be fewer than 255 characters. Object types with names longer than 40 characters and object types that reference through their properties’ object types with names longer than 40 characters can't be used in Flow Builder.
{ "swagger": "2.0", "info": { "title": "bankService", "description": "API description in Markdown.", "version": "1.0.0" },
819 Extend Salesforce with Clicks, Not Code External Services
"host": "api.example.com", "basePath": "/v1", "schemes": [ "https" ], "paths": { "/users/{userId}": { "get": { "summary": "Returns a user by ID.", "parameters": [{ "in": "path", "name": "userId", "required": true, "type": "integer" }], "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones": { "type":"array", "items": { "type": "object", "properties": { "typeofphone": { "type":"string" }, "phone": { "type":"string" } } } } } } } } } }, "/users": { "post": { "summary": "Creates a new user.", "parameters": [{ "in": "body", "name": "user", "schema": {
820 Extend Salesforce with Clicks, Not Code External Services
"type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones": { "type":"array", "items": { "type": "object", "properties": { "typeofphone": { "type":"string" }, "phone": { "type":"string" } } } } } } }], "responses": { "200": { "description": "OK" } } } } } }
External Services API Spec Example 4 Here's an API spec registered with external service name BankingAutomaticTellerMachine. However, the derived object names: • ExternalService__BankingAutomaticTellerMachine_VeryImportantCustomer_phone • ExternalService__BankingAutomaticTellerMachine_getBalanceAccountTypeChecking_OUT_200 Must be no longer than 255 characters. To use Flow Builder, you must shorten the external service schema name and the schema (shown in Example 5).
Tip: If the derived object name is longer than 255 characters, try one of the following methods to resolve the issue. • Shorten the external service name. • If the object is declared inline under an operation parameter, shorten the operation name by adding an operationId to the schema. • If the object is declared inline under a parent object property, shorten the parent object name in the schema. • Declare the nested object as a top-level object under schema “definitions”.
{ "swagger": "2.0",
821 Extend Salesforce with Clicks, Not Code External Services
... "paths": { "/balance/account/{accountId}/type/checking": { "get": { "parameters": [{ "in": "path", "name": "accountId", "required": true, "type": "integer" }], "responses": { "200": { "schema": { "type": "object", "properties": { "balance": { "type": "integer" }, "owner": { "$ref": "#/definitions/VeryImportantCustomer" } } } } } } } }, "definitions": { "VeryImportantCustomer": { "type": "object", "properties": { "name": { "type": "string" }, "phone": { "type": "object", "properties": { "number": { "type": "string" } } } } } } }
External Services API Spec Example 5 Here's an example of an API spec with a schema that results in shortened names. It's registered with the shortened name BankAtm. Shorten the external service schema name to BankAtm, the schema object name to VIP and add operationId as getBalance: • ExternalService__BankAtm_VIP_phone
822 Extend Salesforce with Clicks, Not Code External Services
• ExternalService__BankAtm_getBalance_200
{ "swagger": "2.0", ... "paths": { "/balance/account/{accountId}/type/checking": { "get": { "operationId": "getBalance", "parameters": [{ "in": "path", "name": "accountId", "required": true, "type": "integer" }], "responses": { "200": { "schema": { "type": "object", "properties": { "balance": { "type": "integer" }, "owner": { "$ref": "#/definitions/VIP" } } } } } } } }, "definitions": { "VIP": { "type": "object", "properties": { "name": { "type": "string" }, "phone": { "type": "object", "properties": { "number": { "type": "string" } } } } } } }
External Services API Spec Example 6
823 Extend Salesforce with Clicks, Not Code External Services
Here's an example with an inline array definition.
{ "swagger": "2.0", "host": "Employees.org", "basePath": "/", ... "paths": { "/employees/{employeeId}": { "get": { "operationId": "getEmployee", "parameters": [{ "in": "path", "name": "employeeId", "required": true, "type": "string" }], "responses": { "200": { "schema": { "type": "object", "properties": { "employee": {"$ref": "#/definitions/Employee"}, "manager": {"$ref": "#/definitions/Employee"}, "team": { "type": "array", "items": {"$ref": "#/definitions/Employee"} } } } } } } } }, "definitions": { "Employee" : { "type": "object", "properties": { "employeeId": {"type": "string"}, "firstName": {"type": "string"}, "middleName": {"type": "string"}, "lastName": {"type": "string"}, "dateOfHire": {"type": "date"} } } } }
External Services API Spec Example 7 Here’s how a header parameter is declared in an OpenAPI schema. In Flow, the name “apiKey” shows up as a string parameter. Now when you set any string value in a flow to apiKey, it functions as an HTTP parameter when making a callout request.
{ "swagger": "2.0",
824 Extend Salesforce with Clicks, Not Code External Services
"info": { "description": "A service for checking credit for an account.", "version": "1.0.0", "title": "Credit Decision", "termsOfService": "http://swagger.io/terms/", "contact": { "email": "[email protected]" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, "host": "", "paths": { "/account/lastCreditRating": { "get": { "summary": "Evaluates credit rating and decides what payment terms to offer.", "description": "", "consumes": [ "application/json", "application/xml" ], "produces": [ "application/xml", "application/json" ], "parameters": [{ "name": "body", "description": "Specifies input parameters to calculate payment term", "in": "body", "required": true, "schema": { "$ref": "#/definitions/accountId" } },{ "name": "apiKey", "description": "Your API Key for calling the credit rating service", "in": "header", "type": "string" }], "responses": { "200": { "description": "success", "schema": { "$ref": "#/definitions/creditRating" } }, "405": { "description": "Invalid input" } } } }
825 Extend Salesforce with Clicks, Not Code External Services
}, "definitions": { "accountId": { "type": "object", "properties": { "accountIdString": { "type": "string" } }, "xml": { "name": "accountId" } }, "creditRating": { "type": "object", "properties": { "creditRatingString": { "type": "string" } }, "xml": { "name": "creditRating" } } } }
External Services API Spec Example 8 Request and response form data is declared alongside the matching consumes and produces directives.
{ "swagger": "2.0", "info": { "description": "Apply here for your next mortgage", "version": "1.0.0", "title": "My Mortgage Buddy", "contact": { "email": "[email protected]" }, }, "host": "MyMortgageBuddy.org", "basePath": "/mortgages", "paths": { "/apply": { "post": { "operationId": "applyMortgage", "consumes": [ "application/x-www-form-urlencoded; charset=utf-8" ], "produces": [ "application/x-www-form-urlencoded; charset=utf-8" ], "parameters": [{ "description": "Desired mortgage terms",
826 Extend Salesforce with Clicks, Not Code External Services
"name": "terms", "in": "formData", "type": "array", "items": { "type": "integer" }, "collectionFormat": "multi", "required": true },{ "description": "Full Name", "name": "fullName", "in": "formData", "type": "string", "required": true },{ "description": "Loan amount", "name": "loanAmount", "in": "formData", "type": "number", "required": true }], "responses": { "200": { "description": "200", "schema": { "type": "object", "properties": { "formApplicationId": { "type": "string" }, "loanOfficerFullName": { "type": "string" } } } } } } } }
External Services API Spec Example 9 This JSON schema definition highlights the constructs allOf for schema object composition and additionalProperties for dictionary values. The sample schema is registered as external service MyBank with named credential MyBank. The registration is invoked by a sample flow that accesses the dictionary properties with an Apex invocable action. A flow Apex unit test ties it all together. The schema defines a banking service that gets customer details for a customer ID. • The Customer schema object has dictionary properties of type schema object CreditRating. In Apex, the class ExternalService.MyBank_Customer has property properties of type Map with the customer’s credit ratings.
827 Extend Salesforce with Clicks, Not Code External Services
• Phones and Emails compose their own properties together with the common allOf properties from the schema object Contact.
{ "swagger": "2.0",
"info": { "title": "myBank", "description": "Sample Banking Service with allOf and additionalProperties schema constructs", "version": "1.0.0" },
"host": "api.mybank.com", "basePath": "/v1", "schemes": [ "https" ],
"definitions": { "Customer": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones": { "type":"array", "items": { "$ref": "#/definitions/Phone" } }, "emails": { "type": "array", "items": { "$ref": "#/definitions/Email" } } }, "additionalProperties": { "$ref": "#/definitions/CreditRating" }, "required": [ "id", "name" ] },
"Contact": { "type": "object", "properties": { "primary": { "type": "boolean"
828 Extend Salesforce with Clicks, Not Code External Services
}, "timeOfDay": { "type": "string" } }, "required": [ "primary" ] }, "Phone": { "allOf": [ { "$ref": "#/definitions/Contact" }, { "type": "object", "properties": { "typeOfPhone": { "type":"string" }, "phoneNumber":{ "type":"string" } } } ] }, "Email": { "allOf": [ { "$ref": "#/definitions/Contact" }, { "type": "object", "properties": { "email": { "type":"string" } } } ] },
"CreditRating": { "type": "object", "properties": { "rating": { "type": "string" }, "score": { "type": "number", "format": "double" } }
829 Extend Salesforce with Clicks, Not Code External Services
} },
"paths": { "/customers/{customerId}": { "get": { "summary": "Get the customer by ID.", "parameters": [{ "in": "path", "name": "customerId", "required": true, "type": "integer" }], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/Customer" } } } } } } }
Here is the Apex invokable action that gets the customer credit ratings as a list demonstrating how to work with map data types from flow:
public class MyBankGetCreditRatings { @InvocableMethod( label='Get Credit Ratings' description='A list of credit ratings for a customer' category='MyBank' ) public static List getCreditRatings(List inCustomers) {
List outCreditRatingsList = new List(); for (Customer inCustomer: inCustomers) { ExternalService.MyBank_Customer customer = inCustomer.customer; CustomerCreditRatings outCreditRatings = new CustomerCreditRatings(); outCreditRatings.customerId = customer.id; outCreditRatings.creditRatings = new List();
Map creditRatings = customer.properties; for (String ratingProperty: creditRatings.keySet()) { ExternalService.MyBank_CreditRating creditRating = creditRatings.get(ratingProperty); outCreditRatings.creditRatings.add(creditRating); }
830 Extend Salesforce with Clicks, Not Code External Services
outCreditRatingsList.add(outCreditRatings); }
return outCreditRatingsList; }
public class Customer { @InvocableVariable( label='Customer' description='Banking customer' required=true ) public ExternalService.MyBank_Customer customer; }
public class CustomerCreditRatings { @InvocableVariable( label='Customer ID' description='Bank customer ID' required=true ) public Integer customerId;
@InvocableVariable( label='Credit Ratings' description='Credit ratings for a customer' required=true ) public List creditRatings; } }
The flow starts by calling the external MyBank service action getCustomerById to get the customer details given a customer ID. The Apex invokable flow action getCreditRatings gets the list of credit ratings from the customer details. Phone and email contact details are formatted as a list of customer contacts by looping through the phones and emails properties and assigning the formatted value to the contacts list.
831 Extend Salesforce with Clicks, Not Code External Services
The HTTP callout mock asserts an expected request and responds with a sample customer as application/json:
public class MyBankGetCustomerCalloutMock implements HttpCalloutMock { public HTTPResponse respond(HTTPRequest request) { // Assert expected request test data: customer ID in the request path System.assertEquals('GET', request.getMethod()); System.assertEquals('callout:MyBank/v1/customers/42', request.getEndpoint());
// Send response test data: customer details with sample ratings // as additional properties and sample contacts HttpResponse response = new HttpResponse(); response.setHeader('Content-Type', 'application/json'); response.setBody('{' + '"id": 42, "name": "Foo Bar", "phones": [' + ' {"primary": true, "timeOfDay": "Daytime", ' + ' "typeOfPhone": "Mobile", "phoneNumber": "555-5555"},' + ' {"primary": false, "timeOfDay": "Evening", ' + ' "typeOfPhone": "Landline", "phoneNumber": "222-5555"}' + '], "emails": [' + ' {"primary": true, "timeOfDay": "AllDay", "email": "[email protected]"}' + '],' + '"rating1": {"rating": "Rating 1", "score": 0.95}, ' + '"rating2": {"rating": "Rating 2", "score": 0.78}' + '}'); response.setStatusCode(200); return response; } }
Tip: You can also use JSON to serialize a sample response matching the external service response type if the HTTP response mime type is application/json and the JSON properties are compliant with Apex identifier characters:
ExternalService.MyBank_Customer customer = new ExternalService.MyBank_Customer(); customer.id = 42; ... customer.properties = new Map(); ExternalService.MyBank_CreditRating creditRating = new ExternalService.MyBank_CreditRating(); creditRating.rating = 'Rarging 1'; creditRating.score = 0.95; customer.properties.put('rating1', creditRating); ... response.setBody(System.JSON.serialize(customer)); ....
The Apex unit test sets up the HTTP callout mock and asserts the expected credit ratings and customer contacts:
@IsTest public class MyBankFlowTest { @IsTest static public void testGetCustomer() { // Set HTTP callout mock to match flow's external service action invocation Test.setMock(HttpCalloutMock.class, new MyBankGetCustomerCalloutMock());
// Set flow input variables and create the flow interview Map inputVariables = new Map(); inputVariables.put('customerId', 42);
832 Extend Salesforce with Clicks, Not Code External Services
Flow.Interview myBankFlow = Flow.Interview.createInterview('MyBank', inputVariables);
// Start flow interview with set input variables myBankFlow.start();
// Assert customer's expected credit ratings List creditRatings = (List)myBankFlow. getVariableValue('creditRatings'); System.assertEquals(2, creditRatings == null ? 0 : creditRatings.size()); ExternalService.MyBank_CreditRating actualRating = creditRatings.get(1); ExternalService.MyBank_CreditRating expectedRating = new ExternalService.MyBank_CreditRating(); expectedRating.rating = 'Rating 2'; expectedRating.score = 0.78; System.assertEquals(expectedRating.toString(), actualRating.toString());
// Assert customer's contacts: List contacts = (List)myBankFlow.getVariableValue('*contacts*'); System.assertEquals(3, contacts == null ? 0 : contacts.size()); System.assertEquals('Phone Number: 555-5555', contacts.get(0)); System.assertEquals('Phone Number: 222-5555', contacts.get(1)); System.assertEquals('Email: [email protected]', contacts.get(2)); } }
For another example of a flow Apex unit test, see Testing External Service Actions in Flow on page 850.
MIME Type Mapping in External Service Registrations You can register OpenAPI specifications with non-permitted consumes or produces MIME types directives by mapping the MIME types to permitted MIME types. OpenAPI consumes MIME types: • The Content-Type header is the specified consumes MIME type. • The request body is serialized with the mapped permitted media type. OpenAPI produces MIME types: • The request Accept header is the specified produces MIME type. • The response Content-Type header, if present, is mapped to the permitted MIME type to deserialize the response body. Non-permitted MIME types must be mapped to permitted MIME types as mappings in the field serviceBinding of the ExternalServiceRegistration metadata file.
MIME Type Mapping Example Acme bank specifies an OpenAPI 2.0 service for their credit rating service. It defines its own MIME type for handling the JSON compatible payload: application/x-acme-json:
{ "swagger":"2.0", "info":{
833 Extend Salesforce with Clicks, Not Code External Services
"description":"A service for checking credit for an account.", "version":"1.0.0", "title":"Credit Decision" }, "host":"", "paths":{ "/account/credit-rating":{ "get":{ "operationId":"getCreditRating", "summary":"Evaluates credit rating for offered payment terms.", "consumes":[ "application/x-acme-json" ], "produces":[ "application/x-acme-json" ], "parameters":[{ "description":"Account", "in":"body", "name":"body", "required":true, "schema":{ "$ref":"#/definitions/Account" } }], "responses":{ "200":{ "description": "Credit rating", "schema":{ "$ref":"#/definitions/CreditRating" } } } } } }, "definitions":{ "Account":{ "type":"object", "properties":{ "accountId":{ "type":"string" }, "accountHolder":{ "type":"string" } } }, "CreditRating":{ "type":"object", "properties":{ "creditRating":{ "type":"string" }
834 Extend Salesforce with Clicks, Not Code External Services
} } } }
To map the BankService MIME type to the permitted MIME type application/json, open a command-line terminal. Create a directory in which to retrieve the external service’s metadata.
> mkdir BankService > cd BankService
Create the manifest package.xml for the external service metadata for your BankService to retrieve from your organization:
> touch package.xml
Edit the package.xml:
BankService ExternalServiceRegistration 53.0
Retrieve the metadata for the external service with the Salesforce CLI command after successful authentication to your organization:
> sfdx force:mdapi:retrieve -r . -k package.xml
Unzip the package zip with the metadata and navigate to the directory with the external service:
> unzip unpackaged.zip > cd unpackaged/externalServiceRegistrations
Edit service bindings in the external service registration metadata file BankService.externalServiceRegistration:
BankServiceEndpoint true getcreditrating Custom { ... } OpenApi {"compatibleMediaTypes" :{"application/x-acme-json" :"application/x-acme-json"}} Complete
Note that the section (in bold, above) should not be broken by line breaks as it may break deserialization.
835 Extend Salesforce with Clicks, Not Code External Services
The service binding specifies in JSON format the non-permitted MIME types defined by this external service registration:
{"compatibleMediaTypes":{ "application/x-acme-json":"application/x-acme-json" }}
Map the non-permitted MIME type to the permitted MIME type for the external service payload serialization:
{"compatibleMediaTypes":{ "application/x-acme-json":"application/json" }}
The updated metadata for the bank rating external service sample registration respects the MIME type mapping to the permitted MIME type when deployed in a package:
BankService true getcreditrating Custom { ... } OpenApi {"compatibleMediaTypes" :{"application/x-acme-json" :"application/json"}} Complete
Note that the section should not be broken by line breaks as it may break deserialization. Save the edited external service registration metadata file and deploy it:
> cd ../.. > sfdx force:mdapi:deploy -d unpackaged
For more information see Salesforce DX Developer Guide.
Import MuleSoft APIs Import your MuleSoft Anypoint Platform APIs in a few clicks with External Services for MuleSoft. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account.
Configure a Connected App and Named Credentials To use External Services for MuleSoft, complete these setup steps. Register a MuleSoft-Hosted External Service Registering an external service for MuleSoft Anypoint Platform takes only a few steps and no code.
836 Extend Salesforce with Clicks, Not Code External Services
Configure a Connected App and Named Credentials To use External Services for MuleSoft, complete these setup steps.
Create a Connected App in MuleSoft Anypoint Platform Set up a connected app in MuleSoft Anypoint Platform that allows Salesforce to call MuleSoft APIs. Create an Authentication Provider Use the ID and the secret from your MuleSoft Anypoint Platform connected app to create an authentication provider. Update Your MuleSoft Anypoint Platform Connected App Use the Salesforce authentication provider callback URL to update your MuleSoft Anypoint Platform connected app. Create a Named Credential Create a named credential to access your MuleSoft Anypoint Platform connected app from Salesforce.
Create a Connected App in MuleSoft Anypoint Platform Set up a connected app in MuleSoft Anypoint Platform that allows Salesforce to call MuleSoft APIs. To use the External Services for MuleSoft wizard, you need a valid MuleSoft license or demo account. The MuleSoft user account must have full permissions for the API Manager and Exchange in your MuleSoft Anypoint Platform org. Complete these steps in MuleSoft Anypoint Platform. 1. Log in to MuleSoft Anypoint Platform. 2. Under Management Center, click Access Management. 3. In the Access Management menu, select Connected Apps. 4. Click Create app. 5. Enter a name for your app. 6. Ensure that App acts on behalf of a user is selected for Type. 7. Under Grant types, select Authorization Code, and then select Refresh Token. 8. In Website URL, enter https://www.salesforce.com. 9. In Redirect URIs, enter https://www.salesforce.com, and click Add.
Note: This redirect URI is a temporary value that is updated after you create an authentication provider in your Salesforce org.
10. For Who can use this application? select Members of this organization only. 11. Under Scopes, click Add Scopes. 12. In Add scopes, enable Background Access and Read-Only Access, and click Add scopes. 13. Save your changes. 14. On the Connected Apps page, click Copy Id, and paste the id into a text file. 15. Click Copy Secret, and paste it into the same text file. Create an authentication provider.
837 Extend Salesforce with Clicks, Not Code External Services
Create an Authentication Provider
Use the ID and the secret from your MuleSoft Anypoint Platform connected app to create an EDITIONS authentication provider. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. Available in: Lightning Experience This setup requires the ID and secret that can be copied when you created your connected app in MuleSoft Anypoint Platform. Available in: Enterprise, Complete these steps. Performance, Unlimited, and Developer Editions 1. From Setup, in the Quick Find box, enter Auth. Providers, and then select Auth. Providers. 2. Click New. 3. For Provider Type, select Open ID Connect. 4. Specify a name like MuleSoft Anypoint Platform. 5. For Consumer Key, enter the ID that you copied when you created your connected app in MuleSoft Anypoint Platform. 6. For Consumer Secret, enter the secret that you copied when you created your connected app in MuleSoft Anypoint Platform. 7. For Authorize Endpoint URL, enter https://anypoint.mulesoft.com/accounts/api/v2/oauth2/authorize. 8. For Token Endpoint URL, enter https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token. 9. Save your changes. 10. On the Auth. Provider Detail page, under Salesforce Configuration, copy the Callback URL. Update the connected app in MuleSoft Anypoint Platform.
Update Your MuleSoft Anypoint Platform Connected App Use the Salesforce authentication provider callback URL to update your MuleSoft Anypoint Platform connected app. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. This setup requires the callback URL that can be copied when you created your authentication provider in Salesforce. Complete these steps in MuleSoft Anypoint Platform. 1. In Access Management, on the Connected Apps page, click the name of the connected app you created in MuleSoft Anypoint Platform. 2. On the Update App page, in Redirect URIs, enter the callback URL that you copied when you created an authentication provider in Salesforce, and click Add. 3. Delete the Redirect URI for https://www.salesforce.com. 4. Save your changes. Create a named credential.
838 Extend Salesforce with Clicks, Not Code External Services
Create a Named Credential
Create a named credential to access your MuleSoft Anypoint Platform connected app from Salesforce. EDITIONS To use the External Services for MuleSoft wizard, you need a valid MuleSoft license or demo account. 1. From Setup, in the Quick Find box, enter Named Credentials, and then select Named Available in: Lightning Experience Credentials. 2. Click New Named Credential. Available in: Enterprise, Performance, Unlimited, 3. Enter a label for your named credential. The label can contain no spaces or special characters. and Developer Editions 4. (Optional) Enter a name for your named credentials, or use the name that the system generated based on the label you entered. 5. For URL, enter https://anypoint.mulesoft.com. 6. Select an Identity Type. a. To require that each Salesforce user log into MuleSoft Anypoint Platform from within their personal settings to get a token for their own use, select Per User. b. To allow one named credential to be shared by all users in your org, select Named Principal.
7. For Authentication Protocol, select OAuth 2.0. 8. Select an Authentications Provider. For Authentication Provider, click the magnifying glass and select the name of the auth provider that you created. 9. For Scope, enter read:full offline_access. 10. Ensure that Start Authentication Flow on Save is enabled. 11. Save your changes.
Note: If you receive the “No_Oauth_State: State was not sent back” error when saving the named credential, ensure that the selected scopes for your MuleSoft Anypoint Platform connected app are Read-Only Access and Background Access. You can also receive the error if the read:full offline_access scope you specified has a period at the end of it.
12. (Optional) If you’re not already logged into MuleSoft Anypoint platform, log in now. 13. Grant read-only access and background access to your Salesforce user. 14. On the Named Credential Setup page, Authentication Status is now set to Authenticated. Import MuleSoft Anypoint Platform APIs.
Register a MuleSoft-Hosted External Service
Registering an external service for MuleSoft Anypoint Platform takes only a few steps and no code. EDITIONS To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. 1. From Setup, in the Quick Find box, enter External Services, and then select External Available in: Lightning Experience Services. 2. Select New External Service, and click Next. Available in: Enterprise, Performance, Unlimited, 3. In the Select an API Source window, select From MuleSoft Anypoint Platform, and click and Developer Editions Next.
Note: If you’re in an operationally isolated environment (OIE), the MuleSoft Anypoint Platform tile can’t be selected.
839 Extend Salesforce with Clicks, Not Code External Services
4. In the Select a MuleSoft Anypoint Platform Account window, select the named credential with the most access to MuleSoft.
Important: External Services for MuleSoft use this credential to log in to MuleSoft Anypoint Platform and list MuleSoft APIs available for import. In a later step, you can specify a different named credential with more targeted access to MuleSoft to run the external service in the next step.
5. In the Configure Your MuleSoft Anypoint Platform Service window, set up the details for your external service. a. Select a MuleSoft API. b. Enter a name for your external service. The name must start with a letter, can’t contain spaces or special characters, and be no longer than 80 characters. c. (Optional) Enter a description of your external service. If you don’t enter a description, the system-generated description is used. d. Select a named credential to use to run the external service. e. Ensure that Only include supported operations is enabled.
Important: External Services for MuleSoft use this credential to run a MuleSoft API operation when the external service is called from a flow. You can select a named credential with more targeted access than the one you chose in the previous step.
f. Click Save & Next.
Note: Clicking Save & Next creates an external service record in Salesforce. After this step, you can’t change the MuleSoft API name or version associated with the external service. You can only change the external service name, description, named credential, and included MuleSoft API operations.
6. In the Select Operations window, select up to 625 operations to include in your external service.
Note: For limits, including the maximum number of operations allowed in your org, see External Services Considerations.
7. Click Next. 8. Review your changes, and click Done. Use your external service in a flow.
Create a Flow with External Services Design and test the automation that sends a user’s information from Salesforce to the external employee banking system. Create the variables for user phone numbers, and combine different phone numbers into one piece of data. Then use the external service action to create the user. 1. Define a named credential For the named credential that your org uses to access the banking system, assign the Bank label and the https://api.example.com URL. The named credential URL corresponds to the declared host of the API spec and one of its transfer protocol schemes or URL protocols. The URL can point to a different endpoint as long as it hosts the same external service. The base path is added to the named credential URL on callout.
2. Register the employee banking system’s external service, using the steps described in Register an External Service on page 810 as a guide. Use the BankService name and the Bank named credential, and then copy the schema from one of the API spec examples. 3. Create a flow.
840 Extend Salesforce with Clicks, Not Code External Services
This example uses static values for simplicity. In contrast, a production flow with user data includes elements to get user records, store values to variables, and communicate these values to the external service.
4. To handle the multiple phone numbers nested below the BankService_Phone value, add the two variable resources. a. Click Manager, and then click New Resource. b. For the resource type, select Variable. c. For the API name, enter WorkPhone. d. For the data type, select Apex-Defined. e. For the Apex class, select ExternalService__BankService_Phone.
f. Click Done. g. Repeat these steps using the API name CellPhone.
5. Add the variable resource that acts as the array for the phone number values. a. Click New Resource. b. For the resource type, select Variable. c. For the API name, enter Phones. d. For the data type, select Apex-Defined, and select the Allow multiple values (collection) option. e. For the Apex class, select ExternalService__BankService_Phone.
841 Extend Salesforce with Clicks, Not Code External Services
f. Click Done.
6. Add the variable resource that stores the user’s name. a. Click New Resource. b. For the resource type, select Variable. c. For the API name, enter User. d. For the data type, select Apex-Defined. e. For the Apex class, select ExternalService__BankService_User. f. Click Done.
7. Assign values to the work phone variable. a. From the Toolbox, click Elements. b. Drag an Assignment element to the canvas. c. For Label, enter Assign Work Phone, and let the API name autopopulate. d. Click Search variables, select WorkPhone, then select phone. The variable {!WorkPhone.phone} appears. e. For Value, enter 1234567890. f. Click Add Assignment.
842 Extend Salesforce with Clicks, Not Code External Services
g. Click Search variables, select WorkPhone, then select typeofphone. The variable {!WorkPhone.typeofphone} appears. h. For Value, enter Work.
i. Click Done. j. Connect the Start element to this assignment element.
8. Assign values to the cell phone variable. a. Drag an Assignment element to the canvas. b. For Label, enter Assign Cell Phone, and let the API name autopopulate. c. Click Search variables, select CellPhone, then select phone. The variable {!CellPhone.phone} appears. d. For Value, enter 0987654321 e. Click Add Assignment. f. Click Search variables, select CellPhone, then select typeofphone. The variable {!CellPhone.typeofphone} appears. g. For Value enter Cell. h. Click Done. i. Connect the last element to this one.
843 Extend Salesforce with Clicks, Not Code External Services
9. Assign multiple phone values to the single phone array variable. a. Drag an Assignment element to the canvas. b. For Label, enter Assign Phones, and let the API name autopopulate. c. Click Search variables then select Phones. The variable {!Phones} appears. d. Change the Operator to Add. e. For Value, select Workphone. f. Click Add Assignment. g. Click Search variables then select Phones again. h. Change the Operator to Add. i. For Value select Cellphone.
j. Click Done. k. Connect the last element to this one.
10. Assign the user values. a. Drag an Assignment element to the canvas.
844 Extend Salesforce with Clicks, Not Code External Services
b. For Label, enter Assign User, and let the API name autopopulate. c. Click Search variables, select User, then id. The variable {!User.id} appears. d. For Value, enter 1234. e. Click Add Assignment. f. Click Search variables, select User, then name. The variable {!User.name} appears. g. For Value, enter Maria. h. Click Add Assignment. i. Click Search variables, select User, then phones. The variable {!User.phones} appears. j. For Value, select Phones.
k. Click Done. l. Connect the last element to this one.
11. To create users on the external bank system, add the action generated by your external service schema.
845 Extend Salesforce with Clicks, Not Code External Services
a. Drag an Action element to the canvas. b. Filter the actions by type, and select External Service. c. Select postUser. d. For Label, enter Create a new user, and let the API name autopopulate. e. Next to >_user, click the toggle to include input values. f. From the lookup, select User.
g. Click Done. h. Connect the last element to this one. Your canvas includes these elements.
12. Save and debug the flow. A successful debug includes the assignment and External Service callout.
846 Extend Salesforce with Clicks, Not Code External Services
SEE ALSO: External Services Build a Flow
Add Actions to an Einstein Bot Integrating your Einstein bot with a registered external service is now as easy as adding an action to a dialog. You can add an external service action to your bot from Einstein’s Bot Builder. Sometimes the data that your Einstein bot needs to personalize customer requests is stored outside of Salesforce. For example, a banking customer wants to update their account password and billing address in a single bot conversation. Or a retail customer starts a return process for a purchase and expects the bot to return a unique tracking number. Now you can automate these multi-platform requests directly from the Bot Builder, without writing a single line of code.
SEE ALSO: Add an External Service Action
847 Extend Salesforce with Clicks, Not Code External Services
Edit, Delete, Save As, and View an External Service
Find services that you already registered, view actions for a previously defined service, edit, clone, EDITIONS and delete a service. You can’t edit or delete an external service that is in use by a flow. Available in: Lightning Locate Registered External Services Experience To find your registered services, go to Setup, in the Quick Find box enter External Services, Available in: Enterprise, and then select External Services. Performance, Unlimited, and Developer Editions 1. Actions that you can select for your external service registration: View Actions, Edit, Save As, and Delete. 2. Service recreated with Save As and has the provided prefix of CopyOf in front of the name. Remember to change the name to something more descriptive of the service.
View Actions To view actions available for a service that you defined with your schema, click the arrow in the service’s Actions column, and select View Actions.
Edit To edit an external service, click the arrow in the service’s Actions column, and select Edit. You can modify these service settings: • Named Credential • Description • Service Schema (URL or JSON) • Operations
Save As Save As allows you to recreate your external service registration. Use this action to clone an existing service without changing anything except the name of the new service. 1. To save settings to a new external service, click the arrow in the service’s Actions column, and select Save As. 2. On the Save External Service As page, enter a unique External Service Name
Note: By default, External Services automatically adds the prefix CopyOf in front of the existing external service name. Modify the default name so that it’s unique and descriptive of the external service.
3. Optionally change: • Named Credential • Description • Service Schema Relative URL or Complete JSON • Operations
4. Click Next, then click Done from the External Service Actions page.
848 Extend Salesforce with Clicks, Not Code External Services
Delete To delete an external service, click the arrow in the service’s Actions column, and select Delete.
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
Recreate an External Service
Recreate your external service, and update the related flows. EDITIONS 1. From Setup in Lightning Experience, enter External Services in the Quick Find box, and select External Services. Available in: Lightning Experience 2. Under Actions, next to the name of the external service that you want to recreate, click Save As. Available in: Enterprise, Performance, Unlimited, 3. Note: External Services fills in most of the necessary information, including a modified and Developer Editions external service’s name, named credential used, description, and schema URL or JSON. Modify the external service name so that it’s different from the original registration. If you don’t USER PERMISSIONS provide a name, External Services automatically adds the prefix CopyOf in front of the existing external service name. To manage connections: 4. Verify or change the named credential used, description, schema URL, or JSON. • Customize Application 5. Click Save & Next. 6. If needed, modify the selected operations. 7. Click Next. 8. Click Done. 9. Update the flows that use the actions from the original external service. To locate actions for External Services registrations, filter the actions by type, and select External Service. To find actions that aren’t from External Services registrations, filter by type, and select Apex Action. 10. Return to External Services in Setup. 11. Under Actions, for the original external service that you recreated, click Delete.
SEE ALSO: Register an External Service
External Services and Packaging
You can install or create packages containing an external service. Read these tips before you begin. EDITIONS Consuming an External Services Package Any flow within the package or newly added flows outside the package can reference external Available in: Lightning Experience service actions. Creating an External Services Package Available in: Enterprise, Performance, Unlimited, To ensure that subscriber orgs that install a package can use the External Service actions from the and Developer Editions External Services registration: Add named credential components to the external services registration
849 Extend Salesforce with Clicks, Not Code External Services
package. Alternatively, a subscriber can create a named credential in the subscriber org using the same name as the one specified in the external services registration that references it.
Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement.
SEE ALSO: External Services Components Available in Managed Packages
Testing External Service Actions in Flow Test the example flow MyAtmFlow with a flow external service action MyAtmExternalService by implementing the HttpCalloutMock interface that provides a test response without performing the callout to the external service endpoint. MyAtmExternalService is registered with a Named Credential MyAtmNamedCredential, has operation getBalance with String accountId as path parameter and Integer pin as header parameter. Its output is a JSON data structure with the account ID, account holder, balance and account type. The HTTP callout mock implementation reacts to an expected test request by responding with the appropriate HTTP response output:
global class MyAtmHttpCalloutMock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest request) { // Assert expected request test data System.assertEquals('GET', request.getMethod()); System.assertEquals('callout:MyAtmNamedCredential/A123-456', request.getEndpoint());
System.assertEquals('1234', request.getHeader('pin'));
// Send response test data HttpResponse response = new HttpResponse(); response.setHeader('Content-Type', 'application/json'); response.setBody('{"availableBal": 0, "name": "Account Holder", ' + '"type": "Checking", "accountId": "A123-456"}'); response.setStatusCode(200); return response; } }
The flow test class sets up the HTTP callout mock for the external service action it’s calling. It creates a flow interview with input parameter values to test, runs the flow interview and then asserts the actual flow output parameters with expected test values:
@IsTest public class MyAtmFlowTest { @IsTest static public void testMyAtmFlow() { // Set HTTP callout mock to match flow's external service action invocation Test.setMock(HttpCalloutMock.class, new MyAtmHttpCalloutMock());
// Set flow input variables and create the flow interview Map inputVariables = new Map(); Flow.Interview myAtmFlow = Flow.Interview.createInterview('MyAtmFlow', inputVariables);
850 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
// Start flow interview with set input variables myAtmFlow.start();
// Assert flow output variables System.assertEquals('expected', (String)myAtmFlow.getVariableValue('myFlowOutput')); } }
Access External Data With Salesforce Connect Salesforce Connect lets your users view, search, and modify data that’s stored outside your Salesforce org. Instead of copying the data into standard or custom objects, use external objects to access the data in real time via web service callouts.
Salesforce Connect Salesforce Connect provides seamless integration of data across system boundaries by letting your users view, search, and modify data that’s stored outside your Salesforce org. For example, perhaps you have data that’s stored on premises in an enterprise resource planning (ERP) system. Instead of copying the data into your org, you can use external objects to access the data in real time via web service callouts. External Data Sources With Salesforce Connect Salesforce Connect uses external data sources to access data that's stored outside your Salesforce org. You must configure an external data source and synchronize it to map its tables with external objects in Salesforce. Salesforce Platform Features Supported by Salesforce Connect Salesforce Connect provides seamless integration with the Salesforce Platform and enables users to view, search, and modify external object data. Access Data in Another Salesforce Org with the Cross-Org Adapter for Salesforce Connect Connect your users to data that's stored in another Salesforce org. Access External Data with the OData 2.0 or 4.0 Adapter for Salesforce Connect Connect your users to data that's exposed via the Open Data Protocol. Access External Data with a Custom Adapter for Salesforce Connect Connect your users to any data anywhere by developing your own custom adapter with the Apex Connector Framework.
851 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Connect
Salesforce Connect provides seamless integration of data across system boundaries by letting your EDITIONS users view, search, and modify data that’s stored outside your Salesforce org. For example, perhaps you have data that’s stored on premises in an enterprise resource planning (ERP) system. Instead Available in: both Salesforce of copying the data into your org, you can use external objects to access the data in real time via Classic (not available in all web service callouts. orgs) and Lightning Traditionally, we’ve recommended importing or copying data into your Salesforce org to let your Experience (not for users access that data. For example, extract, transform, and load (ETL) tools can integrate third-party high-data-volume external systems with Salesforce. However, doing so copies data into your org that you don’t need or that objects) quickly becomes stale. Available in: Developer In contrast, Salesforce Connect maps Salesforce external objects to data tables in external systems. Edition Instead of copying the data into your org, Salesforce Connect accesses the data on demand and in Available for an extra cost real time. The data is never stale, and we access only what you need. We recommend that you use in: Enterprise, Performance, Salesforce Connect when: and Unlimited Editions • You have a large amount of data that you don’t want to copy into your Salesforce org. • You need small amounts of data at any one time. • You want real-time access to the latest data. Even though the data is stored outside your org, Salesforce Connect provides seamless integration with the Lightning Platform. External objects are available to Salesforce tools, such as global search, lookup relationships, record feeds, and the Salesforce mobile app. External objects are also available to Apex, SOSL, SOQL queries, Salesforce APIs, and deployment via the Metadata API, change sets, and packages. For example, you store product order information in a back-office ERP system. You want to view those orders as a related list on each customer record in your Salesforce org. Salesforce Connect enables you to set up a lookup relationship between the customer object (parent) and the external object (child) for orders. Then you can set up the page layouts for the parent object to include a related list that displays child records. Going a step further, you can update the orders directly from the related list on the customer record. By default, external object records are read only. But you can define the external data source to enable writable external objects. For information about using Apex DML write operations on external object records, see the Apex Developer Guide.
Note: If transmitting potentially sensitive information, including sensitive or regulated data such as personal health data or financial data, Salesforce recommends that customers encrypt their external data sources at rest. Transmissions through the Salesforce Connect service are already encrypted using mTLS.
Example: This screenshot shows how Salesforce Connect can provide a seamless view of data across system boundaries. A record detail page for the Business_Partner external object includes two related lists of child objects. The external lookup relationships and page layouts enable users to view related data from inside and from outside the Salesforce org on a single page. • Account standard object (1) • Sales_Order external object (2)
852 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Connect Adapters Salesforce Connect uses a protocol-specific adapter to connect to an external system and access its data. When you define an external data source in your organization, you specify the adapter in the Type field. Salesforce Connect Adapters Included per Add-On License Using Salesforce Connect to access external data in an org requires one or more Salesforce Connect add-on licenses. General Limits for Salesforce Connect Understand the limits that are applicable to all Salesforce Connect adapters.
SEE ALSO: External Data Sources With Salesforce Connect External Object Relationships Salesforce Platform Features Supported by Salesforce Connect Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Set Up Salesforce Connect to Access External Data with a Custom Adapter
853 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Connect Adapters
Salesforce Connect uses a protocol-specific adapter to connect to an external system and access EDITIONS its data. When you define an external data source in your organization, you specify the adapter in the Type field. Available in: both Salesforce These adapters are available for Salesforce Connect. Classic (not available in all orgs) and Lightning Salesforce Description When to Use Experience (not for Connect high-data-volume external Adapter objects) Cross-org Uses the Lightning Platform REST API to To seamlessly connect data between Available in: Developer access data that’s stored in other your Salesforce orgs. For example, Edition Salesforce orgs. provide your service representatives a Available for an extra cost unified view of customer transactions by in: Enterprise, Performance, integrating data from different Salesforce and Unlimited Editions orgs.
OData 2.0 Uses Open Data Protocol to access data To integrate external data sources into OData 4.0 that’s stored outside Salesforce. The your org that support the ODATA external data must be exposed via OData protocol and publish an OData provider. producers. For example, give your account executives a unified data view by pulling data from legacy systems such as SAP, Microsoft, and Oracle in real time.
Custom You use the Apex Connector Framework To develop your own adapter with the adapter to develop your own custom adapter Apex Connector Framework when the created via when the other available adapters aren’t other available adapters aren’t suitable Apex suitable for your needs. for your needs. For example, when you A custom adapter can obtain data from want to retrieve data via callouts from a anywhere. For example, some data can REST API. be retrieved from anywhere in the Internet via callouts, while other data can be manipulated or even generated programmatically.
SEE ALSO: Salesforce Connect OData 2.0 or 4.0 Adapter for Salesforce Connect Cross-Org Adapter for Salesforce Connect Custom Adapter for Salesforce Connect Salesforce Connect Adapters Included per Add-On License
854 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Connect Adapters Included per Add-On License
Using Salesforce Connect to access external data in an org requires one or more Salesforce Connect EDITIONS add-on licenses. Each Salesforce Connect add-on license includes a set number of connections per adapter type. A Available in: both Salesforce Salesforce Connect add-on license is associated with a single Salesforce org. Classic (not available in all orgs) and Lightning Salesforce Connect Adapter Number of Connections per License Experience (not for high-data-volume external Cross-org 5 objects)
OData 2.0, OData 4.0, or a custom adapter 1 Available in: Developer Edition Available for an extra cost The number of Salesforce Connect add-on licenses you need depends on where the data is stored in: Enterprise, Performance, and which type of connections are required. These are some common data integration scenarios and Unlimited Editions and the number of licenses required. • Your primary Salesforce org accesses data stored in six other Salesforce orgs. You need two Salesforce Connect add-on licenses. Both Salesforce Connect add-on licenses are assigned to the primary org. • Your primary Salesforce org accesses data stored in one secondary Salesforce org. The secondary org accesses the primary org data. You need two Salesforce Connect add-on licenses, one for each org. • Your primary Salesforce org accesses data stored in five other Salesforce orgs and one external data source. You need one Salesforce Connect add-on license, which is assigned to the primary org.
SEE ALSO: Salesforce Connect Salesforce Connect Adapters OData 2.0 or 4.0 Adapter for Salesforce Connect Cross-Org Adapter for Salesforce Connect Custom Adapter for Salesforce Connect
General Limits for Salesforce Connect
Understand the limits that are applicable to all Salesforce Connect adapters. EDITIONS The assigned user license determines the maximum number of custom objects that each user can access. You can also grant object permissions up to that same number of external objects. External Available in: both Salesforce objects don’t count toward the amount for custom objects. Classic (not available in all orgs) and Lightning Maximum external objects per org1 200 Experience (not for high-data-volume external Note: If the default value for external objects in your org is 100, create objects) a support case to increase your org limit to 200. Available in: Developer Maximum joins per query across external objects and other types of objects 4 Edition Available for an extra cost Maximum length of the OAuth token that’s issued by the external system 4,000 characters in: Enterprise, Performance, Maximum new rows retrieved by SOSL and Salesforce searches per hour. 100,000 and Unlimited Editions
855 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
This limit doesn’t apply to high-data-volume external data sources.
Maximum new rows retrieved or created per hour. 100,000 This limit doesn’t apply to: • High-data-volume external data sources • Rows that are retrieved only as search results and aren’t opened or edited • Other rows that have already been retrieved
Maximum page size for server-driven paging 2,000 rows
1 The amount of 200 external objects applies regardless of how many Salesforce Connect add-ons you purchase for your org. External objects don’t count toward the amount for custom objects.
Callout Limits for Salesforce Connect Adapters Salesforce Connect accesses the external data in real time via Web service callouts to external data sources. • Cross-org adapter: No callout limits. However, each callout counts toward the API usage limits of the provider org. See API Request Limits and Allocations. • OData 2.0 and OData 4.0 adapter – 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require higher limits, create a support case. – 1,000 OData callouts per hour for Developer Edition.
• Custom adapter: See Callout Limits and Limitations and Execution Governors and Limits in the Apex Developer Guide.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect
External Data Sources With Salesforce Connect
Salesforce Connect uses external data sources to access data that's stored outside your Salesforce EDITIONS org. You must configure an external data source and synchronize it to map its tables with external objects in Salesforce. Available in: both Salesforce Classic (not available in all Identity Type for External Data Sources orgs) and Lightning On the external data source configured for Salesforce Connect, the Identity Type field Experience (not for high-data-volume external specifies whether your organization uses one set or multiple sets of credentials to access the objects) external system. Each set of credentials corresponds to a login account on the external system. Sync an External Data Source for Salesforce Connect Available in: Developer Edition When you validate and sync an external data source, it creates or overwrites Salesforce external objects that map to the external system’s schema. Syncing doesn’t copy any data into your Available for an extra cost Salesforce org or write data from your org to the external system. in: Enterprise, Performance, and Unlimited Editions
856 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
External Objects in Salesforce Connect External objects behave similar to custom objects except that they map to data stored outside Salesforce in an external data source. Each external object maps to a data table, and the object fields map to accessible table columns. Record IDs for Salesforce Connect External Objects The first time a data row is retrieved from an external system, the external object record is assigned a Salesforce ID. Each record ID remains associated with the same external data row, unless the external object is deleted from the org. Writable External Objects in Salesforce Connect Select Writable External Objects when you define an external data source and use Salesforce Connect external objects to create, update, and delete data. External objects are read only by default.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Work with External Data Sources
Identity Type for External Data Sources
On the external data source configured for Salesforce Connect, the Identity Type field EDITIONS specifies whether your organization uses one set or multiple sets of credentials to access the external system. Each set of credentials corresponds to a login account on the external system. Available in: both Salesforce If you select Named Principal, your organization uses only one login account on the external Classic (not available in all system. orgs) and Lightning Experience (not for If you select Per User, your organization uses multiple login accounts on the external system. Each high-data-volume external of your users can have a unique set of credentials, or you can group your users—for example, by objects) function or business unit—and have each group share a set of credentials. After you grant user access to the external data source through permission sets or profiles, users can set up and manage Available in: Developer their own authentication settings for the external system. Edition Available for an extra cost Note: For an external data source with Per User Identity Type, site members in Experience in: Enterprise, Performance, Cloud can’t set up their own credentials. However, as an admin you can set up and manage and Unlimited Editions each user’s authentication settings for external systems from Lightning Experience or Salesforce Classic.
Identity Type is Named Principal Identity Type is Per User To access the external system’s... The system uses the credentials that are defined in the... Data External data source definition User’s personal authentication settings for (search or view external objects) the external system
Metadata External data source definition External data source definition (sync to create external objects)
857 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for each external system. If you’re using OAuth 2.0, test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes.
SEE ALSO: Define an External Data Source for Salesforce Connect—Cross-Org Adapter Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Define an External Data Source for Salesforce Connect—Custom Adapter Grant Access to Authentication Settings for External Data Sources Store Authentication Settings for External Systems
Sync an External Data Source for Salesforce Connect
When you validate and sync an external data source, it creates or overwrites Salesforce external EDITIONS objects that map to the external system’s schema. Syncing doesn’t copy any data into your Salesforce org or write data from your org to the external system. Available in: both Salesforce Syncing fails if it causes your org to exceed 200 external objects. Syncing also fails if it tries to create Classic (not available in all an external object with an API name that conflicts with an existing object in the org. In such cases, orgs) and Lightning determine whether the existing object is needed. Experience (not for high-data-volume external • If the object isn’t needed, delete that object, and sync again. objects) • If the object is needed, change the API name of the existing object to no longer conflict with the table that you're trying to sync. However, if the existing object is an external object that Available in: Developer Edition was previously synced, you can’t resync it. Manually update the external object and its fields as needed for schema changes on the external system. Available for an extra cost in: Enterprise, Performance, Tip: We recommend that you create your external data sources and external objects in a and Unlimited Editions Developer Edition org. Then use managed packages to deploy the external data sources and external objects to your other orgs. Doing so prevents your external object names from conflicting with other objects in your org by applying a namespace prefix. When an external object is created via syncing, its Deployment Status is set to In Development. When you’re ready to expose the external object to users, set the status to Deployed. If the external system’s schema changes, the modifications aren’t automatically synced to your Salesforce org. To reflect the changes in the external system, resync the objects. After resyncing, all users who have the same profile as the user who initiated the resync are granted field-level access to the external objects. When you resync an external object: • The Display URL Reference Field is set to None. • If a custom field has the Is Name Field attribute, the attribute is removed. The External ID standard field is used as the name field of the external object. • The Deployment Status doesn’t change.
858 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
To understand how syncing affects relationship fields on external objects, see Relationships on External Objects on page 173.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Deployment Status for Custom Objects and External Objects Validate and Sync an External Data Source
External Objects in Salesforce Connect
External objects behave similar to custom objects except that they map to data stored outside EDITIONS Salesforce in an external data source. Each external object maps to a data table, and the object fields map to accessible table columns. Available in: both Salesforce As with custom objects, you must create custom tabs to display external object data in Salesforce. Classic (not available in all When you add a custom tab to an app in Salesforce Classic, it appears as a tab. When you add a orgs) and Lightning custom tab to an app in Lightning Experience, it appears as an item in the app’s navigation bar and Experience (not for in the App Launcher. See Create a Custom Object Tab. high-data-volume external objects) To know the field types that you can create for external objects, see Custom Field Types. Some special behavior for text and number fields on external objects. Available in: Developer Edition • Text fields: Ensure that the field length matches the length of the associated field on the external object to avoid any display or edit issues. Available for an extra cost in: Enterprise, Performance, • Number fields: Ensure that the specified length can contain all digits to the left of the decimal and Unlimited Editions point in external values. If the numeric value from an external system doesn’t fit within the length of the associated number field on the external object, the value is blank in your Salesforce org. If you notice blank numeric field values, adjust Length and Decimal Places for the number field on the external object to accommodate more digits to the left of the decimal point. If the digits to the right of the decimal point in the external values don’t fit within the specified decimal places, the value is truncated. When a custom field on an external object record is displayed, leading and trailing spaces are removed from the field value. Keep this behavior in mind when you filter by a field that contains leading or trailing spaces. For example, include the leading and trailing spaces in the following SOQL query to match the values that are stored in the external system. However, the spaces aren’t displayed in the query results.
SELECT FirstName__c FROM Buyers__x WHERE FirstName__c = ' Test '
Note: Formulas and Roll-up Summary fields can’t reference fields on external objects.
Features Not Supported • Set up Data with External Objects – Merge Fields – Schema Builder – Validation Rules – Custom fields • Field types not supported – Auto-Number (available only with the cross-org adapter for Salesforce Connect)
859 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
– Currency (available only with the cross-org adapter for Salesforce Connect) – Formula – Geolocation – Master-Detail Relationship – Picklist and Picklist (Multi-select) (available only with the cross-org adapter for Salesforce Connect) – Roll-up Summary – Text (Encrypted) – Text Area (Rich)
• Lookup filter on relationship fields • Default field values
• Record-level security to manage data access for external objects • Record types to customize external data • Productivity Tools – Activities, Events, and Tasks – Attachments – Notes
SEE ALSO: External Object Relationships Considerations for Relationships External Data Sources With Salesforce Connect Manage Custom Objects
Record IDs for Salesforce Connect External Objects
The first time a data row is retrieved from an external system, the external object record is assigned EDITIONS a Salesforce ID. Each record ID remains associated with the same external data row, unless the external object is deleted from the org. Available in: both Salesforce Note: Classic (not available in all orgs) and Lightning • Salesforce IDs aren’t assigned to external object records that are associated with Experience high-data-volume external data sources. Available in: Developer • In a near future release, temporary Salesforce record IDs will be assigned to external object Edition records that are retrieved by SOSL and Salesforce searches, rather than permanent IDs. To prepare for this change, don’t create code or use third-party integrations that require Available for an extra cost these record IDs to remain associated with the same external data rows. For existing code in: Enterprise, Performance, and Unlimited Editions
860 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
and integrations, we recommend removing dependencies on external object record IDs to avoid issues when this change is rolled out.
SEE ALSO: Record IDs and External IDs for External Objects in Salesforce Connect—Cross-Org Adapter Salesforce Connect External Data Sources With Salesforce Connect
Writable External Objects in Salesforce Connect
Select Writable External Objects when you define an external data source and use Salesforce EDITIONS Connect external objects to create, update, and delete data. External objects are read only by default. External systems execute write operations initiated from Salesforce and also handle write conflicts, Available in: both Salesforce if any. Classic (not available in all orgs) and Lightning • It can take some time for changes to external object records to take effect. If you don’t see Experience (not for recent changes when you view or query an external object record, try again later. high-data-volume external • It can’t be guaranteed that all write operations that are initiated from Salesforce are applied in objects) case of write conflicts. Available in: Developer If Salesforce attempts to save changes to an external object and a standard or custom object in the Edition same transaction, an error occurs. As a best practice, we recommend you use a separate transaction Available for an extra cost to access or modify data in an external system. in: Enterprise, Performance, Write operations on external object records initiated from different contexts can occur in varying and Unlimited Editions order. When you create, update, or delete external object records via the user interface, processes or flows, operations occur synchronously. When Apex is used to perform external records operations, operations occur asynchronously and an active background queue minimizes potential save conflicts. To monitor an asynchronous job progress, use BackgroundOperation.
Note: When a custom field on an external object record is edited, leading and trailing spaces are removed from the field value.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect External Data Sources With Salesforce Connect Apex Developer Guide: Writable External Objects
861 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Platform Features Supported by Salesforce Connect
Salesforce Connect provides seamless integration with the Salesforce Platform and enables users EDITIONS to view, search, and modify external object data. Available in: both Salesforce Reports Classic (not available in all Depending on network latency and the availability of the external system, reports that include orgs) and Lightning an external object can take a long time to run. Experience (not for high-data-volume external Record Feed objects) View the Chatter feed associated with external object records you follow to see updates about the record. Following records helps keep you up to date on important changes to the external Available in: Developer Edition objects. Available for an extra cost Quick Actions in: Enterprise, Performance, External objects support quick actions, except when the actions involve features or functionality and Unlimited Editions that are incompatible with external objects. Flows and Processes You can build flows and processes that include external objects and automate your organization’s repetitive business tasks. Salesforce App You can view and search external objects from the Salesforce mobile app, Salesforce on the go! Salesforce Console You can access external objects from the Salesforce console only in Salesforce Classic. Other consoles, such as the Salesforce console in Lightning Experience, aren’t supported. More Features Supported by Salesforce Connect External objects are available to Salesforce APIs, SOQL queries, SOSL and Salesforce searches, SOQL queries, packages, Metadata API, change sets, and Lightning Experience app.
SEE ALSO: Salesforce Connect External Data Sources With Salesforce Connect Cross-Org Adapter for Salesforce Connect OData 2.0 or 4.0 Adapter for Salesforce Connect Custom Adapter for Salesforce Connect
862 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Reports
Depending on network latency and the availability of the external system, reports that include an EDITIONS external object can take a long time to run. When you run a report that includes external objects, your org performs a request callout for each Available in: both Salesforce external object in the report. And if it’s a joined report, your org performs separate request callouts Classic (not available in all for each block. If the URL of a report callout approaches or exceeds 2 KB, the request is split into orgs) and Lightning multiple HTTP calls, with each URL being less than 2 KB Experience (not for high-data-volume external A report that includes an external object fetches up to 20,000 records for the primary object. If the objects) report is customized to include child objects, the total number of rows can be greater or less than 10,000, depending on how many child records are fetched. To obtain more relevant external object Available in: Developer rows, try customizing the report. Edition For custom reports that include external objects as the primary object Available for an extra cost in: Enterprise, Performance, • If the deployment status of the external object changes, custom report type’s Deployment and Unlimited Editions Status changes similarly from Deployed to In Development. See Deployment Status for Custom Objects and External Objects. • If the external object is deleted, custom report type and reports created from it are deleted. For large external data sets, report callouts typically access only a subset of the external data. If the report includes summary fields and formulas, those aggregate values likely reflect only a subset of your data. To improve the accuracy of the aggregate values and obtain more relevant data, try customizing the report. As is true for all callouts for external objects, report callouts are limited by the Salesforce Connect adapters in use. • Cross-org adapter: No callout limits. However, each callout counts toward the API usage limits of the provider org. See API Request Limits and Allocations. • OData 2.0 and OData 4.0 adapter – 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require higher limits, create a support case. – 1,000 OData callouts per hour for Developer Edition.
• Custom adapter: See Callout Limits and Limitations and Execution Governors and Limits in the Apex Developer Guide.
Features Not Supported • Converted currency fields • Cross filters • Buckets and bucket fields • Historical trend reporting
SEE ALSO: Reports and Dashboards Limits, Limitations, and Allocations Troubleshoot Reports External Object Relationships Salesforce Platform Features Supported by Salesforce Connect
863 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Record Feed
View the Chatter feed associated with external object records you follow to see updates about the EDITIONS record. Following records helps keep you up to date on important changes to the external objects. Available in: both Salesforce Features Not Supported Classic (not available in all orgs) and Lightning • Field history tracking. Experience (not for • External objects that map to high-data-volume external data sources. high-data-volume external objects)
SEE ALSO: Available in: Developer Records and List Views Edition Salesforce Connect Available for an extra cost Salesforce Platform Features Supported by Salesforce Connect in: Enterprise, Performance, and Unlimited Editions
Quick Actions
External objects support quick actions, except when the actions involve features or functionality EDITIONS that are incompatible with external objects. With custom quick actions, you can make your users’ navigation and workflow as smooth as possible Available in: both Salesforce by giving them convenient access to information that’s most important. For example, you can let Classic (not available in all users quickly create or update records, send emails, and more in the context of the external object. orgs) and Lightning Experience (not for high-data-volume external Features Not Supported objects) • Log a Call action: Creating tasks isn’t available for external objects. Available in: Developer • Predefined Field Values for Quick Action Fields: Formulas can’t reference external object fields. Edition Available for an extra cost SEE ALSO: in: Enterprise, Performance, Action Types and Unlimited Editions Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect
864 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Flows and Processes
You can build flows and processes that include external objects and automate your organization’s EDITIONS repetitive business tasks. If a flow or a process accesses standard or custom objects along with external objects, you must Available in: both Salesforce commit the changes to the standard or custom object before accessing the external objects. We Classic (not available in all recommend using a separate transaction to access data from the external system. orgs) and Lightning Experience (not for • In Flow Builder, add a screen, local action, or Pause element that pauses until a flow-based time high-data-volume external occurs. See Flow Elements. objects) • In Process Builder, add a scheduled action. See Add Actions to Your Process. Available in: Developer To understand how processes interact with external objects, see Compatibility Considerations for Edition Processes. Available for an extra cost To know the limits while building flows with external objects, see External Object Considerations in: Enterprise, Performance, for Flows. and Unlimited Editions
Features Not Supported These are the automation tool features that aren’t available for external objects in Salesforce Connect. • Approval Processes • Workflow Rules
SEE ALSO: Flow Builder Process Builder Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect
Salesforce App
You can view and search external objects from the Salesforce mobile app, Salesforce on the go! EDITIONS As with custom objects, external objects must be assigned to tabs that users can access, and object permissions must be granted via profiles or permission sets. When you search for an external object, Available in: both Salesforce click More in the Recent section to view the search results. Classic (not available in all orgs) and Lightning When external objects are used with Salesforce for iOS and Salesforce mobile web on iOS devices, Experience (not for you must select Enable Search in the associated external data sources. Only then external objects high-data-volume external appear in these apps. This requirement doesn’t apply to custom adapters for Salesforce Connect. objects)
Available in: Developer SEE ALSO: Edition Salesforce Mobile App Available for an extra cost Salesforce Connect in: Enterprise, Performance, Salesforce Platform Features Supported by Salesforce Connect and Unlimited Editions
865 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Salesforce Console
You can access external objects from the Salesforce console only in Salesforce Classic. Other consoles, EDITIONS such as the Salesforce console in Lightning Experience, aren’t supported. External objects haven’t been fully adapted to a console and can cause unexpected behaviors. Available in: both Salesforce Unlike other objects that haven’t been fully adapted to a console, external objects aren’t marked Classic (not available in all with asterisks in the console setup area. orgs) and Lightning Experience (not for high-data-volume external SEE ALSO: objects) Salesforce Console in Salesforce Classic Available in: Developer Salesforce Classic Console Limitations Edition Salesforce Connect Available for an extra cost Salesforce Platform Features Supported by Salesforce Connect in: Enterprise, Performance, and Unlimited Editions
More Features Supported by Salesforce Connect
External objects are available to Salesforce APIs, SOQL queries, SOSL and Salesforce searches, SOQL EDITIONS queries, packages, Metadata API, change sets, and Lightning Experience app. • API Query Available in: both Salesforce Classic (not available in all – To know how Salesforce Connect accesses the external data in real time via Web service orgs) and Lightning callouts, see query(), queryAll(), and queryMore(). Experience (not for – To understand the limitations that apply to queryAll() and queryMore() calls high-data-volume external on external data, see External Objects in the SOAP API Developer Guide. objects) – To implement server-driven or client-driven paging for external object data that’s obtained Available in: Developer by a custom adapter, see Paging with the Apex Connector Framework. Edition • SOQL Available for an extra cost – To know about the specific limits SOQL applies to external objects, see External objects in in: Enterprise, Performance, SOQL Limits on Objects. and Unlimited Editions – To understand the limitations for external objects when you design SOQL relationship queries, see Understanding Relationship Query Limitations.
• SOSL and Salesforce searches – To know about the specific limits SOSL applies to external objects in search results, see SOSL Limits on External Object Search Results. – To learn about how to add RETURNING clause to a SOSL query with external objects, see RETURNING FieldSpec. – To understand how search works with external objects, look for external objects in Searchable Fields by Object in Lightning Experience and Searchable Fields by Object in Salesforce Classic. – (Salesforce Classic only) Search results for external object display only the top 25 rows.
• Packaging – To understand how packaging affects external data sources and external objects, see Special Behavior of Components in Packages. – To know what components are automatically included in the package when you add external data sources and external objects, see Components Automatically Added to Packages.
866 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
– To learn about the behavior of external data sources and external objects with permission sets or profile settings, see About Permission Sets and Profile Settings.
• Deployment via the Metadata API: In Metadata API, external objects are represented as CustomObject. • Change Sets: External objects are included in the Custom Object component. See Components Available in Change Sets. • Lightning Experience app: When you access external objects from the Lightning Experience app, the associated external data sources must have the High Data Volume option deselected. This requirement doesn’t apply to the cross-org adapter for Salesforce Connect.
SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Writable External Objects in Salesforce Connect
Access Data in Another Salesforce Org with the Cross-Org Adapter for Salesforce Connect Connect your users to data that's stored in another Salesforce org.
Cross-Org Adapter for Salesforce Connect Collaborate more effectively and improve processes by connecting the data across your Salesforce orgs. With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access records in other Salesforce orgs. Nevertheless, setup is quick and easy with point-and-click tools. Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Provide users with seamless access to data in your other Salesforce orgs so that they have a complete view of the business. Setting up the cross-org adapter for Salesforce Connect is quick and easy with point-and-click tools. Considerations for Salesforce Connect—Cross-Org Adapter Understand the special behaviors, limits, and recommendations for using the cross-org adapter for Salesforce Connect.
Cross-Org Adapter for Salesforce Connect
Collaborate more effectively and improve processes by connecting the data across your Salesforce EDITIONS orgs. With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access records in other Salesforce orgs. Nevertheless, setup is quick and easy with point-and-click tools. Available in: both Salesforce Your users and the Lightning Platform interact with other orgs’ data via external objects. The Classic (not available in all cross-org adapter for Salesforce Connect converts each of those interactions into a Lightning orgs) and Lightning Platform REST API call. Experience (not for high-data-volume external Suppose that you store your inventory of products in one Salesforce org. You want your regional objects) and local branch offices, who have their own orgs, to see the latest information about your stock. With the cross-org adapter for Salesforce Connect, those other organizations can easily access your Available in: Developer data while respecting access restrictions that you control. Edition The cross-org adapter makes a Lightning Platform REST API call each time that: Available for an extra cost in: Enterprise, Performance, • A user clicks an external object tab for a list view. and Unlimited Editions • A user views a record detail page of an external object.
867 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• A user views a record detail page of a parent object that displays a related list of child external object records. • A user performs a Salesforce global search. • A user creates, edits, or deletes an external object record. • A user runs a report. • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. To set up Salesforce Connect with the cross-org adapter, you use only point-and-click tools.
Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter The provider org stores the data that the subscriber org accesses. API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter If external objects and custom fields are created in the subscriber org via syncing, their API names are derived from the corresponding API names in the provider org. Record IDs and External IDs for External Objects in Salesforce Connect—Cross-Org Adapter External object record IDs are derived from the corresponding record IDs in the provider organization. External ID values in external object records match the record IDs in the provider organization. User Access to External Data in Salesforce Connect—Cross-Org Adapter A user’s access to external data is determined by settings on both subscriber and provider orgs.
SEE ALSO: Salesforce Connect Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Considerations for Salesforce Connect—Cross-Org Adapter
Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter
The provider org stores the data that the subscriber org accesses. EDITIONS You define the external data source and external objects in the subscriber org. Manually create the external objects and their fields, or automatically create them by syncing the provider org’s metadata. Available in: both Salesforce When users view or search those external objects in the subscriber org, the data is obtained from Classic (not available in all the provider org and displayed in the subscriber org. When users create or edit external object orgs) and Lightning records in the subscriber org, the data is saved in the provider org. Experience (not for high-data-volume external • An org can serve as both a subscriber and a provider. objects) • A subscriber org can access data from multiple provider orgs. Available in: Developer • A provider org can let multiple subscriber orgs access its data. Edition Available for an extra cost SEE ALSO: in: Enterprise, Performance, Cross-Org Adapter for Salesforce Connect and Unlimited Editions
868 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter
If external objects and custom fields are created in the subscriber org via syncing, their API names EDITIONS are derived from the corresponding API names in the provider org. Each external object’s API name ends with __x. Custom fields on external objects use the traditional Available in: both Salesforce __c suffix in the API name. Specifically for objects and custom fields that are synced with the Classic (not available in all cross-org adapter for Salesforce Connect: orgs) and Lightning Experience • For an API name with no suffix in the provider org, the API name is reused in the subscriber org, but with an applied __x suffix for an object or __c suffix for a field. Available in: Developer • For an API name with a suffix in the provider org, the API name is reused in the subscriber org. Edition But one of the underscores (_) from the original suffix is removed, and a new __x or __c Available for an extra cost suffix is applied. in: Enterprise, Performance, and Unlimited Editions Example: If you sync the provider org’s Account object, the subscriber org creates: • An external object with the API name Account__x • Custom fields including one with the API name Account__x.Name__c If you sync the provider org’s CustObj__c object, the subscriber org creates: • An external object with the API name CustObj_c__x • Custom fields including one with the API name CustObj_c__x.Name__c If the provider org’s object has a custom field, the subscriber org creates the custom field on the equivalent external object, for example: • Account__x.MyCustField_c__c • CustObj_c__x.MyOtherCustField_c__c If you sync the provider org’s Account__x external object, the subscriber org creates: • An external object with the API name Account_x__x • Custom fields including one with API name Account_x__x.Name_c__c
SEE ALSO: Cross-Org Adapter for Salesforce Connect
Record IDs and External IDs for External Objects in Salesforce Connect—Cross-Org Adapter
External object record IDs are derived from the corresponding record IDs in the provider organization. EDITIONS External ID values in external object records match the record IDs in the provider organization. Each object in Salesforce has an object ID with a key prefix as the first three characters. When an Available in: both Salesforce external object is created, it’s assigned a unique key prefix. Classic and Lightning Experience Each external object record has a record ID that uses the same key prefix as the external object ID. The rest of the external object record ID matches the original record ID that’s in the provider Available in: Developer organization, excluding its original key prefix. Edition Each record ID that comes from the provider organization becomes a case-insensitive 18-character Available for an extra cost alphanumeric string in the subscriber organization. in: Enterprise, Performance, and Unlimited Editions The original record ID is available in the subscriber organization as the value of the External ID standard field on the external object record.
869 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Each external object has an External ID standard field. Its values uniquely identify each external object record in your org. When the external object is the parent in an external lookup relationship, the External ID standard field is used to identify the child records.
Example: You sync the provider organization’s Account object, and the subscriber organization’s Account__x object is assigned the key prefix x00. An account in the provider organization with the ID 001B0000003SVC7IAO appears in the subscriber organization with the ID x00B0000003SVC7IAO and the external ID 001B0000003SVC7IAO.
SEE ALSO: Cross-Org Adapter for Salesforce Connect
User Access to External Data in Salesforce Connect—Cross-Org Adapter
A user’s access to external data is determined by settings on both subscriber and provider orgs. EDITIONS The credentials that are used by the subscriber org to connect to the provider org are associated with a user in the provider org. We refer to this user as the connected user. Available in: both Salesforce Classic (not available in all A user in the subscriber org can access only data that the connected user can access within the orgs) and Lightning provider org. In other words, the subscriber org’s user access respects the connected user’s access Experience (not for restrictions, which are determined by these settings in the provider org. high-data-volume external • Object-level security—permission sets and profiles objects)
• Field-level security—permission sets and profiles Available in: Developer • Record-level security—organization-wide sharing settings, role hierarchies, and sharing rules Edition In the subscriber org, grant users access to external objects via permission sets and profiles. Available for an extra cost in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Cross-Org Adapter for Salesforce Connect Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter
Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter
USER PERMISSIONS EDITIONS
To create and edit external data sources: Customize Application Available in: both Salesforce Classic and Lightning To create and edit external objects: Customize Application Experience To define or change object-level help: Customize Application Available in: Developer To create and edit custom fields: Customize Application Edition Available for an extra cost To edit permission sets and user profiles: Manage Profiles and Permission Sets in: Enterprise, Performance, To edit another user’s authentication settings Manage Users and Unlimited Editions for external systems:
Provide users with seamless access to data in your other Salesforce orgs so that they have a complete view of the business. Setting up the cross-org adapter for Salesforce Connect is quick and easy with point-and-click tools. Setting up Salesforce Connect with the cross-org adapter involves these high-level steps.
870 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
1. Define an external data source of type Salesforce Connect: Cross-Org. Create an external data source for each provider org.
2. Create the external objects. Perform this task only if you don’t sync to automatically create the external objects. In the subscriber org, create an external object for each object in the provider org that you want to access.
3. Create help content for the external objects. Help your users distinguish between external objects and the other objects in the subscriber org, which can have similar names and types of data. On the subscriber org, create Visualforce pages to describe the external objects. When your users click Help for this Page on an external object, they read your custom help content.
4. Add custom fields and relationships to the external objects. Create relationships between objects. If you didn’t sync to automatically create the external objects and their fields on the subscriber org, create a custom field for each of the provider org’s fields that you want to access.
5. Enable user access to external objects. Grant object permissions through permission sets or profiles.
6. Enable user access to the fields on the external objects. Grant field permissions through permission sets or profiles.
7. If the external data source uses per-user authentication: a. Let users authenticate to the external system. Grant users access to authentication settings for the external data source through permission sets or profiles.
b. Set up each user’s authentication settings. You or your users can perform this task.
Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for the provider org. If you’re using OAuth 2.0, the OAuth flow displays the Salesforce login page twice: first to log in to the provider org to obtain an access token, and then to log back in to the subscriber org. Test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes.
SEE ALSO: Cross-Org Adapter for Salesforce Connect Considerations for Salesforce Connect—Cross-Org Adapter Developer Guide: Visualforce Developer Guide External Object Relationships Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter
871 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Define an External Data Source for Salesforce Connect—Cross-Org Adapter
Give your users seamless access to data across your Salesforce orgs. EDITIONS 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. Available in: both Salesforce Classic and Lightning 2. Click New External Data Source, or click Edit to modify an existing external data source. Experience 3. Complete the fields. Available in: Developer Edition Field Description Available for an extra cost Label A user-friendly name for the external data source. The label is displayed in: Enterprise, Performance, in the Salesforce user interface, such as in list views. and Unlimited Editions If you set Identity Type to Per User, this label appears when your users view or edit their authentication settings for external systems. USER PERMISSIONS To create and edit external Name A unique identifier that’s used to refer to this external data source data sources: definition through the API. • Customize Application The name can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
Type Select Salesforce Connect: Cross-Org.
Connect to Determines which URL is used to connect to the provider org.
URL If you selected Connect to Custom URL, enter the login URL for the provider org.
API Version Select an API version that the provider org supports. The API version determines which of the provider org’s objects, fields, and types you can access from the subscriber org.
Connection Number of seconds to wait for a response from the provider org before Timeout timing out. By default, the value is set to the maximum of 120 seconds.
Writable Lets the Lightning platform and users in this org create, update, and External delete records for external objects associated with the external data Objects source. The external object data is stored outside the org. By default, external objects are read only.
Enable Search Determines whether global searches in the subscriber org also search the external objects’ data, which is stored in the provider org. When selected, you can control which external objects are searchable by selecting or deselecting Allow Search on each external object. Only text, text area, and long text area fields on external objects can be searched. If an external object has no searchable fields, searches on that object return no records.
872 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description Identity Type Determines whether the subscriber org uses one set or multiple sets of credentials to access the provider org. See Identity Type for External Data Sources on page 857.
4. Select the authentication protocol. • If you select Password Authentication, enter the username and password for accessing the external system. • If you select OAuth 2.0, complete the following fields.
Field Description Authentication Select a Salesforce authentication provider. See “Configure a Salesforce Authentication Provider” Provider in the Salesforce Help.
Note: On a production org, an external data source can’t use an authentication provider that directs authorization or token requests to a sandbox org. Similarly, on a sandbox org, an external data source can’t use an authentication provider that directs authorization or token requests to a production org.
Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter.
Note: – The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider. – Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen. – We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system.
Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status.
5. Click Save. 6. Click Validate and Sync, and confirm that the connection is successful. If you instead receive an error message, refer to the following documents. • “Status Codes and Error Responses” in the REST API Developer Guide • The “API Fault Element,” “ExceptionCode,” “Error,” and “StatusCode” sections of “Core Data Types Used in API Calls” in the SOAP API Developer Guide
873 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
7. Optionally, select tables and click Sync to do the following for each selected table. • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type.
Note: Before you sync, make sure that you understand the considerations that are described in these topics. • Sync an External Data Source for Salesforce Connect on page 858 • Sync Considerations for Salesforce Connect—Cross-Org Adapter on page 875
You can instead choose to manually create the external objects and custom fields that map to the external data. Doing so lets you customize the external object names, decide which table columns to create custom fields for, and customize the custom field names. However, this approach takes longer and requires manual maintenance.
SEE ALSO: Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Store Authentication Settings for External Systems API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Developer Guide: REST API Developer Guide
Considerations for Salesforce Connect—Cross-Org Adapter
Understand the special behaviors, limits, and recommendations for using the cross-org adapter for EDITIONS Salesforce Connect. Also review the considerations that apply to all Salesforce Connect adapters. Available in: both Salesforce Classic (not available in all orgs) and Lightning Salesforce Compatibility Considerations for Salesforce Connect—Cross-Org Adapter Experience (not for Some Salesforce features and functionality have special behaviors or aren’t available for external high-data-volume external objects that are associated with an external data source of type Salesforce Connect: objects) Cross-Org. Available in: Developer Sync Considerations for Salesforce Connect—Cross-Org Adapter Edition When you validate and sync an external data source of type Salesforce Connect: Available for an extra cost Cross-Org, some special behaviors and limitations apply. in: Enterprise, Performance, Writable External Objects Considerations for Salesforce Connect—Cross-Org Adapter and Unlimited Editions Some behaviors and limitations affect writable external objects that are associated with the cross-org adapter for Salesforce Connect. API Usage Considerations for Salesforce Connect—Cross-Org Adapter With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access records in other Salesforce orgs. Depending on how the external object is accessed, each call counts toward the API usage limits of only the provider org or of both provider and subscriber orgs. Picklist Considerations for Salesforce Connect—Cross-Org Adapter Special behaviors and limitations apply to picklist and multi-select picklist fields on external objects.
874 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Currency Considerations for Salesforce Connect—Cross-Org Adapter Special behaviors and limitations apply to currency fields on external objects.
SEE ALSO: Salesforce Platform Features Supported by Salesforce Connect
Salesforce Compatibility Considerations for Salesforce Connect—Cross-Org Adapter
Some Salesforce features and functionality have special behaviors or aren’t available for external EDITIONS objects that are associated with an external data source of type Salesforce Connect: Cross-Org. Available in: both Salesforce • The cross-org adapter for Salesforce Connect can access only queryable objects in the provider Classic and Lightning org. If you define an external object whose table name specifies an object that can’t be queried, Experience your users and the Lightning Platform can’t access that external object. Available in: Developer • You can’t use Salesforce Connect external objects to access big objects in another org. Edition • When you deploy an external data source that uses OAuth 2.0 from a sandbox org to a Available for an extra cost production org, you must update the authentication provider. On a production org, an external in: Enterprise, Performance, data source can’t use an authentication provider that directs authorization or token requests and Unlimited Editions to a sandbox org. Similarly, on a sandbox org, an external data source can’t use an authentication provider that directs authorization or token requests to a production org. Also review the considerations that apply to all Salesforce Connect adapters.
Sync Considerations for Salesforce Connect—Cross-Org Adapter
When you validate and sync an external data source of type Salesforce Connect: EDITIONS Cross-Org, some special behaviors and limitations apply. • Which objects and fields can be synced is determined by the object permissions and field Available in: both Salesforce permissions of the provider org’s user whose credentials are defined in the external data source Classic (not available in all definition. See User Access to External Data in Salesforce Connect—Cross-Org Adapter on page orgs) and Lightning 870. Experience (not for high-data-volume external • Only queryable objects can be synced. objects) • You can’t sync an object whose API name contains 38 or more characters. An external object’s name can’t exceed 40 characters, including the automatically appended __x suffix. See API Available in: Developer Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter on Edition page 869. Available for an extra cost • These field types aren’t synced. in: Enterprise, Performance, and Unlimited Editions – Encrypted text – Rich text area
• Global picklist value sets aren’t synced. If a provider org’s picklist field uses a global picklist value set, syncing creates a local picklist field on the subscriber org. A local picklist field has its own set of values. • Inactive picklist values aren’t synced. If the subscriber org accesses an external object record that contains an inactive picklist value, the inactive value is added to the picklist field on the external object.
• Syncing converts restricted picklists on the provider org into unrestricted picklists on the subscriber org’s external objects.
875 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
We recommend having only unrestricted picklists on external objects, even when they’re associated with restricted picklists on the provider org. Restricted picklists on the provider org block unapproved values from the subscriber org, eliminating the need to restrict picklists on external objects.
• To enable users to change the currency when editing an external object record, add the Currency field to the page layouts. All other synced fields are automatically added to the default page layout. • Syncing always enables search on the external object when search is enabled on the external data source, and vice versa. • Hierarchical, lookup, and master-detail relationship fields are synced. However, they become text fields in the subscriber org, and their values appear as IDs, not as record names. For example, suppose that we sync the Account object. When we view the Acme Wireless account in the provider org, the value of the Account Owner (Account.OwnerId) field appears as John Smith. When we view the equivalent account in the subscriber org, the value for the (Account__x.OwnerId__c) field appears as 005B00000019eapIAA.
• You can use external lookup relationships in the subscriber org to mirror lookup relationships in the provider org. For each lookup relationship that you want to bring into the subscriber org, sync the parent and child objects. Each lookup relationship field becomes a text field on the subscriber org. Change the field type of the sync-created text field to External Lookup Relationship. When specifying the parent of the external lookup relationship, select the external object that corresponds to the parent object in the provider org. • The names and labels of synced fields on the subscriber org are derived from the API names—not the labels—of the fields on the provider org. For example, the Account object in the provider org has the Account Owner (OwnerId) standard field. If we sync the Account object, the Account__x.OwnerId__c field in the subscriber org has the label “Owner ID” and the name “OwnerId.”
Important: When you select the provider org objects to sync, determine whether check marks appear in the Synced column. If a Synced check mark appears, the subscriber org has an external object whose object name (for example, Account__x) associates it with the object in the provider org (for example, Account). If you select the object and click Sync: • The external object is overwritten. • Any custom field on the external object is overwritten if its API name (for example, Email_c__c) associates it with a field on the provider org (for example, Email__c). • Any other custom fields on the external object remain as they are, including: – Previously synced custom fields whose API names were changed by editing their Field Name values. – Manually added custom fields whose API names aren’t associated with fields on the provider org’s object.
If no Synced check mark appears, and you sync the object, a new external object is created in the subscriber org. For example, the object name is changed on the provider org to no longer be associated with the object name of the external object on the subscriber org. Syncing that object creates a new external object on the subscriber org. We recommend that you change the object name of the existing external object to match the updated object name on the provider org before you sync.
Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Sync an External Data Source for Salesforce Connect Cross-Org Adapter for Salesforce Connect
876 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Writable External Objects Considerations for Salesforce Connect—Cross-Org Adapter
Some behaviors and limitations affect writable external objects that are associated with the cross-org EDITIONS adapter for Salesforce Connect. • Some fields remain read only on writable external objects, such as fields that are creatable but Available in: both Salesforce not editable and fields that have derived or calculated values. For example: Classic (not available in all orgs) and Lightning – Address fields such as Billing Address and Shipping Address, which are Experience (not for derived from writable fields, such as Street Address, State, and Zip) high-data-volume external – Auto-number fields objects) – Created by fields Available in: Developer – Formula fields Edition – Last Modified fields Available for an extra cost – Roll-up summaries in: Enterprise, Performance, and Unlimited Editions • Picklist values on external objects can get out of sync with picklist values on the provider org. If picklist values are changed on the provider org, resync or manually delete and recreate the associated picklist fields on the subscriber org. • Enable multiple currencies in the subscriber org, and make sure that the subscriber org has all the currencies that the provider orgs use. If a currency is later added to the provider org, add the currency to the subscriber org. If you can’t enable multiple currencies in the subscriber org, make sure that all provider orgs are single-currency and use the same currency as the subscriber org.
• To enable users to change the currency when editing an external object record, add the Currency field to the page layouts. • If a user tries to change the currency in an external object record, the list of currency options isn’t limited to active currencies in the provider org. If the user selects a currency that’s inactive or unavailable in the provider org, the user gets an error and can’t save the record. • You can use external lookup relationships in the subscriber org to mirror lookup relationships in the provider org. For each lookup relationship that you want to bring into the subscriber org, sync the parent and child objects. Each lookup relationship field becomes a text field on the subscriber org. Change the field type of the sync-created text field to External Lookup Relationship. When specifying the parent of the external lookup relationship, select the external object that corresponds to the parent object in the provider org. Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: Writable External Objects in Salesforce Connect Sync an External Data Source for Salesforce Connect Cross-Org Adapter for Salesforce Connect
877 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
API Usage Considerations for Salesforce Connect—Cross-Org Adapter
With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access EDITIONS records in other Salesforce orgs. Depending on how the external object is accessed, each call counts toward the API usage limits of only the provider org or of both provider and subscriber orgs. Available in: both Salesforce When a user accesses an external object in one of the following ways, the Lightning Platform REST Classic (not available in all API call counts toward the API usage limits of the provider org. orgs) and Lightning Experience (not for • Opening a list view of external object records high-data-volume external • Viewing an external object record detail page objects) • Viewing a parent object record that contains an external object related list Available in: Developer • Viewing a child object record that contains an external lookup field Edition • Executing a search that also searches external objects Available for an extra cost • Accessing an external object from a flow, Visualforce page, Apex class, or Apex trigger in: Enterprise, Performance, • Creating, editing, or deleting an external object record and Unlimited Editions • Running a report • Editing a report and causing the preview to load in report builder If a user or system accesses an external object through the SOAP API, Bulk API, or Lightning Platform REST API, that access counts toward the API usage limits of both the subscriber org and the provider org.
SEE ALSO: Salesforce Limits Quick Reference Guide: API Request Limits and Allocations Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter
Picklist Considerations for Salesforce Connect—Cross-Org Adapter
Special behaviors and limitations apply to picklist and multi-select picklist fields on external objects. EDITIONS • You can edit picklist values on external objects, but changes to fields on the provider org aren’t automatically reflected in the subscriber org. To reflect changes on the subscriber org, resync Available in: both Salesforce the external object or manually update the picklist values on the external object. Classic (not available in all orgs) and Lightning If you don’t resync or update the picklist values on the external object: Experience (not for – When an active picklist value is added to the provider org, the subscriber org doesn’t display high-data-volume external it as an available picklist value on external object records. objects)
– When an active picklist value is deleted from or made inactive on a restricted picklist on Available in: Developer the provider org, the subscriber org can’t create or edit external object records with that Edition value. Available for an extra cost • Global picklist value sets aren’t synced. If a provider org’s picklist field uses a global picklist value in: Enterprise, Performance, set, syncing creates a local picklist field on the subscriber org. A local picklist field has its own and Unlimited Editions set of values. • Inactive picklist values aren’t synced. If the subscriber org accesses an external object record that contains an inactive picklist value, the inactive value is added to the picklist field on the external object.
• Syncing converts restricted picklists on the provider org into unrestricted picklists on the subscriber org’s external objects.
878 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• We recommend having only unrestricted picklists on external objects, even when they’re associated with restricted picklists on the provider org. Restricted picklists on the provider org block unapproved values from the subscriber org, eliminating the need to restrict picklists on external objects.
SEE ALSO: Sync Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Considerations for Salesforce Connect—Cross-Org Adapter Picklist Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter
Currency Considerations for Salesforce Connect—Cross-Org Adapter
Special behaviors and limitations apply to currency fields on external objects. EDITIONS • Enable multiple currencies in the subscriber org, and make sure that the subscriber org has all the currencies that the provider orgs use. If a currency is later added to the provider org, add Available in: both Salesforce the currency to the subscriber org. Classic (not available in all orgs) and Lightning If you can’t enable multiple currencies in the subscriber org, make sure that all provider orgs Experience (not for are single-currency and use the same currency as the subscriber org. high-data-volume external • To enable users to change the currency when editing an external object record, add the objects) Currency field to the page layouts. Available in: Developer • If a user tries to change the currency in an external object record, the list of currency options Edition isn’t limited to active currencies in the provider org. If the user selects a currency that’s inactive Available for an extra cost or unavailable in the provider org, the user gets an error and can’t save the record. in: Enterprise, Performance, • The convertCurrency() function is ignored in SOQL queries of external objects. and Unlimited Editions
SEE ALSO: Considerations for Enabling Multiple Currencies Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter
Access External Data with the OData 2.0 or 4.0 Adapter for Salesforce Connect Connect your users to data that's exposed via the Open Data Protocol.
OData 2.0 or 4.0 Adapter for Salesforce Connect Connect to your back office for a complete view of your business. With the OData 2.0 or 4.0 adapter, Salesforce Connect uses Open Data Protocol Version 2.0 or Version 4.0 to access data that’s stored outside Salesforce. Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Let users view and search data that’s stored outside your Salesforce org, such as data in an enterprise resource planning (ERP) system. Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the special behaviors, limits, and recommendations for using the OData 2.0 or 4.0 adapter for Salesforce Connect. Picklist Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter Special behaviors and limitations apply to picklist fields on external objects.
879 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Get to know the Salesforce implementation of the Open Data Protocol (OData) for accessing external systems with Salesforce Connect. Use External Change Data Capture to Track Data Changes on External Objects With External Change Data Capture, you can track changes to data that is stored outside your Salesforce org when using the Odata 4.0 adapter. You can then build automation in response to the changes to increase productivity or provide a better customer experience.
OData 2.0 or 4.0 Adapter for Salesforce Connect
Connect to your back office for a complete view of your business. With the OData 2.0 or 4.0 adapter, EDITIONS Salesforce Connect uses Open Data Protocol Version 2.0 or Version 4.0 to access data that’s stored outside Salesforce. Available in: both Salesforce Your users and the Lightning Platform interact with the external data via external objects. Salesforce Classic (not available in all Connect converts each of those interactions into an OData query that contains the relevant orgs) and Lightning parameters to filter the results. Salesforce performs an OData callout each time that: Experience (not for high-data-volume external • A user clicks an external object tab for a list view. objects) • A user views a record detail page of an external object. Available in: Developer • A user views a record detail page of a parent object that displays a related list of child external Edition object records. Available for an extra cost • A user performs a Salesforce global search. in: Enterprise, Performance, • A user creates, edits, or deletes an external object record. and Unlimited Editions • A user runs a report. • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. The OData 2.0 adapter for Salesforce Connect can access external data that’s exposed via services called OData producers. Learn more about OData producers at www.odata.org. To understand the limitations on Apex code accessing external objects via the OData adapters, see Apex Considerations for Salesforce Connect External Objects.
External IDs and OData Entity Keys When you access external data with the OData 2.0 or 4.0 adapter for Salesforce Connect, the values of the External ID standard field on an external object are derived according to the entity key that’s defined in the OData service metadata document. Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters It's common for Salesforce Connect queries of external data to have a large result set that's broken into smaller batches or pages. You decide whether to have the paging behavior controlled by the external system (server-driven) or by the OData 2.0 or 4.0 adapter for Salesforce Connect (client-driven).
880 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
General Limits for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the limits for the OData adapters for Salesforce Connect.
SEE ALSO: Salesforce Connect Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters
External IDs and OData Entity Keys
When you access external data with the OData 2.0 or 4.0 adapter for Salesforce Connect, the values EDITIONS of the External ID standard field on an external object are derived according to the entity key that’s defined in the OData service metadata document. Available in: both Salesforce Each external object has an External ID standard field. Its values uniquely identify each Classic (not available in all external object record in your org. When the external object is the parent in an external lookup orgs) and Lightning relationship, the External ID standard field is used to identify the child records. Experience (not for high-data-volume external Important: Don’t use sensitive data as the values of the External ID standard field or fields objects) designated as name fields, because Salesforce sometimes stores those values. Available in: Developer • External lookup relationship fields on child records store and display the External ID values Edition of the parent records. Available for an extra cost • For internal use only, Salesforce stores the External ID value of each row that’s retrieved in: Enterprise, Performance, from the external system. This behavior doesn’t apply to external objects that are associated and Unlimited Editions with high-data-volume external data sources.
This list view for the Order_Detail external object displays External ID values.
Each External ID value is derived according to the entity key that’s defined in the OData service metadata document of the remote data service (OData producer). The entity key is formed from a subset of the entity type’s properties. This excerpt from an OData service metadata document shows that the External ID values for the Order_Detail external object are derived from the OrderID and ProductID properties.
881 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
...
This record detail page displays the OrderID and ProductID fields. Their values are combined to create the value of the External ID standard field.
If you enable writable external objects, determine whether the external system requires write operations to specify values for the entity keys. For example, many external systems generate values for entity keys when new external object records are created in Salesforce. If your external system requires write operations to specify values for entity keys, ensure that External ID standard field values and entity key values don’t contradict each other. For each write operation, include either the External ID standard field value or the custom field values that form the entity key, but never both.
SEE ALSO: OData 2.0 or 4.0 Adapter for Salesforce Connect Writable External Objects in Salesforce Connect
Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters
It's common for Salesforce Connect queries of external data to have a large result set that's broken EDITIONS into smaller batches or pages. You decide whether to have the paging behavior controlled by the external system (server-driven) or by the OData 2.0 or 4.0 adapter for Salesforce Connect Available in: both Salesforce (client-driven). Classic (not available in all By default, the OData 2.0 and 4.0 adapters for Salesforce Connect use client-driven paging. orgs) and Lightning Specifically, the OData requests use the $top and $skip system query options to page through Experience (not for the result set. high-data-volume external objects) With server-driven paging, the external system determines the page sizes and batch boundaries. The external system’s paging settings can optimize the external system’s performance and improve Available in: Developer the load times for external objects in your org. Also, the external data set can change while your Edition users or the Lightning Platform are paging through the result set. Typically, server-driven paging Available for an extra cost adjusts batch boundaries to accommodate changing data sets more effectively than client-driven in: Enterprise, Performance, paging. and Unlimited Editions
882 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
The Server Driven Pagination field on the external data source specifies whether to use client-driven or server-driven paging. If you enable server-driven paging on an external data source, Salesforce ignores the requested page sizes, including the default queryMore() batch size of 500 rows. The pages returned by the external system determine the batches, but each page can’t exceed 2,000 rows. However, the limits for the OData adapters for Salesforce Connect still apply.
SEE ALSO: Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter General Limits for Salesforce Connect—OData 2.0 and 4.0 Adapters OData Query String Options
General Limits for Salesforce Connect—OData 2.0 and 4.0 Adapters
Understand the limits for the OData adapters for Salesforce Connect. EDITIONS An org is limited to: • 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require Available in: both Salesforce Classic (not available in all higher limits, create a support case. orgs) and Lightning • 1,000 OData callouts per hour for Developer Edition. Experience (not for • 100k new external object record IDs per hour for long-term ID mapping high-data-volume external • 100k new external object record IDs per hour for short-term ID mapping objects) Available in: Developer Note: To view external object records in Lightning Experience, Salesforce Connect maps the Edition external IDs of the record to Salesforce IDs. Mappings classified as short-term refer to records retrieved via Search results only. Mappings classified as long-term refer to records retrieved Available for an extra cost by all other Lightning Experience components, such as List Views. Record IDs not viewed in in: Enterprise, Performance, 365 days are subject to deletion unless the mappings have customer data attached to them. and Unlimited Editions
Maximum HTTP request size for OData 8 MB
Maximum HTTP response size for OData 8 MB
Maximum result set size for an OData query 16 MB
Maximum result set size for an OData subquery 1,000 rows
SEE ALSO: General Limits for Salesforce Connect OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData 2.0 or 4.0 Adapter for Salesforce Connect Record IDs for Salesforce Connect External Objects
883 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter
USER PERMISSIONS EDITIONS
To create and edit external data sources: Customize Application Available in: both Salesforce Classic (not available in all To create and edit external objects: Customize Application orgs) and Lightning To define or change object-level help: Customize Application Experience (not for high-data-volume external To create and edit custom fields: Customize Application objects)
To edit permission sets and user profiles: Manage Profiles and Permission Sets Available in: Developer To edit another user’s authentication settings Manage Users Edition for external systems: Available for an extra cost in: Enterprise, Performance, and Unlimited Editions Let users view and search data that’s stored outside your Salesforce org, such as data in an enterprise resource planning (ERP) system. Setting up Salesforce Connect with anOData 2.0 or 4.0 adapter involves these high-level steps. 1. Define an external data source of type Salesforce Connect: OData 2.0 or Salesforce Connect: OData 4.0. If your external system hosts multiple services, create an external data source for each service endpoint. Each service endpoint points to an OData service root URL and can expose collections of entities. For example, you’d create a separate external data source for each of these service endpoints. • http://services.example.org/Warehouse.svc • https://services.example.org/Payroll.svc
2. Create the external objects. Perform this task only if you don’t sync to automatically create the external objects. Create an external object for each external data table that you want to access from your Salesforce org.
3. Create help content for the external objects. Create Visualforce pages that describe the external data. When your users click Help for this Page on an external object, they read your custom help content. Remember, your users can’t find information about the external data in Salesforce Help.
4. Add custom fields and relationships to the external objects. Create relationships between objects. If you didn’t sync to automatically create the external objects and their fields, create a custom field for each external table column that you want to access from your Salesforce org.
5. Verify access to external object data. Check that expected user and code interactions with the external objects work, including sorting and filtering search and query results.
Tip: After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results.
6. Enable user access to external objects. Grant object permissions through permission sets or profiles.
7. Enable user access to the fields on the external objects.
884 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Grant field permissions through permission sets or profiles.
8. If the external data source uses per-user authentication: a. Let users authenticate to the external system. Grant users access to authentication settings for the external data source through permission sets or profiles.
b. Set up each user’s authentication settings. You or your users can perform this task.
Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for each external system. If you’re using OAuth 2.0, test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes.
SEE ALSO: OData 2.0 or 4.0 Adapter for Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Developer Guide: Visualforce Developer Guide External Object Relationships
Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter ® Connect your Salesforce org to data that’s stored in an external system, such as SAP NetWeaver EDITIONS Gateway, Microsoft Dynamics® NAV, or IBM WebSphere®.
Note: Available in: both Salesforce Classic (not available in all • The external data must be exposed by a service that uses Open Data Protocol (OData) orgs) and Lightning Version 2.0 or 4.0. Such a service is called an OData producer. Experience (not for • The URL for reaching the OData producer must be accessible by Salesforce application high-data-volume external servers through the Internet. You can allow access by white-listing Salesforce server IP objects) addresses on your corporate network firewall or by setting up a reverse-proxy XML Available in: Developer Gateway. Edition • The extent to which you can customize data visibility depends on the external system. Available for an extra cost To determine the optimal settings for integration with Salesforce, consult the external in: Enterprise, Performance, system’s documentation. and Unlimited Editions 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. USER PERMISSIONS 2. Click New External Data Source, or click Edit to modify an existing external data source. To create and edit external 3. Complete the fields. data sources: • Customize Application
885 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description Label A user-friendly name for the external data source. The label is displayed in the Salesforce user interface, such as in list views. If you set Identity Type to Per User, this label appears when your users view or edit their authentication settings for external systems.
Name A unique identifier that’s used to refer to this external data source definition through the API. The name can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
Type Select Salesforce Connect: OData 2.0 or Salesforce Connect: OData 4.0.
URL The OData service root URL. Make sure that you escape all special characters. Each service endpoint requires its own external data source definition, but you can have multiple entities under one service root URL. For more information about the service root URL and other URL conventions, go to www.odata.org. Examples: • http://services.example.org/Warehouse.svc • https://services.example.org/Payroll.svc If the endpoint is defined in a named credential, enter the named credential URL. A named credential URL contains the scheme callout:, the name of the named credential, and an optional path. For example: callout:My_Named_Credential/some_path. You can append a query string to a named credential URL. Use a question mark (?) as the separator between the named credential URL and the query string. For example: callout:My_Named_Credential/some_path?format=json. If you enter a named credential URL, skip the Authentication section for the external data source. To access the external system, Salesforce Connect uses the authentication settings that are defined in the named credential.
Connection Timeout Number of seconds to wait for a response from the external system before timing out. By default, the value is set to the maximum of 120 seconds. Depending on the availability of and the connection to the external system, it can take a long time to retrieve external data. Use this field to limit how long to wait for external data to load into your org.
Writable External Lets the Lightning platform and users in this org create, update, and delete records for external Objects objects associated with the external data source. The external object data is stored outside the org. By default, external objects are read only.
High Data Volume Salesforce enforces rate limits for retrieving and viewing data from external systems. If your org hits rate limits when accessing external objects, consider selecting the High Data Volume option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. See High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 897.
886 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description High-data-volume external data sources are still limited to 20,000 OData queries per hour for Enterprise, Performance, and Unlimited Editions. If you require higher limits, create a support case. See OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 896.
Server Driven It's common for Salesforce Connect queries of external data to have a large result set that's broken Pagination into smaller batches or pages. Select this option to have the external system control the paging behavior. See Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 882.
Request Row Counts Includes one of the following system query options in each OData query so that the response includes the total row count of the result set. • $inlinecount=allpages for the OData 2.0 adapter • $count=true for the OData 4.0 adapter Some external systems don’t support these system query options. If you receive errors or notice long load times when you try to access their data, deselect Request Row Counts on the external data source. If you do so, however, the external data source and its associated external objects can’t support the following functionality, which requires the total row count. • SOQL COUNT() aggregate function • Batch Apex with Database.QueryLocator
Compress Requests When selected, Salesforce sends compressed HTTP requests to the external system. Make sure that the external system is set up to receive gzip-compressed data. Salesforce automatically accepts gzip-compressed responses.
Enable Search Determines whether SOSL and Salesforce global searches also query the external objects that are associated with this external data source. When selected, you can control which external objects are searchable by selecting or deselecting Allow Search on each external object. Only text, text area, and long text area fields on external objects can be searched. If an external object has no searchable fields, searches on that object return no records. Select this option to allow the external data source’s associated external objects to appear in Salesforce for iOS and Salesforce mobile web when used on iOS devices.
Custom Query Option Available only for the OData 2.0 adapter for Salesforce Connect. If the OData producer has for Salesforce implemented and exposed a free-text-search custom query option, enter the name of that query Search string parameter. Learn more about OData custom query options and other URI conventions at www.odata.org. This field has no effect when Enable Search is deselected or when the OData producer isn’t set up to correctly handle the custom query option. See OData 2.0 Query Options.
Use Free-Text Search Available only for the OData 4.0 adapter for Salesforce Connect. Select this option to use the Expressions $search system query option instead of $filter in search requests that are sent to the
887 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description external system. Make sure that the OData producer is set up to support the $search system query option. This field has no effect when Enable Search is deselected. See OData 4.0 Query Options.
Format The format that the OData producer uses to represent resources, such as collections of data. Make sure that the OData producer is set up to support the selected format. Learn more about representation formats and operations at www.odata.org. If your external data source uses the OData 4.0 adapter and JSON format, make sure that the OData producer accepts headers that contain the odata.metadata=full format parameter. Other variations, including odata.metadata=minimal, aren’t supported.
Special Select Socrata only if the URL specifies a Socrata open data endpoint. See Socrata™ Considerations Compatibility for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 898.
CSRF Protection If the external system requires Cross-Site Request Forgery (CSRF) protection in requests to create, edit or delete its data, select this option. If you do so, your org obtains an anti-CSRF token and cookie from the external system and includes them in each create, edit, and delete request. See CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 898. Available only when Writable External Objects is selected.
Anti-CSRF Token Name HTTP header field that contains the anti-CSRF token. The external system determines the field name. Default: X-CSRF-Token Available only when CSRF Protection is selected.
Certificate If you specify a certificate, your Salesforce org supplies it when establishing each two-way SSL connection with the external system. The certificate is used for digital signatures, which verify that requests are coming from your Salesforce org.
Identity Type Determines whether you're using one set or multiple sets of credentials to access the external system. See Identity Type for External Data Sources on page 857. Select Anonymous only if the external system doesn’t require authentication.
4. Select the authentication protocol. • If you select Password Authentication, enter the username and password for accessing the external system. • If you select OAuth 2.0, complete the following fields.
Field Description Authentication Choose the provider. See Authentication Providers. Provider
888 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter.
Note: – The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider. – Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen. – We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system.
Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status.
5. Click Save. 6. Click Validate and Sync, and confirm that the connection is successful. 7. Optionally, select tables and click Sync to do the following for each selected table. • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type.
Note: Before you sync, make sure that you understand the considerations that are described in these topics. • Sync an External Data Source for Salesforce Connect on page 858 • Sync Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter on page 894
You can instead choose to manually create the external objects and custom fields that map to the external data. Doing so lets you customize the external object names, decide which table columns to create custom fields for, and customize the custom field names. However, this approach takes longer and requires manual maintenance.
Optionally, you can associate custom HTTP headers to the external data source to retrieve or request additional data.
SEE ALSO: Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Store Authentication Settings for External Systems OData Query String Options OData Type Mapping Named Credentials
889 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Define Custom HTTP Headers for OData Connectors
Define and activate custom HTTP headers to pass more request information to the external data EDITIONS source for processing. Custom HTTP headers provide context information from Salesforce such as region, org details, or Available in: both Salesforce the role of the person viewing the external object. For each OData external data source, define up Classic (not available in all 10 HTTP headers to request or data. For example, to see who’s making a callout to the external data orgs) and Lightning source, use a formula that resolves to the name of the user. Experience When naming the custom HTTP header, don’t override the following existing standard header Available with Salesforce names. Connect, which is available in: Developer Edition and for • Content-Type an extra cost in: Enterprise, • Accept Performance, and • maxVersionHeader Unlimited Editions • versionHeader • X-HTTP-METHOD USER PERMISSIONS • Content-Length To create and edit external • X-CSRF-Token (when CSRF-enabled) data sources: • Prefer (when a trigger on the external object is enabled) • Customize Application • Cookie 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. 2. Click the name of an OData 2.0 or 4.0 data source. 3. In the External Custom HTTP Headers related list, click New to create a custom HTTP header or Edit to change an existing one. 4. Complete the fields.
Field Description Header Field Name Enter a name that contains at least one alphanumeric character or underscore. It can also include: ! # $ % & ' * + - . ^ _ ` | ~
Header Field Value Create a formula for the Header Field Value using the formula editor. The values in the formula must evaluate to a string. If the formula resolves to null and an empty string, the header isn’t sent.
Active To start using the header field right away, select the Active checkbox.
Description A text description of the header field’s purpose.
Parent The name of the entity that the custom HTTP header is related to.
Note: A named credential as the parent entity for the custom HTTP header isn’t supported.
5. Click Save.
Note: You can’t add or delete Custom HTTP headers that are included in a managed package. However, you can edit custom HTTP headers that are part of a managed package. The Header Name and Description fields are developer editable. The Active and Header Field Value fields are both subscriber and developer editable.
890 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Named Credential as Callouts for Salesforce Connect OData 2.0 or 4.0 Adapters This example shows how Salesforce Connect OData 2.0 or 4.0 adapters can make callouts using the authentication settings defined in a named credential. Define a named credential that specifies the endpoint URL and the JWT authentication settings.
When you’re defining an external data source with an Odata 2.0 or Odata 4.0 adapter, specify the named credential you defined as the OData service root URL. In this example, the URL is callout:Test_named_credential. And skip the Authentication section for the external data source. To access the external system, Salesforce Connect uses the authentication settings defined in the named credential.
SEE ALSO: Define a Named Credential Store Authentication Settings for External Systems Grant Access to Authentication Settings for Named Credentials
891 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Understand the special behaviors, limits, and recommendations for using the OData 2.0 or 4.0 EDITIONS adapter for Salesforce Connect. Also review the considerations that apply to all Salesforce Connect adapters. Available in: both Salesforce Classic (not available in all orgs) and Lightning Lightning Experience Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Experience (not for Users can access external objects from the Lightning Experience app. But some requirements high-data-volume external and special behaviors apply when the external data is accessed via the OData 2.0 or 4.0 adapter objects) for Salesforce Connect. Available in: Developer Writable External Objects Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Edition Some special behaviors and limitations affect writable external objects that are associated with Available for an extra cost OData adapters for Salesforce Connect. in: Enterprise, Performance, Sync Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter and Unlimited Editions When you validate and sync an external data source of type Salesforce Connect: OData 2.0 or Salesforce Connect: OData 4.0, some special behaviors and limitations apply. OData Producer Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the limits and recommendations for the remote data service that exposes the external data to your Salesforce org. OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters An external object references data that’s stored outside Salesforce. Access to an external object involves a callout to its associated external system. Salesforce enforces rate limits for these callouts. High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters If your org hits rate limits when accessing external objects, consider selecting the High Data Volume option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. Socrata™ Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Socrata Open Data Protocol™ is commonly used for health data and for collaboration between governments and their citizens. Salesforce Connect can access data from endpoints that are backed by Socrata Open Data Portal. To accommodate Socrata-specific requirements, set the Special Compatibility field on the external data source to Socrata. CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the special behaviors, limitations, and recommendations for Cross-Site Request Forgery (CSRF) on OData external data sources.
SEE ALSO: Salesforce Platform Features Supported by Salesforce Connect
892 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Lightning Experience Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Users can access external objects from the Lightning Experience app. But some requirements and EDITIONS special behaviors apply when the external data is accessed via the OData 2.0 or 4.0 adapter for Salesforce Connect. Available in: both Salesforce • If external object records don’t appear in your org, make sure that the OData producer doesn’t Classic and Lightning change the values specified in the OData query filters. When your org sends OData queries that Experience specify field values with the $filter equals (eq) operator, the OData producer must return Available in: Developer those same field values in the resulting data rows. Edition • If external object records don’t appear in relationship fields or related lists, check for case-sensitive Available for an extra cost values. For example, suppose that you set up an indirect lookup relationship. If the external in: Enterprise, Performance, system uses case-sensitive values in the specified External Column Name, make sure that the and Unlimited Editions parent object field is also case-sensitive. When you define the parent object’s custom field, select External ID, Unique, and Treat "ABC" and "abc" as different values (case sensitive).
SEE ALSO: External Object Relationships OData Query String Options OData 2.0 or 4.0 Adapter for Salesforce Connect Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter
Writable External Objects Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Some special behaviors and limitations affect writable external objects that are associated with EDITIONS OData adapters for Salesforce Connect. • An external object custom field associated with an OData complex type on the external system Available in: both Salesforce is always read only, even if the external object is writable. Classic (not available in all • Writable external objects aren’t available for high-data-volume external data sources. orgs) and Lightning Experience (not for • If your external system requires write operations to specify values for entity keys, ensure that high-data-volume external External ID standard field values and entity key values don’t contradict each other. For objects) each write operation, include either the External ID standard field value or the custom field values that form the entity key, but never both. Available in: Developer Edition • When an external object record is edited, Salesforce Connect sends an HTTP request to the external system. Available for an extra cost in: Enterprise, Performance, – If the record is edited from the Salesforce user interface, the HTTP request includes all fields, and Unlimited Editions including the fields that weren’t changed. – If the record is edited from the API, only the specified fields are included in the HTTP request.
• Make sure that the OData producer supports the HTTP methods that are used by your Salesforce Connect adapter.
To Do This OData 4.0 Adapter Uses This HTTP Method OData 2.0 Adapter Uses This HTTP Method Create record POST POST
Edit record POST with X-HTTP-METHOD header set to PATCH POST with X-HTTP-METHOD header set to MERGE
Delete record DELETE DELETE
893 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
To Do This OData 4.0 Adapter Uses This HTTP Method OData 2.0 Adapter Uses This HTTP Method View record GET GET
Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: Writable External Objects in Salesforce Connect External IDs and OData Entity Keys OData 2.0 or 4.0 Adapter for Salesforce Connect
Sync Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter
When you validate and sync an external data source of type Salesforce Connect: OData EDITIONS 2.0 or Salesforce Connect: OData 4.0, some special behaviors and limitations apply. Available in: both Salesforce • Syncing always enables search on the external object when search is enabled on the external Classic (not available in all data source, and vice versa. orgs) and Lightning Experience (not for • For a list of supported OData types, see “OData Type Mapping” in Salesforce Help. high-data-volume external Important: When you select the tables to sync, determine whether check marks appear in objects) the Synced column. Available in: Developer If a Synced check mark appears, your org has an external object whose object name matches Edition the table name. If you select the table and click Sync: Available for an extra cost • The external object is overwritten. in: Enterprise, Performance, and Unlimited Editions • Any custom field on the external object is overwritten if its API name (for example, Email__c) associates it with a table column name (for example, Email). • Any other custom fields on the external object remain as they are, including: – Previously synced custom fields whose API names were changed by editing their Field Name values. – Manually added custom fields whose API names aren’t associated with table column names.
If no Synced check mark appears, and you sync the table, a new external object is created in your org. The new external object’s object name matches the table name. For example, if the table name is changed on the external system to no longer match the object name of the external object, syncing that table creates a new external object in Salesforce. We recommend that you change the object name of the existing external object to match the new table name on the external system before you sync that table.
894 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: Sync an External Data Source for Salesforce Connect Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter OData 2.0 or 4.0 Adapter for Salesforce Connect OData Type Mapping
OData Producer Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Understand the limits and recommendations for the remote data service that exposes the external EDITIONS data to your Salesforce org. • Validate your OData producer by using the Open Data Protocol Service Validation Tool at Available in: both Salesforce services.odata.org/validation. Doing so checks your implementation against Classic and Lightning the OData specification and identifies potential issues. Experience • To improve performance over low-bandwidth connections, set up your OData producer to Available in: Developer receive gzip-compressed data. Then, in the external data source definition in Salesforce, select Edition Compress Requests. You can also set up the OData producer to send gzip-compressed data Available for an extra cost to Salesforce, which automatically accepts gzip-compressed responses. in: Enterprise, Performance, • By default, Salesforce sends each OData request with one of the following system query options and Unlimited Editions so that the response includes the total row count of the result set. – $inlinecount=allpages for the OData 2.0 adapter – $count=true for the OData 4.0 adapter Some external systems don’t support these system query options. If you receive errors or notice long load times when you try to access their data, deselect Request Row Counts on the external data source. If you do so, however, the external data source and its associated external objects can’t support the following functionality, which requires the total row count. – SOQL COUNT() aggregate function – Batch Apex with Database.QueryLocator For details about OData URI conventions, go to www.odata.org.
• Configure your OData producer to use a page size that’s large enough to avoid excessive round trips. Querying a large set of data with a small page size can take a long time because of network latency. Salesforce pages that display external data can take a long time to load. For example, if the query results include 100 records, and the page size holds only 5 records, it takes 20 round trips to retrieve the results. If the network latency is 100 ms per round trip, it takes 2 seconds (20 × 100 ms) to retrieve the results. In contrast, if the page size holds 20 records, it takes only five round trips to retrieve the 100 records. With the same network latency of 100 ms per round trip, it takes 0.5 seconds (5 × 100 ms) to retrieve the results.
• For a list of supported OData types, see “OData Type Mapping” in Salesforce Help. • If your external data source uses the OData 4.0 adapter and JSON format, make sure that the OData producer accepts headers that contain the odata.metadata=full format parameter. Other variations, including odata.metadata=minimal, aren’t supported.
895 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• If external object records don’t appear in your org, make sure that the OData producer doesn’t change the values specified in the OData query filters. When your org sends OData queries that specify field values with the $filter equals (eq) operator, the OData producer must return those same field values in the resulting data rows.
SEE ALSO: OData 2.0 or 4.0 Adapter for Salesforce Connect OData Query String Options OData Type Mapping
OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
An external object references data that’s stored outside Salesforce. Access to an external object EDITIONS involves a callout to its associated external system. Salesforce enforces rate limits for these callouts. An org is limited to: Available in: both Salesforce Classic (not available in all • 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require orgs) and Lightning higher limits, create a support case. Experience (not for • 1,000 OData callouts per hour for Developer Edition. high-data-volume external • 100k new external object record IDs per hour for long-term ID mapping objects) • 100k new external object record IDs per hour for short-term ID mapping Available in: Developer Edition Note: To view external object records in Lightning Experience, Salesforce Connect maps the external IDs of the record to Salesforce IDs. Mappings classified as short-term refer to records Available for an extra cost retrieved via Search results only. Mappings classified as long-term refer to records retrieved in: Enterprise, Performance, by all other Lightning Experience components, such as List Views. Record IDs not viewed in and Unlimited Editions 365 days are subject to deletion unless the mappings have customer data attached to them. To obtain your org’s limits and current usage against those limits, use the Limits resource in the Lightning Platform REST API. Salesforce performs an OData callout each time that: • A user clicks an external object tab for a list view. • A user views a record detail page of an external object. • A user views a record detail page of a parent object that displays a related list of child external object records. • A user performs a Salesforce global search. • A user creates, edits, or deletes an external object record. • A user runs a report. • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. If your users or applications encounter rate limit errors for OData callouts, try one or more of the following. • Select High Data Volume in the external data source definition. Doing so bypasses most rate limits, but some special behaviors and limitations apply. • Run fewer SOQL and SOSL queries. • If you have Apex code that invokes the external system, modify that code to cache frequently accessed external data that seldom changes.
896 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• Contact Salesforce to request a higher limit.
SEE ALSO: REST API Developer Guide : List Organization Limits High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData 2.0 or 4.0 Adapter for Salesforce Connect Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
If your org hits rate limits when accessing external objects, consider selecting the High Data Volume EDITIONS option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. Available in: both Salesforce • The following features aren’t available for external objects that are associated with Classic (not available in all high-data-volume external data sources. orgs) and Lightning Experience (not for – Access via Lightning Experience high-data-volume external – Access via the Salesforce mobile app objects) – Appearance in Recent Items lists Available in: Developer – Record feeds Edition – Reports and dashboards Available for an extra cost – Writable external objects in: Enterprise, Performance, and Unlimited Editions • Salesforce IDs aren’t assigned to external object records that are associated with high-data-volume external data sources. • On record detail pages for external objects that are associated with high-data-volume external data sources, custom buttons, and links that call JavaScript aren’t supported. • Salesforce Console in Salesforce Classic doesn’t support external objects that are associated with high-data-volume external data sources. • CSRF protection for writable external objects isn’t available for high-data-volume external data sources.
SEE ALSO: REST API Developer Guide : List Organization Limits OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter
897 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Socrata™ Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters ™ Socrata Open Data Protocol is commonly used for health data and for collaboration between EDITIONS governments and their citizens. Salesforce Connect can access data from endpoints that are backed by Socrata Open Data Portal. To accommodate Socrata-specific requirements, set the Special Available in: both Salesforce Compatibility field on the external data source to Socrata. Classic (not available in all Socrata doesn’t support the row identifier (_id) column in $select or $orderby clauses in orgs) and Lightning OData queries. When Socrata is selected in the Special Compatibility field: Experience (not for high-data-volume external • OData queries don’t include the _id column in $select clauses. objects) • If an _id column is synced from a Socrata endpoint, the resulting custom field on the external Available in: Developer object isn’t sortable. Edition • If you manually define an external object’s custom field with _id as the External Column Available for an extra cost Name, make sure that you select the Sorting Disabled attribute for that custom field. in: Enterprise, Performance, If you modify the Special Compatibility field on an external data source, we recommend and Unlimited Editions that you resync its external objects. Or instead, you can test whether queries or user access to the external objects result in errors, and resync only the problematic external objects.
SEE ALSO: Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters
Understand the special behaviors, limitations, and recommendations for Cross-Site Request Forgery EDITIONS (CSRF) on OData external data sources. • CSRF protection isn’t available for high-data-volume external data sources. Available in: both Salesforce • Make sure that the URL of the external data source starts with https:// so that secure HTTP Classic (not available in all can prevent unauthorized access to the anti-CSRF token and cookie. orgs) and Lightning Experience (not for • In addition to enabling CSRF protection on the external data source, we recommend keeping high-data-volume external CSRF protection enabled in your org’s session security settings. These session settings are objects) enabled by default, and keeping them enabled protects your Salesforce data and your external data from CSRF attacks. Available in: Developer Edition – Enable CSRF protection on GET requests on non-setup pages Available for an extra cost Enable CSRF protection on POST requests on non-setup pages – in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Modify Session Security Settings
898 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Picklist Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter
Special behaviors and limitations apply to picklist fields on external objects. EDITIONS • Global and local single-select picklists are supported. • You must manually update picklist values to stay in sync between your org and the external Available in: both Salesforce system. If values are not in sync, your users could see an error message when viewing the field. Classic (not available in all orgs) and Lightning – Add values to the picklist as you would a picklist on a custom object. Experience (not for – Remove a value from a picklist by deactivating the value rather than deleting it. high-data-volume external – Replace a value by deactivating it and then adding the new value. Update the external objects) system’s record values to the new value on the external system. Available in: Developer Edition • Convert existing external object text fields to picklists by deleting and recreating. Delete the text field and create a picklist pointing to the text field’s existing External Column Name. Available for an extra cost in: Enterprise, Performance, • If you select to delete, you might be prompted to replace the value with another value. No and Unlimited Editions replace occurs for external object record values. You must manually change the values on the external system. • We recommend having only unrestricted picklists on external objects, even when they’re associated with restricted picklists on the provider org. Restricted picklists on the provider org block unapproved values from the subscriber org, eliminating the need to restrict picklists on external objects.
SEE ALSO: Picklist Considerations for Salesforce Connect—Cross-Org Adapter
OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters
Get to know the Salesforce implementation of the Open Data Protocol (OData) for accessing external EDITIONS systems with Salesforce Connect. Available in: both Salesforce OData Type Mapping Classic (not available in all Salesforce Connect maps OData types to Salesforce metadata field types when syncing metadata orgs) and Lightning and converting values between Salesforce and external systems. Experience (not for high-data-volume external OData Query String Options objects) The OData adapters for Salesforce Connect use a subset of the OData 2.0 and 4.0 system functions and filter expression constructs to query external systems. Available in: Developer Edition Available for an extra cost SEE ALSO: in: Enterprise, Performance, OData 2.0 or 4.0 Adapter for Salesforce Connect and Unlimited Editions
899 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData Type Mapping
Salesforce Connect maps OData types to Salesforce metadata field types when syncing metadata EDITIONS and converting values between Salesforce and external systems. Available in: both Salesforce OData 2.0 Type Mapping Classic (not available in all Understand how the OData 2.0 adapter for Salesforce Connect maps OData types to Salesforce orgs) and Lightning metadata field types. Experience (not for high-data-volume external OData 4.0 Type Mapping objects) Understand how the OData 4.0 adapter for Salesforce Connect maps OData types to Salesforce metadata field types. Available in: Developer Edition Available for an extra cost in: Enterprise, Performance, and Unlimited Editions
OData 2.0 Type Mapping
Understand how the OData 2.0 adapter for Salesforce Connect maps OData types to Salesforce EDITIONS metadata field types. Salesforce Connect supports only the following types when syncing metadata and converting Available in: both Salesforce values between Salesforce and an external system. Classic (not available in all orgs) and Lightning Experience (not for OData 2.0 Primitive Types high-data-volume external objects) OData 2.0 Type Salesforce Metadata Field Type Available in: Developer Binary TextArea Edition Boolean Checkbox Available for an extra cost in: Enterprise, Performance, Byte Number and Unlimited Editions DateTime DateTime
DateTimeOffset DateTime
Decimal Number
Double Number
Guid Text
Int16 Number
Int32 Number
Int64 Number
SByte Number
Single Number
900 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 2.0 Type Salesforce Metadata Field Type String Depends on the declared maximum length of the OData string column.
OData Declared Maximum Salesforce Field Type Salesforce Field Length Length Attribute Not declared Text 128 characters
255 or fewer characters Text Same as declared
More than 255 characters LongTextArea Same as declared
Time Text
Tip: A binary value from an external system is represented in Salesforce as a base64-encoded string. You can convert it to a value of type Blob by using the EncodingUtil.base64Decode(inputString) Apex method.
OData 2.0 Complex Types Salesforce Connect supports OData complex types as follows. • External data of complex type is flattened into a string that contains field names and values. For example, an address is flattened into the following string.
Street: 55 East 5th Street, City: New York, State: NY, Zip: 10003
• An external object custom field associated with an OData complex type on the external system is always read only, even if the external object is writable.
SEE ALSO: Sync an External Data Source for Salesforce Connect Custom Field Types Custom Field Attributes OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Apex Developer Guide : EncodingUtil Class: base64Decode(inputString)
901 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 4.0 Type Mapping
Understand how the OData 4.0 adapter for Salesforce Connect maps OData types to Salesforce EDITIONS metadata field types. Salesforce Connect supports only the following types when syncing metadata and converting Available in: both Salesforce values between Salesforce and an external system. Classic (not available in all orgs) and Lightning Experience (not for OData 4.0 Primitive Types high-data-volume external objects) OData 4.0 Type Salesforce Metadata Field Type Available in: Developer Binary TextArea Edition Boolean Checkbox Available for an extra cost in: Enterprise, Performance, Byte Number and Unlimited Editions Date DateTime with time properties set to 0
DateTimeOffset DateTime
Decimal Number
Double Number
Guid Text
Int16 Number
Int32 Number
Int64 Number
SByte Number
Single Number
String Depends on the declared maximum length of the OData string column.
OData Declared Salesforce Field Salesforce Field Maximum Length Type Length Attribute Not declared Text 128 characters
255 or fewer Text Same as declared characters
More than 255 LongTextArea Same as declared characters
Tip: A binary value from an external system is represented in Salesforce as a base64-encoded string. You can convert it to a value of type Blob by using the EncodingUtil.base64Decode(inputString) Apex method.
902 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 4.0 Complex Types Salesforce Connect supports OData complex types as follows. • External data of complex type is flattened into a string that contains field names and values. For example, an address is flattened into the following string.
Street: 55 East 5th Street, City: New York, State: NY, Zip: 10003
• An external object custom field associated with an OData complex type on the external system is always read only, even if the external object is writable.
SEE ALSO: Sync an External Data Source for Salesforce Connect Custom Field Types Custom Field Attributes OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Apex Developer Guide : EncodingUtil Class: base64Decode(inputString)
OData Query String Options
The OData adapters for Salesforce Connect use a subset of the OData 2.0 and 4.0 system functions EDITIONS and filter expression constructs to query external systems. When your users or the Lightning Platform interact with external objects, the OData 2.0 or 4.0 Available in: both Salesforce adapter for Salesforce Connect converts those actions into OData queries. Salesforce performs an Classic (not available in all OData callout each time that: orgs) and Lightning Experience (not for • A user clicks an external object tab for a list view. high-data-volume external • A user views a record detail page of an external object. objects) • A user views a record detail page of a parent object that displays a related list of child external Available in: Developer object records. Edition • A user performs a Salesforce global search. Available for an extra cost • A user creates, edits, or deletes an external object record. in: Enterprise, Performance, • A user runs a report. and Unlimited Editions • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. The following sections describe the Salesforce Connect implementation as a consumer of OData services. Salesforce automatically creates the OData queries so that you, as an administrator or developer, don’t have to. However, understanding how OData queries are generated—or even attempting manual OData queries—can help you troubleshoot issues with the external system’s OData producer. For details about each system query option, go to www.odata.org. Salesforce Connect supports only the following OData system query options. All other options in the OData 2.0 and 4.0 specifications are unused. • $count (OData 4.0 only) on page 904 • $filter on page 904 • $inlinecount (OData 2.0 only) on page 904
903 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
• $orderby on page 905 • $search (OData 4.0 only) on page 905 • $select on page 905 • $skip on page 906 • $top on page 906 A query search string to an external system is sent as a case-sensitive single phrase after removing all ASCII punctuation characters except hyphens (-). For example, if the search string is Sales & Marketing, the external system receives Sales Marketing.
$count (OData 4.0 only) Specifies that the response must include the number of rows that the URI identifies after $filter system query options are applied, but before $top and $skip system query options are applied. When Request Row Counts is enabled on the external data source, Salesforce includes $count=true in all OData 4.0 queries of that external data source to determine the total number of items in each result set. The total items in the result set is the same as the LIMIT value in the query for values less than 202. If the LIMIT value is greater than 202, then 202 items are returned to indicate that more records exist in the next batch. If Request Row Counts is disabled, Salesforce includes $count=false in all OData 4.0 queries of the external data source, and 2000 items are returned in each result set.
Examples User action in View or access an external object. Salesforce
SOQL query Any SOQL query of an external object
Resulting OData http://services.example.org/my.svc/Suppliers?$select=SupplierID& query $count=true&$top=26
$filter Filters the collection of resources that’s addressed by a request URL. The response contains the results that evaluate to true.
Examples User action in Open a list view of cities from supplier records that are filtered so that the country is USA. Salesforce
SOQL query SELECT City__c FROM Suppliers__x WHERE Country__c = 'USA' ORDER BY City__c ASC LIMIT 26
Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=City& query $select=City,SupplierID&$inlinecount=allpages&$filter=Country+eq+'USA'& $top=26
$inlinecount (OData 2.0 only) Specifies that the response must include a count of the number of rows that the URI identifies after $filter system query options are applied but before $top and $skip system query options are applied.
904 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
When Request Row Counts is enabled on the external data source, Salesforce uses $inlinecount in all OData 2.0 queries of that external data source to determine the total number of items in each result set. If Request Row Counts is disabled, $inlinecount is excluded from all OData 2.0 queries of the external data source.
Examples User action in View or access an external object. Salesforce
SOQL query Any SOQL query of an external object.
Resulting OData http://services.example.org/my.svc/Suppliers?$select=SupplierID& query $inlinecount=allpages&$top=26
$orderby Sorts the result set in ascending or descending order. The fields in the ORDER BY clause of the SOQL query don't always match the properties used by the $orderby option in the resulting OData query. If you use the OFFSET clause in the SOQL query, the entity key property is added in the resulting OData query.
Examples User action in Open a list view of supplier records that are ordered by company name. Salesforce
SOQL query SELECT CompanyName__c,ContactName__c FROM Suppliers__x ORDER BY CompanyName__c ASC LIMIT 26
Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=CompanyName& query $select=CompanyName,ContactName,SupplierID&$inlinecount=allpages&$top=26
$search (OData 4.0 only) Requests entities that match the search query string as a free-text search expression. Enable this option by selecting Use Free-Text Search Expressions on the external data source. By default, Use Free-Text Search Expressions is not enabled. The search query string is used as the contains value in the $filter system query option.
Examples User action in View or access an external object. Salesforce
SOQL query Any SOQL query of an external object
Resulting OData http://services.example.org/my.svc/Shippers? query $select=CompanyName,Phone,ShipperID&$count=true&$search=Acme&$top=25
$select Requests a limited set of properties for each entity.
905 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Examples User action in Open a list view of supplier records where the page layout displays the company name and contact name. Salesforce
SOQL query SELECT CompanyName__c,ContactName__c FROM Suppliers__x ORDER BY CompanyName__c ASC LIMIT 26
Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=CompanyName& query $select=CompanyName,ContactName,SupplierID&$inlinecount=allpages&$top=26
$skip Specifies the number of items in the queried collection to skip in the result set.
Examples User action in Click to view the second page of a list view of supplier records that are ordered by city. Salesforce
SOQL query SELECT City__c,CompanyName__c FROM Suppliers__x ORDER BY City__c ASC OFFSET 25
Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=City& query $select=City,CompanyName,SupplierID&$inlinecount=allpages&$top=25& $skip=25
$top Specifies the number of items in the queried collection to include in the result. The value in the LIMIT clause of a SOQL query doesn’t always match the requested $top value, because the latter is modified as needed for client-driven paging and queryMore() calls.
Examples User action in Open a list view of the top 25 supplier records. Salesforce
SOQL query SELECT SupplierID__c FROM Suppliers__x LIMIT 25
Resulting OData http://services.example.org/my.svc/Suppliers?$select=SupplierID& query $inlinecount=allpages&$top=25
OData 2.0 Query Options By default, the search query string is used as the substringof value in the $filter system query option.
906 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 4.0 Query Options By default, the search query string is used as the contains value in the $filter system query option.
SEE ALSO: OData Producer Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters
OData 2.0 Query Options
By default, the search query string is used as the substringof value in the $filter system EDITIONS query option. In this example, the search query string is Acme. Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience (not for high-data-volume external objects)
Available in: Developer Edition Available for an extra cost in: Enterprise, Performance, and Unlimited Editions
http://services.example.org/my.svc/Shippers? $select=CompanyName,Phone,ShipperID&$inlinecount=allpages& $filter=substringof('Acme',CompanyName)+eq+true+ or+substringof('Acme',Phone)+eq+true&$top=25
OData 2.0 Custom Query Option We recommend that you set up the OData producer to support free text search expressions with the custom query option. You can then specify the name of the query string parameter in the Custom Query Option for Salesforce Search field on the external data source. In this example, the custom query parameter is doSearch and the search query string is Acme.
http://services.example.org/my.svc/Shippers? $select=CompanyName,Phone,ShipperID& $inlinecount=allpages&doSearch=Acme&$top=25
Learn more about OData URI conventions at www.odata.org.
907 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
OData 4.0 Query Options
By default, the search query string is used as the contains value in the $filter system query EDITIONS option. In the following example, the search query string is Acme. Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience (not for high-data-volume external objects)
Available in: Developer Edition Available for an extra cost in: Enterprise, Performance, and Unlimited Editions
http://services.example.org/v4.svc/Shippers? $select=CompanyName,Phone,ShipperID&$count=true& $filter=contains(CompanyName,'Acme') eq true or contains(Phone,'Acme') eq true$top=25&
OData 4.0 Custom Query Option We recommend that you set up the OData producer to support free text search expressions with the $search system query option. You can then select Use Free-Text Search Expressions on the external data source.
http://services.example.org/v4.svc/Shippers? $select=CompanyName,Phone,ShipperID&$count=true& $search=Acme&$top=25
Learn more about OData URI conventions at www.odata.org.
Use External Change Data Capture to Track Data Changes on External Objects With External Change Data Capture, you can track changes to data that is stored outside your Salesforce org when using the Odata 4.0 adapter. You can then build automation in response to the changes to increase productivity or provide a better customer experience. The external data change tracking feature polls the external system at configurable intervals (5–30 minutes) for tracked changes. For each external object that has the feature enabled, a topic channel and an associate change event entity are created where change event notifications are published. You add a subscriber to each topic channel and then process the data changes through Streaming API. You can also add an Apex trigger that is called when change event notifications are published.
External Change Data Capture Considerations Keep these considerations in mind when working with External Change Data Capture. Enable External Change Data Capture and Tracking Enable external change data capture for the data source and each external object that you want to monitor.
908 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Subscribe to Change Events You can use Apex triggers to subscribe to change events. Or you can use a Bayeux client to subscribe to Streaming API on the publication channel. Check the External Change Data Capture Status for an External Object You can quickly check the change-tracking status from an external object’s detail page. More detailed monitoring is also available. Change the Polling Interval for External Change Data Capture By default, the external change data capture feature polls the external system every 30 minutes for tracked changes. You can change the interval to poll the external system as frequently as every 5 minutes. Monitor and Troubleshoot External Change Data Capture Check these tips when troubleshooting change tracking on external objects. Example: How Codey Outfitters Uses External Change Data Capture The fictitious company, Codey Outfitters, distributes outdoor equipment from local small businesses to outdoor enthusiasts around the world. The company handles all logistics, such as complying with import laws for each state and country.
External Change Data Capture Considerations Keep these considerations in mind when working with External Change Data Capture. • Each polling request counts toward your Salesforce org’s OData callout rate allocation. • OData doesn’t differentiate between created and updated change events. Both events are published with update change type. • When you enable change tracking, a $top=0 query for zero rows is sent to the external data source to tell it to track changes, and a delta link is returned. • If an error occurs, Salesforce stops sending polling requests. You can check for an error status by querying the BackgroundOperation object or viewing the latest error on the object’s setup page. • If you create an Apex trigger to respond to change events, these requirements and behaviors apply. – Create the Apex trigger with development tools, such as the Developer Console or Metadata API or Salesforce UI. You can’t create the trigger from the Salesforce UI. – Because the Apex trigger runs after an event occurs, only the after-insert trigger event is supported. – The trigger passes the associated change event, not the object that caused the change. – Changed records can be committed in the same transaction that started the trigger. However, keep in mind that this transaction is separate from the transaction that created the original event.
Enable External Change Data Capture and Tracking
Enable external change data capture for the data source and each external object that you want USER PERMISSIONS to monitor. 1. From Setup, enter External Data Sources in the Quick Find box, then select External To create or edit external Data Sources. objects: • Customize Application 2. Click Edit, and select Eligible for External Change Data Capture. 3. Click Save. 4. From the External Objects list , select the external object that you want to track. 5. Click Edit, and select Track Data Changes. 6. Click Save.
909 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
After you enable change tracking, a publication channel is created under the topic for the external object. For example, /data/Object Name__ChangeEvents appears as /data/Products__ChangeEvents, where Product is the object name.
Subscribe to Change Events You can use Apex triggers to subscribe to change events. Or you can use a Bayeux client to subscribe to Streaming API on the publication channel. After subscribing, you can observe change event notifications when you perform a DML operation on an external object. You can also see change events on the tracked data stored on the external system.
Check the External Change Data Capture Status for an External Object
You can quickly check the change-tracking status from an external object’s detail page. More USER PERMISSIONS detailed monitoring is also available. 1. From Setup, enter External Objects in the Quick Find box, then select External Objects. To create or edit external objects: 2. Click the label of the external object. • Customize Application The External Change Data Capture Status field shows one of the following statuses. • Disabled—Either the data source or the external object doesn’t have external change data capture enabled. • Error—External change data capture encountered an error in the last poll for changes and stopped. After resolving the error, restart external change data capture. • Running—External change data capture is running and polls the external system in the configured time interval for changes. • Stopped—External change data capture is not scheduled to poll for changes.
Change the Polling Interval for External Change Data Capture By default, the external change data capture feature polls the external system every 30 minutes for tracked changes. You can change the interval to poll the external system as frequently as every 5 minutes. 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. 2. Next to the name of the external data source, click Edit. 3. In the Polling Interval for External Change Data Capture field, enter the number of seconds between polling. 4. Click Save.
Monitor and Troubleshoot External Change Data Capture Check these tips when troubleshooting change tracking on external objects. • To check the status of external data change tracking, query the BackgroundOperation object. • Each BackgroundOperation record is available for inspection for one day. You can include the ExpiresAt field in your SOQL query of the BackgroundOperation object to check when the record expires. • Set up and view debug logs.
Example: How Codey Outfitters Uses External Change Data Capture The fictitious company, Codey Outfitters, distributes outdoor equipment from local small businesses to outdoor enthusiasts around the world. The company handles all logistics, such as complying with import laws for each state and country.
910 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Over the years, Codey Outfitters has acquired different IT systems to manage orders, shipments, inventory, and billing. It uses Salesforce CRM to manage its customer base and the suppliers whose items it sells. Codey Outfitters wants to provide customers with a one-stop shopping portal where they can see price changes on the gear. When the inventory is updated, Codey Outfitters wants the change notifications sent to its Salesforce org. Salesforce then performs business logic to determine whether the updates include price changes that are valuable to customers based on their order history. Customers can see or be notified about relevant deals on their Codey Outfitters portal. Let’s see how Codey Outfitters sets up and uses external change data capture to accomplish these goals.
Set Up the External Data Source and the External Object Codey Outfitters has an OData 4.0 service for its inventory. The company connects its Salesforce org to the inventory by creating an external data source called Gear Inventory and creating an external object called Products. Monitor External Change Data Capture With external change data capture enabled, Codey Outfitters’ org polls the external system every 30 minutes. To monitor the tracking status, it queries the BackgroundOperation object. Codey Outfitters prefers to run SOQL queries in the Query Editor of the Developer Console, but you can use your preferred tool. Subscribe to Changes with Streaming API When Codey Outfitters runs its Bayeux client, the client subscribes to Streaming API on the products publication channel. React to Changes with Apex Triggers To automate your business with external change events, use Apex triggers.
Set Up the External Data Source and the External Object Codey Outfitters has an OData 4.0 service for its inventory. The company connects its Salesforce org to the inventory by creating an external data source called Gear Inventory and creating an external object called Products. The Products external object provides the following data. • Name (product name) • UnitPrice (current price) • Stock (number of items in stock) • OrderLimit (limit for each order) To track changes, Codey Outfitters selects Eligible for External Change Data Capture for the Gear Inventory external data source. It then enables Track Data Changes on the Products external object.
Monitor External Change Data Capture With external change data capture enabled, Codey Outfitters’ org polls the external system every 30 minutes. To monitor the tracking status, it queries the BackgroundOperation object. Codey Outfitters prefers to run SOQL queries in the Query Editor of the Developer Console, but you can use your preferred tool. Here’s the SOQL query that Codey Outfitters uses to monitor the tracking status.
SELECT Id,Name,SubmittedAt,StartedAt,FinishedAt,ProcessAfter,Status FROM BackgroundOperation WHERE WorkerUri='v45.0/xds/data-changes'
In the query results, the first row shows the initial callout to the external system. The initial request tells the OData producer to start tracking changes on the Products__x object. In the second row, the org schedules the next callout to request the tracked changes. Notice that the callout is scheduled to occur after 30 minutes have passed.
911 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
ID Name Submitted Started Finished Process After Status
08Pxx0000000019EAA Products__x 2017-10-06T01:11:04.000Z 2017-10-06T01:11:08.000Z 2017-10-06T01:11:08.000Z Complete
08Pxx000000000qEAA Products__x 2017-10-06T01:11:08.000Z 2017-10-06T01:41:08.000Z Waiting
After waiting 30 minutes, querying the BackgroundOperation object shows that the second callout finishes, and the status is Complete. In the third row, a new change request is scheduled to run after 30 more minutes have passed.
ID Name Submitted Started Finished Process After Status 08Pxx0000000019EAA Products__x 2017-10-06T01:11:04.000Z 2017-10-06T01:11:08.000Z 2017-10-06T01:11:08.000Z Complete
08Pxx000000000qEAA Products__x 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:08.000Z Complete
08Pxx000000002MEAQ Products__x 2017-10-06T01:41:09.000Z 2017-10-06T02:11:09.000Z Waiting
Suppose that the Codey Outfitters inventory has a service outage, preventing the scheduled poll request from succeeding. Errors cause change tracking to stop, so querying the BackgroundOperation object shows the error status and no new rows.
ID Name Submitted Started Finished Process After Status 08Pxx0000000019EAA Products__x 2017-10-06T01:11:04.000Z 2017-10-06T01:11:08.000Z 2017-10-06T01:11:08.000Z Complete
08Pxx000000000qEAA Products__x 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z Complete
08Pxx000000002MEAQ Products__x 2017-10-06T01:41:09.000Z 2017-10-06T02:12:07.000Z 2017-10-06T02:12:07.000Z 2017-10-06T02:11:09.000Z Error
When query results show no rows in Waiting status, external change data capture is disabled. When the query results show an error, you can get error details by including the Error field in your SOQL query of the BackgroundOperation object. Here’s how Codey Outfitters investigates the error.
SELECT Error FROM BackgroundOperation WHERE Id=’08Pxx000000002MEAQ’
Because a service outage caused the problem, the error message says:
The external system is unreachable. Try again later, or contact your admin, who can verify the external data source settings and the external system's availability. Attempted to reach this URL: https://codey-outfitters.example.com/inventory/Products
Codey Outfitters fixes the service outage and restarts change tracking on the Products__x object.
Subscribe to Changes with Streaming API When Codey Outfitters runs its Bayeux client, the client subscribes to Streaming API on the products publication channel. Codey Outfitters uses a Visualforce page to show its customers updates to prices and inventory and new and discontinued outdoor gear. This sample source code for the Visualforce page is on Github, and you can modify it to work with your OData 4.0 producer. The heart of the subscription mechanism is in the _subscribeChannels method in src/js/channel/ServerConnection.js.
cometd.subscribe(channelName, function(event) { if (event && event.data && event.data.payload &&
912 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
event.data.payload.ChangeEventHeader) { var header = event.data.payload.ChangeEventHeader; var entityName = header.entityName; var recordId = header.recordIds[0]; var timestamp = header.commitTimestamp; var changeType = header.changeType;
switch (changeType) { case "UPDATE": // Update logic ... break; case "CREATE": // Create logic break; case "DELETE": // Delete logic break; } } }
The channelName for Codey Outfitters’ products is /data/Products__ChangeEvent. Each change event notification that’s published on the channel is in the Bayeux format and represents an updated record in the product inventory. The data.payload contains the change event data and includes a header that describes the nature of the change event. This sample event notification describes a change to a Codey Outfitters product record.
{ schema=”lswW55LyUCYeU7raSrmZ5A”, payload={ ChangeEventHeader={ commitUser=”005xx000001SvAn”, sequenceNumber=15, entityName=”Products__x”, changeType=”UPDATE”, changeOrigin=”Products?$deltaToken=3779”, transactionKey=”f158f145-a...”, commitTimestamp=1507759119826, recordIds=[“x03xx0000000008”] }, Name__c=”Camping Stove”, ExternalId=7801, UnitPrice__c=10.0, Stock__c=1500.0, OrderLimit__c=12.0, ProductId__c=7801.0 }, event={replayId=15} }
Each change event notification has this structure.
Field Description schema Versioned schema reference that defines the change event.
913 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description
payload Details about the change event. • ChangeEventHeader—Describes the nature of the data change event. • Record fields and values—The OData producer can also include fields that have no changed values. To see the current values, query the external object using the record ID in the change event header.
event The replay ID that refers to the position of the event notification in the event stream on a channel.
Each change event header contains these fields.
Field Description commitUser User who publishes the event.
sequenceNumber Change event sequence number. Each change occurs in the order in which it’s received.
entityName API name of the external object.
changeType Specifies whether a record was updated, created, or deleted.
changeOrigin Delta link that’s used to request the change. The OData producer calculates the delta token while executing the previous change request.
transactionKey Unique identifier for the transaction.
commitTimestamp Specifies when the change event notification is published in milliseconds since January 1, 1970.
recordIds Salesforce ID of the external object record that’s updated, created, or deleted. To see the current values of the record’s fields, query the external object using this record ID.
nulledFields List of fields set to null.
React to Changes with Apex Triggers To automate your business with external change events, use Apex triggers. Codey Outfitters can customize Salesforce to send email or SMS notifications on items that are low on stock or have been updated to an attractive price. Gear and other items that are in high demand can be monitored for low stock and automatically ordered. Before customizing Salesforce, make sure that you’re tracking data changes on the external object that you want to track. To track items that are running low on stock, Codey Outfitters creates an Apex trigger named LowOnStock. Next, the company selects the trigger’s sObject and the change event that publishes changes for the external object Products__x: Products__ChangeEvent.
914 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Here’s an example of a simple rule that sends a notification when an item is low on stock.
trigger LowOnStock on Products__ChangeEvent (after insert) { // Get the change event’s product ID for added and updated products Set productIds = new Set(); for (Products__ChangeEvent event: Trigger.new) { if (event.ChangeEventHeader.getChangeType() != 'DELETE') { String productId = event.ChangeEventHeader.getRecordIds()[0]; productIds.add(productId); } } if (productIds.size() > 0) { ProductNotifications.notifyOnLowOnStockProductUpdates(productIds); } }
The product notifications class queries the external Product objects for the given changed product IDs and LowOnStock threshold value. Looking up the current Product records on the external system for qualifying products is a callout and is scheduled as an Apex future.
public class ProductNotifications { // Notify subscribers on product updates that are low on stock. // This method is run asynchronously as it is performing a callout to the external // system to get the latest product details @future (callout=true) public static void notifyOnLowOnStockProductUpdates(Set productIds) { // Look up the current stock threshold to filter the products with Integer productStockThreshold = ...; List lowOnStockProducts = getProductsLowOnStock(productIds, productStockThreshold); // Notify subscribers notifySubscribers(lowOnStockProducts, ‘These items are running out of stock. Act soon!’); }
// Get the external Product objects for each Product ID public static List getProductsLowOnStock(Set productIds, Integer productStockThreshold) { return [SELECT Id, ExternalId, Name__c, ProductId__c, Stock__c, UnitPrice__c FROM Products__x WHERE Stock__c < :productStockThreshold AND Stock__c > 0 AND Id IN :productIds]; }
// Notify subscribers by sending an email or SMS public static void notifySubscribers(String message, List products) { ... } }
You can discover the metadata for change events through the sObject describe API. For example, the sObject describe for Products__ChangeEvent shows the following standard change event fields.
915 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Type Description
Id String The change event’s Salesforce ID. This ID isn’t the Salesforce ID of the record that changed, but the event that carries the record’s changes.
ReplayId String The position of the event notification in the event stream on a channel.
ChangeEventHeader Complex Type The type of data change event.
Each change event object defines fields that hold the updated value at the time the record was updated. The OData producer can also include fields that haven’t changed. To see the current values, query the external object using the record ID in the change event header. The following table shows sample Products__x fields. Event change objects are tailored to their tracked external object. For a change event, not all fields are necessarily present.
Field Type Description Id String Product record’s Salesforce ID in your org
ExternalId String Product record’s external ID
DisplayUrl String URL representing the record in the external system
CreatedOn__c DateTime When the record was created in the external system
UpdatedOn__c DateTime When the record was last updated on the external system
Name__c String Product name in Product__x
OrderLimit__c Integer Number of items that can be ordered at a time
Stock__c Integer Number of items in stock
UnitPrice__c Decimal(8,2) Item’s unit price
The following fields are change event header complex type fields. To access ChangeEventHeader fields from Apex, use its getter method. For example, to access the field ChangeType, use eventObject.ChangeEventHeader.getChangeType().
Field Type Description commitUser String User who published the event.
sequenceNumber Integer Change event sequence number. Each change is listed in the order in which it’s received.
entityName String API name of the external object.
916 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Type Description
changeType ChangeType enum Specifies whether a record was updated, created, or deleted. The enum values for external change events are Create, Update, and Delete.
changeOrigin String Delta link that’s used to request the changes made since the previous or initial change request. The OData producer calculates the delta token while executing the previous change request.
transactionKey String Unique identifier for the transaction.
commitTimestamp Long Specifies when the change event notification is published in milliseconds since January 1, 1970.
recordIds Array of type String Salesforce ID of the external object record that is updated, created, or deleted. To see the current values of the record fields, query the external object using this record ID. This array always has exactly one Salesforce ID.
nulledFields Array of type String List of field names set to null.
Access External Data with a Custom Adapter for Salesforce Connect Connect your users to any data anywhere by developing your own custom adapter with the Apex Connector Framework.
Custom Adapter for Salesforce Connect Connect to any data anywhere for a complete view of your business. Use the Apex Connector Framework to develop a custom adapter for Salesforce Connect. Set Up Salesforce Connect to Access External Data with a Custom Adapter Let users view, search, and modify any data anywhere from within their Salesforce org. Considerations for Salesforce Connect—Custom Adapter Understand the special behaviors, limits, and recommendations for using a custom adapter for Salesforce Connect.
917 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Custom Adapter for Salesforce Connect
Connect to any data anywhere for a complete view of your business. Use the Apex Connector EDITIONS Framework to develop a custom adapter for Salesforce Connect. Your users and the Lightning Platform interact with the external data via external objects. For each Available in: both Salesforce of those interactions, Salesforce Connect invokes methods in the Apex classes that compose the Classic (not available in all custom adapter. Salesforce invokes the custom adapter’s Apex code each time that: orgs) and Lightning Experience (not for • A user clicks an external object tab for a list view. high-data-volume external • A user views a record detail page of an external object. objects) • A user views a record detail page of a parent object that displays a related list of child external Available in: Developer object records. Edition • A user performs a Salesforce global search. Available for an extra cost • A user creates, edits, or deletes an external object record. in: Enterprise, Performance, • A user runs a report. and Unlimited Editions • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. Apex code can access external objects, but some limitations and requirements apply. • To understand the limitations on Apex code accessing external objects, see Apex Considerations for Salesforce Connect External Objects. • To know how to use a custom adapter for Salesforce Connect, see Get Started with the Apex Connector Framework.
External IDs for External Objects in Salesforce Connect—Custom Adapter When you access external data with a custom adapter for Salesforce Connect, the values of the External ID standard field on an external object come from the DataSource.Column named ExternalId.
SEE ALSO: Salesforce Connect Set Up Salesforce Connect to Access External Data with a Custom Adapter Considerations for Salesforce Connect—Custom Adapter
918 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
External IDs for External Objects in Salesforce Connect—Custom Adapter
When you access external data with a custom adapter for Salesforce Connect, the values of the EDITIONS External ID standard field on an external object come from the DataSource.Column named ExternalId. Available in: both Salesforce Each external object has an External ID standard field. Its values uniquely identify each Classic (not available in all external object record in your org. When the external object is the parent in an external lookup orgs) and Lightning relationship, the External ID standard field is used to identify the child records. Experience (not for high-data-volume external Important: objects)
• The custom adapter’s Apex code must declare the DataSource.Column named Available in: Developer ExternalId and provide its values. Edition • Don’t use sensitive data as the values of the External ID standard field or fields designated Available for an extra cost as name fields, because Salesforce sometimes stores those values. in: Enterprise, Performance, – External lookup relationship fields on child records store and display the External ID and Unlimited Editions values of the parent records. – For internal use only, Salesforce stores the External ID value of each row that’s retrieved from the external system. This behavior doesn’t apply to external objects that are associated with high-data-volume external data sources.
Example: This excerpt from a sample DataSource.Connection class shows the DataSource.Column named ExternalId.
override global List sync() { List tables = new List(); List columns; columns = new List(); columns.add(DataSource.Column.text('title', 255)); columns.add(DataSource.Column.text('description',255)); columns.add(DataSource.Column.text('createdDate',255)); columns.add(DataSource.Column.text('modifiedDate',255)); columns.add(DataSource.Column.url('selfLink')); columns.add(DataSource.Column.url('DisplayUrl')); columns.add(DataSource.Column.text('ExternalId',255)); tables.add(DataSource.Table.get('googleDrive','title', columns)); return tables; }
SEE ALSO: Custom Adapter for Salesforce Connect Apex Developer Guide
919 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Set Up Salesforce Connect to Access External Data with a Custom Adapter
USER PERMISSIONS EDITIONS
To create Apex classes: Author Apex Available in: both Salesforce Classic (not available in all To configure remote settings: Modify All Data orgs) and Lightning To create and edit external data sources: Customize Application Experience (not for high-data-volume external To create and edit external objects: Customize Application objects)
To define or change object-level help: Customize Application Available in: Developer To create and edit custom fields: Customize Application Edition Available for an extra cost To edit permission sets and user profiles: Manage Profiles and Permission Sets in: Enterprise, Performance, To edit another user’s authentication settings Manage Users and Unlimited Editions for external systems:
Let users view, search, and modify any data anywhere from within their Salesforce org. Setting up Salesforce Connect with a custom adapter involves these high-level steps. 1. Develop the custom adapter for Salesforce Connect. Using the Apex Connector Framework, create the DataSource.Connection and DataSource.Provider classes that comprise the custom adapter.
2. Define remote sites for Apex callouts. If the custom adapter involves any Apex callouts, define each callout endpoint as a remote site in your organization. However, you don’t need to define a remote site for a callout whose endpoint is specified as a named credential instead of a URL.
3. Define an external data source of type Salesforce Connect: Custom. If you created multiple custom adapters, make sure that the external data source’s Type field specifies the correct DataSource.Provider class.
4. Create the external objects. Perform this task only if you don’t sync to automatically create the external objects. Create an external object for each external data table that you want to access from your Salesforce org.
5. Create help content for the external objects. Create Visualforce pages that describe the external data. When your users click Help for this Page on an external object, they read your custom help content. Remember, your users can’t find information about the external data in Salesforce Help.
6. Add custom fields and relationships to the external objects. Create relationships between objects. If you didn’t sync to automatically create the external objects and their fields, create a custom field for each external table column that you want to access from your Salesforce org.
7. Verify access to external object data. Check that expected user and code interactions with the external objects work, including sorting and filtering search and query results.
920 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Tip: After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results.
8. Enable user access to external objects. Grant object permissions through permission sets or profiles.
9. Enable user access to the fields on the external objects. Grant field permissions through permission sets or profiles.
10. If the external data source uses per-user authentication: a. Let users authenticate to the external system. Grant users access to authentication settings for the external data source through permission sets or profiles.
b. Set up each user’s authentication settings. You or your users can perform this task.
Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for each external system. If you’re using OAuth 2.0, test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes.
SEE ALSO: Custom Adapter for Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Developer Guide: Visualforce Developer's Guide External Object Relationships
Define an External Data Source for Salesforce Connect—Custom Adapter
Connect your Salesforce org to any data anywhere via a Salesforce Connect custom adapter that EDITIONS you create with the Apex Connector Framework. Before you begin, develop the custom adapter for Salesforce Connect. If the custom adapter uses Available in: both Salesforce Apex callouts, also define remote sites for the callout endpoints. See Set Up Salesforce Connect to Classic and Lightning Access External Data with a Custom Adapter on page 920. Experience 1. From Setup, enter External Data Sources in the Quick Find box, then select Available in: Developer External Data Sources. Edition 2. Click New External Data Source, or click Edit to modify an existing external data source. Available for an extra cost in: Enterprise, Performance, 3. Complete the fields. and Unlimited Editions
Field Description Label A user-friendly name for the external data source. The label is displayed USER PERMISSIONS in the Salesforce user interface, such as in list views. To create and edit external If you set Identity Type to Per User, this label appears when data sources: your users view or edit their authentication settings for external • Customize Application systems.
921 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Field Description Name A unique identifier that’s used to refer to this external data source definition through the API. The name can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
Type Select Salesforce Connect: Custom—. If you change and save a DataSource.Connection class, resave the corresponding DataSource.Provider class. Otherwise, when you define the external data source, the custom adapter doesn’t appear as an option for the Type field.
URL URL of the external system. Available only when the DataSource.Provider class declares the REQUIRE_ENDPOINT capability. If the class also declares the REQUIRE_HTTPS capability, the URL must begin with https://. If the endpoint is defined in a named credential, enter the named credential URL. A named credential URL contains the scheme callout:, the name of the named credential, and an optional path. For example: callout:My_Named_Credential/some_path. You can append a query string to a named credential URL. Use a question mark (?) as the separator between the named credential URL and the query string. For example: callout:My_Named_Credential/some_path?format=json.
Writable External Lets the Lightning platform and users in this org create, update, and delete records for external Objects objects associated with the external data source. The external object data is stored outside the org. By default, external objects are read only.
High Data Volume Salesforce enforces rate limits for retrieving and viewing data from external systems. If your org hits rate limits when accessing external objects, consider selecting the High Data Volume option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. See High Data Volume Considerations for Salesforce Connect—Custom Adapters on page 926.
Certificate If you specify a certificate, your Salesforce org supplies it when establishing each two-way SSL connection with the external system. The certificate is used for digital signatures, which verify that requests are coming from your Salesforce org. Available only when the DataSource.Provider class declares the CERTIFICATE authentication capability.
Identity Type Determines whether you're using one set or multiple sets of credentials to access the external system. See Identity Type for External Data Sources on page 857. Available only when the DataSource.Provider class declares the BASIC or OAUTH authentication capability.
4. Select the authentication protocol. • If you select Password Authentication, enter the username and password for accessing the external system.
922 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Password authentication is available only when the DataSource.Provider class declares the BASIC authentication capability.
• If you select OAuth 2.0, complete the following fields. OAuth 2.0 is available only when the DataSource.Provider class declares the OAUTH authentication capability.
Field Description Authentication Choose the provider. See Authentication Providers. Provider
Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter.
Note: – The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider. – Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen. – We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system.
Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status.
5. Click Save. 6. Click Validate and Sync, and confirm that the connection is successful. This step also invokes the sync() method on the DataSource.Connection class to obtain the list of tables that you can sync to create external objects and their fields.
7. Optionally, select tables and click Sync to do the following for each selected table. • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type.
Note: Before you sync, make sure that you understand the considerations that are described in these topics. • Sync an External Data Source for Salesforce Connect on page 858 • Sync Considerations for Salesforce Connect—Custom Adapter on page 927
923 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
You can instead choose to manually create the external objects and custom fields that map to the external data. Doing so lets you customize the external object names, decide which table columns to create custom fields for, and customize the custom field names. However, this approach takes longer and requires manual maintenance.
SEE ALSO: Set Up Salesforce Connect to Access External Data with a Custom Adapter Store Authentication Settings for External Systems Named Credentials
Considerations for Salesforce Connect—Custom Adapter
Understand the special behaviors, limits, and recommendations for using a custom adapter for EDITIONS Salesforce Connect. Also review the considerations that apply to all Salesforce Connect adapters. Available in: both Salesforce Classic (not available in all orgs) and Lightning Apex Connector Framework Considerations for Salesforce Connect—Custom Adapter Experience (not for Understand the limits and considerations for creating Salesforce Connect custom adapters with high-data-volume external the Apex Connector Framework. objects) High Data Volume Considerations for Salesforce Connect—Custom Adapters Available in: Developer If your org hits rate limits when accessing external objects, consider selecting the High Data Edition Volume option on the associated external data sources. Doing so bypasses most rate limits, Available for an extra cost but some special behaviors and limitations apply. in: Enterprise, Performance, Writable External Objects Considerations for Salesforce Connect—Custom Adapters and Unlimited Editions Some special behaviors and limitations affect writable external objects that are associated with custom adapters for Salesforce Connect. Sync Considerations for Salesforce Connect—Custom Adapter When you validate and sync an external data source of type Salesforce Connect: Custom, some special behaviors and limitations apply.
SEE ALSO: Salesforce Platform Features Supported by Salesforce Connect
924 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
Apex Connector Framework Considerations for Salesforce Connect—Custom Adapter
Understand the limits and considerations for creating Salesforce Connect custom adapters with EDITIONS the Apex Connector Framework. • If you change and save a DataSource.Connection class, resave the corresponding Available in: both Salesforce DataSource.Provider class. Otherwise, when you define the external data source, the Classic (not available in all custom adapter doesn’t appear as an option for the Type field. Also, the associated external orgs) and Lightning objects’ custom tabs no longer appear in the Salesforce UI. Experience (not for high-data-volume external • DML operations aren’t allowed in the Apex code that comprises the custom adapter. objects) • Make sure that you understand the limits of the external system’s APIs. For example, some external systems accept only requests for up to 40 rows. Available in: Developer Edition • Apex data type limitations: Available for an extra cost – Double—The value loses precision beyond 18 significant digits. For higher precision, use in: Enterprise, Performance, decimals instead of doubles. and Unlimited Editions – String—If the length is greater than 255 characters, the string is mapped to a long text area field in Salesforce.
• Custom adapters for Salesforce Connect are subject to the same limitations as any other Apex code. For example: – All Apex governor limits apply. – Test methods don’t support web service callouts. Tests that perform web service callouts fail. For an example that shows how to avoid these failing tests by returning mock responses, see Google Drive™ Custom Adapter for Salesforce Connect.
• In Apex tests, use dynamic SOQL to query external objects. Tests that perform static SOQL queries of external objects fail.
SEE ALSO: Custom Adapter for Salesforce Connect External Objects in Salesforce Connect Apex Developer Guide: Primitive Data Types Apex Developer Guide: Execution Governors and Limits Apex Developer Guide: Callout Limits and Limitations Apex Developer Guide: Google Drive™ Custom Adapter for Salesforce Connect Apex Developer Guide: Dymamic SOQL
925 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect
High Data Volume Considerations for Salesforce Connect—Custom Adapters
If your org hits rate limits when accessing external objects, consider selecting the High Data Volume EDITIONS option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. Available in: both Salesforce • The following features aren’t available for external objects that are associated with Classic (not available in all high-data-volume external data sources. orgs) and Lightning Experience (not for – Access via Lightning Experience high-data-volume external – Access via the Salesforce mobile app objects) – Appearance in Recent Items lists Available in: Developer – Record feeds Edition – Reports and dashboards Available for an extra cost – Writable external objects in: Enterprise, Performance, and Unlimited Editions • Salesforce IDs aren’t assigned to external object records that are associated with high-data-volume external data sources. • On record detail pages for external objects that are associated with high-data-volume external data sources, custom buttons, and links that call JavaScript aren’t supported. • Salesforce Console in Salesforce Classic doesn’t support external objects that are associated with high-data-volume external data sources.
SEE ALSO: Custom Adapter for Salesforce Connect Considerations for Salesforce Connect—Custom Adapter
Writable External Objects Considerations for Salesforce Connect—Custom Adapters
Some special behaviors and limitations affect writable external objects that are associated with EDITIONS custom adapters for Salesforce Connect. • Writable external objects aren’t available for high-data-volume external data sources. Available in: both Salesforce • Queued changes to the external data execute over time, so external object records that are Classic (not available in all read successively can contain different data. orgs) and Lightning Experience (not for Also review the considerations that apply to all Salesforce Connect adapters. high-data-volume external objects)
SEE ALSO: Available in: Developer Writable External Objects in Salesforce Connect Edition Custom Adapter for Salesforce Connect Available for an extra cost Apex Developer Guide : Writable External Objects in: Enterprise, Performance, and Unlimited Editions
926 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Sync Considerations for Salesforce Connect—Custom Adapter
When you validate and sync an external data source of type Salesforce Connect: Custom, EDITIONS some special behaviors and limitations apply. • Syncing always enables search on the external object when search is enabled on the external Available in: both Salesforce data source, and vice versa. For an external data source of type Salesforce Connect: Custom, Classic (not available in all search is enabled when the custom adapter’s DataSource.Provider class declares the orgs) and Lightning DataSource.Capability.SEARCH capability. Experience (not for high-data-volume external Important: When you select the tables to sync, determine whether check marks appear in objects) the Synced column. Available in: Developer If a Synced check mark appears, your org has an external object whose object name matches Edition the table name. If you select the table and click Sync: Available for an extra cost • The external object is overwritten. in: Enterprise, Performance, • Any custom field on the external object is overwritten if its API name (for example, and Unlimited Editions Email__c) associates it with a table column name (for example, Email). • Any other custom fields on the external object remain as they are, including: – Previously synced custom fields whose API names were changed by editing their Field Name values. – Manually added custom fields whose API names aren’t associated with table column names.
• Syncing always enables search on the external object when search is enabled on the external data source, and vice versa. For an external data source of type Salesforce Connect: Custom, search is enabled when the custom adapter’s DataSource.Provider class declares the DataSource.Capability.SEARCH capability. If no Synced check mark appears, and you sync the table, a new external object is created in your org. The new external object’s object name matches the table name. For example, suppose you change the table name in the custom adapter’s DataSource.Connection class to no longer match the object name of the external object. Syncing that table creates a new external object in Salesforce. We recommend that you change the object name of the existing external object to match the new table name in the DataSource.Connection class before you sync that table.
Also review the considerations that apply to all Salesforce Connect adapters.
SEE ALSO: Sync an External Data Source for Salesforce Connect Define an External Data Source for Salesforce Connect—Custom Adapter Custom Adapter for Salesforce Connect
Work with External Data Sources An external data source specifies how to access an external system. Salesforce Connect uses external data sources to access data that's stored outside your Salesforce organization. Files Connect uses external data sources to access third-party content systems. External data sources have associated external objects, which your users and the Lightning platform use to interact with the external data and content.
927 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Define External Data Sources Create external data sources to connect to content and data that is stored outside your Salesforce org. Validate and Sync an External Data Source After you configure an external data source, synchronize it to map its tables with external objects in your Salesforce org. The content and data of external objects appear in federated search, together with your Salesforce content and data. Define External Objects Tables in external systems map to external objects in Salesforce, combining all your data and content for users in your org. Validate External Object Connections After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results. Validator is available for external objects from Apex and Odata data sources. Grant Access to Authentication Settings for External Data Sources For external data sources that use per-user authentication, grant users access through permission sets and profiles. Doing so lets users set up and manage their own authentication settings for accessing the external system. Store Authentication Settings for External Systems You or your administrator can set up and manage your authentication settings for external systems. With valid authentication settings, you can access external systems from within your Salesforce org. External Object Relationships External objects support standard lookup relationships, which use the 18-character Salesforce record IDs to associate related records with each other. However, data that’s stored outside your Salesforce org often doesn’t contain those record IDs. Therefore, two special types of lookup relationships are available for external objects: external lookups and indirect lookups.
928 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Define External Data Sources
Create external data sources to connect to content and data that is stored outside your Salesforce EDITIONS org. 1. From Setup, enter External Data Sources in the Quick Find box, then select External Available in: both Salesforce Data Sources. Classic (not available in all orgs) and Lightning 2. Click New External Data Source. To modify an existing external data source, click Edit. Experience 3. Complete the steps for your type of external data source. Salesforce Connect is • Files Connect: Google Drive available in: Developer • Files Connect: SharePoint 2010 or 2013 Edition and for an extra cost • Files Connect: SharePoint Online or OneDrive for Business in: Enterprise, Performance, and Unlimited Editions • Files Connect: Box Files Connect for • Simple URL: Data from Another Web Domain cloud-based external data • Salesforce Connect: OData 2.0 sources is available in: • Salesforce Connect: OData 4.0 Professional, Enterprise, Performance, Unlimited, • Salesforce Connect: Cross-Org and Developer Editions • Salesforce Connect: Custom Federated Search is • Federated Search available in: Enterprise, Professional, Unlimited, and Developer Editions SEE ALSO: Salesforce Connect USER PERMISSIONS
To create and edit an external data source: • Customize Application
929 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Validate and Sync an External Data Source
After you configure an external data source, synchronize it to map its tables with external objects EDITIONS in your Salesforce org. The content and data of external objects appear in federated search, together with your Salesforce content and data. Available in: both Salesforce When you sync a large number of tables, you can select to execute the sync operation asynchronously Classic (not available in all as a background job and avoid connection timeout. You can view the list of sync operations orgs) and Lightning performed as background jobs in the corresponding External Data Source page. Experience
Note: Salesforce Connect is available in: Developer • Syncing creates or overwrites Salesforce external objects that map to the external system’s Edition and for an extra cost schema. Syncing doesn’t copy any data into your Salesforce org or write data from your in: Enterprise, Performance, org to the external system. and Unlimited Editions • Syncing is a one-time process. If the external system’s schema changes, the modifications Files Connect for aren’t automatically synced to your Salesforce org. To reflect the changes in the external cloud-based external data system, resync the objects. After resyncing, full field-level security to the external objects sources is available in: is granted to all users who have the same profile as the user who initiated the resync. Professional, Enterprise, • Each org can have up to 200 external objects. External objects don’t count toward the Performance, Unlimited, amount for custom objects. Syncing fails if it causes your org to exceed 200 external and Developer Editions objects. Federated Search is • For Salesforce Connect external data sources, make sure that you read and understand available in: Enterprise, the sync considerations. See Sync an External Data Source for Salesforce Connect on page Professional, Unlimited, 858. and Developer Editions
1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. USER PERMISSIONS
2. Click the name of the external data source. To create an external object 3. Click Validate and Sync, and confirm that the connection is successful. from an external data source: 4. Select tables and click Sync to do the following for each selected table. • Customize Application • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type.
Example: The resulting external data source detail page will include a list of related external objects like this.
930 Extend Salesforce with Clicks, Not Code Work with External Data Sources
SEE ALSO: Salesforce Connect
Define External Objects
Tables in external systems map to external objects in Salesforce, combining all your data and content EDITIONS for users in your org. External objects are similar to custom objects, except that they map to data that’s stored outside Available in: both Salesforce your Salesforce org. Each external object relies on an external data source definition to connect Classic (not available in all with the external system’s data. Each external object definition maps to a data table on the external orgs) and Lightning system. Each of the external object’s fields maps to a table column on the external system. External Experience objects enable your users and the Lightning Platform to search and interact with the external data. Salesforce Connect is Note: available in: Developer Edition and for an extra cost • Each org can have up to 200 external objects. External objects don’t count toward the in: Enterprise, Performance, amount for custom objects. and Unlimited Editions • If the external system allows it, we recommend that you sync the external data source to Files Connect for automatically create related external objects. You can instead choose to manually define cloud-based external data external objects to customize the external object names and manually create the custom sources is available in: fields. Professional, Enterprise, Performance, Unlimited, To create or modify an external object: and Developer Editions 1. From Setup, enter External Objects in the Quick Find box, then select External Objects. Federated Search is 2. Click New External Object, or click Edit to modify an existing external object. available in: Enterprise, Professional, Unlimited, 3. Enter the following: and Developer Editions
Field Description Label A user-friendly name for the external object. The label is displayed in USER PERMISSIONS the Salesforce user interface, such as in list views. To create or edit external We recommend that you make object labels unique across all objects: standard, custom, and external objects in the org. • Customize Application
Plural Label The plural name of the external object. If you create a tab for this object, this name is used for the tab.
Starts with If it’s appropriate for your org’s default language, select to precede vowel sound your label with “an” instead of “a” for any automated messages.
Object Name A unique identifier used to refer to this external object definition when using the API. Object names must be unique across all standard, custom, and external objects in the org. The Object Name field can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
931 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Field Description Description An optional description of the external object. A meaningful description helps you distinguish among your external objects when you view them in a list.
Context-Sensitive Defines what appears when users click Help for this Page from the external object record home Help Setting (overview) and detail pages, as well as list views and related lists. We recommend that you select Open a window using a Visualforce page to display custom help that you create for your users. See Object-Level Help in Salesforce Classic on page 94. If you instead keep the default value, your users only see Salesforce Help, which doesn’t provide any information about your external data. This setting doesn’t affect the Help & Training link at the top of each page, which always opens Salesforce Help.
Content Name Select the Visualforce page that best describes the data that’s provided by this external object. This field is available only when you select Open a window using a Visualforce page.
External Data Source The external data source definition that contains the connection details you want to use for this external object.
Table Name Table in the external system that the external object maps to. For SharePoint, the table name must match the related scope name.
Display URL Available only for Salesforce Connect. The external object’s Display URL standard field values Reference Field are automatically generated from the external system. For example, with the OData 2.0 adapter for Salesforce Connect, the value is based on the link href that’s defined on the OData producer. You can override the default values with the values of a custom field on the same external object. Select the field name, and make sure that the custom field’s values are valid URLs.
Allow Reports Available only for Salesforce Connect.
Deployment Status Indicates whether the external object is visible to other users.
Launch New Custom If selected, the custom tab wizard starts after you save the external object. Tab Wizard after saving this external object
Allow Search If search is also enabled on the external data source, selecting this option lets users find the external object’s records via SOSL and Salesforce global searches. By default, search is disabled for new external objects. However, you can validate and sync an external data source to automatically create external objects. Syncing always enables search on the external object when search is enabled on the external data source, and vice versa.
4. Click Save.
932 Extend Salesforce with Clicks, Not Code Work with External Data Sources
5. On the external object detail page, view and modify the external object’s custom fields and relationships, page layouts, field sets, search layouts, and buttons and links. • To create field mappings or add fields to an external object, click New on the Custom Fields & Relationships related list. • To assign different page layouts by user profile, click Page Layout Assignments.
Tip: After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results.
SEE ALSO: Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Set Up Salesforce Connect to Access External Data with a Custom Adapter Deployment Status for Custom Objects and External Objects
Validate External Object Connections
After you configure an external data source, run the validator tool on each external object to test EDITIONS and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results. Validator is available for external objects from Apex and Odata data sources. Available in: both Salesforce 1. From Setup, enter External Data Source in the Quick Find box, then select External Classic (not available in all Data Source. orgs) and Lightning Experience 2. Select the external data source that contains the external object you want to validate. 3. Next to the external object’s name, click Validate. Salesforce Connect is available in: Developer 4. Select each query type you want validator to run. Edition and for an extra cost 5. Click Run Queries. in: Enterprise, Performance, and Unlimited Editions The validator results are displayed. Queries that ran successfully are listed in the Passed Queries table. The Failed Queries table lists the unsuccessful queries with information to help with Files Connect for troubleshooting. Queries that weren’t run because a prerequisite query was unsuccessful are in the cloud-based external data sources is available in: Skipped Queries table. Professional, Enterprise, Performance, Unlimited, SEE ALSO: and Developer Editions Define External Objects Federated Search is available in: Enterprise, Professional, Unlimited, and Developer Editions
USER PERMISSIONS
To create or edit external objects: • Customize Application
933 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Grant Access to Authentication Settings for External Data Sources
For external data sources that use per-user authentication, grant users access through permission EDITIONS sets and profiles. Doing so lets users set up and manage their own authentication settings for accessing the external system. Available in: both Salesforce 1. From Setup, enter Permission Sets in the Quick Find box, then select Permission Sets Classic (not available in all or Profiles. orgs) and Lightning Experience 2. Click the name of the permission set or profile that you want to modify. 3. Do one of the following. Salesforce Connect is available in: Developer • For a permission set, or for a profile in the enhanced profile user interface, click External Edition and for an extra cost Data Source Access in the Apps section. Then click Edit. in: Enterprise, Performance, • For a profile in the original profile user interface, click Edit in the Enabled External Data and Unlimited Editions Source Access section. Files Connect for cloud-based external data 4. Add the data sources that you want to enable. sources is available in: 5. Click Save. Professional, Enterprise, Performance, Unlimited, and Developer Editions SEE ALSO: Federated Search is Store Authentication Settings for External Systems available in: Enterprise, Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Professional, Unlimited, Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter and Developer Editions Set Up Salesforce Connect to Access External Data with a Custom Adapter USER PERMISSIONS
To edit permission sets and user profiles: • Manage Profiles and Permission Sets
934 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Store Authentication Settings for External Systems
You or your administrator can set up and manage your authentication settings for external systems. EDITIONS With valid authentication settings, you can access external systems from within your Salesforce org.
Note: All credentials stored within the NamedCredential, ExternalDataSource, and Available in: both Salesforce ExternalDataUserAuth entities are encrypted under a framework that is consistent with other Classic and Lightning encryption frameworks on the platform. Salesforce encrypts your credentials by auto-creating Experience org-specific keys. Credentials encrypted using the previous encryption scheme were migrated Named credentials are to the new framework. available in: All Editions. Your administrator defines external systems in external data sources and named credentials. External Salesforce Connect is data sources specify how to access data or content that’s stored outside your Salesforce org. Named available in: Developer credentials specify callout endpoints, which receive Web service callouts from your org. Edition and for an extra cost in: Enterprise, Performance, Before you begin, your administrator: and Unlimited Editions. • Sets up the external data source or named credential to use per-user authentication. Files Connect for • Grants you access to the external data source or named credential. cloud-based external data • Verifies that your org can connect to the external system. sources is available in: Professional, Enterprise, • Tells you the authentication settings to enter. Performance, Unlimited, • Sets up the community, if applicable, by using the Salesforce Tabs + Visualforce template. and Developer Editions If the community is built with the Customer Service template, only your administrator can set up and manage your authentication settings for external systems. You can’t complete these steps on your own. USER PERMISSIONS
If you don’t see the expected settings or options, contact your administrator. To store authentication settings for an external data 1. Access your authentication settings for external systems in one of the following ways. source: From within a community: • The data source enabled under External • If you have a community license, click My Settings > Authentication Settings for External Data Source Access Systems. To store authentication • Otherwise, from your personal settings, enter Authentication, then select settings for a named Authentication Settings for External Systems credential: From Salesforce, go to your personal settings and enter Authentication in the Quick • The named credential enabled under Named Find box, then select Authentication Settings for External Systems. Credential Access 2. Click New or Edit. To edit another user’s authentication settings for 3. Complete the fields. external systems: • Manage Users Field Description External If you’re not sure which option to select, ask your administrator. System • External Data Source: Provides access to external objects, whose Definition data is stored outside your Salesforce organization. • Named Credential: Enables your actions to trigger authenticated callouts to the endpoint that’s specified in the named credential. A named credential can handle the authentication for an external data source. In this scenario, your administrator instructs you to select Named Credential in this field to access external objects.
935 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Field Description External Data Source Which field appears depends on what’s selected for External System Definition. or If you’re not sure which option to select, ask your administrator. Your administrator can change Named Credential the option labels to make them more relevant or easier to distinguish from each other.
User Available only to administrators. Select the user whose authentication settings you’re entering.
4. Select the authentication protocol that’s required by the external system. If you’re not sure which option to select, ask your administrator. • If you select Password Authentication, enter your username and password for the external system. • If you select OAuth 2.0, complete the following fields.
Field Description Authentication If you’re not sure which option to select, ask your administrator. Your administrator can change Provider the option labels to make them more relevant or easier to distinguish from each other.
Scope If you’re not sure what to enter, ask your administrator. Specifies the scope of permissions to request for the access token.
Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status.
5. Click Save.
SEE ALSO: Define External Data Sources Grant Access to Authentication Settings for External Data Sources Define a Named Credential Grant Access to Authentication Settings for Named Credentials Add Tabs to Your Salesforce Tabs + Visualforce Site Personalize Your Salesforce Experience
936 Extend Salesforce with Clicks, Not Code Work with External Data Sources
External Object Relationships
External objects support standard lookup relationships, which use the 18-character Salesforce record EDITIONS IDs to associate related records with each other. However, data that’s stored outside your Salesforce org often doesn’t contain those record IDs. Therefore, two special types of lookup relationships are Available in: both Salesforce available for external objects: external lookups and indirect lookups. Classic (not available in all External lookups and indirect lookups compare a specific field’s values on the parent object to the orgs) and Lightning relationship field’s values on the child object. When values match, the records are related to each Experience other. Salesforce Connect is To create an external object relationship, create a custom field on the child object with one of the available in: Developer following field types. If the child is an external object, you can instead change the field type of an Edition and for an extra cost existing custom field to one of the following. in: Enterprise, Performance, and Unlimited Editions • Lookup Relationship Files Connect for • External Lookup Relationship cloud-based external data • Indirect Lookup Relationship sources is available in: This table summarizes the types of relationships that are available to external objects. Professional, Enterprise, Performance, Unlimited, Note: Federated Search supports only external lookup relationships, and the Federated and Developer Editions Search external object is always the parent. Federated Search is available in: Enterprise, Relationship Allowed Child Allowed Parent Parent Field for Matching Professional, Unlimited, Objects Objects Records and Developer Editions Lookup Standard Standard The 18-character Salesforce Custom Custom record ID External
External lookup Standard External The External ID standard field Custom External
Indirect lookup External Standard You select a custom field with Custom the External ID and Unique attributes
Lookup Relationship Fields on External Objects Use a lookup relationship when the external data includes a column that identifies related Salesforce records by their 18-character IDs. External Lookup Relationship Fields on External Objects Use an external lookup relationship when the parent is an external object.
937 Extend Salesforce with Clicks, Not Code Work with External Data Sources
Indirect Lookup Relationship Fields on External Objects Use an indirect lookup relationship when the external data doesn’t include Salesforce record IDs.
SEE ALSO: Create Custom Fields Change the Custom Field Type Relationships on External Objects Include a Files Connect Data Source in Global Search Object Relationships Overview
Lookup Relationship Fields on External Objects
Use a lookup relationship when the external data includes a column that identifies related Salesforce EDITIONS records by their 18-character IDs. A lookup relationship field links a child standard, custom, or external object to a parent standard Available in: both Salesforce or custom object. A user who’s editing a child record can click the field’s lookup icon to select a Classic (not available in all specific parent record, and a user who’s viewing a parent record can view a related list of child orgs) and Lightning records. Experience When you create a lookup relationship field on an external object, enter the External Column Name Salesforce Connect is that contains the 18-character Salesforce IDs for identifying the parent records. available in: Developer Edition and for an extra cost Example: in: Enterprise, Performance, • Account record (parent standard object) displays a related list of external SAP sales orders and Unlimited Editions (child external object). Files Connect for • Account record (parent standard object) displays a related list of support cases (child cloud-based external data standard object). sources is available in: Professional, Enterprise, Performance, Unlimited, SEE ALSO: and Developer Editions External Object Relationships Federated Search is Create Custom Fields available in: Enterprise, Professional, Unlimited, Relationships on External Objects and Developer Editions Include a Files Connect Data Source in Global Search
938 Extend Salesforce with Clicks, Not Code Work with External Data Sources
External Lookup Relationship Fields on External Objects
Use an external lookup relationship when the parent is an external object. EDITIONS An external lookup relationship links a child standard, custom, or external object to a parent external object. Available in: both Salesforce Classic (not available in all The values of the standard External ID field on the parent external object are matched against the orgs) and Lightning values of the external lookup relationship field. For a child external object, the values of the external Experience lookup relationship field come from the specified External Column Name. When you sync two external system tables with a lookup relationship field, an external lookup Salesforce Connect is available in: Developer relationship for the mapped external objects is automatically created. This auto mapping happens Edition and for an extra cost only if in: Enterprise, Performance, • The parent and child objects are synced from the same data source. and Unlimited Editions • The parent object is already synced or the parent and child objects are in the same sync Files Connect for operation. cloud-based external data Creating an external lookup relationship on the external object for a lookup relationship on a table sources is available in: is supported by Cross Org, OData 4.0, and Custom Apex adapters. For the OData2.0 adapter, it’s Professional, Enterprise, supported only in the default Olingo library and not supported in OData4J. Performance, Unlimited, and Developer Editions Example: Federated Search is • External product catalog item (parent external object) displays a related list of support available in: Enterprise, cases (child standard object). Professional, Unlimited, and Developer Editions • External customer (parent external object) displays a related list of external orders (child external object).
Example: For the cross-org adapter for Salesforce Connect, suppose that you store contacts and accounts in the provider org. From the subscriber org, you want to view each account’s related contacts. To do so, create an external lookup field on the subscriber org’s Contact external object. Link that external lookup field to the subscriber org’s Account external object. Then set up the page layouts for the Account external object to include a related list that displays the related Contact external object records.
Example: In this screenshot, a record detail page for the Business_Partner external object includes two related lists of child objects. This example shows how external lookup relationships and page layouts enable users to view related data from within and from outside their Salesforce org on a single page. • Account standard object (1) • Sales_Order external object (2)
939 Extend Salesforce with Clicks, Not Code Work with External Data Sources
SEE ALSO: External Object Relationships Create Custom Fields Change the Custom Field Type Relationships on External Objects Include a Files Connect Data Source in Global Search
940 Extend Salesforce with Clicks, Not Code Sync Data Between Salesforce and Heroku
Indirect Lookup Relationship Fields on External Objects
Use an indirect lookup relationship when the external data doesn’t include Salesforce record IDs. EDITIONS An indirect lookup relationship links a child external object to a parent standard or custom object. When you create an indirect lookup relationship field on an external object, you specify the parent Available in: both Salesforce object field and the child object field to match against each other. Classic (not available in all orgs) and Lightning Specifically, you select a custom unique, external ID field on the parent object to match against the Experience child’s indirect lookup relationship field, whose values are determined by the specified External Column Name. Salesforce Connect is available in: Developer If the external system uses case-sensitive values in the specified External Column Name, make sure Edition and for an extra cost that the parent object field is also case-sensitive. When you define the parent object’s custom field, in: Enterprise, Performance, select External ID, Unique, and Treat "ABC" and "abc" as different values (case sensitive). and Unlimited Editions Note: Only objects that have a custom field with the External ID and Unique Files Connect for attributes are available as parent objects in indirect lookup relationships. If you don't see the cloud-based external data desired object when you create an indirect lookup relationship field, add a custom unique, sources is available in: external ID field to that object. Professional, Enterprise, Performance, Unlimited, Example: and Developer Editions • Account record (parent standard object) displays a related list of SAP sales orders (child Federated Search is external object) with matching customer IDs that aren’t Salesforce IDs. available in: Enterprise, • Contact record (parent standard object) displays a related list of social media posts (child Professional, Unlimited, external object) with matching social media handles. and Developer Editions
SEE ALSO: External Object Relationships Create Custom Fields Change the Custom Field Type Relationships on External Objects Include a Files Connect Data Source in Global Search
Sync Data Between Salesforce and Heroku
Heroku Connect lets you sync data between Salesforce and Heroku Postgres. EDITIONS Using Heroku Connect with Heroku Postgres, you can build Heroku apps that interact with your Salesforce data using your favorite language, like Ruby, Node.js, Python, PHP, Java, Scala or Clojure Available in: Salesforce or web framework like Rails, Django, or Play. For more information, refer to the Heroku Connect Classic website and the Heroku Connect documentation on the Heroku Dev Center website. Available for: Developer, Enterprise, Performance, Organization Sync and Unlimited Editions This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable.
941 Extend Salesforce with Clicks, Not Code Build Your Own Salesforce App
Managing Organization Sync This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable. Actions in the Organization Sync Record Queue This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable.
Managing Organization Sync This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable.
Actions in the Organization Sync Record Queue This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable.
Build Your Own Salesforce App
An app is a collection of items that work together to serve a particular function. Salesforce apps EDITIONS come in two flavors: Classic and Lightning. Classic apps are created and managed in Salesforce Classic. Lightning apps are created and managed in Lightning Experience. You can customize both Available in: Salesforce types of app to match the way your users work. Classic (not available in all Classic apps are a collection of standard and custom tabs, including: orgs), Lightning Experience, and the Salesforce mobile • Most standard objects, including Home, the main Chatter feed, Groups, and People app • Your org’s custom objects Available in: Contact • Visualforce tabs Manager, Group, • Lightning component tabs Professional, Enterprise, • Canvas apps via Visualforce tabs Performance, Unlimited, and Developer Editions • Web tabs Lightning apps are a collection of items that include everything from the Classic apps list, plus Lightning page tabs, and utilities like Sales Dialer. In Lightning apps, you can customize the app’s USER PERMISSIONS logo and enhance its branding by customizing the color of the navigation bar. To view apps: You can also upgrade Classic apps to Lightning apps in Lightning Experience, but the two versions • View Setup and of the app must then be managed separately in their own environments. Configuration Salesforce provides standard apps such as Sales and Service. To manage apps: • Customize Application You can also build your own on-demand apps by grouping items into new custom apps. A custom app consists of a label, a description, and an ordered list of items, which often includes tabs. You can also add custom logos and branding to your custom apps. In Salesforce Classic, custom apps are listed in the Lightning Platform app menu, which is a dropdown list displayed at the top of every page.
942 Extend Salesforce with Clicks, Not Code Build Your Own Salesforce App
In Lightning Experience and the Salesforce mobile app, you can find your available custom apps in the App Launcher ( ). In Lightning Experience, to see all your available Salesforce apps and items, click View All.
When you choose an app, your screen changes to reflect the contents of that app. For example, if you switch from an app that contains Opportunities to another app that doesn’t, the Opportunities item disappears. In addition, the app might display a different default landing tab when selected. Apps are associated with profiles. Profiles control which tabs you can see or hide, as well as which apps are available to you.
943 Extend Salesforce with Clicks, Not Code App Tools
App Tools What is a Subtab App? An app is a group of tabs that work as a unit to provide application functionality. Similarly, a subtab app is a collection of tabs that appears on the Chatter profile page. A subtab app can include both default and custom tabs. Lightning Platform Home Page The Lightning Platform Home page contains options for building and managing applications. Configuring System Overview Messages
SEE ALSO: Create Custom Apps for Salesforce Classic Set the Default Sort Order for Apps Salesforce App Considerations
App Tools
The platform includes innovative point-and-click app-building tools that give you the power to EDITIONS customize Salesforce to meet the needs of your business. You can also build your own apps to share and store information that is important to you. You don’t need any programming knowledge to Available in: Salesforce use these tools. You can find them in Salesforce Classic Setup by selecting Create, and in Lightning Classic (not available in all Experience Setup by entering App in the Quick Find box to get started. orgs) and Lightning The platform also includes app building tools that require some programming knowledge. You can Experience find tools that require advanced programming knowledge in Salesforce Classic Setup by selecting Available in: Contact Develop, and in Lightning Experience Setup by entering Custom Code in the Quick Find Manager, Group, box. Professional, Enterprise, Performance, Unlimited, Create Apps in Salesforce Classic with App Quick Start Developer, and Database.com Editions App quick start is a fast way to create a basic Classic app in just one step. App Quick Start: Next Steps for Building and Managing Apps in Salesforce Classic After you've created a basic working app with app quick start in Salesforce Classic, build out the app with more objects and fields, define its access settings, and add users to share your app with them. Create Custom Apps for Salesforce Classic Create custom apps to give your Salesforce Classic users access to everything they need all in one place. Lightning Apps With apps in Lightning Experience, members of your org can work more efficiently by easily switching between apps. Users can open apps you’ve created from the App Launcher. What’s most important to sales reps? Accounts, events, and organizations. How about sales managers? Reports and dashboards make the top of the list. Lightning apps take things to another level past Classic apps by letting you brand your apps with a custom color, logo, and utility bar. Tips for Creating Apps in Lightning Experience It’s time for the fun part: deciding how to set up Lightning apps for your users. Here are some tips for planning Lightning apps for your org.
944 Extend Salesforce with Clicks, Not Code App Tools
Create Lightning Apps As in Salesforce Classic, you can create apps in Lightning Experience, but with even more bells and whistles. You can brand and customize Lightning apps to help your users work more efficiently. For example, you can create a Lightning app for your finance department that includes all important items (including tabs) that users need to complete common tasks. You can customize the navigation bar color, brand it with a logo, and make the app available in the App Launcher for the user profiles associated with the finance department. Customize Lightning Apps with the Lightning App Builder When you edit a Lightning app from the App Manager in Setup, you’re brought into the Lightning App Builder to manage the app’s settings. Update app branding, navigation, and other options, and manage the Lightning pages assigned to that app all in one place. Add a Utility Bar to Lightning Apps The utility bar is a specialized type of Lightning page that gives your users quick access to common productivity tools, like Notes and Recent Items. It appears as a fixed footer that users can access to open utilities in docked panels. Some utilities support pop-out, which lets them open in a new browser window. Lightning App Navigation Bar Items Most of the items that appear in the App Launcher can appear in a Lightning app navigation bar. To add items to an app’s navigation bar, you can use the Lightning app creation wizard, which lets you choose from a list of available items. Upgrade Classic Apps to Lightning Apps You can upgrade a Classic app to a Lightning app in Lightning Experience, enhancing it for your Lightning Experience users with a customized color, logo, utility bar, and more items like Lightning pages supported in the navigation bar. Salesforce App Considerations Keep these considerations in mind when working with apps in either Lightning Experience or Salesforce Classic.
Create Apps in Salesforce Classic with App Quick Start
App quick start is a fast way to create a basic Classic app in just one step. EDITIONS 1. From Setup, enter Apps in the Quick Find box, then select Apps, and click Quick Start. Alternatively, from the Lightning Platform Home page, click Add App under Getting Started, Available in: Salesforce or App Quick Start under Quick Links. Classic (not available in all orgs), Lightning Experience, 2. Enter the information needed for your app. and the Salesforce mobile app Field Name Description Available in: Contact App Label The app's name that appears in the Lightning Manager, Group, Platform app menu. The label can have a Professional, Enterprise, maximum of 40 characters, including spaces. Performance, Unlimited, Plural Label The plural name of the object. This name and Developer Editions appears on the tab. USER PERMISSIONS Singular Label A name used to refer to the object in any user interface pages. To create apps: Gender If it's appropriate for your org’s default • Customize Application language, specify the gender of the label. This AND field appears if the org-wide default language Manage Profiles and expects gender. Permission Sets
945 Extend Salesforce with Clicks, Not Code App Tools
Field Name Description Starts with a vowel sound If it's appropriate for your org’s default language, enable this option if your label should be preceded by “an” instead of “a”.
3. Click Create. 4. On the You’re All Set! page, click here to add new fields to your app. 5. To see your app as it will appear to users, click Go To My App. The app quick start: • Generates an app label and API name (a unique name that's used to refer to the object when using the Lightning Platform API). • Generates an object label and API name. • Generates a tab label, and associates the tab with the object. • Enables feed tracking for the object. Feed tracking lets people follow records of that object type and see Chatter feed updates. • Enables access to the app and tab in your user profile. Any users who have the “Modify All Data” permission can also access the object. • Generates a permission set that grants access to the new custom object. • Assigns the permission set to the user who creates the app.
Note: If you’re in a custom app, only the tabs included in the app appear and include the Create button.
After you've created an app, you can extend it with more components, specify access settings, and add users to your org.
SEE ALSO: App Quick Start: Next Steps for Building and Managing Apps in Salesforce Classic Salesforce App Considerations
946 Extend Salesforce with Clicks, Not Code App Tools
App Quick Start: Next Steps for Building and Managing Apps in Salesforce Classic
After you've created a basic working app with app quick start in Salesforce Classic, build out the EDITIONS app with more objects and fields, define its access settings, and add users to share your app with them. Available in: Salesforce 1. Build out your app with the basic components used in apps. Classic (not available in all orgs), Lightning Experience, • Create objects, which are custom database tables that allow you to store information specific and the Salesforce mobile to your app. app • Create tabs that are associated with the objects you've created. Available in: Contact • For each object, create fields to store the information that's important to your organization. Manager, Group, • Create validation rules, which verify that the data users enter meets the standards you Professional, Enterprise, specify before they save a record. Performance, Unlimited, For quick shortcuts to these tools, use the Lightning Platform quick access menu, which is and Developer Editions available from object list view pages and record detail pages. USER PERMISSIONS 2. Create user profiles or permission sets. These are collections of settings and permissions that determine what users can do in an app. To create objects, tabs, 3. Specify the types of access that users will have to the app. fields, and validation rules: • Customize Application a. Make your app visible using profiles or permission sets. To create users: b. Make your object tabs visible. • Manage Internal Users c. Set the object permissions for the objects you created. To create profiles and permission sets: 4. Add users to your organization. When adding users, be sure to assign them the appropriate • Manage Profiles and profiles or permission sets you created so they can access your app. Permission Sets
SEE ALSO: Create Apps in Salesforce Classic with App Quick Start Salesforce App Considerations
947 Extend Salesforce with Clicks, Not Code App Tools
Create Custom Apps for Salesforce Classic
Create custom apps to give your Salesforce Classic users access to everything they need all in one EDITIONS place. If you're new to custom apps, we recommend using Lightning Platform quick start to create an Available in: Salesforce app. With this tool, you can generate a basic working app in just one step. Classic (not available in all orgs), Lightning Experience, If you’ve already created the objects, tabs, and fields you need for your app, follow these steps. With and the Salesforce mobile this option, you create an app label and logo, add items to the app, and assign the app to profiles. app 1. From Setup, enter Apps in the Quick Find box, then select Apps. Available in: Contact 2. Click New. Manager, Group, 3. If the Salesforce console is available, select whether you want to define a custom app or a Professional, Enterprise, Salesforce console. Performance, Unlimited, and Developer Editions 4. Give the app a name and description. An app name can have a maximum of 40 characters, including spaces. USER PERMISSIONS 5. Optionally, brand your app by giving it a custom logo. 6. Select which items to include in the app. To view apps: • View Setup and 7. Optionally, set the default landing tab for your new app using the Default Landing Tab Configuration drop-down menu below the list of selected tabs. This determines the first tab a user sees when logging into this app. To manage apps: • Customize Application 8. Choose which profiles the app will be visible to. 9. Check the Default box to set the app as that profile’s default app, meaning that new users with the profile see this app the first time they log in. Profiles with limits are excluded from this list. 10. Click Save.
SEE ALSO: Build Your Own Salesforce App Salesforce App Considerations
Lightning Apps
With apps in Lightning Experience, members of your org can work more efficiently by easily switching EDITIONS between apps. Users can open apps you’ve created from the App Launcher. What’s most important to sales reps? Accounts, events, and organizations. How about sales managers? Reports and Available in: Lightning dashboards make the top of the list. Lightning apps take things to another level past Classic apps Experience by letting you brand your apps with a custom color, logo, and utility bar. Available in: Contact Lightning apps contain everything you expect from a custom app, such as custom and standard Manager, Group, objects, and custom tabs. But Lightning apps can also include Lightning page tabs and utilities like Professional, Enterprise, Lightning Voice. The navigation model of Lightning apps is optimized for efficiency, with actions Performance, Unlimited, on certain items like Opportunities in the navigation bar. You can even append navigation items and Developer Editions to a Lightning app that you found on AppExchange and installed from a managed package. Custom apps from Salesforce Classic automatically work in Lightning Experience and can be upgraded to Lightning apps. Classic apps appear in the list of apps in Setup alongside your Lightning apps, and are available from the App Launcher as long as their Show in Lightning Experience attribute is enabled.
948 Extend Salesforce with Clicks, Not Code App Tools
However, the reverse isn’t true for Lightning apps. Lightning apps aren’t available in Salesforce Classic. You can assign multiple user profiles to multiple apps. Also, you can assign as many user profiles to one app as you need to. For instance, you have several groups involved with inside sales. Assign all the groups to your inside sales app, and they all have access to it. To switch between apps, users can use the App Launcher. This makes it easy for users to switch contexts and still have access to the items, objects, and pages they need most. You can view all the apps in your org from the App Manager. In Lightning Experience Setup, enter App in the Quick Find box, then select App Manager.
SEE ALSO: Create Lightning Apps Upgrade Classic Apps to Lightning Apps Salesforce App Considerations
Tips for Creating Apps in Lightning Experience
It’s time for the fun part: deciding how to set up Lightning apps for your users. Here are some tips EDITIONS for planning Lightning apps for your org. The best time to create Lightning apps is when you’re rolling out Lightning Experience. So make Available in: Lightning creating Lightning apps a part of your rollout strategy. Check out the Trailhead module “Lightning Experience Experience Rollout” for many great ideas to help you make a smooth transition. Available in: Enterprise, Talk to your users. Ask them what their priorities are. Customizing tabs in apps gives you a unique Professional, Performance, opportunity to engage with your users. Each group of users has its own priorities. Find out which Unlimited, and Developer objects and items represent their highest priorities. Editions • Ask users to post feedback to a Chatter group. • Publish polls. • Schedule lunch sessions. Everyone likes a free lunch, and nearly everybody is happy to express their opinion. Create a master list of objects that everyone in your org wants. Then trim down the list for each group—sales reps, sales managers, execs, and so on. The menus for every user group share some common objects, like Home, Tasks, and Feed. Keep the high-priority items for each group at the top. Put low-priority items at the bottom, or remove them altogether. Users can always go to the App Launcher to get the items they use less often.
949 Extend Salesforce with Clicks, Not Code App Tools
Create Lightning Apps
As in Salesforce Classic, you can create apps in Lightning Experience, but with even more bells and EDITIONS whistles. You can brand and customize Lightning apps to help your users work more efficiently. For example, you can create a Lightning app for your finance department that includes all important Available in: Lightning items (including tabs) that users need to complete common tasks. You can customize the navigation Experience bar color, brand it with a logo, and make the app available in the App Launcher for the user profiles associated with the finance department. Available in: Contact Manager, Group, App 1. From the Home tab in Setup, enter in the Quick Find box, then select App Manager. Professional, Enterprise, 2. Click New Lightning App, and walk through the New Lightning App wizard. Performance, Unlimited, Here are some things you can do in the wizard: and Developer Editions • Give your app a name, set its primary color, and give it a logo. USER PERMISSIONS The app description displays alongside the icon in the App Launcher. Make sure that the description is meaningful to your users. To view apps: • View Setup and • Choose whether to override a custom theme’s brand image and navigation bar color with Configuration the brand image and color from the app. To manage apps: • Choose which type of navigation to use—standard or console. • Customize Application • Choose which form factors your app is available for. • Add a utility bar for common processes and tools, like Recent Items, Notes, Dialer, and Open CTI. • Customize which items appear in the app’s navigation bar.
Note: If you add more than 50 default navigation items to an app, your users can’t personalize the app’s navigation bar.
When organizing the navigation bar, the item at the top of the list becomes your app’s landing page on both desktop and mobile. The order of items in the navigation bar also determines the default objects shown in the Top Results page on the search results page. After the user interacts with the app for 15 days, Top Results reflects the user's most frequently used objects. If the user doesn’t have access or permissions to the app, Top Results includes the Account, Contact, Opportunity, Case, Lead, People (User), and Group objects until the user’s most frequently used objects are determined.
• Assign the app to user profiles.
SEE ALSO: Lightning Apps Create and Edit a Custom Lightning Console App Add a Utility Bar to Lightning Apps Salesforce App Considerations
950 Extend Salesforce with Clicks, Not Code App Tools
Customize Lightning Apps with the Lightning App Builder
When you edit a Lightning app from the App Manager in Setup, you’re brought into the Lightning EDITIONS App Builder to manage the app’s settings. Update app branding, navigation, and other options, and manage the Lightning pages assigned to that app all in one place. Lightning App Builder is 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager available in: both Salesforce Classic and Lightning 2. Click on a Lightning app’s row, and select Edit. Experience Here are some things you can do from the App Settings tab. Lightning apps are available • Change your app’s name, primary color, and logo. in: Lightning Experience • Override the org theme with your app’s brand image and nav bar color. Available in: Group, • Add a utility bar for common processes and tools, like Recent Items, Notes, Dialer, and Open Professional, Enterprise, CTI. Performance, Unlimited, • Manage which default items appear in the app’s navigation bar. and Developer Editions • Manage user profile assignments. On the Navigation Items tab, you can control which objects and other items—like Visualforce USER PERMISSIONS pages or Lightning components—are included in your app. To create a custom object by To manage apps, and to importing data from a spreadsheet, click Create at the top of the Available Items section. create and save Lightning 3. Click the Pages tab in the Lightning App Builder header to see all the active Lightning pages pages in the Lightning App Builder: assigned to the app, create pages, and open existing pages, even ones not associated with the • Customize Application app. To view apps, and to view Tip: If you create pages for your app, when finished, don’t forget to click Activation to Lightning pages in the make them active for your users and assign them to the app. Lightning App Builder: • View Setup and Configuration SEE ALSO: Lightning Apps Create Lightning Apps Lightning App Builder
951 Extend Salesforce with Clicks, Not Code App Tools
Add a Utility Bar to Lightning Apps
The utility bar is a specialized type of Lightning page that gives your users quick access to common EDITIONS productivity tools, like Notes and Recent Items. It appears as a fixed footer that users can access to open utilities in docked panels. Some utilities support pop-out, which lets them open in a new Available in: Lightning browser window. Experience Utilities harness the power of Lightning components. When you set up a utility bar, you select which Available in: Contact Lightning components to use as utilities. However, not all Lightning components can be utilities. Manager, Group, To be added to a utility bar, a Lightning component must implement the Professional, Enterprise, flexipage:availableForAllPageTypes interface. This interface also makes the Performance, Unlimited, component usable on all types of Lightning pages. To add a Lightning web component to the and Developer Editions utility bar, see Lightning Web Components Developer Guide: Configure a Component for the Utility Bar.
To create a background utility item, implement the lightning:backgroundUtilityItem USER PERMISSIONS interface. Background utility items are added the same way as normal utility items, but don’t appear in the utility bar. The icon appears next to background utility items on the utility item list. If you To view apps: have only background utility items in your utility bar, the utility bar doesn’t appear in your app. You • View Setup and need at least one non-background utility item in your utility bar for it to appear. Configuration You can add or edit a utility bar at any time. To manage apps: • Customize Application 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager. 2. To edit or add a utility bar to an existing app, click Edit in the dropdown menu next to your app. To create a Lightning app with a utility bar, click New Lightning App. 3. Click the Utility Items tab and add the utilities you want. Specify component and utility properties, like the height and width of the utility panel, and what label and icon to display in the utility bar. Some utilities have properties that can’t be changed.
Tip: A Lightning page region can contain up to 100 components. We recommend adding no more than 10 utilities, and that you keep the utility labels short and sweet. You want your users to quickly find the tools and processes they need most.
Example: Here’s a utility bar with the Recent Items and Notes utilities.
When creating a utility bar for your app, keep these things in mind:
952 Extend Salesforce with Clicks, Not Code App Tools
• Utility bars created using the Lightning App Wizard or in the Lightning App Builder can be assigned to only one Lightning app. However, utility bars created using the API can be assigned to multiple Lightning apps. • The utility bar doesn’t support Visualforce pages or components. • The utility bar doesn’t fully support the Chatter Publisher and Feed components. • The History utility works in Lightning console apps only. • The Omni-Channel utility works in the Lightning Service Console app only. • The default utility bar alignment matches the user’s language setting alignment. For example, English is read left to right. If you select Default and a user’s language is set to English, the utility bar appears at the bottom of the left side of the screen. If you select Mirrored, the utility bar appears at the bottom of the right side of the screen.
Using Pop-Out Utilities Utilities that support pop-out can be “popped out” of the utility bar and into their own separate child windows. To pop a utility out, click the icon. From there, you can pop the utility back into the utility bar with the icon, or close the utility. Pop-out utilities are the Lightning equivalent to multi-monitor components in Classic.
SEE ALSO: Customize Your Lightning Console App with Utilities Create Lightning Apps Salesforce Console Developer Guide: Using Background Utility Items Salesforce Console Developer Guide: Using Pop-Out Utilities
Using Pop-Out Utilities Utilities that support pop-out can be “popped out” of the utility bar and into their own separate child windows. To pop a utility out, click the icon. From there, you can pop the utility back into the utility bar with the icon, or close the utility. Pop-out utilities are the Lightning equivalent to multi-monitor components in Classic.
Note: Popping-out docked utility bar items isn't supported in Lightning Experience on iPad Safari.
Standard Utilities Pop-out is supported for these standard utilities. Standard utilities are utilities that are included with Salesforce. • Open CTI Softphone • History • Rich Text • Report Chart • Visualforce • Flow • List View • Recent Items • Chatter Feed • Chatter Publisher • Notes
953 Extend Salesforce with Clicks, Not Code App Tools
Custom Utilities Pop-out is available for custom utilities. To enable pop-out for custom utilities, activate the Utility Bar: Enable Pop-Out for Custom Utilities critical update. The critical update enables pop-out for all utilities in the “Custom” and “Custom – Managed” categories. Test your custom utilities in a sandbox environment before you enable the update.
Disabling Pop-Out If you don’t want your custom utility to be popped out, you can disable pop-out in two ways. Disabling Pop-Out within the Component Use the lightning:utilityItem interface in your component and set the supportsPopOut attribute to false to disable pop-out.
Disabling pop-out within the component itself is a useful and simple way to ensure that the component can never be popped out. Disabling Pop-Out with the Lightning Console JavaScript API Use the disableUtilityPopOut() method and set the disabled argument to true to disable utility pop-out. If you’re migrating from a Classic console app and using a Visualforce page for your utility, we automatically respect if setCustomConsoleComponentPopoutable is set to false. Disabling pop-out with the Lightning Console JavaScript API allows you to enable and disable pop-out in real time.
Lightning App Navigation Bar Items
Most of the items that appear in the App Launcher can appear in a Lightning app navigation bar. EDITIONS To add items to an app’s navigation bar, you can use the Lightning app creation wizard, which lets you choose from a list of available items. Available in: Lightning The list of available items contains only those items in your org that are eligible for Lightning app Experience navigation bars, which includes: Available in: Enterprise, • Most standard objects, including Home, the main Chatter feed, Groups, and People Professional, Performance, • Your org’s custom objects and apps Unlimited, and Developer Editions • Visualforce tabs • Lightning component tabs USER PERMISSIONS • Lightning page tabs • Canvas apps via Visualforce tabs To view navigation menus: • Web tabs • View Setup and Configuration If the Lightning app was installed from a managed package, you can append navigation items To create navigation menus: below the original set of navigation items included in the Lightning app, which are locked. • Customize Application Note: You can’t add Connected apps like Gmail™ and Microsoft® Office 365™ to the navigation bar. Users can continue to access them from the App Launcher.
954 Extend Salesforce with Clicks, Not Code App Tools
Upgrade Classic Apps to Lightning Apps
You can upgrade a Classic app to a Lightning app in Lightning Experience, enhancing it for your EDITIONS Lightning Experience users with a customized color, logo, utility bar, and more items like Lightning pages supported in the navigation bar. Available in: Lightning Note: You can’t upgrade a Salesforce Classic console app to Lightning Experience. You can Experience choose to display or hide the app in the Lightning Experience App Launcher, but you can’t Available in: Contact edit the app from the App Manager page in Lightning Experience Setup. To get started in Manager, Group, Lightning Experience, customize these Salesforce-provided Lightning console apps: Service Professional, Enterprise, Console and Sales Console. You can also recreate your Salesforce Classic console app in Performance, Unlimited, Lightning Experience, but using the Salesforce out-of-the-box app is faster and easier. and Developer Editions 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager. 2. Find the Classic app that you want to upgrade in the apps list. USER PERMISSIONS
Note: A checkmark in the Visible in Lightning Experience column means that the app To view apps: is accessible in Lightning Experience via the App Launcher and is fully functional. Even • View Setup and though a Classic app works in Lightning Experience, it doesn’t take advantage of all the Configuration benefits of being a Lightning app. That’s why we recommend that you upgrade it. To manage apps: • Customize Application 3. Click , and select Upgrade. 4. Review the app properties and update them if necessary. If you have custom Lightning Home pages assigned to profiles in your org, and the app you’re upgrading is visible in Lightning Experience, you see a checkbox that lets you apply those Home page profile assignments to the upgraded app. Selecting the checkbox ensures that users see the custom Home page assigned to their profile when they're working in the upgraded app, and that you can modify those Home page assignments if you need to.
5. Click Upgrade. Your Classic app is copied and upgraded for Lightning Experience. You now have two versions of the app: a Classic version, and a Lightning version. After you upgrade it, the Classic app is no longer accessible in Lightning Experience via the App Launcher. You still see the Classic app in the apps list, but with the Visible in Lightning column deselected. The two versions of your app now must be managed separately. Future changes you make to the Classic app won’t be reflected in the Lightning version of the app, and vice versa.
Note: You can toggle the availability of your Classic apps in Lightning Experience by selecting or deselecting Show in Lightning Experience on the Classic app’s detail page.
SEE ALSO: Lightning Apps Salesforce App Considerations
955 Extend Salesforce with Clicks, Not Code App Tools
Salesforce App Considerations
Keep these considerations in mind when working with apps in either Lightning Experience or EDITIONS Salesforce Classic. Available in: Salesforce General Classic (not available in all orgs), Lightning Experience, • You can delete custom apps, but not standard apps. Deleting a custom app removes it from and the Salesforce mobile the apps menu and the App Launcher, but doesn’t delete any associated objects. If you created app objects for an app, consider deleting them as well. Available in: Contact • Salesforce Classic console apps are custom apps. Manager, Group, • You can’t change an app’s type—such as standard to connected or vice versa—after you create Professional, Enterprise, it. Performance, Unlimited, • For Salesforce Platform and Salesforce Platform One license users, the Platform standard app and Developer Editions is the only app listed in the Lightning Platform app menu and the Lightning Experience App Launcher. For details about specifying a unique label for the Platform standard app in Salesforce Classic, see Create Custom Apps for Salesforce Classic on page 948. • To assign apps to user profiles in Professional Edition, you must have user profiles enabled for your org.
Classic Apps Consider these requirements when choosing a custom app logo for a Classic app from the document library: • The image must be in GIF or JPEG format and less than 20 KB. • If the image is larger than 300 pixels wide by 55 pixels high, then it is scaled to fit. • For the best on-screen display, we recommend that you use an image with a transparent background. • The Externally Available checkbox must be selected on the document’s properties so that users can view the image.
Lightning Apps • The number of Lightning Apps you can create in an org varies by edition.
Edition Lightning Apps Limit Professional Edition 10
Enterprise Edition 25
Unlimited Edition Unlimited
• A Lightning app’s description displays in the App Launcher, so we recommend that you keep the description concise. • Users can’t remove the items you include in the navigation bar, and they can’t personalize the navigation bar when it contains more than 50 items. For example, if you include 32 items in an app’s navigation bar, users can add 18 more personal items. • Consider these requirements when choosing a custom app image for apps in Lightning Experience: – App images represent your app in both Lightning Experience and the Salesforce app. – Choose a JPG, PNG, BMP, or GIF image that's smaller than 5 MB. – For best results, upload an image that's 128 by 128 pixels. Images larger than the maximum display of 128 by 128 pixels are automatically resized.
956 Extend Salesforce with Clicks, Not Code What is a Subtab App?
• Even if you haven’t selected the option to override themes in the App Manager, your app’s brand image and color always override the Lightning Lite and Lightning Blue themes. • If you restrict an app to one type of device, only users viewing the app on that device can access it. For example, if you assign your app to the Phone form factor, your desktop users don’t see the app in the App Launcher. Only your Salesforce mobile app users can see it. • Not all objects that appear in the App Launcher can appear in an app, but it’s easy to figure out which ones can. When you start the wizard from the Lightning Experience App Manager, you see all available items for a navigation bar. • Navigation items in a Lightning app installed from a managed package are locked. You can’t remove or reorder them. However, you can append other navigation items so that they’re accessible in the Lightning app. • You can create records and access recent records and lists for certain items directly from the navigation bar. Items with next to their name support this feature, with a few exceptions. Tasks and Notes allow you to create a record but you can't access recent records or lists. Reports and Dashboards allow you to see recent records but you can't see recent lists or create a record. • Some tabs, such as web tabs and Visualforce tabs, aren't highlighted when you select them on the navigation bar. For example, when you select Contacts, the tab is highlighted (1). However, when you select a web tab, the page displays but the tab isn’t highlighted (2).
What is a Subtab App?
An app is a group of tabs that work as a unit to provide application functionality. Similarly, a subtab EDITIONS app is a collection of tabs that appears on the Chatter profile page. A subtab app can include both default and custom tabs. Available in: both Salesforce Users can see different sets of tabs on the profile page depending on their context. Subtab apps Classic (not available in all are the various sets of tabs available on specific pages, such as users’ profile pages. orgs) and Lightning Experience These default subtab apps determine which tabs display, depending on the user’s context. Available in: Contact Subtab App Displayed to the user when viewing... Manager, Group, Professional, Enterprise, Profile (Others) Another user inside their internal organization Performance, Unlimited, Profile (Self) Their own profile inside their internal and Developer Editions organization
Profile in Communities (Others) Another user while inside a community. It’s shown only if Communities is enabled.
Profile in Communities (Self) Their own profile inside a community. It’s shown only if Communities is enabled.
957 Extend Salesforce with Clicks, Not Code What is a Subtab App?
Note: End users can’t customize the display of subtab apps. Administrators can hide tabs within subtab apps using the Tab Hidden option in Tab Settings. Users can see tabs set to Default Off and Default On.
Managing Subtab Apps You can view and customize the subtab apps on users’ profile pages. Controlling Subtab App Visibility Once you have configured subtab apps, you can specify which users can see specific tabs on the profile page.
Managing Subtab Apps
You can view and customize the subtab apps on users’ profile pages. EDITIONS From Setup, enter Apps in the Quick Find box, then select Apps to display your organization’s subtab apps. Available in: Salesforce Classic (not available in all You can do the following: orgs), Lightning Experience, • To view details for a subtab app, click the name in the Subtab Apps section. This displays its and the Salesforce mobile properties, such as which tabs are part of the app, including any tabs that are not yet deployed. app Click custom tabs in the Included Tabs list to view details. Available in: Contact • To change the properties of a subtab app, click Edit to choose the tabs to include in the subtab Manager, Group, app, change their display order, and set the Default Landing Tab. Professional, Enterprise, Performance, Unlimited, Note: Administrators can change permission sets or profile settings to limit users’ access and Developer Editions to each tab. This allows administrators to make specific tabs available to some users, but not to others. USER PERMISSIONS
SEE ALSO: To view apps: What is a Subtab App? • View Setup and Configuration Controlling Subtab App Visibility To manage apps: • Customize Application
958 Extend Salesforce with Clicks, Not Code Lightning Platform Home Page
Controlling Subtab App Visibility
Once you have configured subtab apps, you can specify which users can see specific tabs on the EDITIONS profile page. To control the visibility of tabs within a subtab app: Available in: Salesforce Classic (not available in all 1. From Setup, enter Profiles in the Quick Find box, then select Profiles. orgs), Lightning Experience, 2. Do one of the following: and the Salesforce mobile • Original profile user interface—Click Edit next to the profile you want to modify and scroll app to the Tab Settings section. Available in: Contact • Enhanced profile user interface—Click the profile you want to modify and click Object Manager, Group, Settings. Click the object you want to modify and click Edit. Professional, Enterprise, Performance, Unlimited, Note: Some profiles, including Chatter External and Chatter Free users, don’t have the and Developer Editions permissions needed to view subtab apps.
3. Change the tab settings. USER PERMISSIONS End users can’t customize the display of subtab apps. Administrators can hide tabs within subtab To view apps: apps using the Tab Hidden option in Tab Settings. Users can see tabs set to Default • View Setup and Off and Default On. Configuration 4. (Original profile user interface only) To reset users’ tab customizations to the tab visibility settings To manage apps: that you specify, select Overwrite users’ personal tab customizations. • Customize Application 5. Click Save.
SEE ALSO: What is a Subtab App? Managing Subtab Apps
Lightning Platform Home Page
The Lightning Platform Home page contains options for building and managing applications. EDITIONS You access the Lightning Platform Home page from Setup. In Lightning Experience: Available in: both Salesforce Classic (not available in all • The left sidebar, which you can browse or search, provides access to all setup actions, tasks, orgs) and Lightning and tools. Experience • The Quick Find lets you quickly navigate to any node using a keyword. Quick Find is the best Available in: all editions way to find what you’re looking for if you know its name. except Database.com • The Create menu gives you quick access to common Setup creation functions—including users, custom objects, custom tabs, apps, email templates, and processes—without having to drill down through the Setup tree to get the page. You can get to the Create menu from any page USER PERMISSIONS in Setup. To access the Lightning • A carousel of quick-access tiles gives you instant access to important setup tools and information, Platform Home page: as well as the release notes. There’s a link to download SalesforceA—which lets you do Salesforce • Customize Application administration from a mobile app—and a link to the System Status screen so you can view your org’s performance and usage data.
959 Extend Salesforce with Clicks, Not Code Lightning Platform Home Page
• The Most Recently Used list shows your most recently used records or customization features in Setup. You can quickly link back to what you were working on by clicking its name. • The Object Manager provides a one-stop shop for managing all objects in your organization, both standard and custom. In Salesforce Classic: • The left sidebar, which you can browse or search, provides access to all setup actions, tasks, and tools. • The Getting Started box contains a tool for generating a basic app in a single step and links to information about extending and managing apps. This box doesn’t appear if you’ve previously dismissed it. • The Recent Items list shows recent metadata items that you’ve viewed, edited, or created and their related objects. • The System Overview messages box displays messages to remind you when your organization reaches its usage limits. The System Overview messages box is not enabled by default. • The Quick Links box provides links for managing tools, users, apps, security, and data. • The Community box showcases available resources. If you’ve previously dismissed this box, it reappears with each new release. • The right pane includes external links that are useful for developers and administrators.
Recent Items List (Beta) The Recent Items list shows recent metadata items that you’ve viewed, edited, or created and their related objects.
Recent Items List (Beta)
The Recent Items list shows recent metadata items that you’ve viewed, edited, or created and their EDITIONS related objects.
Note: The Recent Items list is in beta. It is production quality but has known limitations. Available in: Salesforce Classic (not available in all The Recent Items list includes: orgs) and Lightning Experience • Apex classes • Apex triggers Available in: all editions except Database.com • Approval processes • Apps • Custom report types • Email templates • Fields • Objects • Page layouts • Permission sets • Profiles • Record types • Static resources • Tabs • Users • Validation rules • Visualforce pages • Visualforce components
960 Extend Salesforce with Clicks, Not Code Configuring System Overview Messages
• Workflow email alerts • Workflow field updates • Workflow outbound messages • Workflow rules • Workflow tasks
Note: The Recent Items list in Setup is independent of the Recent Items section in the sidebar column of many Salesforce pages. The list in Setup shows items that administrators use, while the Recent Items section in the sidebar displays records with which end users have worked.
Configuring System Overview Messages
Note: The system overview page shows only the items enabled for your organization. For EDITIONS example, your system overview page shows workflow rules only if workflow is enabled for your organization. Available in: both Salesforce Add system overview usage messages to the Salesforce Home page to remind you when your Classic (not available in all organization approaches its limits. You can expand, collapse, and dismiss the system overview orgs) and Lightning Experience messages that appear on the Home page. By default, the system overview home page messages are enabled. Available in: All Editions To configure the system overview messages on the Home page: except Personal and Database.com 1. From Setup, enter System Overview in the Quick Find box, then select System Overview. USER PERMISSIONS 2. Click Configure Messages. 3. Select or deselect the types of system overview messages to show or hide on the Home page. To configure system messages: 4. Click OK. • Customize Application Important: System overview messages only appear on the Salesforce Home page when your organization approaches its limits. When you enable or dismiss system overview messages, it only impacts your individual view of the messages.
Lightning App Builder
The Lightning App Builder is a point-and-click tool that makes it easy to create custom pages for EDITIONS the Salesforce mobile app and Lightning Experience, giving your users what they need all in one place. The Lightning App Builder is also a one-stop shop for configuring Lightning apps. Available in: both Salesforce You can access the Lightning App Builder from Setup by entering Lightning App Builder Classic and Lightning in the Quick Find box and then selecting Lightning App Builder. Experience
With the Lightning App Builder, you can build: Available in: Group • Single-page apps that drill down into standard pages Essentials, Professional, • Dashboard-style apps, such as apps to track top sales prospects or key leads for the quarter Enterprise, Performance, Unlimited, and Developer • “Point” apps to solve a particular task, such as an expense app for users to enter expenses and Editions monitor expenses they’ve submitted • Custom record pages for your objects, tailored to the needs of your users
961 Extend Salesforce with Clicks, Not Code Create a Custom App Page: The Big Picture
• Custom Home pages containing the components and features that your users use most
But that’s not all. When you edit a Lightning app from the App Manager in Setup, you’re brought into the Lightning App Builder to manage the app’s settings. You can update the app’s branding, navigation, app options, and manage the Lightning pages assigned to that app all inside the Lightning App Builder. The Lightning App Builder supports the same browsers as Lightning Experience and isn’t supported on mobile browsers. The minimum recommended resolution for the Lightning App Builder is 1280x1024.
SEE ALSO: Create an App Home Page with the Lightning App Builder Create and Configure Lightning Experience Record Pages Supported Browsers and Devices for Lightning Experience Lightning Aura Components Developer Guide Lightning Web Components Developer Guide
Create a Custom App Page: The Big Picture With just a few steps, you can create an app page that lets your Lightning Experience and Salesforce mobile app users access the most important objects and items in your custom app. Custom app pages are built using Lightning pages. 1. Before creating your page, determine which components you want to include and the global actions your users need. 2. Create the Lightning page. 3. Add actions to your page. 4. Activate your Lightning page in the Lightning App Builder.
962 Extend Salesforce with Clicks, Not Code Lightning Pages
Activation lets you create a custom tab for your app page, set its visibility, and add it to the Salesforce “Mobile Only” app navigation and Lightning app navigation bar all in one place.
Lightning Pages A Lightning page is a custom layout that lets you design pages for use in the Salesforce mobile app or Lightning Experience. Lightning pages occupy a middle ground between page layouts and Visualforce pages. Like a page layout, Lightning pages allow you to add custom items to a page. However, these items, instead of being fields or Visualforce components, are Lightning components, which allow much more flexibility. The structure of a Lightning page adapts for the device it’s viewed on. The template you choose when creating the page controls how it displays on a given device. The Lightning page’s template divides the page into regions.
Lightning pages are built using Lightning components—compact, configurable, and reusable elements that you can drop into regions of the page in the Lightning App Builder. You can use a Lightning page to create an app page that you can add to the navigation bar of a Lightning app, which makes it appear when that app is viewed in both Lightning Experience and the Salesforce mobile apps. An app page gives your users quick access to the objects and items that are most important in that app. You can also use a Lightning page to create a customized Home page for Lightning Experience, or a custom record page for Lightning Experience and the Salesforce mobile app. And if you have integrated Salesforce with Microsoft® Outlook® or Gmail™, you can create a custom Email Application pane. If you have a console app, you can create a Lightning page with pinned regions to let your users view and work with records while navigating between subtabs.
Lightning pages support these components: Standard Components Standard components are Lightning components built by Salesforce.
963 Extend Salesforce with Clicks, Not Code Lightning Pages
Custom Components Custom components are Lightning components that you or someone else have created. With some configuration, custom Lightning components can work in the Lightning App Builder. Third-Party Components on AppExchange The AppExchange provides a marketplace for Lightning components. You can find packages containing components already configured and ready to use in the Lightning App Builder.
Example: This Lightning app page in the Salesforce mobile app has a list view component, a recent items component, and one global action.
Lightning Page Types You can create different types of Lightning pages with the Lightning App Builder. After you set a Lightning page’s type, you can’t change it.
App Page App pages are supported both in the Salesforce mobile app and Lightning Experience. Use an app page to create a home page for a third-party app that you can add directly into the Salesforce mobile app and Lightning Experience navigation menus. Your users then have an app home page where they can quickly access the most important objects and items. Add global actions to an app page to enhance its functionality. Global actions allow a user to do things from your app page, such as add call details, create and update records, send email, and create a task. When a user visits a Lightning page in the Salesforce mobile app, the page’s actions appear in its action bar. In Lightning Experience, actions appear in the highlights panel at the top of the page.
Important: Create actions in the full Salesforce site before adding them to your app page.
App pages support only global actions. Standard Chatter actions, such as Post, File, Link, and Poll, aren’t supported. When a user visits an app page in the Salesforce mobile app or Lightning Experience, only the actions that you specify for the page are displayed. If you haven’t specified any actions, no actions appear.
964 Extend Salesforce with Clicks, Not Code Lightning Pages
Home Page Create Home pages with features relevant to specific types of users, and assign the customized pages to different apps or app-and-user-profile combinations. Custom Home pages are supported in Lightning Experience only.
Record Page With a record page, you can create a customized version of an object’s record page, tailoring it to your users’ needs. Custom record pages are supported in Lightning Experience and the Salesforce mobile app.
Note: Actions you see on Lightning Experience record pages and the Home page are taken from object and global page layouts. You can’t add, edit, or remove actions on these pages using the Lightning App Builder.
Email Application Pane Create custom email application panes to let users work with Salesforce content that’s most relevant to them in Microsoft® Outlook® and Gmail™. Custom email application panes are supported in Salesforce Classic and Lightning Experience.
SEE ALSO: Create an App Home Page with the Lightning App Builder Create and Configure Lightning Experience Record Pages
Lightning Page Templates
Lightning page templates are Lightning components that have been configured to serve as templates EDITIONS for custom Lightning pages. Page templates can support different form factors, such as desktop or phone. When you create a Lightning page in the Lightning App Builder, you can select a page Lightning App Builder template that matches the device you’re designing the page for. available in: both Salesforce Home page templates are desktop-only. Standard app page templates support both desktop and Classic and Lightning phone. Standard record page templates support both desktop and phone, except the console Experience pinned region templates, which are desktop only. If a form factor isn’t on the options list when you Lightning Home and utility try to assign a Lightning page, then the page template doesn’t support it. bar pages available in: When working on a page in the Lightning App Builder, you can use the form factor switcher to Lightning Experience preview what the page looks like on different devices that the template supports. Lightning app and record Custom Lightning page template components are supported for record pages, app pages, and pages available in: both the Home pages. You can create custom page templates only in Aura. For more information, see “Create Salesforce mobile app and a Custom Lightning Page Template Component” in the Lightning Aura Components Developer Lightning Experience Guide. Email application pane When switching your Lightning record pages to a different template, keep these considerations in pages available in: both mind. Salesforce Classic and Lightning Experience • You can’t switch to a template that supports a smaller scope of devices than the original template. For example, if you have a page using a template that supports both desktop and Available in: Group phone, you can’t switch the page to use a template that supports only phone or only desktop. Essentials, Professional, When you choose to switch, the list of available templates reflects this rule and shows only the Enterprise, Performance, templates that you can switch to. Unlimited, and Developer • If you switch to a page template that doesn’t support the form factor of a component on your Editions page, that component is dropped from the page at run time.
965 Extend Salesforce with Clicks, Not Code Lightning Pages
• You can’t switch from a non-pinned region template to a pinned region template.
Standard Lightning Page Components
Standard components are Lightning components built by Salesforce. Several standard components EDITIONS are available when creating Lightning pages.
Note: The components listed here are supported across all page types, except when otherwise Lightning App Builder indicated. This list doesn’t show all available standard components. Other standard component available in: both Salesforce types are available and vary based on the type of page you create and with which object the Classic and Lightning Experience page is associated. Some standard components have required properties that you must configure for the component Lightning Home and utility to work on the page. When you add a component to a Lightning page in the Lightning App Builder, bar pages available in: its required properties are marked with an asterisk. Lightning Experience A Lightning page region can contain up to 100 components. Lightning app and record pages available in: both the If you have a page to be used in the Salesforce mobile app, use only Lightning components that Salesforce mobile app and the mobile app supports. See Data Available in the Salesforce Mobile App. Lightning Experience
Email application pane Accordion pages available in: both Use the Accordion component to organize your components into collapsible sections. You can put Salesforce Classic and multiple components in each section and customize the section name. You can have up to 25 Lightning Experience sections, but we recommend no more than 10. Available in: Group The Accordion component is supported for record and Home pages. Essentials, Professional, Enterprise, Performance, Note: Programmatic versions of the accordion components don’t provide the same Unlimited, and Developer functionality as their App Builder counterparts. For example, lightning-accordion Editions and lightning:accordion components don’t currently support lazy loading.
Actions & Recommendations Component Give your users a to-do list in the Actions & Recommendations component. Show a variety of steps, including screen flows, field service mobile flows, quick actions, and recommendations from your Next Best Action strategies. When a user opens a flow, in a console app it starts in a subtab. In a navigation app, it starts in a window. You can add this component to supported object pages in Lightning Experience. For more information, see Lightning Flow for Service and the Actions & Recommendations Component.
Activities Display the timeline of the activities of the record. This component appears only if Default Activities View is set to Activity Timeline. The component can contain Create a Record quick actions that point to the Event and Task objects. It contains Log A Call and Send Email actions for each of your org’s accounts, contacts, contracts, leads, opportunities, and activity-enabled custom object records.
Note: On the Case object, the component only shows the timeline of the activities. Actions appear in a Chatter Publisher component.
For more information, see Activities View and Actions in Lightning Experience.
966 Extend Salesforce with Clicks, Not Code Lightning Pages
After Conversation Work (Beta) Display a countdown after a customer conversation ends. During the After Conversation Work (ACW) countdown period, support agents can complete closing tasks like sending follow-up emails, updating a case, or finalizing their notes. Agents can exit the countdown early by closing the call record or let it run its course. When the time runs out, the agent is considered available to help the next customer whether or not they’ve closed the call record. After Conversation Work is available only for Voice Call channels. To learn more, see Configure After Conversation Work (Beta).
App Launcher Component The App Launcher displays a user’s available Salesforce apps and the connected apps the administrator has configured. Users navigate between apps using the App Launcher. This component is supported in API version 35.0 and later. Contact Salesforce to enable the App Launcher component for the Lightning App Builder in your organization.
C360 Global Profiles The C360 Global Profile component shows the matched Customer 360 profile data related to the person account record in the page layout. This component retrieves data from Customer 360 Data Manager for your single customer view. Some of the data in this component isn't stored locally in your Service Cloud org if the data originated in another data source connected to Customer 360 Data Manager. Your admin user can determine which data is copied into your Service Cloud and which data is queried on demand via this component and Customer 360 Data Federation Services. This component displays data in Customer 360 Data Manager that’s matched back to the person account record. The component shows these fields. • Name — First and Last or Family name of a person. • Email — Email addresses of a person • Phone — Phone numbers of a person, grouped by the Primary Phone Type: Home, Business, Fax, Mobile, Other. • Address — Mailing address for a person, used as either a Billing Address, a Shipping Address, or both. • In the Lightning App Builder, users can set component visibility rules, if needed, by defining filter criteria for either a record field or another field.
Note: Removing Data Mappings from the Cloud Information Model in Customer 360 Data Manager can remove data visible in this component.
C360 Order History The C360 Order History component shows the ecommerce order history for the person account that was matched to B2C Commerce orders through Customer 360 Data Manager. This component displays ecommerce order data from B2C Commerce retrieved by the Customer 360 Data Federation Service. Otherwise, an admin must copy and store order data locally in your Service Cloud org. These fields are displayed in this component. • Order No. — The customer’s order number, generated by B2C Commerce. The values in this field are hyperlinks, which open a separate UI for the Order Details. • Checkout Date — The date on which the customer placed the order on the website. • Order Status — The status of the customer’s order, such as Not Shipped, Shipped, or Returned. • Total Amount — The total amount, in the site’s currency, paid by the customer for the order. • WebsiteID — The B2C Commerce site ID as defined in Business Manager.
967 Extend Salesforce with Clicks, Not Code Lightning Pages
Note: Removing Data Mappings from Commerce Cloud in Customer 360 Data Manager can remove data visible in this component.
Call Recording Player Use this component to listen to audio recordings of calls. The Call Recording Player component is available only for the Voice Call object. This component is available in the Lightning App Builder in orgs where Service Cloud Voice is turned on. To view and use this component, users need the Contact Center Agent permission set. Because the Call Recording Player doesn't have an alternative text-based transcript, we recommend adding the Conversation Body component underneath the Call Recording Player to support accessibility.
Chatter Component As of API version 38.0, the Feed component has been renamed Chatter in the Lightning App Builder. Use it to place a publisher and feed combo on a record page.
Chatter Feed Component Use the Chatter Feed component to place a feed anywhere on a record page. The feed gives you a way to view posts, comments, and questions. Its attribute, Feed Type, takes one of these values. • Bookmarked—Shows a feed of all items the current user has bookmarked. • What I Follow—Shows a feed of all items the current user has followed. • To Me—Shows a feed of all items where the current user is mentioned. No coding is required to join a feed to a publisher. The connection is made automatically with the publisher and any feed on the page. The Chatter Feed component is available in API version 38.0 and later.
Chatter Publisher Component Use the Chatter Publisher component to place a feed publisher anywhere on a record page. The publisher gives you a way to post, poll, or ask a question in a feed. Its attribute, Type, has the default value Global. Use the value Record when you want to associate the publisher with an object's feed. Then posts that are created with the publisher are associated with the record rather than the global Chatter feed. Use the Chatter Publisher component with the Chatter Feed component to get a full feed experience. No coding is required to join a publisher to a feed. The connection is made automatically with the publisher and any feed on the page. The Chatter Publisher component is available in API version 38.0 and later.
Conversation Body Use this component to let agents view call transcripts in Service Cloud Voice. The Conversation Body component is available only for the Voice Call object. Transcripts are generated in real time during the call and the complete transcript is stored on the call record. As the call progresses, the transcript is generated and displayed in the component. Configure transcription data streams in Amazon Web Services to generate call transcripts. To view and use this component, users need the Contact Center Agent permission set.
Customer Experience Score (Pilot) The Customer Experience Score component lets users view the score participants gave a particular record and the average score for all records of that object. You can add this component to custom objects and these standard objects: Account, Case, Contact, and User. To use this component, you must enable Salesforce Surveys in your org. This component is supported in API version 47.0 and later. For more information, see Customer Experience Score.
968 Extend Salesforce with Clicks, Not Code Lightning Pages
Note: We provide Customer Experience Score component to selected customers through a pilot program that requires agreement to specific terms and conditions. To be nominated to participate in the program, contact Salesforce. Pilot programs are subject to change, and we can’t guarantee acceptance. Customer Experience Score component isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only based on generally available products and features.
Dynamic Actions Bar Component (Pilot) With this component you can add action buttons anywhere on your Lightning record and app pages. Add, delete, and change the order of actions in the Dynamic Actions Bar. You can also control the visibility of the component and of individual actions in the component, based on record field, permission, or user.
Note: We provide the Dynamic Actions Bar component to selected customers through a pilot program that requires agreement to specific terms and conditions. To be nominated to participate in the program, contact Salesforce. Pilot programs are subject to change, and we can’t guarantee acceptance. Dynamic Actions Bar component isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only based on generally available products and features. To set the visibility of individual actions in the Dynamic Actions Bar component at runtime: 1. In the Dynamic Actions Bar properties pane, click an action name to open the Action dialog. 2. Under Set Action Visibility in the Action dialog, click Add Filter. 3. Select Record Field to control action visibility for a record field, or Advanced to control action visibility for a record, permission, or user. 4. Click the Field name field and select a field from the dropdown list (for Record Field), or select a field type and then select a field (for Advanced). 5. Select an operator and enter a value, then click Done. Considerations • This component is supported only for Lightning Experience desktop on record and app pages. • The Dynamic Actions Bar supports all standard and custom global actions. • This component is supported as a source for Dynamic Interactions on app pages only. See Dynamic Interactions in the Lightning App Builder on page 1005. • Email quick action and FeedItem.MobileSmartActions actions aren’t supported for the Dynamic Actions Bar. • If no actions are supported for the current object, a message appears in the Lightning App Builder properties pane.
Einstein Field Recommendations Component The Einstein Field Recommendations component recommends values for picklist, checkbox, and lookup fields on cases. It’s used in Einstein Case Classification and Einstein Case Wrap-Up, and is available only if you enabled one or both of those features. Einstein’s field value recommendations are based on data from recently closed cases. The component has two types: Case Classification and Case Wrap-Up. To learn more about using this component with Einstein Case Classification, see Display Recommendations in the Service Console. Available in API version 49.0 and later.
969 Extend Salesforce with Clicks, Not Code Lightning Pages
Einstein Next Best Action Component The Einstein Next Best Action component displays suggested recommendations and actions on a record page. Use strategies to apply your org’s business rules to display context-specific suggestions to users. For more information, see Einstein Next Best Action Component.
Einstein Predictions Component The Einstein Predictions component displays predictions and recommendations on a Lightning record page for a standard or custom object. For more information, see Add Einstein Predictions to a Lightning Page.
Einstein Replies Component The Einstein Replies component recommends stock replies that support agents can insert into chat and messaging sessions. It’s used in Einstein Reply Recommendations, and is available only if that feature is enabled. The replies that Einstein recommends are based on past closed chats. To learn more, see Einstein Reply Recommendations. If Einstein Reply Recommendations is enabled, this component appears automatically on the Chat and Messaging console tabs for any users with the View and Act on Einstein Reply Recommendations user permission. Available in API version 49.0 and later.
Highlights Panel Component The Highlights Panel component displays key record fields along with page-level actions. The fields that appear in the highlights panel come from the compact layout assigned to the object. The actions in the highlights panel come from the Salesforce Mobile and Lightning Experience Actions section of the page layout. Record highlights show up to the first 7 fields on desktop and up to the first 10 fields in the Salesforce mobile app. To streamline your highlights panel by not showing the second row of information and reducing the size of the first row, select the Show as collapsed (desktop only) checkbox. To show fewer action buttons, reduce the number using the Number of Visible Action Buttons (desktop only) attribute. To display the highlights horizontally or vertically (desktop only), drag the Highlights Panel component into a region with the horizontal or vertical dimensions you want. The highlights panel adjusts to fit the region’s space. For example, if you drag it into a narrow column, the highlights display vertically. If you drag it to a full-page width column, the highlights display horizontally.
Event Insights Component The Event Insights component shows Salesforce IoT data about your customers’ connected devices on Lightning record pages alongside your CRM data. Salesforce IoT must be enabled, and you need an active orchestration to set up the Event Insights component. You can put up to five IoT orchestration variables in your Event Insights component. In the Lightning App Builder, you specify the parent record, the orchestration to pull the variables from, and the variables to show. You set the component visibility by filtering on record type. Each device (instance) can have up to 1 MB of data. Event message and device allocations follow your normal Salesforce IoT allocations. This component is supported in API version 44.0 and later.
List View Component The List View component points to a list view and displays the first few records from that view. It supports all public and shared list views that are associated with standard and custom objects, except:
970 Extend Salesforce with Clicks, Not Code Lightning Pages
• Activity • ContentVersion (Files) • User • UserProfile By default, a List View component displays the first three records in the list, but you can set it to show a maximum of 30. You can’t give a List View component a custom name. The component’s name is derived from the name of the list view filter you select when you configure the component. In the Lightning App Builder, the Object dropdown list for this component displays only those objects that have list views associated with them. Adding too many List View components can cause page performance issues. Use them sparingly.
Order Product Summaries by Recipient Component Use the Order Product Summaries by Recipient component to display order product details on an Order Summary record page. This component is available in Salesforce Order Management. The Order Product Summaries by Recipient component displays information about the order delivery group summaries associated with the order summary, including the order product summaries associated with them. The displayed order product summary fields are defined by the Order Product Summaries related list on the OrderDeliveryGroup object page layout. To modify the columns in this component on the order summary details page, edit the related list on the Order Delivery Group page layout, not the Order Summary page layout. You can create a custom filter to control which order delivery group summary records are displayed.
Order Summary Totals Use the Order Summary Totals component to display order financial totals on an Order Summary record page. This component is available in Salesforce Order Management. You can customize the panel title and which values to display.
Phone Use this component to give agents easy access to the Service Cloud Voice softphone call controls so they can mute, hold, and end call. This component is displayed when an agent accepts a call and is hidden when the call ends. The Phone component is available for the Account, Case, Contact, and Voice Call objects, and for custom objects. To view and use this component, users need the Contact Center Agent permission set.
Quip Document Component Use the Quip Document component to embed Quip documents directly in records. Set up any Quip document as a template so that your users can quickly create documents on Salesforce records. When you set up the Quip Document component in Lightning App Builder, you can choose different modes. • Allow different documents on each record. Let users attach different documents to different records, or create and embed new documents from scratch. Admins can programmatically attach preselected documents to different records. • Use the same document for every record. Choose an existing document to embed in each record associated with a given object. • Use a template to create new documents for each record. Specify a template from which users can create and embed documents on a per-record basis. You can use any Quip document as a template. You can set up the template to add record data to documents.
971 Extend Salesforce with Clicks, Not Code Lightning Pages
• Use different templates for different records. Specify different templates for different records on the same object. This option requires you to programmatically pre-populate the component field with the URLs of different templates rather than manually choosing a single template URL.
Rebate Types Panel Component The Rebate Types Panel component allows you to select and apply eligible rebate types and incentives to a mapped object. This component is supported in API version 52.0 and later.
Note: To view and use this component, users need the Rebate Management license.
Rebate Types Tab Component The Rebate Types component is used in combination with the Rebate Types Panel component to view and modify the benefit tiers associated with the applied rebate types and incentives. This component is supported in API version 52.0 and later.
Note: To view and use this component, users need the Rebate Management license.
Recent Items Component The Recent Items component displays a list of the most recently used items. The default is three, but you can set it to show a maximum of 30. In the Lightning App Builder, you can specify which objects’ records appear in the recent items list. The Recent Items component supports these objects, based on the specified properties: • All custom objects. • All standard objects for which both of these conditions are true: – A compact layout is defined for the object. – The object is tracked in the most recently used objects list.
Note: The object isn’t supported for this component when it meets both of these criteria but isn’t in the list of available objects when you configure the component. Although they appear in the available objects list, the Task, Report, KnowledgeArticle, and Article objects aren’t supported for this component. If an object is tracked in the most recently used objects list, one or both of the LastViewedDate or LastReferencedDate fields are present.
Record Detail Component The Record Detail component displays fields and sections from the page layout associated with the object. When users view the Lightning record page, they see different fields and sections based on their profile and page layout assignments. You can’t add, remove, or move the fields and sections when you’re viewing the component in the Lightning App Builder. You can only make field and section changes on the page layout.
Related List - Single Component Use the Related List – Single component to include a single related list for a record in your Lightning page. To include all related lists for a record, use the Related Lists component. You can configure this component to display a related list for the record associated with your page, or you can display information for the parent record. Using a parent record is optional.
972 Extend Salesforce with Clicks, Not Code Lightning Pages
This component is supported in API version 39.0 and later. You can use it in record pages only.
Tip: Make sure that the page layout for your users includes the related list you want to use. If using a parent record, update the parent record’s page layout.
Related List Quick Links Component The Related List Quick Links component displays a set of links. Users can hover over the links to see all the related list columns without opening the View All page. Header actions, mass actions, row actions, and text wrapping are all available on the hover pane. The component displays two rows of related list links in large or medium page regions, and six rows in small regions. Users can view the remaining related list links by clicking Show All, which expands the component. When a user hovers over a related list quick link, it displays the first 10 items in the related list. The content of this component is based on the set of related lists on the object's page layout plus the user’s preferences. Users can customize the order of the quick links. They can also exclude the ones they don't want in their personal settings. To exclude, they can enter Customize My Pages in the Quick Find box, selecting Customize My Pages, then clicking the object. The Open Activities and Activity History related lists aren't supported for this component. You can use this component in record pages only.
Related Record Component Use the Related Record component to display the details of a related record, including the details of a parent record, in your Lightning page. This component provides your users with built-in record creation, inline edit, and the ability to unlink a record and link a new one. This functionality is possible because the component uses actions. This component is supported in API version 39.0 and later. You can use it only in record pages. Keep these considerations in mind when using the Related Record component. • To use the component, an object must have an associated quick action to update the records. Some lookup fields have default actions. If no actions are available for your lookup, follow the links in the Lightning App Builder property editor to create the actions. • To change the displayed fields for the Related Record component, configure different lookup fields, and customize the associated action in Setup. If you don’t see the action or can’t modify it, create one. Also, ensure that the lookup field to the related object is included on the page layout of the main object. Otherwise the component can’t be refreshed. • To let users look up two levels of record relationships, specify the first-level lookup and then the second-level lookup. You must specify a first-level lookup before you can add a second-level lookup. • To let users look up polymorphic fields, select a polymorphic lookup field type on the first-level lookup or on the second-level lookup. • To use the Parent Case, Asset, and Case Source lookup fields on cases, change the field-level security to visible instead of hidden. Otherwise, your users see an error. • Users without Read access to the value of a lookup field see an error. • Person account records that display in contact Related Record components are read-only. • Cases are linked to default accounts that can’t be removed (unlinked) from the component unless the contact is also removed at the same time. • The Related Record component typically uses quick action metadata to determine which fields to show. However, if the user viewing the component has read-only access to the related record, a compact layout is used to render the fields instead. As a result, a read-only user sees a smaller set of fields.
973 Extend Salesforce with Clicks, Not Code Lightning Pages
Report Chart Component Use the Report Chart component to include a chart from a report in your Lightning page. If you leave the component’s Label field blank, the component’s label is derived from the report’s label. The chart refreshes if its report data is more than one day old. In the component properties, you can choose to display a refresh button to enable users to refresh the chart. Saving the report’s definitions also updates the chart data in the component. Setting a filter on the report chart data is supported only for record pages. If you set a filter option, the Report Chart component displays only that filtered data to users. This component is supported in API version 32.0 and later. It doesn’t work with reports in the My Personal Custom Reports folder. Report Chart components that refer to reports in the Unfiled Public Reports folder aren’t deployable when you include them in a package.
Rich Text Component Use the Rich Text component to add text and simple HTML markup to your Lightning page.
Note: JavaScript, CSS, iframes, and other advanced markup aren’t supported. To use advanced HTML elements in a component, we recommend using a Visualforce page component or a custom Lightning component. The Rich Text component uses Quill as its text editor. Keep these considerations in mind when using the text editor. • Quill wraps each line of text with tags. The tags can increase the number of characters in the rich text API value when you save the text. If you get a max length warning, break up the text into two Rich Text components. • In Quill, the default color for text is gray in the editor, but the text renders black in the output. • Selecting text using keyboard shortcuts, such as with Cmd+A, and then typing something new resets the formatting of the existing text. You can include up to 4,000 characters in the Rich Text component. This component is supported in API version 32.0 and later.
Salesforce Surveys Component The Salesforce Surveys component adds an active survey to your Lightning page, so you can collect data from your users while they work on Salesforce records. This component is supported in API version 42.0 and later.
Note: To create surveys and add them to Lightning pages, you must enable Salesforce Surveys in your org.
Send Email Later - Pending List The Send Email Later - Pending List component shows the list of scheduled emails. From this list, your users can see pending emails, cancel an email, edit its scheduled time, or edit its content.
Tableau CRM Dashboard Component The Tableau CRM Dashboard component surfaces an entire dashboard right where people work. The dashboard is fully functional and interactive. Users can refresh them, apply filters, and click chart segments to drill into filtered reports. Dashboards need space to display charts and tables. If an embedded dashboard is squished into too small a space, then a collapsed version displays instead of the full dashboard. Users can click View Dashboard to open a collapsed dashboard. Available in API version 41.0 and later. The Dashboard component isn’t available on record pages. Private dashboards aren’t available.
974 Extend Salesforce with Clicks, Not Code Lightning Pages
Tabs Component Use the Tabs component to add tabs to a region of your Lightning page. Choose from a set of standard tabs or create custom tabs to enhance record and Home pages for your Lightning Experience users. The Tabs component is supported only for Lightning Experience record and Home pages. You can place up to 100 tabs in a Tabs component. This component is supported in API version 36.0 and later.
Twitter Component Social Accounts and Contacts must be enabled for your organization before you can add the Twitter component to a Lightning page.
Visualforce Page Component Use the Visualforce Page component to include a Visualforce page in your Lightning page. If you leave the component’s Label field blank, the label is taken from the Visualforce page that you assign to it. If you leave the Height field blank, the Visualforce page’s height defaults to 300 pixels when it displays in the Salesforce mobile app. This component is supported in API version 32.0 and later. To appear in the Salesforce mobile app or Lightning Experience, the Visualforce page must have the Available for Salesforce mobile apps and Lightning pages option selected. This option is available for pages that are set to API version 27.0 and later.
Wave Dashboard Component Use the Wave Dashboard component to include Tableau CRM dashboards in your Lightning page. Contact Salesforce to enable the Wave Dashboard component for the Lightning App Builder. Select the dashboard to display from the dropdown list. If you leave the Height field blank, the dashboard’s height defaults to 300 pixels when it displays in your Lightning page. You can control the visibility of the dashboard’s title and specify whether the dashboard appears when an error occurs. With the Open Links in New Windows attribute, you can specify where links from the dashboard to other assets are opened. With the Filter attribute, you can use JSON to filter dataset fields at run time. For more information, see Embed Tableau CRM Dashboards in Lightning Pages.
SEE ALSO: Custom Lightning Page Components
975 Extend Salesforce with Clicks, Not Code Lightning Pages
Custom Lightning Page Components
The Lightning App Builder supports custom Lightning components. EDITIONS Custom components in your org that are configured for use in the Lightning App Builder appear in the Lightning Components pane. Lightning App Builder available in: both Salesforce Classic and Lightning Experience
Lightning Home and utility bar pages available in: Lightning Experience
Lightning app and record pages available in: both the Salesforce mobile app and Lightning Experience
Email application pane pages available in: both Salesforce Classic and Lightning Experience
Available in: Group Essentials, Professional, Enterprise, Performance, Unlimited, and Developer Editions
If you have a page to be used in the Salesforce mobile app, use only Lightning components that the mobile app supports. See Data Available in the Salesforce Mobile App. Your custom Lightning components don’t automatically work on Lightning pages or in the Lightning App Builder. To make a custom component usable in both: 1. Configure the component and its component bundle so that they’re compatible with the Lightning App Builder and Lightning pages. For Aura components, see the Lightning Aura Components Developer Guide. For Lightning web components, see the Lightning Web Components Developer Guide. . 2. Deploy My Domain in your org. When you deploy My Domain, references and links to Lightning resources are in the format https://MyDomainName.lightning.force.com. You can configure custom components to support different devices. For instance, you have a record page whose template supports both phone and desktop, and you activate the page for both. Then you add a phone-only component to the page. When the page is viewed on a phone, users see the component. When the page is viewed on a desktop, the phone-only component doesn’t appear.
976 Extend Salesforce with Clicks, Not Code Lightning Pages
Note: Pull to refresh doesn’t work for custom Lightning web components in the Salesforce mobile app.
SEE ALSO: Standard Lightning Page Components My Domain
Dynamic Lightning Pages
Control when a component appears on a Lightning page by adding filter conditions and logic to EDITIONS its properties in the Lightning App Builder. For example, you can construct a filter that causes a rich text component on an opportunity page to display when the opportunity’s amount is greater than Lightning App Builder or equal to $1 million. available in: Salesforce Component visibility properties appear when you select a component on a record, app, or Home Classic and Lightning page in the Lightning App Builder. This behavior applies to standard components, custom Experience components, and components from AppExchange. No need to do anything to your custom Lightning pages available in: components. It’s all handled by the Lightning App Builder. Lightning Experience and the On record pages, you can choose record fields or advanced fields, such as fields from related objects Salesforce mobile app or from a global object like User. Field values in component visibility filters can’t span more than five fields. For example, Available in: Group Record.Account.Owner.Manager.Manager.Manager.LastName has six spans, Essentials, Professional, and therefore isn’t supported. Enterprise, Performance, Unlimited, and Developer Editions
App and Home pages aren’t associated with an object, so the filters you can use are limited to other contexts, such as User, User Permission, or Device. But that doesn’t mean that they’re less powerful. If you don’t define a filter, the component displays on the Lightning page as usual. When you define one or more filters and set the filter logic for a component, the component is hidden until the filter logic criteria are met.
In the Lightning App Builder, components that have at least one filter assigned are indicated with an icon ( ).
977 Extend Salesforce with Clicks, Not Code Lightning Pages
Visibility Rules on Dynamic Forms Fields and Field Sections You can make your Lightning record pages even more dynamic by setting visibility filters on Field and Field Section components. For example, you can have a field or set of fields hidden until a person with a certain profile, permission, or viewing on a certain device visits the page. Be careful when setting up visibility rules on multiple components in the same region. If your rules cause all the components in a region to be invisible at run time, the region will be empty. Visibility rules on fields are respected in the edit, clone, inline edit, and new record screens. Component visibility rules on field sections behave differently than they do on fields. Visibility rules on fields are assessed dynamically. Changes a user makes while editing a record can make fields appear and disappear as visibility rules are evaluated. Visibility rules on field sections aren't dynamic and don't react to what a user does while editing. Field section visibility rules are evaluated only after the record is saved.
Component Visibility Based on Form Factor With a filter using the Device context, you can set a component to display exclusively when its page is viewed in a specific experience, such as a phone or a desktop.
Custom Lightning components can also be set to support different form factors. For Lightning web components, see “Configure Your Component for Different Form Factors.” For Aura components, see “Aura Component Bundle Design Resources.”
Supported Objects, Fields, Field Types, and Operators Two objects aren’t supported for component visibility filters: ProcessInstanceStep and ProcessInstanceWorkItem. On record pages, component visibility filters rely on the data captured in fields associated with the page’s object. Not all fields, field types, and operators are supported. These field types are supported: • String type fields: Autonumber, Currency, Email, Number, Percent, Phone, Text, Text Area, URL • ID • Checkbox (boolean) • Geolocation • Picklist • Formula fields which resolve to one of the above types • Roll-up summary fields which resolve to one of the above types These operators are supported:
978 Extend Salesforce with Clicks, Not Code Lightning Pages
• CONTAINS • = and == (Equal) • <> or != (Not Equal) • > (Greater Than) • >= (Greater Than or Equal) • < (Less Than) • <= (Less Than or Equal)
SEE ALSO: Formula Operators and Functions Standard Lightning Page Components
Build Localized Component Labels and Attribute Values on Lightning Pages with Custom Labels
When you specify labels or attributes in the Lightning App Builder such as for components or custom EDITIONS tabs, you can use the {!$Label.customLabelName} expression to help define the label or attribute’s value. Lightning App Builder On a Lightning page, custom Tabs component labels and other component attribute values aren’t available in: both Salesforce localized when they’re entered as plain text in the Lightning App Builder. For example, if you have Classic and Lightning an org whose default language is English, and you have a Tabs component with three custom tabs Experience that you entered as Cars, Trucks, and Planes, the non-English users in your org see those tab label Lightning Home pages values as Cars, Trucks, and Planes when they view the page. The tab label values aren’t translated available in: Lightning into your users’ languages. Experience
But configuring custom label values in the Lightning App Builder using the Lightning app and record {!$Label. } customLabelName expression lets users see labels in their chosen language pages available in: both the if you created a translation for that label in their language. Salesforce mobile app and The {!$Label.customLabelName} expression works with any custom labels that you Lightning Experience create in Setup using the custom label feature. The text that you define in the Value field for your custom label displays as the label value when the component renders on a Lightning page. And, Available in: Group if you create a translated value for the label, users using that language in your org see the translated Essentials, Professional, Enterprise, Performance, value. Unlimited, and Developer Expressions are supported only in String type fields in component labels and attributes on app, Editions Home, and record pages. You can’t use an expression in page-level properties. 1. Create a translated custom label in Setup. USER PERMISSIONS For more information, see Translate Custom Labels. To create and save Lightning 2. Navigate to the Lightning App Builder. From Setup, in the Quick Find box, enter App pages in the Lightning App Builder, then select Lightning App Builder. Builder: 3. Open an app, record, or Home Lightning page. • Customize Application 4. Select the component whose label or property you want to replace with your translated custom To view Lightning pages in label. the Lightning App Builder: • View Setup and 5. Enter {!$Label.customLabelName} in the label or attribute field, replacing Configuration “customLabelName” with the name of your custom label.
979 Extend Salesforce with Clicks, Not Code Lightning Pages
Label and property fields that support using this expression have an info bubble that says so.
6. Save your changes. Users in your org whose language is set to the language of your translated label see the label or attribute in its translated value.
Example: Your org’s default language is English, but you want the custom Planes tab on your Lightning page to show a translated custom label for your German users. Here’s how to do it. 1. Create a custom label in Setup with the name Planes_Label, and enter the Value as Planes. That’s what your English users see. 2. From the Translations related list on the custom label detail page, create a translation for the label with the language set to German and the Translation Text value as Flugzeuge. 3. Save the translation. 4. In the Lightning App Builder, open your page and click the Tabs component on the canvas. 5. In the properties pane, click the Planes tab, and in the Custom Label field, replace the Planes plain text with {!$Label.Planes_Label}.
6. Click Done and save your page. When viewing the page, your English users see the tab as Planes, and your German users see the tab as Flugzeuge.
Note: When a field in a component contains an expression, Salesforce can’t validate the value it resolves to. If the expression resolves to a value that’s invalid for the field, sometimes the component doesn’t work as expected. We recommend that you test the page in the translated languages before you make the page with the expression available to users.
980 Extend Salesforce with Clicks, Not Code Create an App Home Page with the Lightning App Builder
Create an App Home Page with the Lightning App Builder
Create a home page for an app that you can add directly into Lightning apps and the Salesforce EDITIONS mobile apps. Your users can then easily access the objects and items that are most important in that app. Lightning App Builder 1. From Setup, enter App Builder in the Quick Find box, then select Lightning App Builder. available in: both Salesforce Classic and Lightning 2. Click New. Experience 3. Select App Page and then click Next. Lightning app pages 4. Give your app page a label, and then click Next. available in: both the The label can be up to 80 characters. Salesforce mobile app and Lightning Experience 5. Select a page template and click Finish. 6. Drag the components that you want onto the page. Available in: Group, Essentials Professional, Drag components up and down to rearrange them. You can also click a component’s top or Enterprise, Performance, bottom border to create an insertion point ( ) for the next component. Unlimited, and Developer 7. Click each component on the page to configure its properties. Editions 8. Click in the empty area of the canvas or on the Page link in the breadcrumb to configure the page properties. USER PERMISSIONS The Description field is limited to 255 characters. The Developer Name field is limited to 80 characters, but if you have a namespaced org, we recommend using fewer than 65 characters. To create and save Lightning pages in the Lightning App When you create a Lightning page, the developer name is derived from the first 40 characters Builder: of the label that you give the page. • Customize Application 9. Optionally add global actions to your page. To view Lightning pages in the Lightning App Builder: a. In the page properties, click Select. • View Setup and b. Add, remove, or reorder the actions for your page. Configuration Actions you select appear on the page’s action bar and in the highlights panel at the top of the page in Lightning Experience. An app page is the only type of Lightning page that you can add actions to in this way. Other Lightning pages derive their actions from the object and global page layouts.
c. Click OK.
10. Click Save when you’re done editing your page. To give your users access to the app page, you must activate it.
SEE ALSO: Activate Your Lightning App Page Lightning App Builder
981 Extend Salesforce with Clicks, Not Code Create a Mobile App Page with the Lightning App Builder
Create a Mobile App Page with the Lightning App Builder
Create a mobile home page for the Salesforce mobile app. Your users can see this page right when EDITIONS they log in.
Note: These steps are similar to Create an App Home Page with the Lightning App Builder. Lightning App Builder That’s because when you create an app page or record page, it can be made available on available in: both Salesforce both Lightning Experience and the Salesforce mobile app. The following steps focus on Classic and Lightning Experience creating an app page for the mobile app only. 1. From Setup, enter App Builder in the Quick Find box, then select Lightning App Builder. Lightning app pages available in: both the 2. Click New. Salesforce mobile app and 3. Select App Page and then click Next. Lightning Experience 4. Give your app page a label, and then click Next. Available in: Group, The label can be up to 80 characters. Essentials Professional, Enterprise, Performance, 5. Select the first template (Header and Left Sidebar) and click Finish. Unlimited, and Developer If this is a mobile-only page, it doesn't matter which template you pick. If you plan to share this Editions page between mobile and desktop users, choose the template most appropriate for desktop use. On mobile devices, the page responsively collapses into a single column. USER PERMISSIONS 6. Make sure you’re viewing the template preview using the Phone form factor. The regions on the template are displayed in a one column layout. To create and save Lightning pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration
982 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
7. Drag the components that you want onto the page. Drag components up and down to rearrange them. You can also click a component’s top or bottom border to create an insertion point ( ) for the next component. To increase mobile adoption, we recommend making available the top features that your users use most frequently. For example, the Recent Items can take them back into the records that they were working with. Also, the List View standard components can be set to their open tasks to improve productivity in the mobile app. Remember that screen space and bandwidth are precious on mobile, so try to limit each page to 4 or 5 components at most. If you overload the page with features, it can be slow and harder to use. See Preview Mobile App Pages in Lightning App Builder on page 983.
8. Click each component on the page to configure its properties. 9. Click in the empty area of the canvas or on the Page link in the breadcrumb to configure the page properties. The Description field is limited to 255 characters. The Developer Name field is limited to 80 characters, but if you have a namespaced org, we recommend using fewer than 65 characters. When you create a Lightning page, the developer name is derived from the first 40 characters of the label that you give the page.
10. Optionally add global actions to your page. Global actions help your users perform tasks easily from the app page, like log a call, create a new case or event etc. a. In the page properties, click Select. b. Add, remove, or reorder the actions for your page. Actions you select appear on the page’s action bar and in the highlights panel at the top of the page in Lightning Experience. An app page is the only type of Lightning page that you can add actions to in this way. Other Lightning pages derive their actions from the object and global page layouts.
c. Click OK.
11. Click Save when you’re done editing your page. To give your users access to the mobile app page, you must activate it. You can limit the page to mobile users during the page activation process. After activation, you can add this to any Lightning App in the App Manager for your users to personalize. If your Lightning App is available on both desktop and mobile, you can use the same page across both. Or create a Lightning App specifically for your mobile users, and add it to the navigation there.
Preview Mobile App Pages in Lightning App Builder
For a consistent experience across devices, use the Lightning App builder to preview your record EDITIONS and app pages. The Salesforce mobile web experience is no longer available after Summer ’20. To customize and Available in: Lightning preview your apps and pages for Lightning Experience or the mobile app, use the App Builder. You Experience can also specify certain components as mobile- or desktop-only. Available in: Group If you need more than a preview, run the Lightning apps and components in the Salesforce mobile Essentials, Professional, app. Testing in the mobile app helps validate that users have the best experience on mobile. Enterprise, Performance, When you build a mobile app page, the steps include: Unlimited, and Developer Editions • Build a new app page with the App Builder on page 982 • Activate the page and add the page to your mobile navigation • Create a Lightning app in the App Manager for your users to personalize
983 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
Watch a Demo (9 minutes) The following sections discuss best practices on building a mobile app page using the App Builder.
Display Mobile-Friendly Components When you create a Lightning app page or record page via the App Builder, the template you choose controls how it displays across devices.
Here are several ideas on including standard components on page 966 for mobile users. The list can vary depending on your user’s role. • The Report Chart component displays helpful data, such as your top deals, based on a filter. • The List View component can display your events, such as today’s agenda. • The Task List component can display your open tasks, overdue tasks, or another list based on a filter. • The Recent Items component lets you get back to the records you are working with recently. • The Launchpad component lets you add a grid of navigation items, such as your contacts or a custom Visualforce page, which users can access with one tap. If standard components don’t meet your requirements, create custom components on page 976.
Customize Actions for the Mobile Page If you’re creating an app page, you can also customize the actions available for the page. On the Page link, click Select under the Actions label.
984 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
Here are several popular actions for mobile users that make them more productive. Again, the list can vary depending on your user’s role. • Log a call • New case • New event • New task For more information, see Salesforce Mobile App Action Bar.
Activate the Page for Mobile Users When you activate the page, you have the option to add the page to both Lightning Experience and mobile app. You can add the page to any mobile-enabled Lightning app. Adding your app page to Lightning Experience makes it available to users viewing the app on desktop and in the Salesforce mobile app.
Enable Users to Personalize Tabs for the Mobile App If you haven't already, enable your Lightning apps for mobile in the App Manager so your users can access the same navigation on all devices. Or create a Lightning app if you want separate navigation items on mobile. To customize your mobile experience, personalize the app on desktop with your favorite tabs, and then use them on the mobile app. This guideline is optional but highly recommended to optimize your users’ mobile experience. For this use case, choose the Desktop and phone form factors.
985 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
Add navigation items, including the app page you created and several basic tabs like Chatter and Groups. Keep the app lightweight since users can personalize their own tabs using this app.
Add the profiles who need mobile access to this app. For example, the mobile app is ideal for your sales and marketing users who need access to the mobile app on the go. Both profiles can then use the mobile app to personalize the tabs they need for their role. If you have multiple Lightning apps available to different users profiles, the profiles also get access to the mobile app.
Personalize Tabs for the Mobile App In Lightning Experience on desktop, users access the Lightning app you created. Go to a list view and open it in a new tab. This adds the list view to the mobile navigation and enable users to be productive in the mobile app.
986 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
After adding tabs, users can edit the mobile navigation items, edit item names, and reorder the items.
987 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
When users log in to the mobile app, the App Launcher lets them switch to the customized Lightning app. For more information, see Customize the Salesforce Mobile App.
The actions you added are displayed on the home page screen with the components you added to the template in the App Builder.
988 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder
989 Extend Salesforce with Clicks, Not Code Activate Lightning Experience Home Pages
Activate Lightning Experience Home Pages
Is your custom home page ready for your users? Use the Activation function inside the Lightning EDITIONS App Builder to get the page out to them. You have three activation options. You can make your custom home page the default home page for all users, assign it to specific Lightning apps, or assign Lightning App Builder it to app-and-profile combinations. Assigning the page to a Lightning app or app-and-profile available in: both Salesforce combination gives your users access to a home page customized for the context they’re working Classic and Lightning in. Experience
1. Create a home page or open an existing one in the Lightning App Builder. Lightning Home and utility 2. If you opened a home page that is ready for your users and doesn’t need editing, click Activation. bar pages available in: Lightning Experience 3. If you created a page or opened a page that needs adjustment, make the necessary changes, click Save, and then click Activate. Lightning app and record You have a few options for activating a home page. pages available in: both the • Make the page the org default. Salesforce mobile app and Lightning Experience • Make the page the default home page for specific Lightning apps. Email application pane • Assign the page to a combination of Lightning apps and profiles. pages available in: both 4. On the activation screen, click the tab for the option you’ve chosen, and follow the steps to Salesforce Classic and activate the page. Lightning Experience
Tip: You can also assign home pages from Setup. Enter Home in the Quick Find box, Available in: Group and then select Home. Essentials, Professional, Enterprise, Performance, • Classic apps can be viewed in Lightning Experience, but you can’t display different Unlimited, and Developer home pages assigned for specific apps and profiles. Upgrade Classic apps to Lightning Editions apps from the App Manager to make home page assignments. • If you no longer want a page to be an app or org default, redo the activation process for the page, and select the option to remove it as the default. USER PERMISSIONS • If you activate a page and then return to make changes, you don’t have to activate To create and save Lightning it again. Clicking Save after you make your edits pushes the changes to your users. pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration
990 Extend Salesforce with Clicks, Not Code Activate Your Lightning App Page
Activate Your Lightning App Page
To make your custom app page available to users, you must activate it. You can also rename the EDITIONS Lightning page tab, adjust its visibility, and set its position in the navigation list. The Lightning App Builder’s activation feature makes this process easy. Lightning App Builder 1. To open your app page, from Setup, enter Lightning App Builder in the Quick Find available in: both Salesforce box, select Lightning App Builder, and then click Edit next to the page. Classic and Lightning Experience 2. In the Lightning App Builder, click Activation. 3. Update the activation properties, if desired. Lightning Home and utility bar pages available in: You can: Lightning Experience • Change the page’s custom tab label. By default, the label that you give the Lightning page Lightning app and record is used as the label for its custom tab. pages available in: both the • Change the custom tab’s icon. The icon that you choose here is used as the icon for the Salesforce mobile app and page in the mobile app and in Lightning Experience. Lightning Experience
• Adjust the app page custom tab’s visibility. Email application pane Note: If you select System Administrators only, the tab is set to Default On pages available in: both for System Administrators. For all other users, it’s set to Default Off and doesn’t Salesforce Classic and Lightning Experience show up in the navigation of the apps it has been assigned to, but users can see the tab in the App Launcher in Lightning Experience and on the All Tabs page in Salesforce Available in: Group Classic. Essentials, Professional, If you select Active for all users, the tab is set to Default On for all users. It Enterprise, Performance, appears in the visible tabs for its associated app, in the App Launcher in Lightning Unlimited, and Developer Experience, and on the All Tabs page in Salesforce Classic. Editions
4. Add the page to one or more Lightning apps. USER PERMISSIONS Adding your app page to Lightning Experience makes it available to users viewing the app on desktop and in the Salesforce mobile app. To create and save Lightning pages in the Lightning App 5. Set the page’s position in the Salesforce “Mobile Only” app navigation. Builder: The first item that you put in the mobile navigation list becomes your users’ landing page. • Customize Application To view Lightning pages in 6. Click Activate. the Lightning App Builder: Your Lightning page is now ready for your mobile and Lightning Experience users! • View Setup and Configuration To enable your users to personalize the app with their favorite tabs, create a new Lightning App in the App Manager. They can then use the tabs in the Salesforce mobile app.
Tip: You can give your app page a custom icon image by editing the style of the page’s custom tab in Setup.
SEE ALSO: Create Lightning Page Tabs Tab Settings
991 Extend Salesforce with Clicks, Not Code Create Lightning Page Tabs
Create Lightning Page Tabs
Before you can include a Lightning app page in the Salesforce mobile apps or in a Lightning app, EDITIONS you must create a custom tab for it. When you first activate an app page in the Lightning App Builder, a tab is created for the page as Available in: both Salesforce part of the activation process. You can also create a tab for the page manually in Setup before you Classic (not available in all activate it. orgs) and Lightning Experience You can create a custom tab only for an App Page type of Lightning page. 1. From Setup, enter Tabs in the Quick Find box, then select Tabs. Available in: All editions 2. Click New in the Lightning Page Tabs related list. USER PERMISSIONS 3. Choose a Lightning page for the tab. 4. Enter a label. To create and edit custom tabs: This text is used as the display name for the Lightning page. • Customize Application 5. Select a tab style to set a color scheme and icon for the Lightning page tab. 6. Enter a description of the tab, if desired, and click Next. 7. Choose the user profiles the new custom tab is available for.
Note: In Salesforce Classic, the Default On and Default Off options for Lightning page tabs don’t work the same way as for other custom tabs. The Lightning page menu item appears for the selected profiles in Salesforce for Android and Salesforce for iOS whether you choose Default On or Default Off. Select the Tab Hidden option to hide the Lightning page for the selected profiles.
8. Click Save.
Tip: When creating a custom icon for your Lightning page tab, follow these image guidelines. The icon should: • Be less than 10k in size • Be 120 x 120 pixels • Be a PNG with a transparent background • Have a resolution of 72 dpi • Not include a color background • Not include outer shadows on the inner icon graphic
992 Extend Salesforce with Clicks, Not Code Create and Configure Lightning Experience Record Pages
Create and Configure Lightning Experience Record Pages
Use the Lightning App Builder to add, remove, or reorder components on a record page to give EDITIONS users a customized view for each object’s records. 1. Create a record page for Lightning Experience in one of these ways. Lightning App Builder available in: both Salesforce a. From the Setup menu on a record page, select Edit Page. Classic and Lightning Experience
Lightning Home and utility bar pages available in: Lightning Experience
Lightning app and record pages available in: both the Salesforce mobile app and Lightning Experience
Email application pane pages available in: both Salesforce Classic and Lightning Experience
Available in: Group Essentials, Professional, When you select Edit Page for the first time, Salesforce makes a copy of the standard page. Enterprise, Performance, This copy is what you edit in the Lightning App Builder. If a customized page exists and is Unlimited, and Developer active, selecting Edit Page opens that page to edit. Editions b. Create a page from the Lightning App Builder list page in Setup. To find it, enter App Builder in the Quick Find box, then select Lightning App Builder. USER PERMISSIONS To create an empty page, select a page template. To create a page prepopulated with standard components, clone the system default page. To create and save Lightning pages in the Lightning App c. Clone an existing custom Lightning page from its detail page or from the Lightning page Builder: list in Setup. • Customize Application d. Click New Page from the Pages list inside the Lightning App Builder. To view Lightning pages in the Lightning App Builder: 2. In the Lightning App Builder, add, edit, or remove components to change the page’s layout. • View Setup and Reorder components by dragging them around the canvas. Configuration 3. In the page properties, give your customized page a unique, descriptive label. To get to the page properties, click Page from the breadcrumb at the top of the properties pane.
4. Save your page.
993 Extend Salesforce with Clicks, Not Code Add and Customize Tabs on Lightning Pages Using the Lightning App Builder
Hang on, you’re not done yet! To make your customized record page available to your Lightning Experience and mobile users, you must activate it. You can activate the page from the Save dialog when you save it for the first time or later using the Activation button.
SEE ALSO: Add and Customize Tabs on Lightning Pages Using the Lightning App Builder Lightning App Builder Considerations Lightning App Builder Limits and Limitations
Add and Customize Tabs on Lightning Pages Using the Lightning App Builder
With the Lightning App Builder, you can create, update, delete, and change the order of tabs and EDITIONS tab sets on record and Home pages in Lightning Experience. Configure the tabs that your users see, name them whatever you like, and add components to each tab. Lightning App Builder 1. Open a Home or record page for Lightning Experience in one of these ways. available in: both Salesforce Classic and Lightning a. From the Setup menu, select Edit Page. Experience
Lightning Home and utility bar pages available in: Lightning Experience
Lightning app and record pages available in: both the Salesforce mobile app and Lightning Experience
Email application pane pages available in: both Salesforce Classic and Lightning Experience
Available in: Group Essentials, Professional, Enterprise, Performance, When you select Edit Page for the first time, Salesforce makes a copy of the standard page. Unlimited, and Developer This copy is what you edit in the Lightning App Builder. If a customized page exists and is Editions active, selecting Edit Page opens that page to edit.
b. Open a page from the Lightning App Builder list page in Setup. To find it, enter App USER PERMISSIONS Builder in the Quick Find box, then select Lightning App Builder. To create and save Lightning 2. Add a Tabs component to the page. pages in the Lightning App A default set of tabs is added. Builder: 3. To add a tab, click Add Tab in the Tabs component properties. • Customize Application 4. Customize a tab by clicking it in the properties pane. You can select a different standard label To view Lightning pages in or click Custom and enter the tab name you want. the Lightning App Builder: • View Setup and Configuration
994 Extend Salesforce with Clicks, Not Code Add and Customize Tabs on Lightning Pages Using the Lightning App Builder
Note: Custom tab labels in the Tabs component—including those installed from packages—aren’t translated. For example, if you create a custom Goals tab in English, then view the page as a user whose language is set to French, the tab still displays as Goals. However, you can use the {!$Label.customLabelName} expression in a component label or attribute to represent a custom label that you create in Setup using the custom label feature. For more information, see “Build Localized Component Labels and Attribute Values on Lightning Pages with Custom Labels on page 979.”
5. To add your first component to a tab, select the tab on the canvas and then drop the component directly below it.
6. Reorder tabs in the Tabs properties pane by dragging and dropping them into position. You can’t drag and drop individual tabs on the canvas.
SEE ALSO: Create and Configure Lightning Experience Record Pages Lightning App Builder Considerations Personalize the Navigation Bar in Lightning Experience
995 Extend Salesforce with Clicks, Not Code Activate Lightning Experience Record Pages
Activate Lightning Experience Record Pages
Is your custom record page ready for your users? Use the Activation function inside the Lightning EDITIONS App Builder to get the page out to them. You can make your custom record page the default record page for all users, assign it to specific Lightning apps, or assign it to record types and profiles. Lightning App Builder Assigning the page to a Lightning app, record type, or profile gives your users access to a record available in: both Salesforce page customized for the context they’re working in. Classic and Lightning 1. Create a record page or open an existing one in the Lightning App Builder. Experience 2. If you opened a record page that is ready for your users and doesn’t need editing, click Lightning Home and utility Activation. bar pages available in: Lightning Experience 3. If you created a page or opened a page that needs adjustment, make the necessary changes, click Save, and then click Activate. Lightning app and record You have a few options for activating a record page. pages available in: both the • Make the page the org default for the object. Salesforce mobile app and Lightning Experience • Make the page the default object record page for specific Lightning apps. Email application pane • Assign the page to a combination of Lightning apps, record types, and profiles. pages available in: both • Assign the page to a form factor, such as a desktop or phone. Salesforce Classic and Lightning Experience 4. On the activation screen, click the tab for the option you’ve chosen, and follow the steps to activate the page. Available in: Group Essentials, Professional, SEE ALSO: Enterprise, Performance, Create and Configure Lightning Experience Record Pages Unlimited, and Developer Editions Lightning App Builder Considerations
USER PERMISSIONS
To create and save Lightning pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration
Break Up Your Record Details with Dynamic Forms
The more fields that you have on your page layout, the more that the Record Detail component EDITIONS becomes a monolithic block of fields that you can’t customize. With Dynamic Forms, you can migrate the fields and sections from your page layout as individual components into the Lightning App Available in: Lightning Builder. Then, you can configure them just like the rest of the components on the page, and give Experience the users of that page only the fields and sections that they need. Dynamic Forms benefits you three ways. Available in: Group, Professional, Enterprise, • An instant upgrade from page layouts: Place fields and sections wherever you want. Performance, Unlimited, • Dynamic layouts: Use visibility rules to show and hide fields and sections. and Developer Editions
996 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
• Simpler layout management: – Manage the fields and sections on your pages in the Lightning App Builder without touching the page layout editor. – Reduce the number of page layouts you need with component visibility rules. – Take advantage of a single assignment model for the Lightning page instead of the dual model of assigning a Lightning page and a page layout.
You can start using Dynamic Forms in two ways. • Create a custom object record page, then drag Field and Field Section components onto it. • Open an existing record page and migrate its record details using the migration wizard. Dynamic Forms doesn’t only affect how your users see fields on a record page. It also affects what they see when they click to edit, create, or clone a record. On Dynamic Forms-based pages, the fields that users see when creating, editing, or cloning come from the fields on the page, not from the page layout.
Note: Dynamic Forms is supported on record pages for custom objects only.
Migrate a Record Page to Dynamic Forms With Dynamic Forms, you can migrate the fields and sections from your existing record pages as individual components in the Lightning App Builder. Then you can configure them just like the rest of the components on the page, and give the users of that page only the fields and sections that they need. Dynamic Forms is supported only for custom objects. Required and Read-Only Fields in Dynamic Forms Universally required fields retain their status when you’re working with them on a Dynamic Forms-based Lightning page. However, you can make other fields required or read-only just for the page you’re working on. Dynamic Forms and Mobile The Dynamic Forms Field Section component and the Field components that go inside it are desktop-only. But your mobile users are still covered. The Record Detail - Mobile component gives your mobile users a way to see the record details on a Dynamic Forms-enabled page.
997 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
Dynamic Forms Tips and Considerations Keep these tips and considerations in mind when working with Dynamic Forms. Dynamic Forms Limitations Keep these limitations in mind when working with Dynamic Forms. Dynamic Forms Known Issues Keep these known issues in mind when working with Dynamic Forms.
Migrate a Record Page to Dynamic Forms
With Dynamic Forms, you can migrate the fields and sections from your existing record pages as EDITIONS individual components in the Lightning App Builder. Then you can configure them just like the rest of the components on the page, and give the users of that page only the fields and sections that Available in: Lightning they need. Dynamic Forms is supported only for custom objects. Experience 1. Open an existing custom object record page for Lightning Experience in one of these ways. Available in: Group, a. From the Setup menu on a record page, select Edit Page. Professional, Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create and save Lightning pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration
When you select Edit Page for the first time, Salesforce makes a copy of the standard page. This copy is what you edit in the Lightning App Builder. If a customized page exists and is active, selecting Edit Page opens that page to edit.
b. From the Object Manager in Setup, open a custom object, then select Lightning Record Pages. c. Open a custom object record page from the Lightning App Builder list page in Setup. To find it, enter App Builder in the Quick Find box, then select Lightning App Builder.
2. Click the Record Detail component. 3. In the component detail pane, click Upgrade Now to start the Dynamic Forms migration wizard.
998 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
4. Walk through the wizard, and select which page layout has the fields that you want to migrate to the page. Why choose a page layout when the Fields tab has all the fields you need? Well, the upgrade wizard takes the fields and sections from the page layout you choose and automatically adds them to your page. Just a few clicks and you’re done. No need to drag all those fields manually. As long as a field is inside a Field Section component, you can put it anywhere on the page, even inside tabs.
Note: By default, fields and field sections are migrated into an Accordion component to prevent page performance issues. If you disable this option, migrated fields and sections are added to the page in place of the Record Detail component. If the Record Detail was in a region that's visible on page load, and you have a lot of fields, disabling this option can significantly impair page performance.
As part of the migration process, the Record Detail component is removed from the page, replaced with fields and sections that you can configure and place anywhere you like.
999 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
If your record page supports the phone form factor, a “Record Detail - Mobile” component is added to your page as part of the migration. This new component is unique to Dynamic Forms. It displays the standard record detail fields and sections to your users when they view the page on a mobile device.
SEE ALSO: Dynamic Forms and Mobile Break Up Your Record Details with Dynamic Forms
Required and Read-Only Fields in Dynamic Forms
Universally required fields retain their status when you’re working with them on a Dynamic EDITIONS Forms-based Lightning page. However, you can make other fields required or read-only just for the page you’re working on. Available in: Lightning A field set to Required in the field definition in the Object Manager is a universally required field. Experience Its Required value isn’t editable in the field’s properties in the Lightning App Builder property panel. Also, the read-only status of some standard fields—such as Created By, Last Modified By, Owner, Available in: Group, and Record Type—can’t be changed in the Lightning App Builder property panel. Professional, Enterprise, Performance, Unlimited, Fields marked as Required or Read-Only on a page layout retain that state when migrated into a and Developer Editions Dynamic Forms-based page. You can find all universally required fields for your page in the Universally Required Fields section of the Fields palette. Fields that you make required at the page layout level or in the Lightning App Builder property panel don’t appear in the Universally Required Fields section of the palette. If you set a field on a Lightning page to Required or Read-Only in the Lightning App Builder property panel, the behavior applies only to the field on that page, not all instances of the field.
1000 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
Be sure to include required fields on your Lightning pages. They aren’t added automatically. If there are required fields missing from the page, and the missing required fields don't have values, users can’t save a record after editing, creating, or cloning it. Don’t hide universally required fields with visibility filters.
SEE ALSO: Break Up Your Record Details with Dynamic Forms Require Field Input to Ensure Data Quality Considerations for Universally Required Fields
Dynamic Forms and Mobile
The Dynamic Forms Field Section component and the Field components that go inside it are EDITIONS desktop-only. But your mobile users are still covered. The Record Detail - Mobile component gives your mobile users a way to see the record details on a Dynamic Forms-enabled page. Available in: Lightning When you migrate a record page that supports both desktop and phone to Dynamic Forms, a Experience Record Detail - Mobile component is added to the page for you. Available in: Group, But when you create a fresh page using a template that supports both desktop and phone, after Professional, Enterprise, adding the fields and field sections, you must add the Record Detail - Mobile component to the Performance, Unlimited, page yourself. and Developer Editions The Record Detail - Mobile component wraps fields from the Record Detail component into a mobile-only container. So, on pages that support both desktop and phone, your desktop users see the Field Section components, and your mobile users see the Record Detail - Mobile component.
Example: Here’s what a page that you create in desktop mode in the Lightning App Builder looks like when viewed on a phone. The Field Section components just below the Highlights Panel on desktop are dropped on mobile, and the Record Detail - Mobile component takes over to deliver the sections and fields.
1001 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
The Record Detail - Mobile component displays with an “Unsupported form factor” message when viewed on a page in the Lightning App Builder in Desktop preview mode.
SEE ALSO: Migrate a Record Page to Dynamic Forms Break Up Your Record Details with Dynamic Forms
Dynamic Forms Tips and Considerations
Keep these tips and considerations in mind when working with Dynamic Forms. EDITIONS
General Considerations Available in: Lightning Experience • When you switch page templates on a page that uses Dynamic Forms, the list of available templates contains only the templates that are supported for your Dynamic Forms-enabled Available in: Group, page. Professional, Enterprise, • The Owner and Record Type fields get special handling in Dynamic Forms. They’re set to Performance, Unlimited, Read-Only, and that state isn’t editable in the properties pane. and Developer Editions • You can add more than one instance of the same field to a Lightning page, but all instances of that field on the page show the same data. • Programmatic versions of the accordion components don’t provide the same functionality as their App Builder counterparts. For example, lightning-accordion and lightning:accordion components don’t currently support lazy loading. • Expanding or collapsing a field section while designing a page has no effect on whether a section is expanded or collapsed for users during runtime. • When you clone a record based on a Dynamic Forms-enabled page that has visibility rules, all the fields referenced in the visibility rules are added to the cloned record, regardless of whether those fields are on the page. • When you save a new record with an empty custom object name, the API populates the custom object name field with the record ID. So make sure that the Name field is on the page and is marked as required.
Visibility Rules and Dynamic Forms • If a field is hidden on a page due to a visibility rule, and a user edits the value of the field, its new or changed value isn’t saved. • Dependent picklist fields don’t respect visibility rules. Even if they have visibility rules assigned to them, dependent picklist fields still appear in the View All Dependencies list. • Component visibility rules on field sections behave differently than they do on fields. Visibility rules on fields are assessed dynamically. Changes a user makes while editing a record can make fields appear and disappear as visibility rules are evaluated. Visibility rules on field sections aren't dynamic and don't react to what a user does while editing. Field section visibility rules are evaluated only after the record is saved.
Tips • We recommend not having both a Record Detail component and field sections on the same page. If you do, users can have issues with the page, including: – Multiple, overlapping save and cancel bars when both are on the page and both in inline edit. – Visibility rules on Field and Field Section components not working properly.
1002 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
– When users create, edit, or clone a record, the fields they see come from the Field Sections on the page, not from the Record Detail. – Field sections are top-down-left-right tab order only, while Record Detail is left-right-top-down tab order, which can cause confusion. As a result, fields inside a Field Section sometimes don’t line up horizontally, while Record Detail fields do.
• Don’t place Field Section components on mobile-only Lightning pages. Field Section components are desktop-only and don’t appear when the page is viewed on a phone. • You can use one Lightning page for both desktop and phone. Add the Record Detail - Mobile component to the same page with your Field Section components. Your desktop users see the Field Section components, and your mobile users see the Record Detail - Mobile component.
SEE ALSO: Dynamic Forms Limitations Dynamic Forms Known Issues Break Up Your Record Details with Dynamic Forms
Dynamic Forms Limitations
Keep these limitations in mind when working with Dynamic Forms. EDITIONS
Limitations Available in: Lightning Experience • Dynamic Forms is supported on record pages for custom objects only. • Dynamic Forms doesn’t work in Internet Explorer 11. Users with IE 11 who try to view a page Available in: Group, that uses Dynamic Forms see a page with an error. Professional, Enterprise, • Dynamic Forms doesn’t work on pages based on pinned region templates and custom templates. Performance, Unlimited, and Developer Editions • Blank spaces aren’t supported. • You can add up to 100 fields per column in a Field Section component. • Only fields and sections containing fields are included when migrating a page to Dynamic Forms. Other elements on the page layout, such as custom links and blank spaces, aren't included. • If the page layout you choose to migrate has more fields and sections than we can handle, we migrate up to the first 100 sections in each region and the first 100 fields in each column. The rest of the fields are dropped, even if they’re required fields. You can manually add the dropped items later. If you change your mind after you make the switch, you can click the undo button ( ) to roll back the changes. • If you convert a section from two columns to one, the new single column can only hold 100 fields. If you had more than 100 fields total between the two columns, when you switch to a single column, the first 100 fields are moved into the single column, and the rest of the fields are dropped. If you change your mind after switching to single column, you can revert the change by immediately clicking the undo button ( ).
1003 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms
• Users can expand or collapse field sections only while in view or inline edit mode, not in the full edit, create, or clone windows.
SEE ALSO: Knowledge Article: Extended Support for Accessing Lightning Experience Using Microsoft Internet Explorer 11 Dynamic Forms Tips and Considerations Dynamic Forms Known Issues Break Up Your Record Details with Dynamic Forms
Dynamic Forms Known Issues
Keep these known issues in mind when working with Dynamic Forms. EDITIONS • Density settings for field sections aren’t respected in Lightning App Builder preview. Lightning App Builder preview always shows the Comfy setting for field sections. Proper density settings Available in: Lightning are applied during runtime. Experience • If you click View All Dependencies from the Path component, the dependencies that you see Available in: Group, come from the record details on the page layout, not from the Dynamic Forms fields on the Professional, Enterprise, page. Performance, Unlimited, • If you create a record from a lookup, the fields on the window that appears come from the and Developer Editions record details, not from the Dynamic Forms fields on the page. • The CurrencyISOCode field doesn’t display as required (with the asterisk) at runtime, although it still behaves as required. • When you hover over fields in the palette, the data types shown are inaccurate. • On a Dynamic Forms-based page, multiple instances of the same lookup field that look up to an object that’s not supported in the UI API result in a page error. See the User Interface API Developer Guide for the list of supported objects. • Fields in two-column Field Section components don’t horizontally align correctly. • For a non-UI API supported object that has a Forms-enabled object as a related list, if you click New from the related list, the parent lookup field doesn't appear in the New dialog. But you can save the new record. • A record’s printable view is based on the fields from its default page layout, not the fields on the Dynamic Forms-based page. • Dynamic Forms field components aren’t supported inside the Macro Builder. When a Dynamic Forms-enabled record page is opened inside of the Macro Builder, the field components don’t appear.
Visibility Rule Known Issues with Dynamic Forms • Visibility rules based on parent object fields don’t work correctly. • When you clone a record based on a Dynamic Forms-enabled page that has visibility rules, all the fields referenced in the visibility rules are added to the cloned record, regardless of whether those fields are on the page. The field value used in the rule evaluation and the field’s saved value on the cloned record can vary, depending on the cloning user’s access to the field used in the visibility rule. – If the user has read and write access to the field used in the visibility rule, and the field has a value, the source record's original value is used in the rule evaluation and saved to the cloned record. – If the user has read and write access to the field used in the visibility rule, and the field has no value, the source record's blank value is used in the rule evaluation, but the cloned record saves with the field’s default value. – If the user has only read access to the field used in the visibility rule, the source record's original value is used in the rule evaluation, but the cloned record saves with the field’s default value.
1004 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
– If the user doesn’t have read or write access to the field used in the visibility rule, the source value is treated as blank, and the cloned record saves with the field’s default value.
SEE ALSO: Dynamic Forms Tips and Considerations Dynamic Forms Limitations Break Up Your Record Details with Dynamic Forms
Dynamic Interactions in the Lightning App Builder
Dynamic Interactions is part of our continuing drive to make Lightning pages more dynamic and EDITIONS interactive. With Dynamic Interactions, an event occurring in one component on a Lightning page, such as the user clicking an item in a list view, can update other components on the page. Dynamic Available in: Lightning Interactions lets admins create applications with components that communicate and transform Experience based on user interactions, all in the Lightning App Builder UI. It unlocks capabilities that previously were reserved only for developers. Available in: Group, To get the most out of Dynamic Interactions, admins and developers work together. Professional, Enterprise, Performance, Unlimited, Developers write custom components that power the Dynamic Interactions. The developer defines and Developer Editions the events that the component supports and then exposes the events in the Lightning App Builder UI. Then, in the Lightning App Builder, an admin configures the event by setting up the interactions between the components. Dynamic Interactions has four major building blocks. • Event—Anything that can trigger an interaction, such as a mouse click, a button press, or a change in a field’s value. • Interaction—An activity that happens between the source and the target. • Source—The item triggering the event. Currently, only custom Lightning web components and the Dynamic Actions Bar component (Pilot) on page 969 are supported as sources. • Target—The item that’s the target of the interaction. Any component on a Lightning page can be a target. An event occurring in one component (the source) can trigger changes in one or more other components on the page (the targets). A single source can have multiple targets.
Note: Dynamic Interactions is supported only on app pages, and interactions are limited to activity between components.
Example: Kai (they/them) and Rina (she/her) are an admin and developer team. Kai wants to give their on-the-go users an easy way to check the location of various accounts so that they can plan efficient site visits using a simple app page. Kai enlists Rina’s help to make this happen. As a developer, Rina knows that she can wire up events between components using code. But she wants to give Kai the power to configure the event interactions in the way that they need to without having to come back to her every time a change is necessary. Rina creates a custom source component for Kai, plus two other components to act as event targets. After installing the new components in their org, Kai has an app page with three custom components: Account List, Account Detail, and Account Location (a map).
1005 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
The source component is the Account List on the left. It has an Item Selected event enabled, which Rina exposed to the Lightning App Builder UI using new Dynamic Interactions code. After Kai finishes configuring the event interactions, when a user clicks a list item in the Account List component, the event fires. The Account Detail component updates to show that account’s details. At the same time, the Account Location component pinpoints that account’s location on a map. Every new click or tap on an account in the list results in updating the content in the other two components.
SEE ALSO: Lightning Web Components Dev Guide: Configure a Component for Dynamic Interactions in the Lightning App Builder Lightning Web Components Dev Guide: XML Configuration File Elements
1006 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
Configure Interactions in the Lightning App Builder
After you have a custom source component with exposed events in your org, you can assign event EDITIONS targets and configure the event interactions in the Lightning App Builder. 1. From Setup, in the Quick Find box, enter App Builder, then select Lightning App Builder. Available in: Lightning Experience 2. Edit an existing app page, or click New to create one. 3. In the Lightning App Builder, add a custom source component to your page. Available in: Group, If you don’t have target components on your page, add those too. Professional, Enterprise, Performance, Unlimited, 4. Click the source component on the canvas. and Developer Editions 5. In the properties pane, click the Interactions tab. 6. Under the desired event, click Add Interaction. USER PERMISSIONS The properties pane changes to show you the interaction details. To create and save Lightning 7. Select an interaction. pages in the Lightning App Currently, the only interaction available is Update Properties. Builder: • Customize Application 8. Select the target component for the interaction. To view Lightning pages in Components are listed with their region location to help you select the correct component the Lightning App Builder: when you work on pages with components spread across multiple regions. • View Setup and Configuration
9. Configure the target component properties. When you select a target component, its properties appear in the Interaction Details pane. There you define the value that you want each target property to have when the interaction happens. If you leave a target property blank, its value remains unchanged when the event triggers. To use an expression to define a target property value dynamically, click . Checkbox properties have a No change option. If you’ve changed the value of a checkbox property, use this option to reset it back to its original value, and to indicate that you want its value to remain unchanged when the event triggers.
10. Save the page.
SEE ALSO: Dynamic Interactions in the Lightning App Builder Dynamic Interactions Considerations
1007 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
Expressions in Dynamic Interactions Target Properties
An expression is a small chunk of code that can be evaluated to a value. It can be as literal and EDITIONS simple as 1+1 or a more complex combination of variables, operators, and functions. One expression is supported for Dynamic Interactions in the Lightning App Builder: Available in: Lightning {!Event.eventPropertyName}. You can use this expression when setting target Experience component property values in the Lightning App Builder UI and in Metadata API. The value of the eventPropertyName part of the expression varies based on which properties the developer Available in: Group, makes available for the event in the source component. Professional, Enterprise, Performance, Unlimited, Note: If you see the button on a target property, you can set its value with an expression. and Developer Editions With an expression, you can pass a value, such as a record ID or an API name, to the target item. Then when the event fires, the target item can use that value. Using an expression to define a property value makes the event interaction dynamic. We can illustrate this with an example of an app page with custom Account List and Account Location components. Here, an admin is configuring an interaction between the Account List source component and the Account Location target component.
The goal for the interaction in this example is that when a user clicks an account in the list, the Account Location component updates to show the selected account’s location as a point on a map. But the Account Location component needs to know the record ID of the selected account to do that. Passing the record ID into the Account Location component tells the component which record to look at to pull the address information. In this case, the developer made the recId property available as part of the event, so the target value can be set to the active list item’s record ID using the {!Event.recId} expression.
1008 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder
Why not enter a 15- or 18-digit record ID into the field? If you do, any item clicked in the Account List always resolves to that one record ID, which isn’t dynamic and is incorrect. If the developer makes more than one target property available, you can set the property to be passed in by starting to type the expression in the field. After the period, you can use autocomplete to select which property to use in the expression. But don’t forget to add the ending bracket } after you make your selection.
Note: Expression autocomplete doesn’t work when: • Using expressions in the rich text editor • Typing an expression in a text field without first clicking the expression button ( )
SEE ALSO: Configure Interactions in the Lightning App Builder Dynamic Interactions Limits and Limitations Dynamic Interactions in the Lightning App Builder
Dynamic Interactions Considerations
Keep these considerations in mind when working with Dynamic Interactions. EDITIONS • Informational components within target components are ignored when the target component’s properties are shown in the Event property editor. Available in: Lightning • If you switch page templates for a page that contains Dynamic Interactions, the available Experience template list shows only templates that support Dynamic Interactions. Available in: Group, • Aura components re-render when an interaction targeting them is triggered. Professional, Enterprise, • Autocomplete doesn’t work when entering an expression in the rich text editor. Performance, Unlimited, and Developer Editions
1009 Extend Salesforce with Clicks, Not Code Guidance for App Builder
• After a component’s event metadata is used on a Lightning page or released as part of a managed package, certain breaking changes aren’t allowed, such as removing the event, renaming a property, or changing a property type.
Dynamic Interactions Limits and Limitations
Keep these considerations in mind when working with Dynamic Interactions in the Lightning App EDITIONS Builder. • Dynamic Interactions is supported only on app pages. Available in: Lightning • Only LWC custom components can be source components, but any component present on Experience the page (Aura or LWC) can be a target. Available in: Group, • Dynamic Interactions isn’t supported on pages based on custom page templates. Professional, Enterprise, • Only String and Rich Text type properties can use expressions to define their values. Performance, Unlimited, • The “required” property restriction isn’t respected when defining a new value for a target and Developer Editions property in Dynamic Interactions, regardless of its type or whether it’s defined with an expression. • Event is the only context supported for expressions in interactions. • You can use expressions only for properties of type String, Integer, and Boolean. • You can’t set a target property value as an array or list of values, such as a multi-select picklist. • You can set a target property value of a String attribute to empty or a Boolean attribute to false using Metadata API but not in the Lightning App Builder UI. • Dynamic Interactions doesn’t work in the Mobile Only app in the Salesforce mobile app or in the legacy tablet mobile experience. • When a dependent property is autopopulated with a value based on a selection you made or a value you entered in another property, the autopopulated value isn’t saved unless you “touch” the dependent property field by clicking into it or tabbing to it.
Guidance for App Builder
Get suggestions for improving your Lightning pages just when you need them. Guidance for App EDITIONS Builder gives you feedback for enhancing your Lightning pages right in the design phase, via tips in a docked prompt. Available in: Lightning Tips are available for categories such as performance, usability, and structural issues. Some issues Experience that the tips cover are also captured in the Salesforce Optimizer report. For example, if two components on a page are identical, you see a tip that tells you so. After you fix the issue, the tip Available in: Group disappears. Essentials, Professional, Enterprise, Performance, Unlimited, and Developer Editions
1010 Extend Salesforce with Clicks, Not Code Guidance for App Builder
If there are tips available for your page, you see an indicator icon on the Help menu. To hide the tips docked prompt while you design your page, go to the Help menu and select Mute Tips. You can reopen the tips prompt by selecting View Tips.
SEE ALSO: Lightning App Builder Considerations Salesforce Help: Improve Your Implementation with Salesforce Optimizer
1011 Extend Salesforce with Clicks, Not Code Lightning Page Performance
Lightning Page Performance
Several factors can negatively affect your Lightning page’s performance at runtime. For example, EDITIONS your users can run into page performance issues if they aren’t using the latest version of a Salesforce recommended browser to view the page. Some factors you can control, and others you can’t. Here Lightning App Builder are some ways you can improve performance while configuring your page in the Lightning App available in: both Salesforce Builder. Classic and Lightning Consider the number, type, and placement of components on the page. These design-related issues Experience can cause a page to load slowly: Lightning Home and utility • Too many components visible on page load bar pages available in: • Too many heavy-impact related lists visible, especially those lists with multiple-object Lightning Experience relationships Lightning app and record • Too many fields in your Record Detail component pages available in: both the Salesforce mobile app and • Having the News or Twitter component visible Lightning Experience If your page falls into one or more of these categories, we recommend that you move some components into a non-default tab or Accordion component section, unless you’re designing the Email application pane page for blind or low-vision users. For the heavy-impact related lists, we recommend that you move pages available in: both the related lists lower on their respective page layouts so that they aren’t part of the initial page Salesforce Classic and Lightning Experience load. If your Record Detail component has many fields, we recommend that you reduce the fields on Available in: Group your page layout to fewer than 60. Alternatively, move the Record Detail component into a Essentials, Professional, non-default tab or Accordion section so that it’s not part of the initial page load. Enterprise, Performance, Unlimited, and Developer For pages that are viewed on a phone, we recommend a maximum of eight visible components Editions per page. If a page has more than eight, put some in a tab or Accordion section or hide them for mobile with a visibility filter. You can see how your pages are performing in the Lightning Usage App from the App Launcher. It shows you the most used pages in your org and their page load time by browser or by page. Performance Analysis for App Builder automatically runs when you build a page. If your page performance is poor or moderate, recommendations to improve performance appear. You can manually check a Lightning record page’s runtime performance at any time by clicking Analyze from the Lightning App Builder toolbar. It assesses page performance based on all visible standard and custom components on the page. Components in nondefault tabs and Accordion sections aren’t analyzed. The User Metrics card provides 90 days of your org’s user data such as browser speeds, network latency, and number of cores. Use this information to help you decide which Performance Analysis for App Builder recommendations to take.
Note: Salesforce measures performance in Experienced Page Time (EPT). The page load time mentioned here and in the Performance Analysis for App Builder tool is EPT.
Considerations • If a page has more than 5 related lists or more than 25 fields in the record detail, users can encounter performance issues when viewing the page in the Salesforce mobile app. • In the Performance Analysis for App Builder tool: – Components that are restricted to the desktop form factor via a visibility rule aren’t included in the phone form factor performance assessment. – Analysis of page performance on a phone is available only on pages whose template supports the phone form factor.
1012 Extend Salesforce with Clicks, Not Code Lightning App Builder Considerations
– Components aren't the only factors influencing page load time, so the numbers in the component impact chart don't add up to 100% of the predicted page load time. – Analysis of pages for the desktop form factor is measured in seconds. For the phone form factor, the page is scored based on the components that are visible when the page loads on a phone. – User metrics are org-specific or page-specific data. Previously activated pages display metrics from visits to that page. New pages display metrics from visits to all org pages. Metrics displayed in a sandbox can differ from metrics in production.
SEE ALSO: Supported Browsers and Devices Technical Requirements and Performance Best Practices Measure Performance for Your Salesforce Org Get Lightning Experience Adoption Insights with the Lightning Usage App
Lightning App Builder Considerations
Keep these considerations in mind when working with Lightning pages and Lightning apps in the EDITIONS Lightning App Builder. Lightning App Builder General available in: both Salesforce Classic and Lightning • The Lightning App Builder supports the same browsers as Lightning Experience and isn’t Experience supported on mobile browsers. The minimum recommended resolution for the Lightning App Lightning Home and utility Builder is 1280x1024. bar pages available in: • To reduce user confusion, give each tab and Accordion section a unique label. Lightning Experience • The Lightning App Builder palette displays only the components that are available for the Lightning app and record devices supported by the page template. For example, you’re working on a page whose template pages available in: both the supports only desktop, the component palette contains components that support desktop, Salesforce mobile app and whether they support desktop only or both desktop and phone. Lightning Experience • When you open a record page in the Lightning App Builder, you see only the components that are available for the object tied to that page. For person account pages, some of the components Email application pane pages available in: both you see apply only to business accounts. Salesforce Classic and • When viewing a page in the Lightning App Builder, the form factor switcher displays only the Lightning Experience devices that the page template supports. • If the Lightning App Builder canvas view is switched to a form factor that a component on the Available in: Group page doesn’t support, that component displays as a placeholder with a warning. Essentials, Professional, Enterprise, Performance, • When a component is viewed on a device that the component doesn’t support, it’s dropped Unlimited, and Developer from the page. Editions • If you’re curious about a component, click it to see more information in the properties pane. • You can create and edit a record page even if you don’t have permission to access the object that the page is associated with. You can add, remove, delete, and reconfigure components on the page, but you don’t see any of the content for the components that are based on that object. • In Salesforce Classic, Lightning page tabs don’t display on the All Tabs page when you click . Lightning page tabs also don’t appear in the Available Tabs list when you customize the tabs for your apps.
1013 Extend Salesforce with Clicks, Not Code Lightning App Builder Considerations
• When editing navigation items in a Lightning app, consider how many items you include. Users can’t remove the items you include in the navigation bar, and they can’t personalize the navigation bar when it contains more than 50 items. For example, if you include 32 items in an app’s navigation bar, users can add 18 more personal items. Users can personalize the navigation to add or move items, but users can't remove or rename the items that you add. • Put the activity timeline component at the bottom of a layout, with no other components beneath it. • On Lightning Experience record pages, a Record Detail component that contains more than four external lookup fields breaks the page at runtime.
Page Templates • The Three Regions template and the pinned region templates are designed with Lightning console apps in mind. They feature a main region and two sidebars with fixed proportional widths. The main region is 50%, and the side region widths are each 25%. Three-region templates require more screen width to display correctly. Three-region templates can display incorrectly on certain devices or monitors with low resolutions. • When switching page templates, if a region in the template that you’re switching to has more than 25 components mapped to it, all components after the 25th are dropped from the page. You can proceed with the template swap, but you must then manually add the dropped components from the palette and reconfigure their properties. • The console pinned region templates let users view and work with records while navigating subtabs in console apps. These templates also work in apps with standard navigation. However, we recommend that you use a non-pinned region template in standard apps because those apps don’t benefit from a pinned region. When working with pinned region templates, keep the following in mind. – The templates are available only for record pages. – Pinned regions don’t support theming. For example, if you use custom theming to brand your app with the color green, the pinned region doesn’t apply the green color.
Page Activation and Assignment • If a device isn’t on the options list when you try to assign a Lightning page as the org default, the page template doesn’t support it. • You can see which record pages are activated for which Lightning app and which form factor in the Lightning Record Pages related list in the Object Manager. • If you no longer want a page to be an app or org default, redo the activation process for the page, and select the option to remove it as the default. • If you activate a page and then return to make changes, you don’t have to activate it again. Clicking Save after you make your edits pushes the changes to your users. • If you no longer want a page assigned to a particular form factor, redo the activation process, and select the option to remove it. • If you activate a page for only one form factor, you can add support for another form factor later as long as the page’s template supports it. • Changes that you make to Lightning record page assignments aren’t immediately reflected in the Salesforce mobile app. To see a newly assigned record page, close and restart the Salesforce mobile app. • If there are no custom app-level page assignments set for the Service Console or Lightning Sales Console apps, users viewing those apps in the Salesforce mobile app see the org default record page assigned to the object instead of the system app default record page. • If you assign a custom record page as the org-wide default for an object, it becomes the default page for that object across all your Lightning apps. It also appears as the default record page for that object in Classic apps when you open them in Lightning Experience. • Accounts and person accounts have different standard default pages to begin with. However, when you create a Lightning page for accounts and assign it as the default for an org or an app, that page becomes the org or app default for business accounts and
1014 Extend Salesforce with Clicks, Not Code Considerations and Limitations for Flows in Lightning Pages
person accounts. To display a custom record page for person accounts, create a custom account record page, then assign it to the person account record type.
Component Visibility Rules • If a visibility filter assigns a component to “Device equals desktop,” the component appears on a page when viewed in Lightning Experience on a desktop and when viewed in a browser on an iPad. • The Salesforce mobile app on an iPad uses the phone form factor. Salesforce viewed in a browser on an iPad uses the desktop form factor. These form factors affect components on record pages differently. – If the visibility filter is “Device not equal to desktop” or “Device equals phone,” the component appears on record pages in the Salesforce mobile app on a phone and an iPad. It doesn’t appear on pages viewed in a browser on an iPad. – If the visibility filter is “Device not equal to phone,” the component appears on record pages in Lightning Experience on a desktop and on pages viewed in a browser on an iPad. It doesn’t appear in the Salesforce mobile app on a phone or an iPad.
Pages and Packages • If you package a Lightning page that references protected labels, then if a subscriber org clones that page, the protected labels cause the components that use them on the cloned page to be invalid. • A Lightning page installed from a managed package appears in the Lightning pages list with a Clone option rather than Edit or Delete. The Edit and Delete buttons are also replaced with Clone on the installed page’s detail page.
SEE ALSO: Create and Configure Lightning Experience Record Pages Lightning App Builder Limits and Limitations Supported Browsers and Devices
Considerations and Limitations for Flows in Lightning Pages
Here are some things to keep in mind when you add a flow component to a Lightning page. EDITIONS Lightning pages always use Lightning runtime, so also review Limitations of Lightning Runtime for Flows. Available in: both Salesforce Classic and Lightning Running Flows from a Lightning Page Experience When a user opens a Lightning page that has a flow component, the flow runs when the page loads. Make sure that the flow doesn’t perform any actions – such as create or delete records Available in: Essentials, – before the first screen. Professional, Enterprise, Performance, Unlimited, Input Variable Limitations and Developer Editions • These variables aren’t supported. – Collection variables – Record variables – Record collection variables
• The component supports only manually entered values for input variables. • Text input variables accept a maximum length of 4,000 characters.
1015 Extend Salesforce with Clicks, Not Code Lightning App Builder Limits and Limitations
Deployment Considerations Change sets and the Metadata API deploy all flows as inactive, which users can’t run. If you deploy a Lightning page (known as FlexiPage in the API) that contains a flow component, make sure to activate the flow.
Lightning App Builder Limits and Limitations
Keep these limits and limitations in mind when working with Lightning pages and Lightning apps EDITIONS in the Lightning App Builder. • In Salesforce Classic, the Default On and Default Off options for Lightning page tabs don’t work Lightning App Builder the same way as for other custom tabs. The Lightning page menu item appears for the selected available in: both Salesforce profiles in Salesforce for Android, Salesforce for iOS, and Salesforce mobile web whether you Classic and Lightning choose Default On or Default Off. Select the Tab Hidden option to hide the Lightning page Experience for the selected profiles. Lightning Home and utility • You can place up to 100 tabs in a Tabs component. bar pages available in: • A Lightning page region can contain up to 100 components. Lightning Experience • Lightning component global actions aren’t supported for app pages. Lightning app and record • Page overrides by profile aren’t supported in packaging. They are supported in change sets, pages available in: both the but have to be added manually. Salesforce mobile app and Lightning Experience • Dropdown menus in the Lightning App Builder can display up to 200 items. Enter a few characters, and all available matches are displayed as you type. Email application pane • Although you can add the Potential Duplicates component to person account pages, the pages available in: both Salesforce Classic and component doesn’t display duplicate person accounts. Lightning Experience • Custom tab labels in the Tabs component—including those installed from packages—aren’t translated. For example, if you create a custom Goals tab in English, then view the page as a Available in: Group user whose language is set to French, the tab still displays as Goals. However, you can use the Essentials, Professional, {!$Label.customLabelName} expression in a component label or attribute to represent Enterprise, Performance, a custom label that you create in Setup using the custom label feature. For more information, Unlimited, and Developer see “Build Localized Component Labels and Attribute Values on Lightning Pages with Custom Editions Labels on page 979.”
Component Visibility Rules • A component can have up to 10 filters. • Visibility filters aren’t supported for individual tabs inside the Tabs component. • Some person account fields, including Email and Mobile, can’t be used in filters.
SEE ALSO: Lightning App Builder Considerations
Resources for the Point & Click Administrator
In addition to online help, Salesforce creates guides and tip sheets to help you learn about our features and successfully administer Salesforce.
1016 Extend Salesforce with Clicks, Not Code Resources for the Point & Click Administrator
Platform and Apps
Guides and Tip Sheets For End Users For Admins Implementing State and Country/Territory Picklists
Useful Workflow Rules
Useful Approval Processes
Salesforce Sites Implementation Guide
Formulas
Guides and Tip Sheets For End Users For Admins Useful Formula Fields
Tips for Reducing Formula Size
Using Date and Date/Time in Formulas
Useful Validation Rules
1017 INDEX
C N clickjack protection Notification Builder 461 Site.com 528 Custom fields P references 242 Prompts 57, 63, 68, 70, 72–73, 75, 77 Custom Help 93 S I Site.com In-App Guidance 57 clickjacking 528
1018
Note: Rich text editors in custom rich text area fields have minor formatting differences in Lightning Experience and the Salesforce mobile app, as compared to Salesforce Classic. For more information, see Editing Rich Text Area Fields in Records. The tags can include the following attributes. alt face size background height src border href style class name target colspan rowspan width 277 Extend Salesforce with Clicks, Not Code Customize Fields The following URL protocols are supported. • http: • https: • file: • ftp: • mailto: • # • / for relative links Rich Text Editors Using CKEditor Rich text editors in Salesforce Classic continue to use CKEditor. Beginning in Spring ’21, Salesforce uses CKEditor version 4.14.0. In Salesforce Classic, CKEditor is used by: • Chatter Publisher • Custom Fields • Email • Flow Builder • Groups • Idea Themes • Knowledge Article In Lightning Experience and the Salesforce mobile app, the following features have rich text editors that use CKEditor. • Email Composer, using the Send Email action • Lightning Knowledge These features load the rich text editor in an iframe. To load the editor correctly in an iframe, your browser must use appropriate security settings. Refer to your browser’s instructions to configure the settings. For example: Internet Explorer Make sure that the Launching programs and files in an IFRAME security setting is set to Enable or Prompt. Safari We recommend changing your Privacy settings for cookies to Allow from websites I visit. Chrome Make sure that Block third-party cookies and site data is not selected in the Content settings. To enter content in Internet Explorer 11 on touch-enabled devices running Windows, first click the rich text area field, then tab into the editor. Add Videos Using the HTML Editor Adding Code Samples to Posts You can paste code samples into your posts in Chatter Answers and Ideas. SEE ALSO: Editing Rich Text Area Fields in Records Rich Text Fields in Knowledge Articles 278 Extend Salesforce with Clicks, Not Code Customize Fields Add Videos Using the HTML Editor Available in: Salesforce Classic and Lightning Experience USER PERMISSIONS Available in: Enterprise, Performance, Unlimited, and Developer Editions To create or change custom fields: • Customize Application Approved Video Sites • app.ustudio.com • dailymotion.com • documentforce.com • fast.wistia.net • force.com • ooyala.com • play.vidyard.com • player.youku.com • players.brightcove.net • salesforce.com • salesforce-sites.com • sites.com • ustream.tv • visualforce.com • videos.sproutvideo.com • vimeo.com • youtube.com (including youtube.co.uk, youtube.ca, youtube.com.br, youtube.es, youtube.fr, youtube.ie, youtube.jp, youtube.nl, youtube-nocookie.com, and youtube.pl) 1. Copy the Button Description Lets you paste the Lets you paste the 3. Click Save. 279 Extend Salesforce with Clicks, Not Code Customize Fields Note: If you run into problems embedding videos, check your browser security settings. Some browsers block iframe elements. Also, embedded videos are removed from emails when you insert Knowledge articles into case emails. Also, you can't send embedded videos via email. SEE ALSO: Rich Text Editor Adding Code Samples to Posts You can paste code samples into your posts in Chatter Answers and Ideas. When you enable Chatter Answers and Ideas, users can add code samples to their posts. Code can be copied from any text editor and pasted into the body of a post with the formatting preserved. 1. Copy the code sample from a text editor to your clipboard. 2. In the editor, enter the text for your posts and click the button to add the code sample. 3. Paste the code sample into the Add a code sample text box and click OK. The code sample appears in the body of the post with its formatting intact. Change the Custom Field Type 1. From the management settings for the field’s object, go to Fields. EDITIONS Note: For fields on Salesforce Knowledge article types, from Setup, enter Knowledge Article Types in the Quick Find box, select Knowledge Article Types, and Available in: both Salesforce then select an article type. Classic and Lightning Experience 2. Click Edit next to the custom field you want to change. Available in: All Editions 3. Click Change Field Type. Standard Objects are not 4. Select a new data type and click Next. available in Database.com 5. Enter a field label, name, and any other attributes, and then save your changes. Salesforce Connect external objects are available in: Developer Edition and for Notes on Changing Custom Field Types an extra cost in: Enterprise, Performance, and SEE ALSO: Unlimited Editions Custom Field Types Which Standard Fields Can I Encrypt? USER PERMISSIONS Which Custom Fields Can I Encrypt? To change custom fields: Find Object Management Settings • Customize Application Notes on Changing Custom Field Types Note these considerations before you convert fields from one type to another: • Only convert custom fields that there’s no data for or you risk losing your data. Changing the data type of an existing custom field can cause data loss in these situations: 280 Extend Salesforce with Clicks, Not Code Customize Fields – Changing to or from type Date or Date/Time – Changing to Number from any other type – Changing to Percent from any other type – Changing to Currency from any other type – Changing from Checkbox to any other type – Changing from Picklist (Multi-Select) to any other type – Changing to Picklist (Multi-Select) from any other type Currently defined picklist values are retained when you change a picklist to a multi-select picklist. If records contain values that aren’t in the picklist definition, those values are deleted from those records when the data type changes. – Changing from Auto Number to any other type – Changing to Auto Number from any type except Text – Changing from Text to Picklist – Changing from Text Area (Long) to any type except Email, Phone, Text, Text Area, or URL • If data is lost, any list view based on the custom field is deleted, and assignment and escalation rules can be affected. • You can’t change the data type of any custom field that is mapped for lead conversion. • If you change the data type of a custom field that‘s set as an external ID, choosing a data type other than text, number, or email causes the field to no longer act as an external ID. • The option to change the data type of a custom field isn’t available for all data types. For example, an existing custom field can’t be converted into an encrypted field nor can an encrypted field be converted into another data type. • In Salesforce Knowledge article types, the file field type can't be converted into other data types. • You can’t change the data type of a custom field referenced by other items in Setup such as Visualforce pages, Apex code, processes, or flows. • Changing a custom field type can require changing many records at once. If your request is queued to process these changes efficiently, you receive an email notification when the process has completed. • Before changing a custom field’s type, make sure it isn’t the target of a workflow field update or referenced in a field update formula that would be invalidated by the new type. • If you encrypt a custom field using Shield Platform Encryption, you can’t change the field type. These data types have other restrictions when you convert them: Data Type Description Auto Number If you convert an auto-number field into a text field, the data in that field remains unchanged. Also, you can safely convert a text custom field into an auto-number field without losing your data. Converting an auto-number field into any other data type results in data loss. Auto-number fields can contain a maximum of 30 characters. Before converting a text custom field into an auto-number field, change any records that contain more than 30 characters in that field. Formula Formula fields are special read-only fields that can’t be converted to any other data type. Likewise, you can’t convert any other field type into a formula field. 281 Extend Salesforce with Clicks, Not Code Customize Fields Data Type Description Picklist Changing your custom picklists into custom checkboxes is simple. If you select Checkbox as the new data type, you can choose which picklist values to map to checked boxes and unchecked boxes. You can change custom picklists into multi-select picklists without losing any data. Since your records contain only a single value of that picklist, that value is still selected but users can select more values. Relationships • You can convert relationship fields to nonrelationship fields and vice versa, but only on external objects. • If your org has a large number of records, Salesforce displays a waiting page after you request to change a master-detail into a lookup relationship or a lookup into a master-detail relationship. • After you have created a roll-up summary field on an object, you cannot convert the object's master-detail relationship into a lookup relationship. • If any records on an object have a null value set for the lookup field, you can’t convert the lookup relationship to a master detail relationship. • If you convert a master-detail relationship to a lookup for a custom object on the “detail” side, the org-wide default for the object is automatically updated to Public Read/Write. Similarly, converting a lookup to a master-detail-relationship changes the org-wide default to Controlled by Parent. Text By default, an upper bound limit of 4,000 is applied to inactive unrestricted picklists for each field. If you exceed this limit when converting a text field to a picklist field, you receive an error message. You can’t convert a defined unique text field to a picklist or a multi-select picklist. Text Area (Long) When you convert a long text area field to an Email, Phone, Text, Text Area, or URL type field, the record data is truncated to the first 255 characters of the field. Text Area (Rich) You can convert rich text area fields into long text area fields only. Any images get deleted the next time you save the long text area field. After converting, markup is hidden in the long text area field but it isn’t removed from the record, so if you change your mind, you can restore the markup before you save the record. SEE ALSO: Change the Custom Field Type Custom Metadata Type Fields 282 Extend Salesforce with Clicks, Not Code Customize Fields Define Default Field Values Define a default value for a field. Use a formula to generate dynamic values or constants for static EDITIONS values. 1. Create a custom field. See Create Custom Fields. You can also define a default value for an Available in: both Salesforce existing custom field. See Edit Custom Fields. Classic and Lightning Experience 2. Choose the type of field and click Next. For a list of the types available for default values, see Default Field Values. Available in: Contact 3. Enter the attributes for the field. Manager, Group, Professional, Enterprise, 4. Enter a default value or define a formula to calculate the default value. Performance, Unlimited, and Developer Editions Note: You can define a formula for default values only where appropriate. For example, the default value options for a checkbox field are limited to the options available for those types of fields, such as Checked or Unchecked. USER PERMISSIONS For picklists, a valid formula result is either a constant or the API name of an entry in the To view default field values: Values list. The formula result has higher precedence than the default assigned in the • View Setup and Values list. If the formula doesn’t generate a valid result, the default assigned in the Values Configuration list is entered in the field. If a default isn’t assigned to the Values list, no value is entered To define or change default in the picklist field. field values: • Customize Application 5. Click Next. 6. Set the field-level security to determine whether the field is visible for specific profiles, and click Next. 7. Choose the page layouts that display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is added to the bottom of the user detail page. 8. Click Save to finish or Save & New to create more custom fields. You must specify a default value for required campaign member custom fields. To avoid uniqueness errors, don’t assign default values to fields that are both required and unique. Default Field Values Prepopulate field values with defaults to save your users time and improve consistency. Default field values make your users more productive by reducing the number of fields they need to fill in manually. Useful Default Field Value Formulas Default Field Value Considerations Be aware of the behavior and rules when you assign default values to custom fields. 283 Extend Salesforce with Clicks, Not Code Customize Fields Default Field Values Prepopulate field values with defaults to save your users time and improve consistency. Default EDITIONS field values make your users more productive by reducing the number of fields they need to fill in manually. Available in: both Salesforce Default field values automatically insert the value of a custom field when a new record is created. Classic (not available in all You can use a default value on a formula for some types of fields or exact values, such as Checked orgs) and Lightning or Unchecked for checkbox fields. Experience After you have defined default values: Available in: Contact Manager, Group, 1. The user chooses to create a new record. Professional, Enterprise, 2. Default field value is executed. Performance, Unlimited, 3. Salesforce displays the edit page with the default field value prepopulated. and Developer Editions 4. The user enters the fields for the new record. 5. The user saves the new record. The user can change the field’s value but the initial default field value is only executed once, during record creation. For example, you can set the default field value on a custom lead field to seven days after the creation date to signify when to contact the lead again. You can change this value later, but you cannot automatically restore the value that was seven days after the creation date. Set up default field values for the following types of custom fields: • Checkbox • Currency • Date • Date/Time • Email • Number • Percent • Phone • Picklist • Text • Text Area • Time • URL For a description of these types, see Custom Field Types on page 225. SEE ALSO: Define Default Field Values Default Field Value Considerations Useful Default Field Value Formulas Reference Custom Metadata Type Records in Default Values 284 Extend Salesforce with Clicks, Not Code Customize Fields Useful Default Field Value Formulas EDITIONS Maximum Discount Rate Your organization may apply different discount rates to opportunities based on the department of Available in: both Salesforce the person creating the opportunity. Use the following example to set a default value for a custom Classic (not available in all field called Discount Rate on opportunities. orgs) and Lightning Experience Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions USER PERMISSIONS To view default field values: • View Setup and Configuration To define or change default field values: • Customize Application CASE(User.Department, "IT", 0.25, "Field", 0.15, 0) In this example, the formula inserts a discount rate of 25% on any opportunity created by a user in the IT department or 15% on any opportunity created by someone in the Field department. A zero is applied if the creator doesn't belong to either of these departments. This is a custom percent field on opportunities that uses the standard user field Department. Product Language You might want to associate a product with its language so that your users know the type of documentation or adapter to include. Use the following default value formula to automatically set the language of a product based on the country of the user creating the product. In this example, the default value is Japanese if the user's country is Japan and English if the user's country is US. If neither is true, the default value unknown is inserted into the Product Language field. CASE($User.Country , "Japan", "Japanese", "US", "English","unknown") Tax Rate Use this default value formula to set the tax rate of an asset based on the user's city. Create a custom percent field with the following default value: IF($User.City = "Napa", 0.0750, IF($User.City = "Paso Robles", 0.0725, IF($User.City = "Sutter Creek", 0.0725, IF($User.City = "Los Olivos", 0.0750, IF($User.City = "Livermore", 0.0875, null ) ) 285 Extend Salesforce with Clicks, Not Code Customize Fields ) ) ) In this example, a tax rate of 8.75% is applied to an asset when the user's address is in the city of Livermore. When none of the cities listed applies, the Tax Rate field is empty. You can also use the Tax Rate field in formulas to automatically calculate taxable amounts and final sales prices. Default Field Value Considerations Be aware of the behavior and rules when you assign default values to custom fields. EDITIONS Default field values automatically insert the value of a custom field when a new record is created. You can use a default value on a formula for some types of fields or exact values, such as Checked Available in: both Salesforce or Unchecked for checkbox fields. Review the following considerations before incorporating default Classic (not available in all field values in your organization. orgs) and Lightning Experience • If a default value is based on the value of a merge field, Salesforce uses the value of the merge field at the time the default value is executed. If the value of the merge field changes later, the Available in: Contact default value is not updated. Manager, Group, • Users can change or remove the default field value on a record. Professional, Enterprise, Performance, Unlimited, • Don’t assign default values to fields that are both required and unique, because uniqueness and Developer Editions errors can result. • If you make an activity custom field universally required, you must also provide a default value. • If an activity custom field is unique, you cannot provide a default value. • Default field values are different from formula fields in the following ways: they are only executed once, at record creation; they are not read only; and the user can change the value but cannot restore the default field value. • Since the default value is inserted before users enter any values in the new record, you cannot use the fields on the current record to create a default field value. For example, you cannot create a default field value on a contact that uses the first initial and last name because those values are not available when you click New to create a contact record. However, you can use the record type because it is selected before the record edit page displays. • Record type default field values have precedence over an object’s default field values. • To apply a different default value for different record types, use the record type as a merge field in a CASE function within the default field value setup. • Fields that are not visible to the user due to field-level security are still available in the formula for a default field value. • Connect Offline and Salesforce for Outlook do not display default values. However, Salesforce inserts the default values when a user syncs unless the user entered a value. • Default field values are not available in the Self-Service portal. • Lead conversion, Web-to-Lead, and Web-to-Case do not execute default field values. • Visualforce pages don’t support default field values. Note: You can define a formula for default values only where appropriate. For example, the default value options for a checkbox field are limited to the options available for those types of fields, such as Checked or Unchecked. For picklists, a valid formula result is either a constant or the API name of an entry in the Values list. The formula result has higher precedence than the default assigned in the Values list. If the formula doesn’t generate a valid result, the default assigned in the Values list is entered in the field. If a default isn’t assigned to the Values list, no value is entered in the picklist field. 286 Extend Salesforce with Clicks, Not Code Customize Fields Validation Rules Improve the quality of your data using validation rules. Validation rules verify that the data a user EDITIONS enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns Available in: both Salesforce a value of “True” or “False”. Validation rules also include an error message to display to the user Classic and Lightning when the rule returns a value of “True” due to an invalid value. Experience Important: We don’t recommend using a custom number field that Einstein Prediction Available in: Essentials, Builder manages in a validation rule. If the prediction changes the field value in a way that Contact Manager, Group, violates the validation rule, you can’t update the record that uses the field. If you get a Professional, Enterprise, validation rule error when saving a record that contains an Einstein Prediction Builder field, Performance, Unlimited, edit, deactivate, or delete the validation rule. Developer, and Database.com Editions After you have defined validation rules: 1. The user chooses to create a record or edit an existing record. 2. The user clicks Save. 3. All validation rules are verified. • If all data is valid, the record is saved. • If any data is invalid, the associated error message displays without saving the record. 4. The user makes the necessary changes and clicks Save again. You can specify the error message to display when a record fails validation and where to display it. For example, your error message can be “The close date must occur after today's date.” You can choose to display it near a field or at the top of the page. Like all other error messages, validation rule errors display in red text and begin with the word “Error”. Note: In Salesforce Classic, users with custom profiles must have Read permission on a standard object to view validation rules for that object. Important: Validation rules apply to new and updated records for an object, even if the fields referenced in the validation rule aren’t included in a page layout or an API call. Validation rules don't apply if you create records for an object with Quick Create. If your organization has multiple page layouts for the object on which you create a validation rule, verify that the validation rule works on each layout. If your organization has any integrations that use this object, verify that the validation rule works for each integration. Managing Validation Rules Define Validation Rules Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value. Clone Validation Rules Activate Validation Rules Validation Rules Fields Tips for Writing Validation Rules 287 Extend Salesforce with Clicks, Not Code Customize Fields Validation Rule Considerations Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value. Review these considerations before implementing validation rules in your organization. SEE ALSO: Examples of Validation Rules Custom Metadata Type Fields and Validation Rules Custom Metadata Types and Validation Rule Formulas Set an AI Prediction Field Einstein Prediction Builder Edit Object Permissions in Profiles Managing Validation Rules Validation rules verify that the data a user enters in a record meets the standards you specify before EDITIONS the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include Available in: both Salesforce an error message to display to the user when the rule returns a value of “True” due to an invalid Classic and Lightning value. Experience From the validation rules page you can: Available in: Essentials, • Define a validation rule. Contact Manager, Group, • Click Edit next to a rule name to update the rule fields. Professional, Enterprise, Performance, Unlimited, • Delete a validation rule. Developer, and • Click a validation rule name to view more details or to clone the rule. Database.com Editions • Activate a validation rule. SEE ALSO: Examples of Validation Rules 288 Extend Salesforce with Clicks, Not Code Customize Fields Define Validation Rules Validation rules verify that the data a user enters in a record meets the standards you specify before EDITIONS the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include Available in: both Salesforce an error message to display to the user when the rule returns a value of “True” due to an invalid Classic and Lightning value. Experience Before creating validation rules, review the Validation Rule Considerations. Available in: Essentials, 1. From the management settings for the relevant object, go to Validation Rules. Contact Manager, Group, Professional, Enterprise, 2. In the Validation Rules related list, click New. Performance, Unlimited, Note: The detail page of a custom activity field does not list associated validation rules. Developer, and To edit the validation rule for a custom activity field, select the validation rule from Setup Database.com Editions by entering Activities in the Quick Find box, then selecting Activities and choose Task Validation Rules or Event Validation Rules. USER PERMISSIONS 3. Enter the properties of your validation rule. To view field validation rules: 4. To check your formula for errors, click Check Syntax. • View Setup and Configuration SEE ALSO: To define or change field validation rules: Validation Rules • Customize Application Clone Validation Rules Tips for Writing Validation Rules Examples of Validation Rules Clone Validation Rules 1. From the management settings for the relevant object, go to Validation Rules. EDITIONS 2. In the Validation Rules related list, click the name of the validation rule. 3. Click Clone. Available in: both Salesforce Classic and Lightning 4. Define the new rule based on the original rule. Experience 5. Click Save to finish or Save & New to create additional validation rules. Available in: Essentials, Note: The detail page of a custom activity field does not list associated validation rules. To Contact Manager, Group, edit the validation rule for a custom activity field, select the validation rule from Setup by Professional, Enterprise, Performance, Unlimited, entering Activities in the Quick Find box, then selecting Activities and choose Developer, and Task Validation Rules or Event Validation Rules. Database.com Editions SEE ALSO: USER PERMISSIONS Define Validation Rules Validation Rules Fields To view field validation rules: • View Setup and Activate Validation Rules Configuration To define or change field validation rules: • Customize Application 289 Extend Salesforce with Clicks, Not Code Customize Fields Activate Validation Rules 1. From the management settings for the relevant object, go to Validation Rules. EDITIONS 2. Click Edit next to the rule you want to activate. 3. To activate the rule, select Active, and save your changes. Available in: both Salesforce Classic and Lightning 4. To deactivate the rule, deselect Active, and save your changes. Experience Note: The detail page of a custom activity field does not list associated validation rules. Available in: Essentials, Contact Manager, Group, Professional, Enterprise, SEE ALSO: Performance, Unlimited, Define Validation Rules Developer, and Validation Rules Fields Database.com Editions Find Object Management Settings USER PERMISSIONS To view field validation rules: • View Setup and Configuration To define or change field validation rules: • Customize Application Validation Rules Fields Field Description EDITIONS Rule Name Unique identifier of up to 40 characters with no spaces or special Available in: both Salesforce characters such as extended characters. Classic and Lightning Experience Active Checkbox that indicates if the rule is enabled. Available in: Essentials, Description A 255-character or less description that distinguishes the validation Contact Manager, Group, rule from others. For internal purposes only. Professional, Enterprise, Error Condition The expression used to validate the field. See Build a Formula Field Performance, Unlimited, Formula and Formula Operators and Functions. Developer, and Database.com Editions Error Message The message that displays to the user when a field fails the validation rule. If your organization uses the Translation Workbench, you can translate the error message into the languages Salesforce supports. See Enable or Disable Translation Workbench. Error Location Determines where on the page to display the error. To display the error next to a field, choose Field and select the field. If the error location is a field, the validation rule is also listed on the detail page of that field. If the error location is set to a field that is later deleted, to a field that is read only, or to a field that isn’t visible on 290 Extend Salesforce with Clicks, Not Code Customize Fields Field Description the page layout, Salesforce automatically changes the location to Top of Page. Note: Error messages can only be displayed at the top of the page in validation rules for case milestones and Ideas. SEE ALSO: Define Validation Rules Tips for Writing Validation Rules • Consider all the settings in your organization that can make a record fail validation, including EDITIONS assignment rules, field updates, field-level security, or fields hidden on a page layout. • Be careful not to create contradicting validation rules for the same field; otherwise, users won’t Available in: both Salesforce be able to save the record. Classic and Lightning Experience Tip: A poorly designed validation rule can prevent users from saving valid data. Make sure you thoroughly test a validation rule before activating it. You can also use the debug Available in: Essentials, log to monitor the details of your rule implementation. Contact Manager, Group, Professional, Enterprise, • When referencing related fields in a validation formula, make sure those objects are deployed. Performance, Unlimited, • Use the RecordType.Id merge field in your formula to apply different validations for Developer, and different record types. Database.com Editions • You don’t have to begin a validation rule formula with the IF function. Any Boolean error condition expression works. For example: – Correct: CloseDate < TODAY() – Incorrect: IF(CloseDate < TODAY(), TRUE, FALSE) • Keep in mind that when a validation rule contains the BEGINS or CONTAINS function, it processes blank fields as valid. For example, if you have a validation rule that tests whether the serial number of an asset begins with “3”, all assets with a blank serial number are considered valid. • When using a validation rule to ensure that a number field contains a specific value, use the ISBLANK function to include fields that don’t contain any value. For example, to validate that a custom field contains a value of ‘1’, use the following validation rule to display an error if the field is blank or any other number: OR (ISBLANK (field__c), field__c<>1) • Avoid using the IsClosed or IsWon opportunity merge fields in validation formulas. Instead, use the ISPICKVAL function to determine if the Stage contains the appropriate value. For example, the following validation formula makes a custom Project Start Date field required whenever the Stage is “Closed Won”: AND(ISPICKVAL(StageName, "Closed Won"), ISBLANK(Project_Start_Date__c)) • Simplify your validation formulas by using checkbox fields, which don't require any operator because they return true or false. For example, the following validation formula checks to be sure an opportunity has opportunity products using the HasOpportunityLineItem merge field before users can save a change to it: NOT(OR(ISNEW(),HasOpportunityLineItem)) 291 Extend Salesforce with Clicks, Not Code Customize Fields Tips for Writing Validation Rule Error Messages • Give instructions. An error message like “invalid entry” doesn’t tell the user what type of entry is valid. Write something more specific, such as “Close Date must be after today.” • Always include the field label. Users might not know what field is failing validation, especially if the error message appears at the top of the page. Note: When defining validation rules, you can set the error location to Top of Page or Field. If the error location is set to a field that is later deleted, to a field that is read only, or to a field that isn’t visible on the page layout, Salesforce automatically changes the location to Top of Page. • If you have a multilingual organization, translate your error messages. You can translate error messages using the Translation Workbench. • Assign corresponding numbers to validation rules and their error messages. This allows you to identify the source of the error. SEE ALSO: Define Validation Rules Validation Rule Considerations Validation Rule Considerations Validation rules verify that the data a user enters in a record meets the standards you specify before EDITIONS the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include Available in: both Salesforce an error message to display to the user when the rule returns a value of “True” due to an invalid Classic (not available in all value. Review these considerations before implementing validation rules in your organization. orgs) and Lightning Experience How Salesforce Processes Validation Rules Available in: Essentials, Salesforce processes rules in the following order: Contact Manager, Group, Professional, Enterprise, 1. Validation rules Performance, Unlimited, 2. Assignment rules Developer, and Database.com Editions 3. Auto-response rules 4. Workflow rules (with immediate actions) 5. Escalation rules In addition, • When one validation rule fails, Salesforce continues to check other validation rules on that field or other fields n the page and displays all error messages at once. • If validation rules exist for activities and you create an activity during lead conversion, the lead converts but a task isn’t created. • Validation rules are only enforced during lead conversion if validation and triggers for lead conversion are enabled in your organization. • Campaign hierarchies ignore validation rules. • Salesforce runs validation rules before it creates records submitted via Web-to-Lead and Web-to-Case and then creates records that have valid values. • To give a default value to a division field before the validation rule evaluation, the division field must be on the page layout. • Validation rules continue to run on individual records if the owner is changed. If the Mass Transfer tool is used to change the ownership of multiple records, however, validation rules don’t run on those records. 292 Extend Salesforce with Clicks, Not Code Customize Fields Validation Rule Field Restrictions Validation rule formulas don’t or can’t refer to: • Compound fields, including addresses, first and last names, and dependent picklists and lookups Note: However, you can use compound fields in ISNULL, ISBLANK, and ISCHANGED functions. • Campaign statistic fields, including statistics for individual campaigns and campaign hierarchies • Merge fields for auto-number or compound address fields, such as Mailing Address Note: You can use merge fields for individual address fields, such as Billing City, in validation rule formulas. In relation to other fields and functions in Salesforce, validation rules behave as follows: • The detail page of a custom activity field doesn't list associated validation rules. • Workflow rules and some processes can invalidate previously valid fields. Invalidation occurs because updates to records based on workflow rules and also on process scheduled actions don’t trigger validation rules. • Process record updates on immediate actions do fire validation rules. • You can’t create validation rules for relationship group members. • You can use roll-up summary fields in validation rules because the fields don’t display on edit pages. Don’t use roll-up summary fields as the error location. Lookup Filters vs. Validation Rules Validation rules and lookup filters achieve similar ends, but offer different advantages. Use a lookup filter: • To improve user efficiency by limiting the number of available options in a lookup search dialog. • To improve user efficiency by automating filters on lookup search dialogs that your users manually set. Use a validation rule: • If you're close to the maximum number of lookup filters allowed. • To implement a complex business rule that requires you to use a formula. Formulas can reference fields that basic filter criteria can't reference, such as fields on the parent of the source object. Formulas can also use functions. For example, use ISNEW to apply the rule only on record creation, or ISCHANGED to apply the rule only when a field changes. SEE ALSO: Define Validation Rules Activate Validation Rules Examples of Validation Rules 293 Extend Salesforce with Clicks, Not Code Customize Fields Examples of Validation Rules Review examples of validation rules for various types of apps that you can use and modify for your EDITIONS own purposes. Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. Available in: both Salesforce Use the following samples for validation rules in Salesforce and Salesforce AppExchange apps, Classic and Lightning including: Experience Available in: Contact Sample Account Address Validation Rules Manager, Group, Professional, Enterprise, Sample Account Validation Rules Performance, Unlimited, Sample Call Center Validation Rules Developer, and Sample Experience Cloud Site Validation Rules Database.com Editions Sample Contact Validation Rules USER PERMISSIONS Sample Cross Object Validation Rules Sample Date Validation Rules To view field validation rules: • View Setup and Sample Number Validation Rules Configuration Sample Opportunity Management Validation Rules To define or change field Sample Quote Validation Rules validation rules: • Customize Application Sample User, Role, and Profile Validation Rules Miscellaneous Sample Validation Rules SEE ALSO: Validation Rules Define Validation Rules Sample Account Address Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions 294 Extend Salesforce with Clicks, Not Code Customize Fields Canadian Billing Postal Code Field Value Description: Validates that the account Billing Zip/Postal Code is in the correct format if Billing Country is Canada. Formula: AND( OR(BillingCountry = "CAN", BillingCountry = "CA", BillingCountry = "Canada"), NOT(REGEX(BillingPostalCode, "((?i)[ABCEGHJKLMNPRSTVXY]\\d[A-Z]?\\s?\\d[A-Z]\\d)?")) ) Error Message: Canadian postal code must be in A9A 9A9 format. Error Location: Billing Zip/Postal Code Billing Zip Code Is in Billing State Field Value Description: Validates that the account Billing Zip/Postal Code is valid by looking up the first five characters of the value in a custom object called Zip_Code__c that contains a record for every valid zip code in the US. If the zip code is not found in the Zip_Code__c object, or the Billing State does not match the corresponding State_Code__c in the Zip_Code__c object, an error is displayed. Formula: VLOOKUP( $ObjectType.Zip_Code__c.Fields.City__c , $ObjectType.Zip_Code__c.Fields.Name , LEFT(BillingPostalCode,5)) <> BillingCity Error Message: Billing Zip Code does not exist in specified Billing State. Error Location: Billing Zip/Postal Code 295 Extend Salesforce with Clicks, Not Code Customize Fields US Billing Zip Code Field Value Description: Validates that the account Billing Zip/Postal Code is in 99999 or 99999-9999 format if Billing Country is USA or US. Formula: AND( OR(BillingCountry = "USA", BillingCountry = "US"), NOT(REGEX(BillingPostalCode, "\\d{5}(-\\d{4})?")) ) Note: This example uses the REGEX function; see Shipping Zip Code if you are not familiar with regular expressions. Error Message: Zip code must be in 99999 or 99999-9999 format. Error Location: Billing Zip/Postal Code 296 Extend Salesforce with Clicks, Not Code Customize Fields Shipping Zip Code Field Value Description: Validates that the account Shipping Zip/Postal Code is in 99999 or 99999-9999 format if Shipping Country is USA or blank. Formula: AND( OR(ShippingCountry = "USA", ISBLANK(ShippingCountry)), OR( AND(LEN(ShippingPostalCode) <>5, LEN(ShippingPostalCode) <> 10), NOT(CONTAINS("0123456789", LEFT( ShippingPostalCode, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 2, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 3, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 4, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 5, 1))), AND( LEN(ShippingPostalCode) = 10, OR( MID( ShippingPostalCode , 6, 1) <> "-", NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 7, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 8, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 9, 1))), NOT(CONTAINS("0123456789", MID( ShippingPostalCode , 10, 1))) ) ) ) ) Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.” Tip: You can also validate zip codes using a regular expression; for an example of a formula using a regular expression, see REGEX on page 401. Error Message: Zip code must be in 99999 or 99999-9999 format. Error Location: Shipping Zip/Postal Code 297 Extend Salesforce with Clicks, Not Code Customize Fields Valid Billing State (US) Field Value Description: Validates that the account Billing State/Province is a valid two-character abbreviation if Billing Country is US, USA, or blank. Formula: AND ( OR(BillingCountry = "US", BillingCountry="USA", ISBLANK(BillingCountry)), OR( LEN(BillingState) < 2, NOT( CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & "IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & "NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & "WA:WV:WI:WY", BillingState) ))) Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.” Error Message: A valid two-letter state code is required. Error Location: Billing State/Province Valid Billing Province (Canada) Field Value Description: Validates that the account Billing State/Province is a valid two-character abbreviation if Billing Country is CA or CAN. Formula: AND ( OR(BillingCountry = "CA", BillingCountry="CAN"), OR( LEN(BillingState) < 2, NOT( CONTAINS("AB:BC:MB:NB:NL:NT:NS:NU:ON:PC:QC:SK:YT", BillingState) ))) Error Message: A valid two-letter province code is required. Error Location: Billing State/Province 298 Extend Salesforce with Clicks, Not Code Customize Fields Valid Shipping State Field Value Description: Validates that the account Shipping State/Province is a valid two-character abbreviation if Shipping Country is US, USA, or blank. Formula: AND ( OR(ShippingCountry = "US", ShippingCountry="USA", ISBLANK(ShippingCountry)), OR( LEN(ShippingState) < 2, NOT( CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & "IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & "NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & "WA:WV:WI:WY", ShippingState) ))) Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.” Error Message: A valid two-letter state abbreviation is required. Error Location: Shipping State/Province Valid Shipping Province (Canada) Field Value Description: Validates that the account Shipping State/Province is a valid two-character abbreviation, if Billing Country is CA or CAN. Formula: AND ( OR(ShippingCountry = "CA", ShippingCountry="CAN"), OR( LEN(ShippingState) < 2, NOT( CONTAINS("AB:BC:MB:NB:NL:NT:NS:NU:ON:PC:QC:SK:YT", ShippingState) ))) Error Message: A valid two-letter province abbreviation is required. Error Location: Shipping State/Province 299 Extend Salesforce with Clicks, Not Code Customize Fields Valid Billing Country Field Value Description: Validates that the account Billing Country is a valid ISO 3166 two-letter code. Formula: OR( LEN(BillingCountry) = 1, NOT( CONTAINS( "AF:AX:AL:DZ:AS:AD:AO:AI:AQ:AG:AR:AM:" & "AW:AU:AZ:BS:BH:BD:BB:BY:BE:BZ:BJ:BM:BT:BO:" & "BA:BW:BV:BR:IO:BN:BG:BF:BI:KH:CM:CA:CV:KY:" & "CF:TD:CL:CN:CX:CC:CO:KM:CG:CD:CK:CR:CI:HR:" & "CU:CY:CZ:DK:DJ:DM:DO:EC:EG:SV:GQ:ER:EE:ET:FK:" & "FO:FJ:FI:FR:GF:PF:TF:GA:GM:GE:DE:GH:GI:GR:GL:" & "GD:GP:GU:GT:GG:GN:GW:GY:HT:HM:VA:HN:HK:HU:" & "IS:IN:ID:IR:IQ:IE:IM:IL:IT:JM:JP:JE:JO:KZ:KE:KI:" & "KP:KR:KW:KG:LA:LV:LB:LS:LR:LY:LI:LT:LU:MO:MK:" & "MG:MW:MY:MV:ML:MT:MH:MQ:MR:MU:YT:MX:FM:MD:MC:" & "MC:MN:ME:MS:MA:MZ:MM:MA:NR:NP:NL:AN:NC:NZ:NI:" & "NE:NG:NU:NF:MP:NO:OM:PK:PW:PS:PA:PG:PY:PE:PH:" & "PN:PL:PT:PR:QA:RE:RO:RU:RW:SH:KN:LC:PM:VC:WS:" & "SM:ST:SA:SN:RS:SC:SL:SG:SK:SI:SB:SO:ZA:GS:ES:" & "LK:SD:SR:SJ:SZ:SE:CH:SY:TW:TJ:TZ:TH:TL:TG:TK:" & "TO:TT:TN:TR:TM:TC:TV:UG:UA:AE:GB:US:UM:UY:UZ:" & "VU:VE:VN:VG:VI:WF:EH:YE:ZM:ZW", BillingCountry))) Error Message: A valid two-letter country code is required. Error Location: Billing Country Sample Account Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Account Number Is Numeric Classic and Lightning Experience Field Value Available in: Contact Description: Validates that the Account Number is numeric if not blank. Manager, Group, Professional, Enterprise, Formula: Performance, Unlimited, AND( Developer, and ISBLANK(AccountNumber), Database.com Editions NOT(ISNUMBER(AccountNumber)) ) Error Message: Account Number is not numeric. Error Location: Account Number 300 Extend Salesforce with Clicks, Not Code Customize Fields Account Number Length Field Value Description: Validates that the Account Number is exactly seven digits (if it is not blank). The number seven is simply illustrative. You can change this to any number you like. Formula: AND( ISBLANK(AccountNumber), LEN(AccountNumber) <> 7 ) Error Message: Account Number must be seven digits. Error Location: Account Number Annual Revenue Range Field Value Description: Validates that the account Annual Revenue is not negative and does not exceed $100 billion. This limit is designed to catch typos. Formula: OR( AnnualRevenue < 0, AnnualRevenue > 100000000000 ) Error Message: Annual Revenue cannot exceed 100 billion. Error Location: Annual Revenue Sample Call Center Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience Available in: Essentials, Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions 301 Extend Salesforce with Clicks, Not Code Customize Fields Conditionally Require Description When Case Reason is “Other” Field Value Description: Validates that a custom field called Other Reason contains a value if a case has a Case Reason of “Other.” Formula: AND( ISPICKVAL( Reason, "Other" ), ISBLANK(Other_Reason__c) ) Error Message: Description of Other Reason is required. Error Location: Other Reason Prevent Open Cases from Being Reset to New Field Value Description: If a case is already open, prevents the Status from being changed back to “New.” Formula: AND( ISCHANGED( Status ), NOT(ISPICKVAL(PRIORVALUE( Status ), "New")), ISPICKVAL( Status, "New") ) Error Message: Open case Status cannot be reset to New. Error Location: Status Restrict Status of Re-Opened Cases Field Value Description: Validates that the case Status is “Re-opened” when a closed case is opened again. Formula: AND( ISCHANGED( Status ), OR( ISPICKVAL(PRIORVALUE( Status ), "Closed"), ISPICKVAL(PRIORVALUE( Status ), "Closed in SSP")), NOT( ISPICKVAL( Status, "Re-Opened")) ) Error Message: Closed case can only be changed to “Re-opened.” Error Location: Status 302 Extend Salesforce with Clicks, Not Code Customize Fields Prevent Case Milestone Completion After Cases Are Closed Field Value Description: Validates that a milestone's Completion Date can't occur after the case's Status is Closed. Formula: Case.IsClosed = true Error Message: You can't complete a milestone after a case is closed. Error Location: Top of Page Prevent Case Milestone Completion Before Case Creation Dates Field Value Description: Validates that the milestone's Completion Date has occurred after the case's Date/Time Opened. Formula: CompletionDate >= Case.CreatedDate && CompletionDate <= Case.ClosedDate Error Message: The milestone Completion Date must occur after the date the case was created and before the case was closed. Error Location: Top of Page Sample Experience Cloud Site Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Preventing Offensive Language in Questions Classic and Lightning Experience Field Value Available in: Contact Description: Prevents users from entering offensive language in the Title and Manager, Group, Professional, Enterprise, Description fields when asking a question. Performance, Unlimited, Formula: Developer, and OR(CONTAINS(Title, 'darn'), CONTAINS(Body, Database.com Editions 'darn')) Error Message: Question title or description contains offensive language. 303 Extend Salesforce with Clicks, Not Code Customize Fields Preventing Offensive Language in Replies Field Value Description: Prevents users from entering offensive language when replying to a question. Formula: OR(CONTAINS(Body, 'darn'), CONTAINS(Body, 'dang')) Error Message: Reply contains offensive language. Preventing Offensive Language in Ideas Field Value Description: Prevents users from entering offensive language in the Title and Description fields when posting an idea. Formula: OR(CONTAINS(Title, 'darn'), CONTAINS(Body, 'darn')) Error Message: Idea title or description contains offensive language. Preventing Offensive Language in Idea Comments Field Value Description: Prevents users from entering offensive language when posting a comment. Formula: OR(CONTAINS(CommentBody , 'darn'), CONTAINS(CommentBody, 'dang')) Error Message: Comment contains offensive language. Sample Contact Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions 304 Extend Salesforce with Clicks, Not Code Customize Fields Mailing Address Fields Are Required Field Value Description: Validates that the contact Mailing Street, Mailing City, and Mailing Country are provided. Formula: OR( ISBLANK( MailingStreet ), ISBLANK( MailingCity ), ISBLANK( MailingCountry ) ) Error Message: Mailing Street, City, and Country are required. Error Location: Top of Page Mailing Street Is Required Field Value Description: Validates that the contact Mailing Street is provided. Formula: ISBLANK( MailingStreet ) Error Message: Mailing Street is required. Error Location: Mailing Street 305 Extend Salesforce with Clicks, Not Code Customize Fields Mailing Zip Code Field Value Description: Validates that the contact Mailing Zip/Postal Code is in 99999 or 99999-9999 format if Mailing Country is USA or blank. Formula: AND( OR(MailingCountry = "USA", ISBLANK(MailingCountry)), OR( AND(LEN(MailingPostalCode) <>5, LEN(MailingPostalCode) <> 10), NOT(CONTAINS("0123456789", LEFT( MailingPostalCode, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 2, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 3, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 4, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 5, 1))), AND( LEN(MailingPostalCode) = 10, OR( MID( MailingPostalCode , 6, 1) <> "-", NOT(CONTAINS("0123456789", MID( MailingPostalCode , 7, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 8, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 9, 1))), NOT(CONTAINS("0123456789", MID( MailingPostalCode , 10, 1))) ) ) ) ) Note: This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.” Tip: You can also validate zip codes using a regular expression; for an example of a formula using a regular expression, see REGEX on page 401. Error Message: Zip code must be in 99999 or 99999-9999 format. Error Location: Mailing Zip/Postal Code 306 Extend Salesforce with Clicks, Not Code Customize Fields Phone Number Has International Format Field Value Description: Validates that the Phone number begins with a plus sign (+) for country code. Note that this validation rule conflicts with the ten-digit rule. Formula: LEFT(Phone, 1) <> "+" Error Message: Phone number must begin with + (country code). Error Location: Phone US Phone Number Has Ten Digits Field Value Description: Validates that the Phone number is in (999) 999-9999 format. This works by using the REGEX function to check that the number has ten digits in the (999) 999-9999 format. Formula: NOT(REGEX(Phone, "\\D*?(\\d\\D*?){10}")) Error Message: US phone numbers should be in this format: (999) 999-9999. Error Location: Phone Sample Cross Object Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Discounts Must Be Within Range Classic and Lightning Experience This example consists of three validation rules on opportunity products. The examples below work together to help you manage discount amounts for products and require a custom percent field Available in: Contact on opportunity products called Line Discount. The examples below also require you to use Manager, Group, price books and customize the Product Family field to include the following values: Professional, Enterprise, Software, Consulting, and Training. Performance, Unlimited, Developer, and Software Discounts Database.com Editions Field Value Description: Prevents users from saving software products with a discount over 10 percent. Formula: AND(Line_Discount__c > 0.10, ISPICKVAL(Product2.Family, "Software")) 307 Extend Salesforce with Clicks, Not Code Customize Fields Field Value Error Message: The discount must be 10% or less for software products. Error Location: Line Discount Consulting Discounts Field Value Description: Prevents users from saving consulting products with a discount over 15 percent. Formula: AND(Line_Discount__c > 0.15, ISPICKVAL(Product2.Family, "Consulting")) Error Message: The discount must be 15% or less for consulting products. Error Location: Line Discount Training Discounts Field Value Description: Prevents users from saving training products with a discount over 20 percent. Formula: AND(Line_Discount__c > 0.20, ISPICKVAL(Product2.Family, "Training")) Error Message: The discount must be 20% or less for training products. Error Location: Line Discount Prevent Changing Opportunity Products on Closed Opportunities This example consists of two validation rules: one on opportunity products and another on opportunities. Field Value Description: Prevents users from editing opportunity products after an opportunity is closed. Create the following validation rule example on opportunity products. Formula: OR(ISPICKVAL(Opportunity.StageName, "Closed Won"), ISPICKVAL(Opportunity.StageName, "Closed Lost")) Error Message: Cannot change opportunity products for closed opportunities. 308 Extend Salesforce with Clicks, Not Code Customize Fields Field Value Error Location: Top of Page The following validation rule is on opportunities. Field Value Description: Prevents users from deleting opportunity products after an opportunity is closed. Create the following validation rule example on opportunities. It uses a custom roll-up summary field on opportunities that counts the number of opportunity products on an opportunity. Formula: AND(OR(ISPICKVAL(StageName, "Closed Won"), ISPICKVAL(StageName, "Closed Lost")), Number_of_Line_Items__c < PRIORVALUE(Number_of_Line_Items__c) ) Error Message: Cannot delete opportunity products for closed opportunities. Error Location: Top of Page Prevent Saving a Case When Account Does Not Have Support Field Value Description: Prevents users from saving a case for an account that does not have support. This example assumes you have a custom checkbox field on accounts called Allowed Support that tracks if the account has support. Formula: Account.Allowed_Support__c = FALSE Error Message: Unable to create cases for this account because it is not signed up for support. Error Location: Top of Page Prevent Saving a Case When Contact is No Longer with the Company Field Value Description: Prevents users from saving an open case associated with a contact that is no longer with the company. This example uses a custom checkbox field on contacts called No Longer With Company. 309 Extend Salesforce with Clicks, Not Code Customize Fields Field Value Formula: AND(Contact.Not_Longer_With_Company__c, NOT(IsClosed)) Error Message: Unable to save this case because the related contact is no longer with the company. To continue, choose another contact. Error Location: Contact Name Sample Date Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Date Must Be a Weekday Classic and Lightning Experience Field Value Available in: Contact Description: Validates that the value of a custom date field is a weekday (not Manager, Group, Professional, Enterprise, Saturday or Sunday). Performance, Unlimited, Formula: Developer, and CASE(MOD( My_Date__c - DATE(1900, 1, 7), 7), Database.com Editions 0, 0, 6, 0, 1) = 0 Error Message: Date must be a weekday. Error Location: My Date Date Must Be a Weekend Day Field Value Description: Validates that the value of a custom date field is a Saturday or Sunday. Formula: CASE( MOD( My_Date__c - DATE(1900, 1, 7), 7), 0, 1, 6, 1, 0) = 0 Error Message: Date must be a weekend day. Error Location: My Date 310 Extend Salesforce with Clicks, Not Code Customize Fields Date Must Be in the Current Month Field Value Description: Validates that a custom date field contains a date within the current month and year. Formula: OR ( YEAR( My_Date__c ) <> YEAR ( TODAY() ), MONTH( My_Date__c ) <> MONTH ( TODAY() ) ) Error Message: Date must be in the current month. Error Location: My Date Date Must Be in the Current Year Field Value Description: Validates that a custom date field contains a date within the current year. Formula: YEAR( My_Date__c ) <> YEAR ( TODAY() ) Error Message: Date must be in the current year. Error Location: My Date Date Must Be the Last Day of the Month Field Value Description: Validates whether a custom field called My Date is the last day of the month. To do this, it determines the date of the first day of the next month and then subtracts 1 day. It includes special case logic for December. Formula: DAY(My_Date__c) <> IF(Month(My_Date__c)=12, 31, DAY(DATE(YEAR(My_Date__c),MONTH(My_Date__c)+1,1) - 1)) Error Message: Date must be the last day of the month. Error Location: My Date 311 Extend Salesforce with Clicks, Not Code Customize Fields Date Must Be Within One Year of Today Field Value Description: Validates whether a custom field called Follow-Up Date is within one year of today’s date. This example assumes a 365 day year. (It does not handle leap years.) Formula: Followup_Date__c - TODAY() > 365 Error Message: Follow-Up Date must be within one year of today. Error Location: Follow-Up Date Day of Month Cannot Be Greater Than 15 Field Value Description: Validates that a custom field called Begin Date contains a date in the first 15 days of the specified month. Formula: DAY( Begin_Date__c ) > 15 Error Message: Begin Date cannot be after the 15th day of month. Error Location: Begin Date End Date Cannot Be Before Begin Date Field Value Description: Validates that a custom field called End Date does not come before another custom field called Begin Date. Formula: Begin_Date__c > End_Date__c Error Message: End Date cannot be before Begin Date. Error Location: Begin Date 312 Extend Salesforce with Clicks, Not Code Customize Fields Expiration Date Cannot Be Before Close Date Field Value Description: Validates that a custom field called Expiration Date does not come before Close Date. Formula: Expiration_Date__c < CloseDate Error Message: Expiration Date cannot be before Close Date. Error Location: Expiration Date Sample Number Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Time Cards Must Total 40 Hours Classic and Lightning Experience Field Value Available in: Contact Description: Ensures that users cannot save a time card record with more than Manager, Group, Professional, Enterprise, 40 hours in a work week. This example requires five custom fields on Performance, Unlimited, your custom object, one for each day of work. Developer, and Formula: Database.com Editions Monday_Hours__c + Tuesday_Hours__c + Wednesday_Hours__c + Thursday_Hours__c + Friday_Hours__c > 40 Error Message: Your total hours cannot exceed 40. Error Location: Top of Page Number Cannot Be Negative Field Value Description: Validates that a custom field called Hours Worked is not a negative number. Formula: Hours_Worked__c < 0 Error Message: Hours Worked cannot be less than zero. Error Location: Hours Worked 313 Extend Salesforce with Clicks, Not Code Customize Fields Number Must Be Even Field Value Description: Validates that a custom field called Ark Passengers is a non-negative even number. Formula: OR( Ark_Passengers__c < 0, MOD( Ark_Passengers__c, 2) <> 0 ) Error Message: Ark Passengers must be a positive even number. Error Location: Ark Passengers Number Must Be Odd Field Value Description: Validates that a custom field called Socks Found is a non-negative odd number. Formula: OR( Socks_Found__c < 0, MOD( Socks_Found__c, 2) = 0 ) Error Message: Socks Found must be an odd number. Error Location: Socks Found Number Must Be a Multiple of Five Field Value Description: Validates that a custom field called Multiple of 5 is a multiple of five. Formula: MOD( Multiple_of_5__c, 5) <> 0 Error Message: Number must be a multiple of five. Error Location: Multiple of 5 314 Extend Salesforce with Clicks, Not Code Customize Fields Number Must Be an Integer Field Value Description: Validates that a custom field called My Integer is an integer. Formula: FLOOR( My_Integer__c) <> My_Integer__c Error Message: This field must be an integer. Error Location: My Integer Number Must Be Between -50 and 50 Field Value Description: Validates that a custom field called Volume is between -50 and 50. Formula: ABS( Volume__c) > 50 Error Message: Volume must be between -50 and 50. Error Location: Volume Number Range Validation Field Value Description: Validates that the range between two custom fields, Salary Min and Salary Max, is no greater than $20,000. Formula: (Salary_Max__c - Salary_Min__c) > 20000 Error Message: Salary range must be within $20,000. Adjust the Salary Max or Salary Min values. Error Location: Salary Max 315 Extend Salesforce with Clicks, Not Code Customize Fields Percentage Must Be Between Zero and 100 Field Value Description: Validates that a custom field called Mix Pct is between 0 and 100%. Note that percent fields are expressed divided by 100 in formulas (100% is expressed as 1; 50% is expressed as 0.5). Formula: OR( Mix_Pct__c > 1.0, Mix_Pct__c < 0.0 ) Error Message: Mix Pct must be between 0 and 100%. Error Location: Mix Pct Sample Opportunity Management Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Conditionally-Required Field Based on Opportunity Stage Classic and Lightning Experience Field Value Available in: Contact Description: Validates that a custom field called Delivery Date is provided Manager, Group, Professional, Enterprise, if an opportunity has advanced to the Closed Won or Performance, Unlimited, Negotiation/Review stage. Developer, and Formula: Database.com Editions AND ( OR ( ISPICKVAL(StageName, "Closed Won"), ISPICKVAL(StageName, "Negotiation/Review")), ISBLANK(Delivery_Date__c) ) Error Message: Delivery Date is required for this stage. Error Location: Delivery Date 316 Extend Salesforce with Clicks, Not Code Customize Fields Close Date Cannot Be Prior to Current Month Field Value Description: Validates that the Close Date of an opportunity is not within a month prior to the current month. Note the use of ISNEW and ISCHANGED in this formula to ensure the condition is only checked when the opportunity is being created or the Close Date field is modified subsequently. Formula: AND( OR ( ISNEW(), ISCHANGED( CloseDate )), CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1) ) Error Message: Close Date cannot be prior to current month. Error Location: Close Date Close Date Must Be a Future Date Field Value Description: Ensures that users do not change the Close Date of an opportunity to a day in the past. Formula: SampleDate < TODAY() Error Message: Close Date cannot be a day in the past. Error Location: Close Date Discounts on Opportunities Field Value Description: Validates that a custom discount percent field is between 0 and 40%. Formula: OR(Discount_Rate__c < 0, Discount_Rate__c > 0.40) Error Message: The Discount Rate must not exceed 40%. Error Location: Discount Rate 317 Extend Salesforce with Clicks, Not Code Customize Fields High-Value Opportunity Must Be Approved Before Closed Field Value Description: Opportunities with amounts greater than $50,000 require that a custom checkbox field called Approved is checked in order to change the stage to Closed Won or Closed Lost. To automate this, set field-level security on the Approved checkbox so that it can only be checked via a custom approval process (Enterprise Edition, Unlimited Edition, or Performance Edition). Formula: AND( OR( ISPICKVAL(StageName,"Closed Won"), ISPICKVAL(StageName,"Closed Lost")), (Amount > 50000), NOT(ISPICKVAL(Approval_Status__c ,"Approved"))) Error Message: All high-value opportunities must be approved for closure. Click the Request Close button. Error Location: Top of Page Opportunity Amount Cannot Exceed $10 Million Field Value Description: Validates that opportunity Amount is positive and no more than $10 million. This limit is designed to catch typos. Formula: OR( Amount < 0, Amount > 10000000 ) Error Message: Amount cannot exceed $10 million. Error Location: Amount Opportunity Check for Products Field Value Description: Validates that an opportunity has at least one opportunity product before users can save a change to an opportunity. Formula: NOT(OR(ISNEW(),HasOpportunityLineItem)) Error Message: You must add products to this opportunity before saving. Error Location: Top of Page 318 Extend Salesforce with Clicks, Not Code Customize Fields Opportunity Must Have Products if Beyond “Needs Analysis” Stage Field Value Description: Validates that an opportunity has opportunity products before the Stage can move beyond Needs Analysis. Formula: AND ( CASE( StageName, "Value Proposition", 1, "Id. Decision Makers", 1, "Perception Analysis", 1, "Proposal/Price Quote", 1, "Negotiation/Review", 1, "Closed Won", 1, 0) = 1, NOT(HasOpportunityLineItem) ) Error Message: Opportunity products are required to advance beyond the Needs Analysis stage. Error Location: Top of Page Opportunity Name Format Field Value Description: Validates that an opportunity contains a hyphen as a way of enforcing an “[Account] - [Amount]” opportunity naming convention. Formula: FIND( " - ", Name ) = 0 Error Message: Opportunity Name should use “[Account] - [Amount]” format. Error Location: Opportunity Name 319 Extend Salesforce with Clicks, Not Code Customize Fields Prevent Sales Reps from Moving Opportunity Stage Backwards Field Value Description: Prevent sales reps from changing opportunity Stage “backwards” to specific values, once they have accepted the opportunity via a custom approval process. The approval process sets the custom Accepted Flag checkbox to True. Formula: AND( Accepted_Flag__c, OR ( ISPICKVAL( StageName, "Stage 1"), ISPICKVAL( StageName, "Stage 2")) ) Error Message: Invalid stage for accepted opportunity. Error Location: Stage Probability Must Be 100% for Won Opportunities Field Value Description: Validates that the probability of a won opportunity is properly set to 100%. This is useful for data cleanliness and reporting purposes. Formula: AND ( ISPICKVAL( StageName, "Closed Won"), Probability <> 1) Error Message: Probability must be 100% for won opportunities. Error Location: Probability Probability Must Be Zero for Lost Opportunities Field Value Description: Validates that the probability of a lost opportunity is properly set to zero. This is useful for data cleanliness and reporting purposes. Formula: AND ( ISPICKVAL( StageName, "Closed Lost"), Probability <> 0) Error Message: Probability must be 0% for lost opportunities. Error Location: Probability 320 Extend Salesforce with Clicks, Not Code Customize Fields Project Start Date Field Value Description: Validates that a field is conditionally required based on the values of other fields. Use this validation formula to ensure that users include a Project Start Date for an opportunity that is closed/won. Formula: AND(ISPICKVAL(StageName, "Closed Won"), ISNULL(Project_Start_Date__c)) Error Message: Project start date is required for won opportunities. Error Location: Project Start Date Sample Quote Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Display Error if Quote Line Item Discount Exceeds 40% Classic and Lightning Experience Field Value Available in: Contact Description: Shows an error if a quote line item's discount exceeds 40%. Manager, Group, Professional, Enterprise, Formula: Performance, Unlimited, Discount > .40 Developer, and Database.com Editions Error Message: The discount on this quote line item cannot exceed 40%. Error Location: Discount on quote Sample User, Role, and Profile Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Classic and Lightning Experience Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions 321 Extend Salesforce with Clicks, Not Code Customize Fields Discount Percent Does Not Exceed Role-Based Limit Field Value Description: Validates that a custom field on opportunities called Discount Percent does not exceed a maximum value that varies depending on the user’s role. The default maximum is 15%. Formula: Discount_Percent__c > VLOOKUP($ObjectType.Role_Limits__c.Fields.Limit__c, $ObjectType.Role_Limits__c.Fields.Name, $UserRole.Name) Error Message: Discount (%) exceeds limit allowed for your role. Error Location: Discount Percent Expense Amount Does Not Exceed User's Max Allowed Expense Field Value Description: Validates a custom field called Expense Amount against a custom user field called Max Allowed Expense. Formula: Expense_Amount__c > $User.Max_Allowed_Expense__c Error Message: Amount cannot exceed your maximum allowed expense. Error Location: Expense Amount Only Record Owner Can Change Field Field Value Description: Ensures that only the record owner can make changes to a custom field called Personal Goal. Formula: AND( ISCHANGED( Personal_Goal__c ), Owner <> $User.Id ) Error Message: Only record owner can change Personal Goal. Error Location: Personal Goal 322 Extend Salesforce with Clicks, Not Code Customize Fields Only Record Owner or Administrator Can Change Field Field Value Description: Ensures that a user can make changes to a custom field called Personal Goal only if the user is the record owner or has a custom profile of “Custom: System Admin.” Formula: AND( ISCHANGED( Personal_Goal__c ), Owner <> $User.Id, $Profile.Name <> "Custom: System Admin" ) Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions. Error Message: Only record owner or administrator can change Personal Goal. Error Location: Personal Goal Opportunity Close Date Can Only Be Back-Dated by Administrator Field Value Description: Validates that the Close Date of an opportunity does not fall prior to the current month, except for users who have a custom profile called “Custom: System Admin.” Formula: AND( OR ( ISNEW(), ISCHANGED( CloseDate )), CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1), $Profile.Name <> "Custom: System Admin" ) Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions. Error Message: Close Date cannot be prior to current month. Error Location: Close Date 323 Extend Salesforce with Clicks, Not Code Customize Fields Miscellaneous Sample Validation Rules For more information on any of the formula functions used in these examples, see Formula Operators EDITIONS and Functions on page 355. Available in: both Salesforce Allow Number to Be Increased but Not Decreased Classic and Lightning Experience Field Value Available in: Contact Description: Allows a custom field called Commit Amount to be increased Manager, Group, Professional, Enterprise, but not decreased after initial creation. This rule uses the Performance, Unlimited, PRIORVALUE() function to compare the updated value of the field to Developer, and its value prior to update. Database.com Editions Formula: PRIORVALUE(Commit_Amount__c) > Commit_Amount__c Error Message: Commit Amount cannot be decreased. Error Location: Commit Amount California Driver's License Field Value Description: Ensures that a custom field called Drivers License is in the correct A9999999 format when the Mailing State is “CA”. Formula: AND( MailingState = "CA", NOT(REGEX(Drivers_License__c, "([A-Z]\\d{7})?")) ) Error Message: Invalid California driver's license format. Error Location: Drivers License 324 Extend Salesforce with Clicks, Not Code Customize Fields Force Users to Check “I Accept Terms” to Enter Certain Values Field Value Description: Uses a checkbox labeled “I accept terms” to force the user to select a checkbox in order to enter a value called Number of Days that exceeds their Paid Time Off (PTO) balance available. Formula: AND( NOT( I_accept_terms__c ), Number_of_Days__c > $User.PTO_Balance__c ) Error Message: Request will cause a negative PTO balance. You must accept Negative PTO Balance terms. Error Location: I accept terms Prohibit Changes to a Field After It Has Been Saved Field Value Description: Prevents users from changing a custom field called Guaranteed Rate after it has been saved initially. Formula: AND( NOT( ISNEW() ), ISCHANGED( Guaranteed_Rate__c ) ) Error Message: Guaranteed Rate cannot be changed. Error Location: Guaranteed Rate 325 Extend Salesforce with Clicks, Not Code Customize Fields Social Security Number Format Field Value Description: Validates that a custom text field called SSN is formatted in 999-99-9999 number format (if it is not blank). The pattern specifies: • Three single digits (0-9):\\d{3} • A dash • Two single digits (0-9):\\d{2} • A dash • Four single digits (0-9):\\d{4} Formula: NOT( OR( ISBLANK(Social_Security_Number__c), REGEX( Social_Security_Number__c , "[0-9]{3}-[0-9]{2}-[0-9]{4}") ) ) Error Message: SSN must be in this format: 999-99-9999. Error Location: SSN Valid Currency Field Value Description: Validates selected currency against an explicit subset of active currencies in your organization using the Currency picklist. Use this example if you only allow some of the active currencies in your organization to be applied to certain types of records. Formula: CASE(CurrencyIsoCode, "USD", 1, "EUR", 1, "GBP", 1, "JPY", 1, 0) = 0 Error Message: Currency must be USD, EUR, GBP, or JPY. Error Location: Currency 326 Extend Salesforce with Clicks, Not Code Customize Fields Valid Credit Card Number Field Value Description: Validates that a custom text field called Credit_Card_Number is formatted in 9999-9999-9999-9999 or 9999999999999999 number format when it is not blank. The pattern specifies: • Four digits (0-9) followed by a dash: \\d{4}- • The aforementioned pattern is repeated three times by wrapping it in () {3} • Four digits (0-9) • The OR character (|) allows an alternative pattern of 16 digits of zero through nine with no dashes: \\d{16} Formula: NOT( REGEX( Credit_Card_Number__c , "(((\\d{4}-){3}\\d{4})|\\d{16})?")) Error Message: Credit Card Number must be in this format: 9999-9999-9999-9999 or 9999999999999999. Error Location: Credit Card Number Valid IP Address Field Value Description: Ensures that a custom field called IP Address is in the correct format, four 3-digit numbers (0-255) separated by periods. Formula: NOT( REGEX( IP_Address__c, "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.) {3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" )) Error Message: Error: IP Address must be in form 999.999.999.999 where each part is between 0 and 255. Error Location: IP Address 327 Extend Salesforce with Clicks, Not Code Customize Fields Website Extension Field Value Description: Validates a custom field called Web Site to ensure its last four characters are in an explicit set of valid website extensions. Formula: AND( RIGHT( Web_Site__c, 4) <> ".COM", RIGHT( Web_Site__c, 4) <> ".com", RIGHT( Web_Site__c, 4) <> ".ORG", RIGHT( Web_Site__c, 4) <> ".org", RIGHT( Web_Site__c, 4) <> ".NET", RIGHT( Web_Site__c, 4) <> ".net", RIGHT( Web_Site__c, 6) <> ".CO.UK", RIGHT( Web_Site__c, 6) <> ".co.uk" ) Error Message: Web Site must have an extension of .com, .org, .net, or .co.uk. Error Location: Web Site Require Field Input to Ensure Data Quality Improve the quality of data that users enter in Salesforce by creating universally required fields. EDITIONS A universally required field is a custom field. It must have a value whenever a record is saved within Salesforce, the Lightning Platform API, Connect Offline, Salesforce for Outlook, the Self-Service Available in: both Salesforce portal, or automated processes such as Web-to-Lead and Web-to-Case. Making a field required on Classic (not available in all a page layout or through field-level security ensures that users must enter a value. Making a field orgs) and Lightning required universally gives you a higher level of data quality beyond the presentation level of page Experience layouts. Available in: Contact You can make the following types of custom fields universally required: Manager, Group, Professional, Enterprise, • Currency Performance, Unlimited, • Date Developer, and • Date/Time Database.com Editions • Email Connect Offline, Salesforce • Master-Detail Relationship (always required) for Outlook, the Self-Service portal, Web-to-Lead, and • Number Web-to-Case are not • Percent available in Database.com • Phone . • Picklist • Text • Text Area • URL To make a custom field universally required, select the Required checkbox when defining the custom field. 328 Extend Salesforce with Clicks, Not Code Customize Fields Note: You must specify a default value for required campaign member custom fields. If you make a user field universally required, you must specify a default value for that field. Relationship group members do not support universally required fields. Considerations for Universally Required Fields Considerations for Universally Required Fields A universally required field is a custom field. It must have a value whenever a record is saved within EDITIONS Salesforce, the Lightning Platform API, Connect Offline, Salesforce for Outlook, the Self-Service portal, or automated processes such as Web-to-Lead and Web-to-Case. Review the following Available in: both Salesforce considerations before making your custom fields universally required. Classic (not available in all • Standard fields cannot be universally required. orgs) and Lightning Experience • Universally required fields are required across all record types. • Edit pages always display universally required fields, regardless of field-level security. Available in: Contact Manager, Group, • When designing your page layouts, universally required fields: Professional, Enterprise, – Cannot be removed from a page layout Performance, Unlimited, – Are automatically added to the end of the first section of a page layout if not already on it Developer, and Database.com Editions – Cannot be read only or optional – Display in bold, indicating they are always visible Standard Objects, Page Layouts, Connect Offline, – Are disabled on the field properties page because you cannot remove the required setting Salesforce for Outlook, the • Universally required fields are only enforced during lead conversion if validation and triggers Self-Service portal, Web-to-Lead, and for lead conversion are enabled in your organization. Web-to-Cases are not • Quick Create does not enforce universally required fields. available in Database.com • If you make an activity custom field universally required, you must also provide a default value. • You must include universally required fields in your import files or the import will fail. • Don’t assign default values to fields that are both required and unique, because uniqueness errors can result. • You cannot make a field universally required if it is used by a field update that sets the field to a blank value. • Required fields may be blank on records that existed before making the field required. When a user updates a record with a blank required field, the user must enter a value in the required field before saving the record. • Web-to-Lead and Web-to-Case request data is not validated by Salesforce. Invalid data isn’t saved when requests are submitted. For example, if your custom field is a currency field and a user enters alphabetic characters such as “Abc” instead of numbers, the request is still submitted but with no value saved in the custom currency field. SEE ALSO: Require Field Input to Ensure Data Quality 329 Extend Salesforce with Clicks, Not Code Customize Fields About Field Sets A field set is a grouping of fields. For example, you could have a field set that contains fields describing EDITIONS a user's first name, middle name, last name, and business title. When a field set is added to a Visualforce page, developers can loop over its fields and render them. If the page is added to a Available in: Salesforce managed package, administrators can add, remove, or reorder fields in a field set to modify the Classic fields presented on the Visualforce page without modifying any code. The same Visualforce page can present different sets of information, depending on which fields a subscriber prefers to keep. Available in: Group, Professional, Enterprise, As an administrator, you can create or edit field sets for your organization, or edit any installed field Performance, Unlimited, set. Field sets are available on all standard objects that support custom fields, and any organization and Developer Editions that supports creating Visualforce pages. Note: Only fields available in the API can be added to field sets. Fields added to a field set can be in one of two categories: • If a field is marked as Available for the Field Set, it exists in the field set, but the developer hasn’t presented it on the packaged Visualforce page. Administrators can display the field after the field set is deployed by moving it from the Available column to the In the Field Set column. • If a field is marked as In the Field Set, the developer has rendered the field on the packaged Visualforce page by default. Administrators can remove the field from the page after the field set is deployed by removing it from the In the Field Set column. Creating and Editing Field Sets Field Sets Required Bit SEE ALSO: Create Custom Fields Developer's Guide: Visualforce Developer's Guide ISVforce Guide Creating and Editing Field Sets Salesforce has a drag-and-drop WYSIWYG tool for creating and editing field sets The enhanced EDITIONS field sets editor is enabled by default, and provides all of the functionality of the original editor, as well as additional functionality and an easier-to-use WYSIWYG interface. Available in: Salesforce 1. From the management settings for the appropriate object, go to Field Sets, and then click New. Classic 2. Enter a Field Set Label. This is the name presented to subscribers who install the field through Available in: Contact a managed package. Manager, Group, 3. Optionally, enter a name for your field set. This is used by your Visualforce page to reference Professional, Enterprise, Performance, Unlimited, the field set. and Developer Editions 4. In the Where is this used? area, provide a brief description of which Visualforce pages use the field set, and for what purpose. This information helps a subscriber understand where and how an installed field set is being used, so that they can populate it with their own fields. 5. Save your changes. 330 Extend Salesforce with Clicks, Not Code Customize Fields 6. To add fields to the field set, drag the fields from the object palette and drop them into the Available for the Field Set or the In the Field Set container. The fields in the Available for the Field Set container are not initially visible on the Visualforce page. The fields in the In the Field Set container are visible by default. Note: In the field set, you can span to fields that reference multiple objects. When you span a field into a field set that references multiple objects, the only field you can span to is the Name object. You can drag and drop a field from one container to the other. The vertical order of the In the Field Set list indicates the order of how the fields render on Visualforce pages. 7. To remove a field from the field set, drag the element back to the object palette, or click next to the element. 8. To make a field required, double click the element or click ( ) next to it and select the Required checkbox. Note: Indicates the field is required and must have a value to save the record. 9. Save your changes. Important: The total number of cross object spans within the In the Field Set container can't exceed 25. After a field set is deployed in your organization, you can always mark fields that are in the Available for the Field Set list as In the Field Set, or vice versa. To do so: 1. Find the field set that you want to edit. From Setup enter Installed Packages in the Quick Find box, select Installed Packages, click an installed package, and then click the field set you want to edit. Alternatively, if you know which object contains the field set you want to edit, go to the object detail page and click Edit in the field set related list. 2. If you didn't create the field set initially, you'll only be able to edit the fields within the field set. To move fields between containers, drag and drop a field from one container to the other. To change the order of a rendered field, drag a field up or down the list and drop the field in the order you want it to appear. 3. Save your changes. SEE ALSO: About Field Sets Field Sets Required Bit You can define a field as required when you create or edit field sets. You may want to define a field EDITIONS as required to ensure a user enters the necessary information on a field. The required field is only available in the In the Field Set container. If you define a field as required in the In Available in: Salesforce the Field Set container, and remove the field from the In the Field Set, the Classic required attribute is removed. Available in: Group, Note: If you remove fields that were made required by an installed managed package from Professional, Enterprise, the In the Field Set container, the required attribute isn’t removed from those Performance, Unlimited, fields. and Developer Editions To define a field as required in a field set, see Creating and Editing Field Sets on page 330 SEE ALSO: About Field Sets 331 Extend Salesforce with Clicks, Not Code Customize Fields Roll-Up Summary Field A roll-up summary field calculates values from related records, such as those in a related list. You EDITIONS can create a roll-up summary field to display a value in a master record based on the values of fields in a detail record. The detail record must be related to the master through a master-detail relationship. Available in: both Salesforce For example, you want to display the sum of invoice amounts for all related invoice custom object Classic (not available in all records in an account’s Invoices related list. You can display this total in a custom account field orgs) and Lightning called Total Invoice Amount. Experience You can perform different types of calculations with a roll-up summary field. You can count the Available in: Contact number of detail records related to a master record. Or, you can calculate the sum, minimum value, Manager, Group, or maximum value of a field in the detail records. Professional, Enterprise, Before you begin creating roll-up summary fields for your organization, review the implementation Performance, Unlimited, tips and best practices. Developer, and Database.com Editions Implementation Tips Administration • Create roll-up summary fields on: – Any custom object that is on the master side of a master-detail relationship – Any standard object that is on the master side of a master-detail relationship with a custom object – Opportunities using the values of opportunity products related to the opportunity – Accounts using the values of related opportunities – Campaigns using campaign member status or the values of campaign member custom fields Note: Campaign member custom formula fields that reference fields derived from leads or contacts are not supported. • The types of fields you can calculate in a roll-up summary field depend on the type of calculation. For example, – Number, currency, and percent fields are available when you select SUM as the roll-up type. – Number, currency, percent, date, and date/time fields are available when you select MIN or MAX as the roll-up type. • Sometimes you can’t change the field type of a field that you reference in a roll-up summary field. • Make sure that the filter for your roll-up summary doesn't encounter a formula field that results in “#Error!”. If one of your filter criteria uses a formula field that results in an error, no matches are returned for that filter criterion. For example, your roll-up summary filter is “Formula Field equals 10”. Two records contain errors, and one contains the value “10” in that field. In this case, your summary includes only the record with the value “10.” • Salesforce does not recalculate the value of campaign roll-up summary fields when leads or contacts are deleted. Select the Force a mass recalculation of this field option on the edit page of the roll-up summary field to manually recalculate the value. • You can’t use long text area, multi-select picklist, Description fields, system fields like Last Activity, cross-object formula fields, and lookup fields in the field column of roll-up summary filters. • Auto number fields are not available as the field to aggregate in a roll-up summary field. • After you have created a roll-up summary field on an object, you cannot convert the object's master-detail relationship into a lookup relationship. • Roll-up summary fields are not available for mapping lead fields of converted leads. Management 332 Extend Salesforce with Clicks, Not Code Customize Fields • If a roll-up summary field doesn’t contain cross-object field references or functions that derive values on the fly, such as NOW or TODAY, it can calculate the values of formula fields. Note: The value of a formula field can result in “#Error!”, which affects the summarized total. If your roll-up summary type is COUNT, records are included regardless of whether they contain a formula field with an error. However, when the Field to Aggregate is a formula field that results in “#Error!”, calculations of type MIN, MAX, and SUM exclude those formula values. • Changes to the value of a roll-up summary field can trigger assignment rules to run. If a roll-up summary field is part of the criteria in an assignment rule, the field’s new value is used to evaluate whether to reassign the record. • A roll-up summary field can trigger workflow rules and field validations. However, workflow rules and field validations do not fire when the following changes cause a mass recalculation of roll-up summary values: – Changing the roll-up summary definition (such as the object, function, or field being aggregated) – Changing the expression of a formula field referenced in a roll-up summary field – Replacing picklist values for picklist fields referenced in the roll-up summary filter – Changing picklist record type definitions – Changing currency conversion rates – Changing price book entries • Calculating roll-up summary field values can take up to 30 minutes, depending on the number of records affected and other factors. • You aren’t prevented from creating roll-up summary fields that can result in invalid values, such as February 29 in a non-leap year. If a roll-up summary field results in an invalid value, the value is not recalculated. The field continues to display with an invalid roll-up summary icon ( ) until you change the values being summarized. • If your organization uses multiple currencies, the currency of the master record determines the currency of the roll-up summary field. For example, if the master and detail records are in different currencies, the detail record value is converted into the currency of the master record. • Changing a conversion rate triggers roll-up summary fields to recalculate. If you’re using multiple currencies, we recommend changing the conversion rate from Manage Currencies in Setup, and not from the API. If you change the rate from the API, related jobs that are less than 24 hours old can interfere with your change. For details, see Edit Conversion Rates. • If your organization has advanced currency management enabled, currency roll-up summary fields are invalid if they are on accounts and summarizing opportunity values, or on opportunities and summarizing custom object values. • Salesforce prevents users from saving a record if it invalidates a related record. For example, a master record has a validation rule that requires the roll-up summary field value to be greater than 100. If the user’s change to a related child record would put the value over 100, the user can’t save the record. • If a lookup field references a record that has been deleted, Salesforce clears the value of the lookup field by default. Alternatively, you can choose to prevent records from being deleted if they’re in a lookup relationship. To be used in a roll-up summary field with a Roll-Up Type of COUNT or SUM, the lookup field must have the What to do if the lookup record is deleted? option set to Don’t allow deletion of the lookup record that’s part of a lookup relationship. If the option Clear the value of this field. You can’t choose this option if you make the field required is selected, you can’t create a COUNT or SUM roll-up summary field that pulls data from your lookup field. • When multiple currencies are enabled in an org and corporate currency is different from the currency set on the record, the UI and the database for roll-up summary field values can display different decimal values. Values in the UI are displayed as two decimal places, whereas the database displays the exact value, which can be several decimal places. This behavior is due to the way values are stored in the database. The UI precision doesn’t affect the precision of the database, which is a floating-point value. 333 Extend Salesforce with Clicks, Not Code Customize Fields In some cases, there can be small numerical remainders after deletion or filtering of records when you use SUM as the roll-up type. To correct the value, select the Force a mass recalculation of this field option on the edit page of the roll-up summary field to manually recalculate the value. • When you delete a roll-up summary field using Metadata API, the field isn't saved in the Recycle Bin. The field is purged even if you don’t set the purgeOnDelete deployment option to true. Best Practices • Apply field-level security to your roll-up summary fields if they calculate values that you do not want visible to users. Fields that your users cannot see due to field-level security settings on the detail record are still calculated in a roll-up summary field. • If you have validation rules, consider how they affect roll-up summary fields. The value in a roll-up summary field changes when the values in the detail records change. So, validation errors can display when saving either the detail or master record. • Because roll-up summary fields are not displayed on edit pages, you can use them in validation rules but not as the error location for your validation. • Avoid referencing a roll-up summary field from a child record. The roll-up summary fields referenced from child records can have outdated values, because their parent records have not been updated. Instead, reference roll-up summary fields from parent records. Your roll-up summary fields will always have updated values, because that rule runs after the parent value has been updated. If you’re trying to enforce a record limit of 25 on the parent roll-up summary field, create validation rules on your child objects. When you add a child record, your validation rule on the child object can check if the count is already 25 or greater. AND(ISNEW(), Sample.Line_Count__c >= 25) • Plan your implementation of roll-up summary fields carefully before creating them. Once created, you cannot change the detail object selected or delete any field referenced in your roll-up summary definition. • Advanced currency management affects roll-up summary fields. If your organization enables advanced currency management, delete the currency roll-up summary fields on accounts that summarize opportunity values and on opportunities that summarize custom object values. Otherwise, the fields continue to display with an invalid roll-up summary icon because their values are no longer calculated. • Automatically derived fields, such as current date or current user, aren’t allowed in a roll-up summary field. Forbidden fields include formula fields containing functions that derive values on the fly, such as DATEVALUE, NOW, and TODAY. Formula fields that include related object merge fields are also not allowed in roll-up summary fields. • When you refer to a roll-up summary field in a list view or report, you can’t use certain qualifiers, including: – Starts with – Contains – Does not contain – Includes – Excludes – Within 334 Extend Salesforce with Clicks, Not Code Customize Fields Defining Roll-Up Summaries Define roll-up summary fields on the object that is on the master side of a master-detail relationship. SEE ALSO: Create Custom Fields Custom Fields Allowed Per Object Defining Roll-Up Summaries Define roll-up summary fields on the object that is on the master side of a master-detail relationship. EDITIONS If a relationship does not already exist, first create a master-detail relationship between the master object that displays the value and the detail object containing the records you are summarizing. Available in: both Salesforce Classic and Lightning To define a roll-up summary field: Experience 1. Create a custom field on the object where you want the field displayed. Summary fields summarize the values from records on a related object, so the object on which you create the Available in: Contact field should be on the master side of a master-detail relationship. For instructions on creating Manager, Group, Professional, Enterprise, a custom field, see Create Custom Fields on page 218. Performance, Unlimited, 2. Choose the Roll-Up Summary field type, and click Next. Developer, and 3. Enter a field label and any other attributes. Click Next. Database.com Editions 4. Select the object on the detail side of a master-detail relationship. This object contains the records you want to summarize. USER PERMISSIONS 5. Select the type of summary: To view roll-up summary field definitions: Type Description • View Setup and Configuration COUNT Totals the number of related records. To edit roll-up summary field SUM Totals the values in the field you select in the Field to Aggregate definitions: option. Only number, currency, and percent fields are available. • Customize Application MIN Displays the lowest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available. MAX Displays the highest value of the field you select in the Field to Aggregate option for all directly related records. Only number, currency, percent, date, and date/time fields are available. 6. Enter your filter criteria if you want a selected group of records in your summary calculation. If your organization uses multiple languages, enter filter values in your organization's default language. When you use picklists to specify filter criteria, the selected values are stored in the organization's default language. If you edit or clone existing filter criteria, first set the Default Language on the Company Information page to the same language that was used to set the original filter criteria. Otherwise, the filter criteria may not be evaluated as expected. 7. Click Next. 8. Set the field-level security to determine whether the field should be visible for specific profiles, and click Next. 335 Extend Salesforce with Clicks, Not Code Customize Fields 9. Choose the page layouts that should display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is automatically added to the bottom of the user detail page. 10. Click Save to finish or Save & New to create more custom fields. SEE ALSO: Roll-Up Summary Field Lookup Filters Improve user productivity and data quality with lookup filters. Lookup filters are administrator EDITIONS settings that restrict the valid values and lookup dialog results for lookup, master-detail, and hierarchical relationship fields. Available in: both Salesforce Administrators specify the restrictions by configuring filter criteria that compare fields and values Classic (not available in all on: orgs) and Lightning Experience • The current record (source) • The lookup object (target) Available in: All Editions except for Database.com. • The user's record, permissions, and role • Records directly related to the target object USER PERMISSIONS For example, you can: • Restrict the Account Name field on opportunities to allow only accounts with a record type To manage lookup filters: of Customer, filtering out Partner and Competitor. • Customize Application • Restrict the Account Name field on opportunities to allow only active accounts. • Restrict the Contact field on cases to allow only contacts associated with the account specified in the Account Name field on the case record. • Restrict the Account Name field on cases to allow only users with the “International Sales” profile to create or edit cases for accounts outside the United States. Tip: When you define a lookup filter, you can choose from a list of filter criteria that Salesforce suggests. The list is based on the relationships between objects in your org. To see the suggested criteria, select Insert Suggested Criteria. In Salesforce Classic, administrators can make lookup filters required or optional. In Lightning Experience, all lookup filters are required, even if admins specify them as optional in Setup. • For fields with required lookup filters, values that match the lookup filter criteria appear in the lookup dialog. When editing the record, users can't save invalid values that they type in the field. If a user tries to save an invalid value, Salesforce displays an error message, which administrators can customize. • For fields with optional lookup filters (Salesforce Classic only), values that match the lookup filter criteria appear in the lookup dialog. To remove the filter and view all search results for the lookup field, users can select Show all results in the lookup dialog. Also, optional lookup filters let users save values that don't match the lookup filter criteria without Salesforce displaying any error message. Lookup filter criteria can compare fields on the source object with different types of fields on the target object as long as the fields are compatible. Source Object Field Type Compatible Target Object Field Types Currency Currency, Roll-Up Summary Date Date, Date/Time, Roll-Up Summary 336 Extend Salesforce with Clicks, Not Code Customize Fields Date/Time Date, Date/Time, Roll-Up Summary Hierarchy Hierarchy, Lookup, Master-Detail Lookup Hierarchy, Lookup, Master-Detail Master-Detail Lookup, Hierarchy, Master-Detail Number Number, Percent, Roll-Up Summary Percent Number, Percent, Roll-Up Summary Picklist Text, Text Area, Email, URL Roll-Up Summary Currency, Number, Date, Date/Time, Roll-Up Summary Supported Objects Salesforce supports lookup filters on relationship fields that point to: • Accounts • Assets • Badges • Badges Received • Business Hours • Campaigns • Cases • Contacts • Content Folders • Contracts • Endorsements • Entitlements • Ideas • Leads • Opportunities • Order Products • Orders • Products • Quotes • Service contracts • Skill Users • Skills • Social Personas • Solutions • Thanks • User Provisioning Accounts 337 Extend Salesforce with Clicks, Not Code Customize Fields • User Provisioning Logs • User Provisioning Requests • Users • Work Order Line Items • Work Orders • Zones • Custom objects Define Lookup Filters Delete or Deactivate Lookup Filters View a List of Lookup Filters for a Target Object Dependent Lookups Considerations for Lookup Filters Notes on Using Lookup Filters with Person Accounts Lookup Filters Best Practices Lookup Filter Examples Limitations on Lookup Filters Define Lookup Filters 1. You can create lookup filters for new relationship fields in step 3 of the custom field wizard. EDITIONS a. From the management settings for the field’s object, go to Fields. b. Click Edit next to the name of the lookup or master-detail relationship field to which you Available in: both Salesforce Classic (not available in all want to apply the filter. orgs) and Lightning 2. In the Lookup Filter Options section, click Show Filter Settings. Experience 3. Specify the filter criteria a record must meet to be a valid value. To specify criteria, click Insert Available in: All Editions Suggested Criteria and choose from a list of suggested criteria, or manually enter your own except for Database.com. criteria. To enter your own criteria: a. In the first column, click the lookup icon or start typing in the text box and select a field. USER PERMISSIONS b. In the second column, select an operator. To define lookup filters: c. In the third column, select Value if Salesforce should compare the field in the first column • Customize Application with a static value, or select Field if Salesforce should compare the field in the first column with the value of another field. d. In the fourth column, enter the value or select the field that Salesforce should compare with the field in the first column. Note: • Click Add Filter Logic to add Boolean conditions. • Select a suggested field from the Field text box. You can only select fields on the current record, the lookup object, or the user record. You can also choose related fields that are one relationship away from the lookup object. Salesforce assists you by listing the available fields and relationships when you click the lookup icon or click inside the text box. • Lookup filter criteria can compare fields of different types as long as they are compatible. 338 Extend Salesforce with Clicks, Not Code Customize Fields • Value-based filters are supported in Lightning Experience and Salesforce Classic. 4. Specify whether the filter is required or optional. For fields with optional lookup filters (Salesforce Classic only), values that match the lookup filter criteria appear in the lookup dialog. To remove the filter and view all search results for the lookup field, users can select Show all results in the lookup dialog. Also, optional lookup filters let users save values that don't match the lookup filter criteria without Salesforce displaying any error message. Note: In Lightning Experience, all filters are required, even if admins specify them as optional in Setup. There’s no Show all results view. For required lookup filters, specify whether you want Salesforce to display the standard error message or a custom message when a user enters an invalid value. 5. Optionally, enter text to display in the lookup search dialog. Consider text that guides users in their searches and explains the business rule that the lookup filter implements. 6. Leave Enable this filter selected. 7. Save your changes. SEE ALSO: Considerations for Lookup Filters Dependent Lookups Lookup Filter Examples Find Object Management Settings Delete or Deactivate Lookup Filters 1. From the managements settings for the relationship field’s object, go to Fields. EDITIONS 2. Scroll to the Custom Fields & Relationships related list. 3. Click the name of the field containing the lookup filter. Available in: both Salesforce Classic (not available in all 4. Click Edit. orgs) and Lightning 5. To deactivate the lookup filter, deselect Enable this filter, then save your changes. Experience Deactivating a lookup filter preserves the lookup filter configuration but: Available in: All Editions • Prevents it from applying to the relationship field except for Database.com. • Prevents it from impacting the cross-object references limit • Removes it as a dependency for fields referenced in the lookup filter criteria USER PERMISSIONS 6. To delete the lookup filter, click Clear Filter Criteria, then save your changes. To define lookup filters: • Customize Application Deleting a lookup filter permanently removes it. You can’t recover deleted lookup filters. SEE ALSO: Dependent Lookups Considerations for Lookup Filters Find Object Management Settings 339 Extend Salesforce with Clicks, Not Code Customize Fields View a List of Lookup Filters for a Target Object You can quickly see a list of all of the lookup filters that restrict the values of each target object. This EDITIONS is useful when creating similar filters for a target object. Also, lookup filters that reference fields on related objects count against the cross-object reference limit, which is the number of unique Available in: both Salesforce relationships allowed for a target object. The Related Lookup Filters list lets you see which lookup Classic (not available in all filters might impact that limit. orgs) and Lightning To see which lookup filters affect the limit for a particular target object, from the management Experience settings for the object, go to Related Lookup Filters. Available in: All Editions except for Database.com. SEE ALSO: Dependent Lookups USER PERMISSIONS Considerations for Lookup Filters To define lookup filters: • Customize Application Dependent Lookups A dependent lookup is a relationship field with a lookup filter that references fields on the source EDITIONS object. For example, you can configure the case Contact field to only show contacts associated with the account selected in the case Account Name field. Available in: both Salesforce When a user changes the value of a referenced field on the source object, Salesforce immediately Classic and Lightning verifies that the value in the dependent lookup still meets the lookup filter criteria. If the value Experience doesn't meet the criteria, an error message is displayed and users can't save the record until the Available in: All Editions value is valid. If the referenced field on the source object is a lookup, master-detail, or hierarchy field, users can't USER PERMISSIONS change its value by typing. Instead, users must click the lookup icon and select a value in the lookup search dialog. To manage dependent lookups: Tip: Dependent lookups are supported in Visualforce pages. • Customize Application SEE ALSO: Define Lookup Filters Lookup Filter Examples 340 Extend Salesforce with Clicks, Not Code Customize Fields Considerations for Lookup Filters • On the Fields page, the icon indicates all fields with active lookup filters. The icon EDITIONS indicates that the lookup filter is required. • The lookup filters you create in Salesforce also appear in the partner portal and Customer Portal. Available in: both Salesforce • Lookup filters are case-sensitive. Classic (not available in all orgs) and Lightning • If you convert a required lookup filter with a custom error message to be optional, Salesforce Experience deletes the message. • If you create a lookup filter that invalidates an existing value for that field, the value persists. Available in: All Editions However, when a user edits the record, Salesforce displays an error message and requires the except for Database.com. user to change the invalid value before saving. • You can’t save changes that cause required lookup filters on related records to contain invalid USER PERMISSIONS values. To manage lookup filters: • Versions 16.0 and higher of the Salesforce API support lookup filters. Lookup filters are enforced • Customize Application when you load data through the API. • If you configure a lookup filter to show inactive users only, the relationship field has no valid options. Inactive users are never valid for relationship fields that point to the User object. • If you create a filtered lookup on a field that looks up to another object, deploy both objects into the organization at the same time. • If the field criteria include a master-detail relationship field, lookup field filters don’t work. • If the value of a controlling field invalidates the value of a dependent master-detail relationship field, Salesforce doesn’t display an error message. • Dependent lookups are supported in Visualforce pages. • In Lightning Experience, a lookup filter doesn’t work if a field referenced in the filtered lookup criteria isn't added to the page layout. When a user opens the lookup dialog box, the value being searched is automatically deleted. To avoid this issue, add the missing field that is being used in the lookup field filter criteria to the page layout. • Knowledge articles don’t support lookup filters. • Value-based filters are supported in Lightning Experience and Salesforce Classic. • If an unlocked 2GP package installs a lookup filter, then a later version of the package deletes that lookup filter, the lookup filter isn’t removed from the subscriber org. The lookup filter must be deleted manually instead. • When changing ownership of a record in Salesforce Classic, fields on the record that have active lookup filters aren’t validated. As a workaround, we recommend doing lookup filter validation for a record’s fields before changing the record’s owner. Spanning Relationships in Lookup Filters Filter criteria can include fields related to the target object (one level only). For example, a lookup field points to a contact. The lookup filter can reference fields on the account related to the contact using the Account Name relationship field. The lookup field can also reference fields on the contact related to the contact via the Reports To relationship field. For required lookup filters, each field referenced on a related lookup object counts against the number of unique relationships allowed for the referenced object. The relationships aren’t counted against the source object. For example, the two unique relationships described above count against the number allowed for the Contact object. Optional lookup filters don't count against the limit on the number of unique relationships allowed per object. To see which lookup filters affect the limit for a particular target object, from the management settings for the object, go to Related Lookup Filters. 341 Extend Salesforce with Clicks, Not Code Customize Fields Lookup Filters vs. Validation Rules Validation rules and lookup filters achieve similar ends, but offer different advantages. Use a lookup filter: • To improve user efficiency by limiting the number of available options in a lookup search dialog. • To improve user efficiency by automating filters on lookup search dialogs that your users manually set. Use a validation rule: • If you're close to the maximum number of lookup filters allowed. • To implement a complex business rule that requires you to use a formula. Formulas can reference fields that basic filter criteria can't reference, such as fields on the parent of the source object. Formulas can also use functions. For example, use ISNEW to apply the rule only on record creation, or ISCHANGED to apply the rule only when a field changes. SEE ALSO: Lookup Filters Dependent Lookups Notes on Using Lookup Filters with Person Accounts If your organization uses person accounts, note the following: EDITIONS • Person Accounts don't support Contact filters; however, Person Accounts support Account filters. For example, if the Account field has a dependent lookup filter that's added to a Person Available in: both Salesforce Account, dependent lookups are supported. If the Contact field has a dependent lookup filter Classic (not available in all that's added to a Person Account, dependent lookups aren't supported. orgs) and Lightning Experience • Lookup filter criteria on Account Name only apply to business accounts, not person accounts. For example, your lookup filter criteria is Account Name does not contain book. Available in: All Editions Business accounts with “book” in the name, such as John’s Bookstore, aren’t valid. Person except for Database.com. accounts with “book” in the name, such as John Booker, are valid. The person accounts show in the lookup dialog for the Account field. If you must filter on the name for a person account, use the First Name or Last Name fields instead. • To restrict the values of a lookup field to one type of account (person or business), use the Is Person Account field in your lookup filter criteria. For example, to restrict a lookup to only person accounts, include the following in your lookup filter criteria: Is Person Account equals True. • You can't package lookup filters that reference standard fields specific to person accounts, such as the Email and Title fields. SEE ALSO: Lookup Filters 342 Extend Salesforce with Clicks, Not Code Customize Fields Lookup Filters Best Practices Custom Help EDITIONS Define custom help for fields with lookup filters to let users know about the business rule the filter enforces. For example, if the lookup filter restricts the Account Name on opportunities Available in: both Salesforce to only allow active accounts, define custom help that states You can only associate Classic (not available in all active accounts with opportunities. orgs) and Lightning Error Messages Experience Customize lookup filter error messages to guide users who type invalid values. For example, if Available in: All Editions the lookup filter restricts the Account Name on opportunities to only allow active accounts, except for Database.com. define an error message that states Value doesn't exist or isn't an active account. Important: Salesforce translates the standard error message for required lookup filters, but not custom error messages. Use the Translation Workbench to translate lookup filter custom error messages. To restore the standard error message after modifying it, click Reset to default message. Working with Master-Detail Relationship Fields When creating a lookup filter on a master-detail relationship field, verify that the current values of the field on all of the detail records meet the criteria you specify. If you specify criteria that an existing value doesn't meet, Salesforce prevents the user from saving changes to the detail record. If this occurs, the user must first modify the value on the master record to meet the criteria. For example, consider a custom object with a master-detail relationship field that points to accounts. If you define a lookup filter that excludes all accounts with a Create Date before 01/01/2009, verify that no existing records of that custom object have a master-detail relationship with any account created before 2009. A quick way to do this is to create a report that shows all accounts with a Create Date before 01/01/2009. Profile-Based Lookup Filters Use Current User Profile: ID in filter criteria to define different filter criteria for different users, or to let administrators enter values that don't match the criteria. Avoid using Current User Profile: Name due to technical limitations on standard profiles. If you enter Current User Profile: Name or Profile: Name in the Field column of your lookup filter criteria, Salesforce displays a lookup icon in that row. Click the lookup icon to select from a list of existing profiles rather than typing profile names. Record IDs vs. Record Names To reference a specific record in filter criteria, use the ID of the record instead of its name. IDs are always unique whereas names are not. Testing After creating a lookup filter, test it to make sure it is not too restrictive. Depending on their permissions, some users may have read-only access to some relationship fields; ensure your lookup filters don't prevent those users from editing records critical to their job functions. Dependent Lookups on Page Layouts and Mini Page Layouts in the Console When designing page layouts with dependent lookups: • If a dependent lookup is above its controlling field on a layout, make its lookup filter optional or redesign the layout. Moving a required dependent lookup above its controlling field may confuse users who typically start from the top of a page when entering data. • Ensure that both the controlling and dependent fields are visible so users can correct invalid values. 343 Extend Salesforce with Clicks, Not Code Customize Fields Lookup Filters and the Lookup Filter Fields Search Layout Don’t reference the same fields in both lookup filter criteria and the Lookup Filter Fields search layout. Users might assume that results from their custom search override administrator-controlled lookup filters. SEE ALSO: Lookup Filters Lookup Filter Examples EDITIONS Record Types in Lookup Filters If the value of a relationship field should only consist of records with a particular record type, specify Available in: both Salesforce the record type in a lookup filter. For example, if the Account Name field on opportunities Classic (not available in all should only have accounts with a Customer Account custom record type, define the following orgs) and Lightning lookup filter to restrict users to only creating or editing opportunities associated with accounts that Experience have a Customer Account record type, excluding accounts with Partner Account and Competitor Available in: All Editions Account record types: except for Database.com. Filter Criteria Record types available in: Account Name: Account Record Type equals value Customer Professional, Enterprise, Account Performance, Unlimited, Custom Error Message and Developer Editions Account does not exist or is not a customer account. Lookup Window Text USER PERMISSIONS You can only associate customer accounts to an opportunity. Search results only display customer accounts. To define lookup filters: • Customize Application Record Status in Lookup Filters If the value of a relationship field should only consist of records with particular status, specify the status in a lookup filter. For example, consider a Job Application object with a relationship field that points to the Position object. If the relationship field should only have open positions, define the following lookup filter to restrict users to only creating or editing job applications for positions with the Status field set to Open: Filter Criteria Position: Status equals value Open Custom Error Message Position does not exist or is not an open position. Lookup Window Text You can associate only open positions with job applications. Search results display open positions only. Profiles in Lookup Filters When a business rule does not apply to users with every profile, use the Current User Profile global variable fields to define lookup filters that only affect users with a particular profile. 344 Extend Salesforce with Clicks, Not Code Customize Fields For example, the following lookup filter on the Case object Account Name field restricts users with a “Domestic Sales” profile to only creating or editing opportunities associated with accounts that have a billing country of “USA” while allowing other users to associate opportunities with any account: Filter Criteria 1. Current User Profile: Name equals value Domestic Sales 2. Account Name: Billing Country equals value USA 3. Current User Profile: Name not equal to value Domestic Sales Filter Logic (1 AND 2) OR 3 Custom Error Message Account does not exist or the account billing country is not USA. Domestic sales reps can only create opportunities for accounts in the United States. Lookup Window Text Search results show only United States accounts in the for domestic sales representatives. You can modify the above example to simultaneously restrict users with a “Global Sales” custom profile to only associating opportunities to accounts with a non-US billing country: Filter Criteria 1. Current User Profile: Name equals value Global Sales 2. Account Name: Billing Country not equal to value USA 3. Current User Profile: Name equals value Domestic Sales 4. Account Name: Billing Country equals value USA 5. Current User Profile: Name not equal to value Global Sales, Domestic Sales Filter Logic (1 AND 2) OR (3 AND 4) OR 5 Custom Error Message Account does not exist or the account billing country is not in your sales area. Sales reps can only create opportunities for accounts in their sales area. Lookup Window Text Search results only display accounts in your region. Important: If you do not include line 5 in the filter criteria, users who are not in Global Sales or Domestic Sales cannot select or save any values on account records. Roles in Lookup Filters When a business rule does not apply to users in every role, use the Current User Role global variable fields to define lookup filters that only affect users with particular roles. For example, in a recruiting application that has a Position object with a lookup field to a Compensation Package object, you can restrict users from editing or creating positions that have an executive compensation plan unless they are executive administrators or vice presidents. To do this, define the following lookup filter on the Position object Compensation Package Name field: Filter Criteria 1. Current User Role: Name does not start with value VP 345 Extend Salesforce with Clicks, Not Code Customize Fields 2. Current User Role: Name does not equal value Executive Administrator 3. Compensation Package: Plan Type does not equal value Executive 4. Current User Role: Name starts with value VP 5. Current User Role: Name equals value Executive Administrator Filter Logic ((1 OR 2) AND 3) OR (4 OR 5) Custom Error Message The compensation plan does not exist, or you have selected an executive compensation plan but do not have access to create executive positions. Lookup Window Text Search results only display compensation plans that are relevant to positions you are allowed to create. Important: Include the condition you are testing and the opposite condition. In this example, lines 1, 2, and 3 of the filter criteria ensure that users who are not VPs or Executive Administrators cannot select Executive compensation plans, while lines 4 and 5 ensure that VPs and Executive Administrators can select Executive compensation plans. Blank Values in Lookup Filters Your lookup filter criteria might reference a field that users often leave blank. You can design your lookup filter criteria to accept blank values by using the Add Filter Logic in the filter criteria to create an OR condition. For example, if you have a Partner Contact custom field on opportunities, restrict the field to only allow contacts that are associated to an account with a Partner Account record type, or private contacts not associated with any account. Filter Criteria 1. Partner Contact: Account: Account Record Type equals value Partner Account 2. Partner Contact: Account: Account Name equals value Filter Logic 1 OR 2 Custom Error Message The partner contact must be associated with a partner account, or must be a private contact. Lookup Window Text Search results only display contacts from partner accounts or your private contacts. User IDs in Lookup Filters Using user IDs in optional lookup filters can significantly improve user efficiency by first showing lookup search dialog results that are most relevant to the user while still allowing users to see all results if necessary. For example, on a lookup field to accounts, you can create an optional lookup filter that restricts the search results to accounts that the user owns in the search lookup dialog results. If the user is looking for an account that someone else owns, the user can remove the filter. Filter Criteria Current User: User ID equals Field Account: Owner ID Lookup Window Text By default, search results only display accounts you own. To search all accounts, click “Show all results.” 346 Extend Salesforce with Clicks, Not Code Customize Fields Simple Dependent Lookups If the value of a relationship field should depend on the value of another relationship field on the current record, specify the field to field comparison in the criteria. For example, if the case Contact Name field should only have contacts associated to the account specified in the case Account Name field, use the following lookup filter: Filter Criteria Contact Name: Account ID equals field Case: Account ID Custom Error Message Contact does not exist or is not associated to the case account. Lookup Window Text Search results only display contacts associated to the case account. Note: When comparing lookup fields in lookup filter criteria, Salesforce always uses the ID of the relationship field, not the name. Complex Lookup Filters and Dependent Lookups Achieving complex business rules with lookup filters often involves combing your rules with filter logic and fields of various types. For example, consider an app for booking conference rooms that has the following data model: Object Fields Meeting • Meeting Name • Office lookup to the Office object • Projector Required checkbox • Number of Participants number field • Conference Room lookup to the Conference Room object Conference Room • Conference Room Name • Has Projector checkbox • Number of Seats Available number field • Conference Room Location lookup to the Office object Office • Office Name The following lookup filter on the meeting Conference Room field restricts the valid values to conference rooms that have a projector if the meeting requires one, as well as the necessary number of seats: Filter Criteria 1. Meeting: Projector Required equals field Meeting Conference Room: Has Projector 2. Meeting: Projector Required equals value False 3. Conference Room: Number of Seats Available greater or equal field Meeting: Number of Participants Filter Logic (1 OR 2) AND 3 347 Extend Salesforce with Clicks, Not Code Customize Fields Custom Error Message Conference room not found or is insufficient for your meeting. Lookup Window Text Search results only display conference rooms that can support your meeting requirements. To refine the valid values even further, incorporate the office where the conference room is located: Filter Criteria 1. Meeting: Projector Required equals field Meeting Conference Room: Has Projector 2. Meeting: Projector Required equals value False 3. Conference Room: Number of Seats Available greater than field Meeting: Number of Participants 4. Meeting: Office equals Field Conference Room: Conference Room Location Filter Logic (1 OR 2) AND 3 AND 4 Custom Error Message Conference room not found or is insufficient for your meeting. Lookup Window Text Search results only display conference rooms that can support your meeting requirements. SEE ALSO: Considerations for Lookup Filters Limitations on Lookup Filters These limitations apply to lookup filters. • Lookup filter criteria can’t reference these types of fields: – Relationship fields on activities – System fields that are always read only, such as Created By and Modified By – Relationship fields that support queues, such as Case Owner and Lead Owner • Each object can have up to five active required lookup filters. In Salesforce Classic, you can also have an unlimited number of optional lookup filters. If you reach the limit of required lookup filters, create optional filters. When a user saves a record, use validation rules to enforce your business rule. In Lightning Experience, all lookup filters are required. • Lookup filters aren’t available for external lookup relationship fields. • Lookup filters on currency fields don't convert currencies. For example, your organization uses multiple currencies and there’s lookup filter criteria Expected Revenue greater than 100000. The lookup shows all records with an Expected Revenue field value greater than 100,000, regardless of the currency. • You can’t use special date values, such as “Today” or “This Month,” in lookup filter criteria. • You can’t delete fields that are referenced in an active lookup filter. • You can’t change the field type of fields referenced by an active lookup filter. • You can add up to 10 criteria rows in a lookup filter. 348 Extend Salesforce with Clicks, Not Code Customize Fields • Lookup filter criteria can’t reference these types of fields on the source object: – Autonumber – Email – Encrypted – Formula Note: Formula fields containing "$USER", "$USERROLE", "$PROFILE", or "$SOURCE" are supported. – GeoLocation – Long text area – Multi-select picklist – Roll-up summary – Text – Text (Encrypted) – Text area (Rich) – Text area (Long) – Time – URL • Lookup auto-completion doesn’t work for user lookups with other dropdown lists. Auto-completion is primarily for organizations that have set up either a partner portal or customer portal. • In enhanced list views, you can’t change fields that dependent lookup filter criteria reference. • Lookup filters don’t support mass owner changes. If your lookup filter criteria reference the Owner field, performing a mass owner change can result in incorrect values. The incorrect values aren’t noticeable until you try to save the record. • If a formula references global merge fields that the lookup filter doesn’t support, the lookup filter can’t reference the formula. • Lookup filter criteria on Account Name only apply to business accounts, not person accounts. For example, your lookup filter criteria is Account Name does not contain book. Business accounts with “book” in the name, such as John’s Bookstore, aren’t valid. Person accounts with “book” in the name, such as John Booker, are valid. The person accounts show in the lookup dialog for the Account field. If you must filter on the name for a person account, use the First Name or Last Name fields instead. Fields: What’s Different or Not Available in the Salesforce Mobile App Not every Lightning Experience feature is in the Salesforce mobile app. Find out what’s different. EDITIONS Fields Available in: Lightning Experience and the Unsupported Fields Salesforce mobile app for • division fields iOS and Android Combo Boxes Available in: all editions • Combo boxes, which combine a picklist with a text field, aren’t available. Typically the text field is available but the picklist is not. Lookup Fields • User-defined lookup filter fields aren't supported. • You can’t create a record from a lookup field like you can in Lightning Experience. 349 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • Lookup fields in Salesforce Classic show record names regardless of sharing permissions. As a result, users can see the names of records that they can’t access. In Lightning Experience and the Salesforce mobile app, lookup fields respect sharing permissions and only show the name of records that the user can access. The one exception is owner lookup fields, which always display the name of the record's owner, regardless of sharing permissions. Picklist Fields • Controlling and dependent picklists are supported, but doesn’t display indicators on create and edit pages for these fields. To determine if a picklist field is dependent, and which picklist field controls it, switch to the full site. • Disabled picklists aren’t grayed out like they are in the full site. Phone Number Fields • The keypad that displays in phone number fields doesn’t include parentheses, hyphens, or periods, and doesn’t apply any phone number formatting when you save the record. To apply a specific phone number format, edit the record in the full site. Rich Text Area Fields Support for rich text area fields varies by the version of the Salesforce mobile app and the type of device. App Version View Rich Text Area Fields Edit Rich Text Area Fields Salesforce for Android Yes Yes Salesforce for iOS Yes Yes User Fields • While user detail pages aren’t available in the app, user fields are supported and appear on user profiles, in related lists, and so forth. • There are some issues when these user fields appear in related lists or mobile cards. – The Company Name field is blank if an internal user is viewing a mobile card or related list entry related to another internal user. If the referenced user is an external user, the company name appears correctly. – The Active field is blank unless the user is inactive. Calculate Field Values With Formulas A formula is an algorithm that derives its value from other fields, expressions, or values. Formulas EDITIONS can help you automatically calculate the value of a field based on other fields. Watch a Demo: Getting Started With Formulas (Salesforce Classic) Available in: both Salesforce Classic and Lightning This video gives a brief introduction to Salesforce formulas, accessing the formulas editor in the Experience app, and how to use the editor tools to create formulas. Available in: All Editions Where are Formulas Used in Salesforce? Reports and Approvals are Many areas in Salesforce use formulas. Before you begin using formulas, review the differences not available in in their uses. Database.com Formula Data Types The data type of a formula determines the type of data you expect returned from your formula. Elements of a Formula A formula can contain references to the values of fields, operators, functions, literal values, or other formulas. 350 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Formula Operators and Functions Use these operators and functions when building formulas. All functions are available everywhere that you can include a formula—such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified. Using Date, Date/Time, and Time Values in Formulas Date formulas are useful for managing payment deadlines, contract ages, or any other features of your organization that are time or date dependent. Build a Formula Field Your custom formula fields require special attributes. Formula Field Limits and Restrictions Before you create formula fields, be aware of their limits and limitations. Formula Best Practices You can use the Formula Editor in Salesforce to construct a simple formula with a few clicks. But what if you want to build something more complex? Use these tips to help you map out formula logic and make it easier to troubleshoot errors. Examples of Advanced Formula Fields Review examples of formula fields for various types of apps that you can use and modify for your own purposes. Formulas: How Do I ... ? Common Formula Errors Review common errors that can occur with formulas and how to fix them. Where are Formulas Used in Salesforce? Many areas in Salesforce use formulas. Before you begin using formulas, review the differences in EDITIONS their uses. Available in: both Salesforce Use Formulas for: To: Classic and Lightning Approval Processes Define the criteria a record must meet to enter the approval process. Experience Approval Steps Define the criteria a record must meet to enter the approval step. Available in: All Editions Reports and Approvals are Assignment Rules for Define the criteria the lead or case must meet for it to be assigned. not available in Leads and Cases Database.com Auto-Response Rules for Define the criteria a lead or case must meet to trigger an auto-response Leads and Cases rule. Case Escalation Rules Specify criteria a case must meet for it to be escalated. Custom Buttons and Define the content for custom links and buttons. Links Custom Fields Create custom formula fields that automatically calculate a value based on other values, merge fields, or expressions. Users can view formula fields on record detail pages but can’t see the underlying algorithm or edit the value of a formula field. Note: Custom formula fields are not available in Connect Offline, Web-to-Lead forms, or Web-to-Case forms. 351 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use Formulas for: To: Custom Summary Formulas in Automatically calculate more totals based on existing report summaries using the values, merge Reports fields, or expressions you specify. Users can’t change these totals. Data Validations Verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can include a formula such as CloseDate >= TODAY(). Default Field Values Apply a value to a custom field when a user creates a record. Use formulas to define a default value such as TODAY() + 7. Users can change a default value. Default field values can be based on a formula using values, merge fields, or expressions you specify. Escalation Rules Define the criteria that a case must meet to be escalated. Formula Fields Automatically calculate the value of a custom field using the values, merge fields, or expressions you specify. Users can’t change the value of a formula field. Reports Create custom summary formulas in your reports to calculate more totals based on the existing summaries in that report. S-Controls Define the content for s-controls. Validation Rules Prevent users from entering an invalid value in a standard or custom field. Validation rules can be based on formulas and display an error message to users when the value they enter is not valid. Workflow Field Updates Automatically change the value of a field to a value you specify. The formula can include other values, merge fields, or expressions. You can set field updates to occur as a result of a workflow rule or an approval process. Workflow Rules Define the criteria a record must meet to trigger a workflow rule. Visualforce Pages Define the content for Visualforce pages. Common Formula Processes When are they Read only? Can include Can specify null Can include executed? functions? handling? references to parent merge fields? Default Field Values Record creation No Yes No No Formula Fields Record display Yes Yes Yes Yes Validation Rules Record save Not applicable Yes No Yes Workflow Rules Record save Not applicable Yes No Yes Approval Processes Record submitted Not applicable Yes No Yes for approval Field Updates Workflow or Not applicable Yes No Yes approval process 352 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas When are they Read only? Can include Can specify null Can include executed? functions? handling? references to parent merge fields? Custom Summary Report display Yes Yes, a limited subset Yes No Formulas for Reports of functions Formula Data Types The data type of a formula determines the type of data you expect returned from your formula. Data Type Description Checkbox Returns a true or false value. The field appears as a checkbox in record detail pages and reports. Use True for checked values and False for unchecked values. Currency Returns a number in currency format of up to 18 digits with a currency sign. Note: Salesforce uses the round-half-to-even tie-breaking rule for currency fields. For example, 23.5 becomes 24, 22.5 becomes 22, −22.5 becomes −22, and −23.5 becomes −24. Date Returns data that represents a day on the calendar. The current date can be acquired by calling the built-in function TODAY() in a formula. This data type is not available for custom summary formulas in reports. Date/Time Returns data that represents a moment in time. A date/time field includes the date and also the time of day including hour, minutes, and seconds. You can insert the current date and time in a formula using the NOW() function. This data type is not available for custom summary formulas in reports. Number Returns a positive or negative integer or decimal of up to 18 digits. Salesforce uses the round half up tie-breaking rule for numbers in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35. Percent Returns a number in percent format of up to 18 digits followed by a percent sign. Percent data is stored as a decimal divided by 100, which means that 90% is equal to 0.90. Text Returns a string of up to 3900 characters. To display text in addition to the formula output, insert that text in quotes. Use the text data type for text, text area, URL, phone, email, address, and auto-number fields. This data type isn’t available for custom summary formulas in reports. Note: Text area isn’t a supported data type. 353 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Data Type Description Time Returns data that represents a moment in time, without the date. A time field includes the time of day by hour, minutes, seconds, and milliseconds. You can insert the current time in a formula using the TIMENOW() function. Note: In formula expressions, use the international date format (ISO) for text arguments. For example, use TIMEVALUE("11:30:00.000") instead of TIMEVALUE("11:30 AM"). SEE ALSO: Build a Formula Field Elements of a Formula A formula can contain references to the values of fields, operators, functions, literal values, or other formulas. Use any or all of these elements to build a formula. Element Description Name Literal A text string or number you enter that is not calculated or changed. For example, if you have a value that’s always multiplied Value by 2% of an amount, your formula would contain the literal value of 2% of that amount: ROUND((Amount*0.02), 2) This example contains every possible part of a formula: • A function called ROUND used to return a number rounded to a specified number of decimal places. • A field reference called Amount. • An operator, *, that tells the formula builder to multiply the contents of the Amount field by the literal value, 0.02. • A literal number, 0.02. Use the decimal value for all percents. To include actual text in your formula, enclose it in quotes. • The last number 2 in this formula is the input required for the ROUND function that determines the number of decimal places to return. Field Reference the value of another custom or standard field using a merge field. The syntax for a merge field is field_name Reference for a standard field or field_name__c for a custom field. The syntax for a merge field on a related object is object_name__r.field_name. Use the Insert Field button or the drop-down list to insert a merge field in your formula where necessary. To reference a field from a custom metadata type record, use $CustomMetadata.CustomMetadataTypeAPIName.RecordAPIName.FieldAPIName . Function A system-defined formula that can require input from you and returns a value or values. For example, TODAY() does not require input but returns the current date. The TEXT(value) function requires your percent, number, or currency input and returns text. 354 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Element Description Name Operator A symbol that specifies the type of calculation to perform or the order in which to do it. For example, the + symbol specifies two values should be added. The open and close parentheses specify which expressions you want evaluated first. Comment An annotation within a formula that begins with a forward slash followed by an asterisk (/*). and concludes with an asterisk followed by a forward slash (*/). For example, /*This is a formula comment*/ Comments are ignored when processing a formula. Comments are useful for explaining specific parts of a formula to anyone viewing the formula definition. For example: AND( /*competitor field is required, check to see if field is empty */ LEN(Competitor__c) = 0, /* rule only enforced for ABCD record types */ RecordType.Name = "ABCD Value", /* checking for any closed status, allows for additional closed picklist values in the future */ CONTAINS(TEXT(StageName), "Closed") ) You can also use comments to comment out sections of your formula when debugging and checking the syntax to locate errors in the formula. Note: • Nesting comments causes a syntax error. For example, you cannot save a formula that has the following: /* /* comment */ */ • Commenting out a whole formula causes a syntax error. • Comments count against the character and byte size limits in formulas. Formula Operators and Functions Use these operators and functions when building formulas. All functions are available everywhere that you can include a formula—such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified. Note: • Within an email template, merge fields can only be used in formula functions and operations when the merge field belongs to the record the email will be related to, otherwise these fields won’t resolve. • Extraneous spaces in the samples below are ignored. • Math Operators • Logical Operators • Text Operators • Date and Time Functions • Logical Functions 355 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • Math Functions • Text Functions • Summary Functions • Advanced Functions Math Operators Operator Description + (Add) Calculates the sum of two values. - (Subtract) Calculates the difference of two values. * (Multiply) Multiplies its values. / (Divide) Divides its values. ^ (Exponentiation) Raises a number to a power of a specified number. () (Open Parenthesis and Specifies that the expressions within the open parenthesis and close parenthesis are evaluated first. All Close Parenthesis) other expressions are evaluated using standard operator precedence. Logical Operators Operator Description = and == (Equal) Evaluates if two values are equivalent. The = and == operators are interchangeable. <> and != (Not Equal) Evaluates if two values aren’t equivalent. < (Less Than) Evaluates if a value is less than the value that follows this symbol. > (Greater Than) Evaluates if a value is greater than the value that follows this symbol. <= (Less Than or Equal) Evaluates if a value is less than or equal to the value that follows this symbol. >= (Greater Than or Equal) Evaluates if a value is greater than or equal to the value that follows this symbol. && (AND) Evaluates if two values or expressions are both true. Use this operator as an alternative to the logical function AND. || (OR) Evaluates if at least one of multiple values or expressions is true. Use this operator as an alternative to the logical function OR. Text Operators Operator Description & (Concatenate) Connects two or more strings. 356 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Date and Time Functions Function Description ADDMONTHS Returns the date that is the indicated number of months before or after a specified date. If the specified date is the last day of the month, the resulting date is the last day of the resulting month. Otherwise, the result has the same date component as the specified date. DATE Returns a date value from year, month, and day values you enter. Salesforce displays an error on the detail page if the value of the DATE function in a formula field is an invalid date, such as February 29 in a non-leap year. DATEVALUE Returns a date value for a date/time or text expression. DATETIMEVALUE Returns a year, month, day, and GMT time value. DAY Returns a day of the month in the form of a number between 1 and 31. HOUR Returns the local time hour value without the date in the form of a number from 1 through 24. MILLISECOND Returns a milliseconds value in the form of a number from 0 through 999. MINUTE Returns a minute value in the form of a number from 0 through 60. MONTH Returns the month, a number between 1 (January) and 12 (December) in number format of a given date. NOW Returns a date/time representing the current moment. SECOND Returns a seconds value in the form of a number from 0 through 60. TIMENOW Returns a time value in GMT representing the current moment. Use this function instead of the NOW function if you only want to track time, without a date. TIMEVALUE Returns the local time value without the date, such as business hours. TODAY Returns the current date as a date data type. WEEKDAY Returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday. YEAR Returns the four-digit year in number format of a given date. Logical Functions Function Description AND Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false. BLANKVALUE Determines if an expression has a value and returns a substitute expression if it doesn’t. If the expression has a value, returns the value of the expression. CASE Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn't equal to any values, it returns the else_result. IF Determines if expressions are true or false. Returns a given value if true and another value if false. 357 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Function Description ISBLANK Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE. ISCLONE Checks if the record is a clone of another record and returns TRUE if one item is a clone. Otherwise, returns FALSE. ISNEW Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE. ISNULL Determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE. Important: Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas. ISNUMBER Determines if a text value is a number and returns TRUE if it is. Otherwise, it returns FALSE. NOT Returns FALSE for TRUE and TRUE for FALSE. NULLVALUE Determines if an expression is null (blank) and returns a substitute expression if it is. If the expression is not blank, returns the value of the expression. Important: Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas. OR Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false. PRIORVALUE Returns the previous value of a field. Math Functions Function Description ABS Calculates the absolute value of a number. The absolute value of a number is the number without its positive or negative sign. CEILING Rounds a number up to the nearest integer, away from zero if negative. DISTANCE Calculates the distance between two locations in miles or kilometers. EXP Returns a value for e raised to the power of a number you specify. FLOOR Returns a number rounded down to the nearest integer, towards zero if negative. GEOLOCATION Returns a geolocation based on the provided latitude and longitude. Must be used with the DISTANCE function. LN Returns the natural logarithm of a specified number. Natural logarithms are based on the constant e value of 2.71828182845904. 358 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Function Description LOG Returns the base 10 logarithm of a number. MAX Returns the highest number from a list of numbers. MCEILING Rounds a number up to the nearest integer, towards zero if negative. MFLOOR Rounds a number down to the nearest integer, away from zero if negative. MIN Returns the lowest number from a list of numbers. MOD Returns a remainder after a number is divided by a specified divisor. ROUND Returns the nearest number to a number you specify, constraining the new number by a specified number of digits. SQRT Returns the positive square root of a given number. Text Functions Function Description BEGINS Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't. BR Inserts a line break in a string of text. CASESAFEID Converts a 15-character ID to a case-insensitive 18-character ID. CONTAINS Compares two arguments of text and returns TRUE if the first argument contains the second argument. If not, returns FALSE. FIND Returns the position of a string within a string of text represented as a number. GETSESSIONID Returns the user’s session ID. HTMLENCODE Encodes text and merge field values for use in HTML by replacing characters that are reserved in HTML, such as the greater-than sign (>), with HTML entity equivalents, such as >. HYPERLINK Creates a link to a URL specified that is linkable from the text specified. IMAGE Inserts an image with alternate text and height and width specifications. INCLUDES Determines if any value selected in a multi-select picklist field equals a text literal you specify. ISPICKVAL Determines if the value of a picklist field is equal to a text literal you specify. JSENCODE Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe ('). JSINHTMLENCODE Encodes text and merge field values for use in JavaScript inside HTML tags by replacing characters that are reserved in HTML with HTML entity equivalents and inserting escape characters before unsafe JavaScript characters. JSINHTMLENCODE(someValue) is a convenience function that is equivalent to JSENCODE(HTMLENCODE((someValue)). That is, JSINHTMLENCODE first encodes someValue with HTMLENCODE, and then encodes the result with JSENCODE. LEFT Returns the specified number of characters from the beginning of a text string. 359 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Function Description LEN Returns the number of characters in a specified text string. LOWER Converts all letters in the specified text string to lowercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided. LPAD Inserts characters you specify to the left-side of a text string. MID Returns the specified number of characters from the middle of a text string given the starting position. RIGHT Returns the specified number of characters from the end of a text string. RPAD Inserts characters that you specify to the right-side of a text string. SUBSTITUTE Substitutes new text for old text in a text string. TEXT Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. Also, converts picklist values to text in approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, validation rules, formula fields, field updates, and custom buttons and links. TRIM Removes the spaces and tabs from the beginning and end of a text string. UPPER Converts all letters in the specified text string to uppercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided. URLENCODE Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with %20, and exclamation points are replaced with %21. VALUE Converts a text string to a number. Summary Functions The following functions are available with summary, matrix, and joined reports. Function Description PARENTGROUPVAL This function returns the value of a specified parent grouping. A “parent” grouping is any level above the one containing the formula. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels. PREVGROUPVAL This function returns the value of a specified previous grouping. A “previous” grouping is one that comes before the current grouping in the report. Choose the grouping level and increment. The increment is the number of columns or rows before the current summary. The default is 1; the maximum is 12. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels. 360 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Advanced Functions Function Description CURRENCYRATE Returns the conversion rate to the corporate currency for the given currency ISO code. If the currency is invalid, returns 1.0. GETRECORDIDS Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list. IMAGEPROXYURL Securely retrieves external images and prevents unauthorized requests for user credentials. INCLUDE Returns content from an s-control snippet. Use this function to reuse common code in many s-controls. ISCHANGED Compares the value of a field to the previous value and returns TRUE if the values are different. If the values are the same, this function returns FALSE. JUNCTIONIDLIST Returns a JunctionIDList based on the provided IDs. LINKTO Returns a relative URL in the form of a link (href and anchor tags) for a custom s-control or Salesforce page. PREDICT Returns an Einstein Discovery prediction for a record based on the specified record ID or for a list of fields and their values. REGEX Compares a text field to a regular expression and returns TRUE if there is a match. Otherwise, it returns FALSE. A regular expression is a string used to describe a format of a string according to certain syntax rules. REQUIRESCRIPT Returns a script tag with source for a URL you specify. Use this function when referencing the Lightning Platform AJAX Toolkit or other JavaScript toolkits. URLFOR Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page. VLOOKUP Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function. Formula Operators and Functions A–H Formula Operators and Functions I–Z SEE ALSO: Examples of Advanced Formula Fields Time Custom Field Formula Operators and Functions A–H Use the following operators and functions when building formulas. Click the name of the operator or function to view more details. All functions are available everywhere that you can include a formula such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified. Note: Extraneous spaces in the samples are ignored. 361 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas + (Add) Description: Calculates the sum of two values. Use: value1 + value2 and replace each value with merge fields, expressions, or other numeric values. Formula Field Example: Amount + Maint_Amount__c + Services_Amount__c This formula calculates the sum of the product Amount, maintenance amount, and services fees. Maint amount and Service Fees are custom currency fields. Report Example: EMAIL_OPT_OUT:SUM + DO_NOT_CALL:SUM calculates all Email Opt Out fields plus all Do Not Call fields on the leads in your report. This formula is a number data type that returns a positive integer. Validation Rule Example: Let’s say you have a custom object that allows users to track the total number of hours worked in a week. Use the following example to ensure that users can’t save a time card record with more than 40 hours in a work week. Monday_Hours__c + Tuesday_Hours__c + Wednesday_Hours__c + Thursday_Hours__c + Friday_Hours__c > 40 Use a formula like this one in a validation rule to display the following error message when the total number of hours entered for each work day is greater than 40: “Your total hours can’t exceed 40.” This example requires five custom fields on your custom object, one for each day of work. - (Subtract) Description: Calculates the difference of two values. Use: value1 - value2 and replace each value with merge fields, expressions, or other numeric values. Example: Amount - Discount_Amount__c This formula calculates the difference of the product Amount less the Discount Amount. Discount Amount is a custom currency field. Report Example: AMOUNT:SUM - Product.Discount_Amount__c:SUM calculates the difference of all Amount fields and all Discounted Amount custom fields on the products in your report. This formula is a currency data type that returns a currency sign and decimal places. * (Multiply) Description: Multiplies its values. 362 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use: value1 * value2 and replace each value with merge fields, expressions, or other numeric values. Example: Consulting_Days__c * 1200 This formula calculates the number of consulting days times 1200 given that this formula field is a currency data type and consulting charges a rate of $1200 per day. Consulting Days is a custom field. Report Example: RowCount * AGE:AVG calculates the record count times the average age value of your report. This formula is a number data type that returns a positive or negative integer or decimal. / (Divide) Description: Divides its values. Use: value1 / value2 and replace each value with merge fields, expressions, or other numeric values. Example: AnnualRevenue/ NumberOfEmployees This formula calculates the revenue amount per employee using a currency field. IF(NumberOfOpportunities > 0, NumberOfWonOpportunities / NumberOfOpportunities, null) This formula calculates the win rate of opportunities on a campaign. Report Example: % Won Opportunities WON:SUM / RowCount calculates the percent of Won opportunities using a record count representing the number of all opportunities in your report. This formula is a number data type that returns a positive or negative integer. % Difference between Cost and Sales Price (TOTAL_PRICE:SUM - QUANTITY:SUM * Product2.Cost__c:SUM) / (QUANTITY:SUM * Product2.Cost__c:SUM) calculates the average percent difference between what a product costs and its selling price on a product-by-product level. Product2.Cost__c:SUM is a custom currency field named Cost on products, which includes the cost of each product. This formula is a percent data type that returns a positive or negative integer. For best results, use this formula on a summary Opportunities with Products report that is summarized by Product Name and includes summary totals for Quantity, Total Price, and Cost. ^ (Exponentiation) Description: Raises a number to a power of a specified number. Use: number^integer and replace number with a merge field, expression, or another numeric value; replace integer with a merge field that contains an integer, expression, or any integer. Example: NumberOfEmployees^4 calculates the number of employees to the 4th power. 363 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Report Example: ACTIVE:SUM ^ 2 calculates the number of active Salesforce users to the 2nd power for administration. This formula is a number data type that returns a positive integer. Tips: Avoid replacing integer with a negative number. () (Open Parenthesis and Close Parenthesis) Description: Specifies that the expressions within the open parenthesis and close parenthesis are evaluated first. All other expressions are evaluated using standard operator precedence. Use: (expression1) expression2... and replace each expression with merge fields, expressions, or other numeric values. Example: (Unit_Value__c - Old_Value__c) / New_Value__c calculates the difference between the old value and new value divided by the new value. Report Example: (DURATIONHOURS:SUM * RowCount) / 24 calculates the duration of all event times the record count per 24 hours. This formula is a percent data type that returns a positive or negative integer or decimal, representing what percent of a day is spent on events. = and == (Equal) Important: Don’t use this function for a null comparison, such as MyDateTime__c == null. Use ISBLANK instead. Description: Evaluates if two values are equivalent. The = and == operators are interchangeable. Use: expression1=expression2 or expression1 == expression2, and replace each expression with merge fields, expressions, or other numeric values. Example: Due Date Due Date = CreatedDate + 5 returns true if the due date is equal to five days following a record’s created date. Commission Amount IF(Probability =1, ROUND(Amount*0.02, 2), 0) This formula calculates the 2% commission amount of an opportunity that has a probability of 100%. All other opportunities have a commission value of 0. Possible results: • An opportunity with a Probability of 90% has a commission of 0. • An opportunity with a Probability of 100% and an Amount of $100,000 has a commission of $2,000. <> and != (Not Equal) Important: Don’t use this function for a null comparison, such as MyDateTime__c != null. Use ISBLANK instead. 364 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Description: Evaluates if two values aren’t equivalent. Use: expression1 <> expression2 or expression1 != expression2, and replace each expression with merge fields, expressions, or other numeric values. Example: IF(Maint_Amount__c + Services_Amount__c<> Amount, "DISCOUNTED", "FULL PRICE") This formula displays DISCOUNTED on product if its maintenance amount and services amount don’t equal the product amount. Otherwise, displays FULL PRICE. Note that this example uses two custom currency fields for Maint Amount and Services Amount. < (Less Than) Description: Evaluates if a value is less than the value that follows this symbol. Use: value1 < value2 and replace each value with merge fields, expressions, or other numeric values. Example: IF(AnnualRevenue < 1000000, 1, 2) assigns the value 1 with revenues less than one million and the value 2 to revenues greater than one million. > (Greater Than) Description: Evaluates if a value is greater than the value that follows this symbol. Use: value1 > value2 and replace each value with merge fields, expressions, or other numeric values. Example: IF(commission__c > 1000000, "High Net Worth", "General") assigns the High Net Worth value to a commission greater than one million. Note, this is a text formula field that uses a commission custom field. <= (Less Than or Equal) Description: Evaluates if a value is less than or equal to the value that follows this symbol. Use: value1 <= value2 and replace each value with merge fields, expressions, or other numeric values. Example: IF(AnnualRevenue <= 1000000, 1, 2) assigns the value 1 with revenues less than or equal to one million and the value 2 with revenues greater than one million. >= (Greater Than or Equal) Description: Evaluates if a value is greater than or equal to the value that follows this symbol. 365 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use: value1 >= value2 and replace each value with merge fields, expressions, or other numeric values. Example: IF(Commission__c >= 1000000, "YES", "NO") assigns the YES value with a commission greater than or equal to one million. Note, this is a text formula field that uses a custom currency field called Commission. && (AND) Description: Evaluates if two values or expressions are both true. Use this operator as an alternative to the logical function AND. Use: (logical1) && (logical2) and replace logical1 and logical2 with the values or expressions that you want evaluated. Example: IF((Price<100 && Quantity<5),"Small", null) This formula displays Small if the price is less than 100 and quantity is less than five. Otherwise, this field is blank. || (OR) Description: Evaluates if at least one of multiple values or expressions is true. Use this operator as an alternative to the logical function OR. Use: (logical1) || (logical2) and replace any number of logical references with the values or expressions you want evaluated. Example: IF((ISPICKVAL(Priority, "High")) || (ISPICKVAL(Status , "New")), ROUND(NOW()-CreatedDate, 0), null) This formula returns the number of days a case has been open if the Status is new or the Priority is high. If the case was opened today, this field displays a zero. Validation Rule Example: (Discount_Rate__c < 0) || (Discount_Rate__c > 0.40) This validation rule formula displays the following error message when the Discount Rate custom field isn’t between 0 and 40%: "Discount Rate cannot exceed 40%." & (Concatenate) Description: Connects two or more strings. Use: string1&string2 and replace each string with merge fields, expressions, or other values. Example: "Expense-" & Trip_Name__c & "-" & ExpenseNum__c This formula displays the text Expense- followed by trip name and the expense number. This is a text formula field that uses an expense number custom field. 366 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas ABS Description: Calculates the absolute value of a number. The absolute value of a number is the number without its positive or negative sign. Use: ABS(number) and replace number with a merge field, expression, or other numeric value that has the sign you want removed. Example: ABS(ExpectedRevenue) calculates the positive value of the Expected Revenue amount regardless of whether it’s positive or negative. ADDMONTHS Description: Returns the date that is the indicated number of months before or after a specified date. If the specified date is the last day of the month, the resulting date is the last day of the resulting month. Otherwise, the result has the same date component as the specified date. Use: ADDMONTHS (date, num) and replace date with the start date and num with the number of months to be added. Example: ADDMONTHS (StartDate, 5) Adds 5 months to the start date. For example, if the start date is September 20, 2017, the resulting date is February 20, 2018, If the start date is September 30, 2017, the resulting date is February 28, 2018. AND Description: Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false. Use this function as an alternative to the operator && (AND). Use: AND(logical1,logical2,...) and replace logical1,logical2,... with the values that you want evaluated. Formula Field Example: IF(AND(Price<1,Quantity<1),"Small", null) This formula displays Small if the price and quantity are less than one. This field is blank if the asset has a price or quantity greater than one. BEGINS Description: Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't. Use: BEGINS(text, compare_text) and replace text, compare_text with the characters or fields you want to compare. 367 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Example: IF(BEGINS (Product_type__c, "ICU"), "Medical", "Technical") This example returns the text Medical if the text in any Product Type custom text field begins with ICU. For all other products, it displays Technical. Tips: • This function is case-sensitive so be sure your compare_text value has the correct capitalization. • When using this function in a validation rule or workflow rule, fields that are blank are considered valid. For example, if you have a validation rule that tests to see if the serial number of an asset begins with “3,” all assets that have a blank serial number are considered valid. BLANKVALUE Description: Determines if an expression has a value and returns a substitute expression if it doesn’t. If the expression has a value, returns the value of the expression. Use: BLANKVALUE(expression, substitute_expression) and replace expression with the expression you want evaluated; replace substitute_expression with the value you want to replace any blank values. Example: Example 1 BLANKVALUE(Department, “Undesignated”) This formula returns the value of the Department field if the Department field contains a value. If the Department field is empty, this formula returns the word Undesignated. Example 2 (BLANKVALUE(Payment_Due_Date__c, StartDate +5) This formula returns the date five days after the contract start date whenever Payment Due Date is blank. Payment Due Date is a custom date field. Tips: • Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas. • A field is not empty if it contains a character, blank space, or zero. For example, a field that contains a space inserted with the spacebar is not empty. • Use the BLANKVALUE function to return a specified string if the field doesn't have a value; use the ISBLANK function if you only want to check if the field has a value. • If you use this function with a numeric field, the function only returns the specified string if the field doesn't have a value and isn't configured to treat blank fields as zeroes. BR Description: Inserts a line break in a string of text. Use: BR() 368 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Example: CASE(ShippingCountry, "USA", ShippingStreet & BR() & ShippingCity & ", " & ShippingState & " " & ShippingPostalCode & BR() & ShippingCountry, "France", ShippingStreet & BR() & ShippingPostalCode & " " & ShippingCity & BR() & ShippingCountry, "etc") This formula field displays a formatted mailing address for a contact in standard format, including spaces and line breaks where appropriate depending on the country. Tips: • Don't remove the parentheses after the function name. • Keep the parentheses empty. They don't contain values. • Remember to surround the BR() with concatenation operators: &. • Avoid using this function in mail merge templates. • This function isn't available in custom buttons and links, s-controls, or reports. CASE Description: Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it isn't equal to any values, it returns the else_result. Use: CASE(expression,value1, result1, value2, result2,..., else_result) and replace expression with the field or value you want compared to each specified value. Replace each value and result with the value that must be equivalent to return the result entry. Replace else_result with the value you want returned when the expression doesn't equal any values. Formula Field Example: Days Open for Cases Use this example of a custom formula field called Days Open to display different text depending on the number of days a case has been open: CASE(Days_Open__c, 3, "Reassign", 2, "Assign Task", "Maintain") The following text is displayed: • “Reassign” for any case open three days. • “Assign Task” for any case open two days. • “Maintain” for all other cases. Last Activity Month 369 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas This formula field displays the month of the last activity or None if there are no activities. CASE(MONTH(LastActivityDate), 1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", 7, "July", 8, "August", 9, "September", 10, "October", 11, "November", 12, "December", "None") Default Value Example: Discount Rate Use the following default value formula to insert a different discount rate on an opportunity based on the department of the person creating the opportunity: CASE(User.Department, "IT", 0.25, "Field", 0.15, 0) In this example, the formula inserts a discount rate of 25% on any opportunity created by a user in the IT department or 15% on any opportunity created by someone in the Field department. A zero is applied if the creator doesn't belong to either of these departments. This is a custom percent field on opportunities that uses the standard user field Department. Product Language You might want to associate a product with its language so that your users know the type of documentation or adapter to include. Use the following default value formula to automatically set the language of a product based on the country of the user creating the product. In this example, the default value is Japanese if the user's country is Japan and English if the user's country is US. If neither is true, the default value unknown is inserted into the Product Language field. CASE($User.Country , "Japan", "Japanese", "US", "English","unknown") Tips: • Be sure your value1, value2... expressions are the same data type. • Be sure your result1, result2... expressions are the same data type. • CASE functions can’t contain functions that return true or false. Instead, make true or false expressions return numbers such as: CASE(1, IF(ISPICKVAL (Term__c, "12"), 1, 0), 12 * Monthly_Commit__c, IF(ISPICKVAL(Term__c, "24"), 1, 0), 24 * Monthly_Commit__c, 0) In this formula, Term is a picklist field that is multiplied by the Monthly Commit whenever it contains the value 1 for true. • The else_result value is required. 370 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • CASE functions return an error whenever any of the expressions return an error, regardless of which one should be returned. For example, CASE(Field__c,"Partner", "P", "Customer", "C", LEFT(Field__c, -5)) returns an error even if the value of the field is “Partner” or “Customer” because the last statement is illogical. • If the field in your CASE function is blank, it returns your else_result value. For example, this formula: CASE(Days_Open__c, 3, "Reassign", 2, "Assign Task", "Maintain") displays Maintain if the Days Open field is blank, 0, or any value other than 2 or 3. • Use CASE functions to determine if a picklist value is equal to a particular value. For example the formula CASE(Term__c, "12", 12 * Monthly_Commit__c, "24", 24 * Monthly_Commit__c, 0) multiplies the Monthly Commit amount by 12 whenever the Term is 12 or multiplies the Monthly Commit amount by 24 whenever the Term is 24. Otherwise, the result is zero. CASESAFEID Description: Converts a 15-character ID to a case-insensitive 18-character ID. Use: CASESAFEID(id) and replace id with the object’s ID. Example: CASESAFEID (Id) This formula replaces the 15-character ID with the 18-character, case-insensitive ID. Tips: • Convert to 18-character IDs for better compatibility with Excel. • The CASESAFEID function is available everywhere that you can define a formula except reports and s-controls. CEILING Description: Rounds a number up to the nearest integer, away from zero if negative. Use: CEILING(number) and replace number with the field or expression you want rounded. Example: CEILING(2.5) returns 3, which is 2.5 rounded up to the nearest integer. CEILING(-2.5) returns -3, which is -2.5 rounded away from zero for a negative number. CONTAINS Description: Compares two arguments of text and returns TRUE if the first argument contains the second argument. If not, returns FALSE. Use: CONTAINS(text, compare_text) and replace text with the text that contains the value of compare_text. 371 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Example: IF(CONTAINS(Product_Type__c, "part"), "Parts", "Service") This formula checks the content of a custom text field named Product_Type and returns Parts for any product with the word “part” in it. Otherwise, it returns Service. Note that the values are case-sensitive, so if a Product_Type field contains the text “Part” or “PART,” this formula returns Services. Tips: • This function is case-sensitive so be sure your compare_text value has the correct capitalization. • When using this function in a validation rule or workflow rule, fields that are blank are considered valid. For example, if you have a validation rule that tests to see if the serial number of an asset contains “A,” all assets that have a blank serial number are considered valid. • The CONTAINS function doesn't support multi-select picklists. Use INCLUDES to see if a multi-select picklist has a specific value. CURRENCYRATE Description: Returns the conversion rate to the corporate currency for the given currency ISO code. If the currency is invalid, returns 1.0. Use: CURRENCYRATE(currency_ISO_code) and replace currency_ISO_code with a currency ISO code, such as “USD”. Example: CURRENCYRATE(”USD”) returns the conversion rate to US dollars. DATE Description: Returns a date value from year, month, and day values you enter. Salesforce displays an error on the detail page if the value of the DATE function in a formula field is an invalid date, such as February 29 in a non-leap year. Use: DATE(year,month,day) and replace year with a four-digit year, month with a two-digit month, and day with a two-digit day. Example: DATE(2005, 01, 02) creates a date field of January 2, 2005. DATEVALUE As of Winter ’20, the DATAVALUE() formula option provides more accurate daylight savings time values without workarounds. The option avoids an existing one-hour discrepancy when processing times between 11:00 PM and 1:00 AM. From Setup, in the Quick Find box, enter Company Information. Under Locale Settings, select Improve DATEVALUE() accuracy for DST. Important: If your org's custom formulas include workarounds that adjust date values between 11:00 PM and 1:00 AM, remove them before enabling this setting. If you don't remove the workarounds, your data could be inaccurate. Enabling the preference can also increase the compiled size of existing formulas with the DATEVALUE() function. Description: Returns a date value for a date/time or text expression. 372 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use: DATEVALUE(expression) and replace expression with a date/time or text value, merge field, or expression. Example: Closed Date DATEVALUE(ClosedDate) displays a date field based on the value of the Date/Time Closed field. Date Value DATEVALUE("2005-11-15") returns November 15, 2005 as a date value. Tips: • If the field referenced in the function isn't a valid text or date/time field, the formula field displays #ERROR! • When entering a date, surround the date with quotes and use the following format: YYYY-MM-DD, that is, a four-digit year, two-digit month, and two-digit day. • If the expression doesn't match valid date ranges, such as the MM isn't between 01 and 12, the formula field displays #ERROR! • Dates and times are always calculated using the user’s time zone, except in list views, reports, and related lists. These items calculate dates and times using Coordinated Universal Time. DATETIMEVALUE Description: Returns a year, month, day, and GMT time value. Use: DATETIMEVALUE(expression) and replace expression with a date/time or text value, merge field, or expression. Example: Closed Date DATETIMEVALUE(ClosedDate) displays a date field based on the value of the Date/Time Closed field. Date Value DATETIMEVALUE("2005-11-15 17:00:00") returns November 15, 2005 5:00 PM GMT as a date and time value. Tips: • DATETIMEVALUE is always calculated using GMT time zone and can’t be changed. • When entering a specific date, surround the date with quotes and use the following format: YYYY-MM-DD, that is, a four-digit year, two-digit month, and two-digit day. • If the expression doesn't match valid date ranges, such as the MM isn't between 01 and 12, the formula field displays #ERROR! DAY Description: Returns a day of the month in the form of a number between 1 and 31. Use: DAY(date) and replace date with a date field or value such as TODAY(). 373 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Example: DAY(Code_Freeze__c) returns the day in your custom code freeze date. Note this doesn't work on date/time fields. DISTANCE Description: Calculates the distance between two locations in miles or kilometers. Use: DISTANCE(mylocation1, mylocation2, 'unit') and replace mylocation1 and mylocation2 with two location fields, or a location field and a value returned by the GEOLOCATION function. Replace unit with mi (miles) or km (kilometers). Examples: Distance between two geolocation fields DISTANCE(warehouse_location__c, store_location__c, 'mi') This formula returns the distance, in miles, between the warehouse and the store. In this example, warehouse_location__c and store_location__c are the names of two custom geolocation fields. Distance between an address field and a geolocation field DISTANCE(BillingAddress, store_location__c, 'mi') This formula returns the distance, in miles, between an account’s billing address and a store. In this example, BillingAddress is the standard billing address field on an Account object, and store_location__c is the name of a custom geolocation field. Distance between a custom geolocation field and fixed coordinates DISTANCE(warehouse_location__c, GEOLOCATION(37.775,-122.418), 'km') This formula returns the distance, in kilometers, between the warehouse and the known latitude and longitude 37.775°, -122.418° (San Francisco). Distances with conditions IF(DISTANCE(warehouse_location__c, ShippingAddress, 'mi')<10, "Near", "Far") This formula updates a text formula field to Near if the distance between the warehouse and the account shipping address compound field is less than 10 miles. Otherwise, it updates the text field to Far. Tip: Although DISTANCE can be calculated in miles or kilometers, the unit isn't returned in the calculation. If possible, include the unit of measure in the name of your distance formula field, so users know whether the distance is in miles or kilometers. Tips: • The DISTANCE function returns a number data type. Distance is always calculated in decimals, even if you’re displaying the geolocation notation in degrees, minutes, and seconds in the user interface. Specify the number of decimal places to show when you create a custom field. • The DISTANCE function isn’t available in reports, but it can be used in list views. To use DISTANCE in your reports, set up a formula field, and then reference the field in your reports. • DISTANCE is the only formula function that can use GEOLOCATION parameters. • There are limitations on DISTANCE accuracy and equality calculations. 374 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas – DISTANCE supports only the logical operators > and <, returning values within (<) or beyond (>) a specified radius. – Distance is calculated as a straight line, regardless of geography and topography between the two points. For more details, see “How SOQL Calculates and Compares Distances” in the SOQL and SOSL Reference. EXP Description: Returns a value for e raised to the power of a number you specify. Use: EXP(number) and replace number with a number field or value such as 5. Example: Exponent of a Literal Value EXP(3) This formula returns the value of e to the third power. Compound Interest Principal__c * EXP(Rate__c * Years__c) This formula calculates the compound interest based on a custom currency field for principal, custom percent field for rate, and custom number field for years. FIND Description: Returns the position of a string within a string of text represented as a number. Use: FIND(search_text, text[, start_num]) and replace search_text with the string you want to find, replace text with the field or expression you want to search, and replace start_num with the number of the character from which to start searching from left to right. Example: Street Address FIND(" ", Street) returns the character position of the first space in the Street field. You can use this number to find out the length of the street address as a means of separating a street address from street name in an address field. Deriving Website Addresses SUBSTITUTE(Email, LEFT(Email, FIND("@", Email)), "www.") finds the location of the @ sign in a person's email address to determine the length of text to replace with a “www.” as a means of deriving their website address. Tips: • Be sure to remove the brackets, [ and ], from your formula before validating it. • If the field referenced in your text parameter is blank, the formula field displays 0. • Your search_text parameter is case-sensitive and can't contain any wildcard characters. • If your search doesn't return any results, a 0 displays in the field. 375 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • The start_num parameter is optional. If you don't enter a start_num value, the formula uses the value one, or the first character in the string. • If your start_num isn't greater than zero, a 0 displays in the field. • If your start_num is greater than the length of the text, a 0 displays in the field. • When entering your start_num parameter, remember that some fields like the Website field are unique because a http:// is automatically appended to the beginning of the text you enter. • The first character in a string is designated as one rather than zero. FLOOR Description: Returns a number rounded down to the nearest integer, towards zero if negative. Use: FLOOR(number) and replace number with a number field or value such as 5.245. Example: FLOOR(2.5) returns 2, which is 2.5 rounded down to the nearest integer. FLOOR(-2.5) returns -2, which is -2.5 rounded towards zero for a negative number. GEOLOCATION Description: Returns a geolocation based on the provided latitude and longitude. Must be used with the DISTANCE function. Use: GEOLOCATION(latitude, longitude) and replace latitude and longitude with the corresponding geolocation, numerical code values. Examples: Distance between a custom geolocation field and fixed coordinates DISTANCE(warehouse_location__c, GEOLOCATION(37.775,-122.418), 'km') This formula returns the distance, in kilometers, between the warehouse and the known latitude and longitude 37.775°, -122.418° (San Francisco). Tips: • The GEOLOCATION function returns a location data type that can be used only by, and must be used with, the DISTANCE function. The GEOLOCATION function doesn’t work on its own. GETRECORDIDS Description: Returns an array of strings in the form of record IDs for the selected records in a list, such as a list view or related list. Use: {!GETRECORDIDS(object_type)} and replace object_type with a reference to the custom or standard object for the records you want to retrieve. 376 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Custom Button Example: {!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")} var records = {!GETRECORDIDS($ObjectType.Sample)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one row") } else { for (var n=0; n In this example, all selected case records are updated with a Status of New. To set this up in your org, create a custom list button for cases with the following attributes: • Display Type is List Button • Behavior is Execute JavaScript • Content Source is OnClick JavaScript Paste the sample code above into the content of your custom button. Finally, add the list button to the page layout that contains the Cases related list, such as accounts or opportunities. Users can select any number of cases in the related list and click the list button to change the status of those cases at once. Notice the check for records[0] == null, which displays a message to users when they don't select at least one record in the list. Tips: • Use global variables to access special merge fields for s-controls, custom buttons, and links. • Activities are special types of objects. Use {!GETRECORDIDS($ObjectType.Task)} when creating a task list button. Use {!GETRECORDIDS($ObjectType.Event)} when creating an event list button. • This function is only available in custom buttons, links, and s-controls. GETSESSIONID Description: Returns the user’s session ID. Use: GETSESSIONID() Example: HYPERLINK ("https://www.myintegration.com?sId="& GETSESSIONID() & "?&rowID="&Name & "action=CreateTask","Create a Meeting Request") creates a link to an application outside of Salesforce, passing the parameters so that it can connect to Salesforce via the API and create the necessary event. Tips: Important: $Api.Session_ID and GETSESSIONID() return the same value, an identifier for the current session in the current context. This context varies depending on where the global variable or function is evaluated. For example, if you use either in a custom formula field, and that field is displayed on a standard page layout in Salesforce Classic, the referenced session is a basic Salesforce session. That same field (or the underlying variable or formula result), when used in a Visualforce page, references a Visualforce session instead. 377 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Session contexts are based on the domain of the request. That is, the session context changes whenever you cross a hostname boundary, such as from .salesforce.com to .vf.force.com or .lightning.force.com. Session identifiers from different contexts, and the sessions themselves, are different. When you transition between contexts, the old session is replaced by the new one, and the old session is no longer valid. The session ID also changes at this time. Normally Salesforce transparently handles session hand-off between contexts, but if you’re passing the session ID around yourself, you might need to re-access $Api.Session_ID or GETSESSIONID() from the new context to ensure a valid session ID. Not all sessions are created equal. In particular, sessions obtained in a Lightning Experience context have reduced privileges, and don't have API access. You can't use these session IDs to make API calls. {!$Api.Session_ID} isn’t generated for guest users. HOUR Description: Returns the local time hour value without the date in the form of a number from 1 through 24. Use: HOUR(time) and replace time with a time value or value such as TIMENOW(). Examples: HOUR(TIMEVALUE(ClosedDate)) displays only the hour in a time field based on the value of the Time Closed field. HOUR(TIMEVALUE("17:30:45.125")) returns 17. HTMLENCODE Description: Encodes text and merge field values for use in HTML by replacing characters that are reserved in HTML, such as the greater-than sign (>), with HTML entity equivalents, such as >. Use: {!HTMLENCODE(text)} and replace text with the merge field or text string that contains the reserved characters. Example: If the merge field foo__c contains Enter the user's name, {!HTMLENCODE(foo__c)} results in: <B>Enter the user's name</b> Tips: This function is only available in custom buttons and links, and in Visualforce. HYPERLINK Description: Creates a link to a URL specified that is linkable from the text specified. Use: HYPERLINK(url, friendly_name [,target]) and replace url with the Web address, replace friendly_name with the link text, and, optionally, replace target with the window or frame in which to display the content. 378 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Example: Creating Events HYPERLINK("/00U/e? retURL=%2F006x0000001T8Om&what_id=" & Id, "Create Event") adds a link called Create Event that, when clicked, creates an event that is associated with the current object. Phone Dialer HYPERLINK("http://servername/call?id=" & Id & "&phone=" & Phone, Phone)creates a linkable phone number field that automatically dials the phone number when clicked. In this example, replace "servername" and "call" with the name of your dialing tool and the command it uses to dial. The merge field, Id, inserts the identifier for the contact, lead, or account record. The first Phone merge field tells the dialing tool what number to call and the last Phone merge field uses the value of the Phone field as the linkable text the user clicks to dial. Tips: • Hyperlink formula fields are of type text. • Include the protocol and URL in quotes as in HYPERLINK("http://www.cnet.com", "cnet"). • Avoid using text functions such as LEN, LEFT, or RIGHT on HYPERLINK function results. • The URL can’t contain JavaScript. This increases security for your org. Using JavaScript is permitted in packages, sandbox copies, and change sets. • Use a relative link to link to Salesforce pages. If your full link is https://yourInstance.salesforce.com/00U/e, then its relative link is /00U/e. Relative links allow the hyperlink to work correctly on all Salesforce pages. Use the relative URL in a hyperlink formula to add it to a search layout. Make sure to prepend your relative URL with a forward slash “/”. • Use the $Api variable to reference API URLs. • Be sure to remove the brackets, [ and ], from your formula before validating it. • The target parameter is optional. If you don't specify a target, the link opens in a new browser window. Some common target parameters are: _blank Displays link in a new unnamed window. _self Displays link in the same frame or window as the element that refers to it. _parent Displays link in the immediate frameset parent of the current frame. This value is the same as _self if the current frame has no parent. _top Displays link in the full original window, canceling any other frames. This value is the same as _self if the current frame has no parent. For more information on basic HTML tags, consult an HTML reference on the Internet. 379 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • The HYPERLINK function is available everywhere that you can define a formula except default values, field updates, s-controls, validation rules, approval processes, custom buttons and links, and workflow rules. SEE ALSO: Formula Operators and Functions I–Z Formula Operators and Functions Tips for Working with Hyperlink Formula Fields Formula Operators and Functions I–Z Use the following operators and functions when building formulas. Click the name of the operator or function to view more details. All functions are available everywhere that you can include a formula such as formula fields, validation rules, approval processes, and workflow rules, unless otherwise specified. Note: Extraneous spaces in the samples are ignored. IF Description: Determines if expressions are true or false. Returns a given value if true and another value if false. Use: IF(logical_test, value_if_true, value_if_false) and replace logical_test with the expression you want evaluated; replace value_if_true with the value you want returned if the expression is true; replace value_if_false with the value you want returned if the expression is false. Formula Field Example: Overdue Payments IF(AND(Payment_Due_Date__c < TODAY(),Payment_Status__c ="UNPAID") , "PAYMENT OVERDUE", null) This formula determines if the payment due date is past and the payment status is “UNPAID.” If so, returns the text “PAYMENT OVERDUE” and if not, leaves the field blank. This example uses a custom date field called Payment Due Date and a text custom field called Payment Status. Insert Tax Rate Use this default value formula to set the tax rate of an asset based on the user's city. Create a custom percent field with the following default value: IF($User.City = "Napa", 0.0750, IF($User.City = "Paso Robles", 0.0725, IF($User.City = "Sutter Creek", 0.0725, IF($User.City = "Los Olivos", 0.0750, IF($User.City = "Livermore", 0.0875, null ) ) ) ) ) 380 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Custom Button Example: {! IF(Sample.BillingCountry = "US", "http://maps.google.com/maps?q="&Sample.BillingStreet& "+"&Sample.BillingCity&"+"&Sample.BillingState&"+ "&Sample.BillingCountry, (IF(Sample.BillingCountry = "UK", "http://maps.google.co.uk/maps?q="&Sample.BillingStreet &"+"&Sample.BillingCity&"+"&Sample.BillingCountry, "http://maps.google.com"))) } This example uses the IF function to determine if an address is in the United States or United Kingdom so that it can use the appropriate type of Google map to display the address. Tips: • Make sure your value_if_true and value_if_false expressions are the same data type. • When using an IF function with the $Profile.UserType variable to determine the type of Salesforce user license the logged in user has, use the following values: – Standard for Salesforce – PowerPartner for PRM User – CustomerSuccess for Customer Portal User – PowerCustomerSuccess for Customer Portal Manager For example, use the following formulas to determine if the logged in user has the license type in quotes: IF(ISPICKVAL($Profile.UserType ,"Standard"), 100, 0.1) IF(ISPICKVAL($Profile.UserType ,"PowerPartner"), 100, 0.1) IF(ISPICKVAL($Profile.UserType ,"CustomerSuccess"), 100, 0.1) Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions. IMAGE Description: Inserts an image with alternate text and height and width specifications. Use: IMAGE(image_url, alternate_text, height, width) and replace image_url with the full path to the image. Replace alternate_text with the string of text you want to appear when the image can’t be rendered for some reason. This text can be used by screen reader software. Replace height with the vertical size of the image in pixels. Replace width with the horizontal size of the image in pixels. For reports, images aren't automatically resized to fit into a report column. Use the height and width parameters to explicitly size the image so it fits into the column without being partially cut off. 381 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Example: HYPERLINK("ymsgr:sendIM?" & Yahoo_Name__c, IMAGE("http://opi.yahoo.com/online?u=" & Yahoo_Name__c & "&m;=g&t;=0", "Yahoo")) This formula displays a clickable Yahoo! Messenger icon indicating if the person is logged on to the service. Users can click the icon to launch a Yahoo! Messenger conversation with the person. This example uses a custom text field called Yahoo Name on contacts where you can store the contact's Yahoo! Messenger ID. Tips: • The height and width parameters are optional. • Use a text string to replace the image_url and alternate_text parameters. Surround each text string in quotes. • Use numbers to replace the height and width parameters. • Add images to your Documents tab if you want to display them elsewhere. For example, store the image of a product in a document folder, copy the URL to the document, and paste that URL in the image_url parameter of a formula field on the Products tab. • If you use Internet Explorer, you sometimes must to change your security settings so that Explorer doesn’t display a warning prompt when images use HTTP protocol. See the online help for Internet Explorer for instructions on changing your security settings. • The IMAGE function cannot include the GETSESSIONID function as one of its arguments. • The IMAGE function is available only in formula fields and email templates. • You can’t display an image related to a contact in a custom formula field if it’s referenced through a person account. IMAGEPROXYURL Description: Securely retrieves external images and prevents unauthorized requests for user credentials. Use: Example: alt="Salesforce on Twitter" /> This IMAGEPROXYURL function retrieves and displays an image from Twitter’s image host, an external source. This function loads the Salesforce Twitter profile image over HTTPS. This function also prevents the image from making unauthorized requests for user credentials. Tips: • Use IMAGEPROXYURL for all images hosted on servers you don’t control. • The rendered image URL can change at any time. Don’t copy and paste it anywhere. • Don’t use the rendered image URL outside of Salesforce. 382 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas INCLUDE Description: Returns content from an s-control snippet. Use this function to reuse common code in many s-controls. Use: {!INCLUDE(source, [inputs])} and replace source with the s-control snippet you want to reference. Replace inputs with any information you need to pass the snippet. S-Control Example: Including Header Snippet This example references a snippet that provides a header for a page that you created to display in a Web tab. It displays the page title “My Title.” Use the $SControl global variable to reference a custom s-control. Including Input Parameters Use the following two examples to see how you can create a reusable snippet and include it in an s-control. This snippet requires two input parameters: titleTheme and titleText. It is a reusable HTML tag that presents a page title and theme based on input parameters. Next, create an s-control that includes this snippet: This s-control uses the snippet titled Title_Snippet to display the title of the page “My Sample Title” and modern theme. Replace Insert your page specific content here with your own HTML content and use the s-control as the source of a Web tab to create your own pages in Salesforce. Tips: • Because this function references an s-control snippet and does not copy it, it always runs the latest content of the s-control snippet. Remember that making a change to your s-control snippet affects all INCLUDE functions that refer to it. • Use the $Request global variable to access any information inside the snippet. • This function is only available in custom buttons, links, and s-controls. INCLUDES Description: Determines if any value selected in a multi-select picklist field equals a text literal you specify. 383 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use: INCLUDES(multiselect_picklist_field, text_literal) and replace multiselect_picklist_field with the merge field name for the multi-select picklist; and replace text_literal with the multi-select picklist value you want to match in quotes. Examples: INCLUDES(Hobbies__c, "Golf") returns TRUE if one of the selected values in the Hobbies custom multi-select picklist field is Golf. Tips: • The text_literal expression must be of type text and enclosed in quotes. It cannot be a merge field or the result of a function. • Salesforce returns an error if any of the following occurs: – You do not provide a text_literal expression. – You provide an empty text_literal expression, such as "" or " ". • Use ISBLANK to determine if a multi-select picklist field is empty. • Use the PRIORVALUE function inside the INCLUDES function to check if the previous value of a multi-select picklist field included a specific value. For example: INCLUDES( PRIORVALUE(multiselect_picklist_field), text_literal ) ISBLANK Description: Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE. Use: ISBLANK(expression) and replace expression with the expression you want evaluated. Example: (IF(ISBLANK(Maint_Amount__c), 0, 1) + IF(ISBLANK(Services_Amount__c), 0,1) + IF(ISBLANK(Discount_Percent__c), 0, 1) + IF(ISBLANK(Amount), 0, 1) + IF(ISBLANK(Timeline__c), 0, 1)) / 5 This formula takes a group of fields and calculates what percent of them are being used by your personnel. This formula field checks five fields to see if they are blank. If so, a zero is counted for that field. A “1” is counted for any field that contains a value, and this total is divided by five (the number of fields evaluated). This formula requires you to select the Treat blank fields as blanks option under Blank Field Handling while the Advanced Formula subtab is showing. Tips: • Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas. • A field is not empty if it contains a character, blank space, or zero. For example, a field that contains a space inserted with the spacebar is not empty. 384 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • Use the BLANKVALUE function to return a specified string if the field doesn't have a value; use the ISBLANK function if you only want to check if the field has a value. • If you use this function with a numeric field, the function only returns TRUE if the field has no value and is not configured to treat blank fields as zeroes. • If you use this function with a picklist, use ISBLANK(TEXT( ISCHANGED Description: Compares the value of a field to the previous value and returns TRUE if the values are different. If the values are the same, this function returns FALSE. Use: ISCHANGED(field) and replace field with the name of the field you want to compare. Validation Rule Example: The following validation rule prevents users from changing an object name after it has been created: ISCHANGED(Name). NOT(AND(ISCHANGED(Priority), ISPICKVAL(Priority, “Low”))) is a validation rule that ensures if a user changes the Priority of a case, the new priority cannot be “Low.” NOT(AND(ISCHANGED(CloseDate), OR(MONTH(CloseDate) <> MONTH(TODAY()), YEAR(CloseDate) <> YEAR(TODAY())),$Profile.Name <> "Sales Manager")) is a validation rule that prevents a user from changing the Close Date of an opportunity to a date outside of the current month and year unless that user has the “Sales Manager” profile. Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions. Tips: • This function is available only in: – Assignment rules – Validation rules – Field updates – Workflow rules if the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited . – Formula criteria for executing actions in Process Builder. • Use the NOT function to reverse the return values of TRUE and FALSE. • This function returns FALSE when evaluating any field on a newly created record. • If a text field was previously blank, this function returns TRUE when it contains any value. • For number, percent, or currency fields, this function returns TRUE when: – The field was blank and now contains any value – The field was zero and now is blank – The field was zero and now contains any other value 385 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas ISCLONE Description: Checks if the record is a clone of another record and returns TRUE if one item is a clone. Otherwise, returns FALSE. Use: ISCLONE() Validation Rule Example: Use (ISCLONE() to create a validation rule on an object and identify a record that’s a clone of another record. Tips: • This function cannot be used with fields. • Use the NOT function to reverse the return values of TRUE and FALSE. ISNEW Description: Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE. Use: ISNEW() Validation Rule Example: Use the following validation rule to prevent users from creating a record with a close date in the past. AND (ISNEW(), CloseDate < TODAY()) checks if the user is creating a new opportunity and, if so, ensures that the Close Date is today or after today. Use this validation rule to ensure users add at least one product to an opportunity after they have created it. NOT(OR(ISNEW(),HasOpportunityLineItem)) In this example, the validation rule formula displays the following error message when an existing opportunity does not have any products: “You must add products to this opportunity before saving.” This does not display an error on the initial save because they cannot add products until after saving the record initially; but it prevents them from resaving or closing an opportunity that does not contain products. Tips: • This function is available only in validation rules, field updates, workflow rules, assignment rules, and processes. • Use the NOT function to reverse the return values of TRUE and FALSE. • This function always returns FALSE when used in a workflow rule with a time-based trigger. • This function always returns FALSE when used in a field update for an approval action. ISNULL Important: Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce will continue to support ISNULL, so you do not need to change any existing formulas. Description: Determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE. 386 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use: ISNULL(expression) and replace expression with the expression you want evaluated. Example: (IF(ISNULL(Maint_Amount__c), 0, 1) + IF(ISNULL(Services_Amount__c), 0,1) + IF(ISNULL(Discount_Percent__c), 0, 1) + IF(ISNULL(Amount), 0, 1) + IF(ISNULL(Timeline__c), 0, 1)) / 5 This formula takes a group of fields and calculates what percent of them are being used by your personnel. This formula field checks five fields to see if they are blank. If so, a zero is counted for that field. A “1” is counted for any field that contains a value, and this total is divided by five (the number of fields evaluated). This formula requires you to select the Treat blank fields as blanks option under Blank Field Handling while the Advanced Formula subtab is showing. Validation Rule Example: AND(ISPICKVAL(StageName, "Closed Won"), ISNULL(Project_Start_Date__c)) This validation rule makes the Project Start Date custom date field conditionally required whenever the stage is Closed Won. Tips: • Text fields are never null, so using this function with a text field always returns false. For example, the formula field IF(ISNULL(new__c) 1, 0) is always zero regardless of the value in the New field. For text fields, use the ISBLANK function instead. • Multi-select picklist fields are never null in s-controls, buttons, and email templates, so using this function with a multi-select picklist field in those contexts always returns false. • Empty date and date/time fields always return true when referenced in ISNULL functions. • Don’t use ISNULL for date/time fields. • Choose Treat blank fields as blanks for your formula when referencing a number, percent, or currency field in an ISNULL function. Choosing Treat blank fields as zeroes gives blank fields the value of zero so none of them will be null. • Merge fields can be handled as blanks, which can affect the results of components like s-controls because they can call this function. • When using a validation rule to ensure that a number field contains a specific value, use the ISNULL function to include fields that do not contain any value. For example, to validate that a custom field contains a value of '1', use the following validation rule to display an error if the field is blank or any other number: OR(ISNULL(field__c), field__c<>1) ISNUMBER Description: Determines if a text value is a number and returns TRUE if it is. Otherwise, it returns FALSE. Use: ISNUMBER(text) and replace text with the merge field name for the text field. 387 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Validation Rule Example: OR(LEN(Bank_Account_Number__c) <> 10, NOT(ISNUMBER(Bank_Account_Number__c))) This validation rule ensures a custom text field called Bank Account Number is a number of 10 digits and is not blank. Tips: • This function returns FALSE for blank values. • The ISNUMBER function is not aware of your locale. For example, ISNUMBER("123,12") and ISNUMBER("1 000") return FALSE even if the user's locale is “French.” • Chinese, Japanese, Korean, and special characters including a space return FALSE. • The ISNUMBER function returns TRUE for scientific formatting such as “2E2” or “123.123.” ISPICKVAL Description: Determines if the value of a picklist field is equal to a text literal you specify. Use: ISPICKVAL(picklist_field, text_literal) and replace picklist_field with the merge field name for the picklist; replace text_literal with the picklist value in quotes. text_literal cannot be a merge field or the result of a function. Examples: Contract Activation IF(ISPICKVAL(Status, "Activated"), NOW()-ActivatedDate, null) calculates the number of days since the contract was activated. If the contract status is not “Activated,” this field is blank. Commission Amounts IF(ISPICKVAL(StageName, "Closed Won"), ROUND(Amount *0.02, 2), 0) This example calculates the commission amount for any opportunity that has a “Closed Won” stage. The value of this field will be the amount times 0.02 for any closed/won opportunity. Open or lost opportunities will have a zero commission value. Competitor-Triggered Workflow ISPICKVAL(Stage, “Closed Lost”) && INCLUDES(Competitor__c, “Acme”) In a workflow rule or process, this formula configures Salesforce to trigger the associated actions if the Competitor multi-select picklist field on a lost business is Acme. Tips: • Replace picklist_field with a custom or standard field of type picklist. • Your text_literal expression must be of type text and enclosed in quotes. It cannot be a merge field or the result of a function. • Use CASE functions to determine if a picklist value is equal to a particular value. 388 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • When using the ISPICKVAL function to return the previous value of a picklist field, include the PRIORVALUE function inside the ISPICKVAL function as in this example: ISPICKVAL(PRIORVALUE (picklist_field), text_literal) JSENCODE Description: Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe ('). Use: {!JSENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters. Example: If the merge field foo__c contains Enter the user's name, {!JSENCODE(foo__c)} results in: \u003CB\u003EEnter the user\'s name\u003C\/b\u003E Tips: This function is only available in custom buttons and links, and in Visualforce. JSINHTMLENCODE Description: Encodes text and merge field values for use in JavaScript inside HTML tags by replacing characters that are reserved in HTML with HTML entity equivalents and inserting escape characters before unsafe JavaScript characters. JSINHTMLENCODE(someValue) is a convenience function that is equivalent to JSENCODE(HTMLENCODE((someValue)). That is, JSINHTMLENCODE first encodes someValue with HTMLENCODE, and then encodes the result with JSENCODE. Use: {!JSINHTMLENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters. Example: If the merge field foo__c contains Enter the user's name, {!JSINHTMLENCODE(foo__c)} results in: <B>Enter the user's name</b> Tips: • This function is only available in custom buttons and links, and in Visualforce. JUNCTIONIDLIST Description: Returns a JunctionIDList based on the provided IDs. A JunctionIDList is a string array of referenced ID values that represent the many-to-many relationship of an underlying junction entity. Use: JUNCTIONIDLIST(id, id,...) and replace id with the Salesforce ID you want to use. 389 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Example: JUNCTIONIDLIST(Case.ContactId) This formula returns the case’s contact record ID. When used on the email action for cases, you can use this formula as a predefined value for the To Recipients field. Using this formula as a predefined value for the field ensures that sent emails are always associated with a Salesforce record. In the case feed publisher, users see the contact name instead of the ID or email address. Tips: • You can enter IDs only. • You can use the JUNCTIONLISTID formula with the To Recipients, CC Recipients, and BCC Recipients fields to send emails to multiple contacts and users. However, these fields work only with the email action for cases. LEFT Description: Returns the specified number of characters from the beginning of a text string. Use: LEFT(text, num_chars) and replace text with the field or expression you want returned; replace num_chars with the number of characters from the left you want returned. Example: TRIM(LEFT(LastName, 5)) & "-" & TRIM(RIGHT(SSN__c, 4)) This formula displays the first five characters of a name and the last four characters of a social security number separated by a dash. Note that this example uses a text custom field called SSN. Tips: • Reference auto-number fields as text fields in formulas. • If the num_chars value is less than zero, Salesforce replaces the value with zero. LEN Description: Returns the number of characters in a specified text string. Use: LEN(text) and replace text with the field or expression whose length you want returned. Example: LEN(PartNumber__c) This formula returns the number of characters in a Product Code field. LINKTO Description: Returns a relative URL in the form of a link (href and anchor tags) for a custom s-control or Salesforce page. Use: {!LINKTO(label, target, id, [inputs], [no override]} and replace label with the text for the link, target with the URL, and id with a reference to the record. Inputs are optional and can include any additional parameters you want to add to the link. The no override argument is also optional and defaults to “false.” It applies to targets for standard Salesforce pages such as $Action.Account.New. Replace no override with “true” when you 390 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas want to display a standard Salesforce page regardless of whether you have defined an override for it elsewhere. S-Control Example: New Account S-Control This example allows users to click a link to create a new account. It is useful in account list views or Web tabs where you want users to create an account directly from that page. Use the $Action global variable to access the new account page in Salesforce. New Email Window S-Control This example launches a new email window addressed to support@yourcompany.com with the subject “Please Help” whenever a user clicks “Mail link.” Link to Another S-Control Use this example to generate a page containing a hyperlink labeled “Check for duplicates.” When users click this link, Salesforce runs your custom s-control. This example assumes you have already created a custom s-control to find duplicate accounts and merge their information. Tips: • Avoid using this function in an inline s-control if you want it to open in a new window. • Enclose multiple inputs in brackets to indicate they are together: {!LINKTO("View Case", $Action.Case.View, Case.Id, [parm1="A", parm2="B"])} • Set inputs to null if you do not have any to pass yet you want to set the no override argument: {!LINKTO("View Case", $Action.Case.View, Case.Id, null, true)} • When you override the tab home page for a standard or custom tab, use the tab’s $Action global variable as the target value, and the tab’s object type for the id value. For example, LINKTO("Accounts Tab", $Action.Account.Tab, $ObjectType.Account) • This function is only available in custom buttons, links, and s-controls. 391 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas LN Description: Returns the natural logarithm of a specified number. Natural logarithms are based on the constant e value of 2.71828182845904. Use: LN(number) and replace number with the field or expression for which you want the natural logarithm. Note: the LN function is the inverse of the EXP function. Example: LN(10) returns the natural logarithm of 10, which is 2.30. LN(Value__c) returns the natural logarithm of a custom number field called Value. LOG Description: Returns the base 10 logarithm of a number. Use: LOG(number) and replace number with the field or expression from which you want the base 10 logarithm calculated. Example: Salary LOG(Salary__c) calculates the logarithm of a person’s salary. In this example, Salary is a custom currency field. Hydrogen -LOG(Hydrogen__c) calculates the pH and acidity using the LOG function and a custom number field called Hydrogen, which represents the concentration of Hydrogen ions in the liquid measured in moles per liter. LOWER Description: Converts all letters in the specified text string to lowercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided. Use: LOWER(text, [locale]) and replace text with the field or text you wish to convert to lowercase, and locale with the optional two-character ISO language code or five-character locale code, if available. Example: MYCOMPANY.COM LOWER("MYCOMPANY.COM") returns “mycompany.com.” Ticker Symbol LOWER(TickerSymbol) returns the text in Ticker Symbol in lower case characters. Applying Turkish Language Locale Rules The Turkish language has two versions of the letter “i”: one dotted and one dotless. The locale rules for Turkish require the ability to capitalize the dotted i, and allow the dotless I to be lowercase. To correctly use the LOWER() function with the Turkish language locale, use the Turkish locale code tr in the LOWER() function as follows: LOWER(text, "tr") 392 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas This ensures that Salesforce does not transform any dotted i in the text to a dotless I. LPAD Description: Inserts characters you specify to the left-side of a text string. Use: LPAD(text, padded_length[, pad_string]) and replace the variables: • text is the field or expression you want to insert characters to the left of. • padded_length is the number of total characters in the text that will be returned. • pad_string is the character or characters that should be inserted. pad_string is optional and defaults to a blank space. If the value in text is longer than pad_string, text is truncated to the size of padded_length. Example: Field Name: Padding LPAD(Name, 20) truncates the Name field after 20 characters. For example, if the name is mycompany.com, the value returned is "mycompany.com." My_Company: No Change LPAD('my_company.com', 14, 'z') returns “my_company.com” without change because it has 14 characters. Field Name Padded with Z LPAD(Name, 15, 'z') returns the name “zmycompany.com.” Field Name: Truncating LPAD(Name, 2) truncates the name after the second character. For example, if the name is mycompany.com, the value returned is “my.” Tips: Leading blank spaces and zeros are omitted. MAX Description: Returns the highest number from a list of numbers. Use: MAX(number, number,...) and replace number with the fields or expressions from which you want to retrieve the highest number. Example: Service Charge MAX(0.06 * Total_Cost__c, Min_Service_Charge__c) In this example, the formula field calculates a service charge of 6% of the total cost or a minimum service charge, whichever is greater. Note that Min Service Charge is a custom currency field with a default value of $15. However, you could make it a formula field if your minimum service charge is always the same amount. 393 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Book Royalties MAX(0.10 * Pages__c, (Retail_Price__c * 0.07) * Total_Sold__c) This formula determines which amount to pay in royalties for a book. It displays the greater of two amounts: $0.07 for each book sold or $0.10 per page. It assumes you have custom number fields for Pages and Total Sold and a custom currency field for Retail Price. Commissions MAX($User.Commission_Percent__c * Price, Price * Account_Discount__c, 100) This formula determines what commission to log for an asset based on which is greater: the user's commission percentage of the price, the price times the discount percent stored for the account or 100 dollars. This example assumes you have two custom percent fields on users and assets. MCEILING Description: Rounds a number up to the nearest integer, towards zero if negative. Use: MCEILING(number) Example: MCEILING(2.5) returns 3, which is 2.5 rounded up to the nearest integer. MCEILING(-2.5) returns -2, which is -2.5 rounded up towards zero for a negative number. MFLOOR Description: Rounds a number down to the nearest integer, away from zero if negative. Use: MFLOOR(number) Example: MFLOOR(2.5) returns 2, which is 2.5 rounded down to the nearest integer. MFLOOR(-2.5) returns -3, which is -2.5 rounded away from zero for a negative number. MID Description: Returns the specified number of characters from the middle of a text string given the starting position. Use: MID(text, start_num, num_chars) and replace text with the field or expression to use when returning characters; replace start_num with the number of characters from the left to use as a starting position; replace num_chars with the total number of characters to return. Example: MID(Division, 3, 4) returns four characters of the Division name beginning with the third character from the left. On a user record, this represents the department code. 394 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas MILLISECOND Description: Returns a milliseconds value in the form of a number from 0 through 999. Use: MILLISECOND(time) and replace time with a time value or value such as TIMENOW(). Examples: MILLISECOND(TIMEVALUE(ClosedDate)) displays only the milliseconds in a time field based on the value of the Time Closed field. MILLISECOND(TIMEVALUE("17:30:45.125")) returns 125. MIN Description: Returns the lowest number from a list of numbers. Use: MIN(number, number,...) and replace number with the fields or expressions from which you want to retrieve the lowest number. Example: 401K Matching MIN(250, Contribution__c /2) This example formula determines which amount to provide in employee 401K matching based on a matching program of half of the employee's contribution or $250, whichever is less. It assumes you have custom currency field for Contribution. Bonus MIN(Gross__c * Bonus_Percent__c, Performance__c / Number_of_Employees__c) This example determines an employee's bonus amount based on the smallest of two amounts: the employee's gross times bonus percent or an equally divided amount of the company's performance amount among all employees. It assumes you have custom number field for Number of Employees, a custom percent field for Bonus Percent, and currency custom fields for the employee's Gross and company's Performance. MINUTE Description: Returns a minute value in the form of a number from 0 through 60. Use: MINUTE(time) and replace time with a time value or value such as TIMENOW(). Examples: MINUTE(TIMEVALUE(ClosedDate)) displays only the minutes in a time field based on the value of the Time Closed field. MINUTE(TIMEVALUE("17:30:45.125")) returns 30. MOD Description: Returns a remainder after a number is divided by a specified divisor. 395 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use: MOD(number, divisor) and replace number with the field or expression you want divided; replace divisor with the number to use as the divisor. Example: MOD(3, 3) returns 0 MOD(4, 3) returns 1 MOD(123, 100) returns 23 You might want to prevent users from scheduling meetings on a Saturday or Sunday. Use the following example to apply a validation rule to a custom date field called My Date. CASE(MOD(My_Date__c - DATE(1900, 1, 7), 7), 0, 0, 6, 0, 1) = 0 This example displays the following error message when the value of My Date is not Monday through Friday: “My Date is not a weekday.” MONTH Description: Returns the month, a number between 1 (January) and 12 (December) in number format of a given date. Use: MONTH(date) and replace date with the field or expression for the date containing the month you want returned. Example: SLA Expiration MONTH(SLAExpirationDate__c) returns the month that your service-level agreement expires. This example uses a custom date field called SLA Expiration Date. Current Month MONTH(TODAY()) returns the current month in a number format. For example, the month of February would be the value “2.” NOT Description: Returns FALSE for TRUE and TRUE for FALSE. Use: NOT(logical) and replace logical with the expression that you want evaluated. Example: IF(NOT(ISPICKVAL(Status, "Closed")), ROUND(NOW()-CreatedDate, 0), null checks to see if a variable is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number of days open rounded to zero decimal places. If the variable is not open, this field is blank. 396 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas NOW Description: Returns a date/time representing the current moment. Use: NOW() Example: IF(ISPICKVAL(Status, "Open"), ROUND(NOW()-CreatedDate, 0), null) This formula checks to see if a lead is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number of days open rounded to zero decimal places. If the lead is not open, this field is blank. Tips: • Do not remove the parentheses. • Keep the parentheses empty. They do not need to contain a value. • Use a date/time field in a NOW function instead of a date field. Created Date and Last Modified Date are date/time fields whereas Last Activity Date is a date field. • Use TODAY if you prefer to use a date field. • Dates and times are always calculated using the user’s time zone. • Use addition and subtraction operators with a NOW function and other date/time fields to return a number, representing number of days. For example NOW() - CreatedDate calculates the number of days since the created date of a record. In this example, the formula field data type is a number. • Use addition and subtraction operators with a NOW function and numbers to return a date and time. For example NOW() +5 calculates the date and time five days ahead of now. In this example, the formula field data type is a date/time. NULLVALUE Important: Use BLANKVALUE instead of NULLVALUE in new formulas. BLANKVALUE has the same functionality as NULLVALUE, but also supports text fields. Salesforce continues to support NULLVALUE, so you don’t need to change existing formulas. Description: Determines if an expression is null (blank) and returns a substitute expression if it is. If the expression is not blank, returns the value of the expression. Use: NULLVALUE(expression, substitute_expression) and replace expression with the expression you want to evaluate; replace substitute_expression with the value you want to replace any blank values. Example: (NULLVALUE(Sample_Due_Date__c, StartDate +5) This formula returns the date five days after the start date whenever Sample Due Date is blank. Sample Due Date is a custom date field. Tips: • Avoid using this function with text fields because they are never null even when they are blank. Instead, use the BLANKVALUE function to determine if a text field is blank. • Don’t use NULLVALUE for date/time fields. 397 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • Choose Treat blank fields as blanks for your formula when referencing a number, percent, or currency field in a NULLVALUE function. Choosing Treat blank fields as zeroes gives blank fields the value of zero so none of them will be null. • Use the same data type for both the expression and substitute_expression. OR Description: Determines if expressions are true or false. Returns TRUE if any expression is true. Returns FALSE if all expressions are false. Use this function as an alternative to the operator || (OR). Use: OR(logical1, logical2...) and replace any number of logical references with the expressions you want evaluated. Formula Field Example: IF(OR(ISPICKVAL(Priority, "High"), ISPICKVAL(Status, "New")), ROUND(NOW()-CreatedDate, 0), null) This formula returns the number of days a case has been open if the Status is new or the Priority is high. If the case was opened today, this field displays a zero. Validation Rule Example: OR(Sample_Rate__c < 0, Sample_Rate__c > 0.40) This validation rule formula displays the following error message when the Sample Rate custom field is not between 0 and 40%: “SampleRate cannot exceed 40%.” PARENTGROUPVAL Description: This function returns the value of a specified parent grouping. A “parent” grouping is any level above the one containing the formula. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels. Use: Summary and Joined: PARENTGROUPVAL(summary_field, grouping_level) Matrix: PARENTGROUPVAL(summary_field, parent_row_grouping, parent_column_grouping) Where summary_field is the summarized field value, grouping_level is GRAND_SUMMARY or the API name of the parent level group for summary reports, and parent_row_level and parent_column_level are the parent levels for matrix reports. In reports with multiple grouping levels, you can set the grouping_level to be any group level higher than the formula display level. Example: TOTAL_PRICE:SUM/PARENTGROUPVAL(TOTAL_PRICE:SUM, GRAND_SUMMARY) This formula calculates, for each product, its relative size compared to the grand total. In this example, the report is a summary of opportunities and their products, grouped by Product Name. 398 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas PREDICT Description: Returns an Einstein Discovery prediction for a record based on the specified record ID or for a list of fields and their values. Use: PREDICT(PredDefId, [recordId] | [field, value, ...]). Replace PredDefId with the Prediction Definition ID of a deployed prediction in your org. Specify the recordId of the record to predict or a list of fields and their associated values ([field, value, ...]). Examples: Example with recordId PREDICT($SmartDataDiscovery.PredictionDefinitions.Recommende_kFjqS_1370.Id, Id) This example calls the PREDICT function and passes a prediction definition and recordId. Example with List of Fields and Values PREDICT($SmartDataDiscovery.PredictionDefinitions.Recommende_kFjqS_1370.Id, ‘Customer_Typec’, Text(Customer_Typec), ‘List_Price__c’, List_Price__c) This example calls the PREDICT function and passes a prediction definition and list of fields with associated values. Tips: • The specified PredDefId must link to a deployed and active prediction in your Salesforce org. To insert a value, select PredDefId, click Insert Field, select SmartDataDiscovery > Prediction Definitions, select an available prediction, select Prediction Definition Id, and then click Insert. Note: The syntax for PredDefId must match the following pattern: $SmartDataDiscovery.PredictionDefinitions. • If you specify a recordId, the function returns a prediction for the data values in that record. • If you specify a list of field names and values, the function returns a prediction for the data values you provided. Be sure to provide all the fields that the prediction requires as input. • Getting predictions from Einstein Discovery predictions requires the View Einstein Discovery Recommendations system permission. To learn more, see Learn About Einstein Discovery Permissions and Permission Sets. • The PREDICT function is available when defining formulas for the following Process Automation components: approval processes, flows, processes (in Process Builder), workflow rules, and Next Best Action. • The PREDICT function is not supported in formula-based fields on Salesforce objects. • To learn more, see Get Predictions in Process Automation Formulas. 399 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas PREVGROUPVAL Description: This function returns the value of a specified previous grouping. A “previous” grouping is one that comes before the current grouping in the report. Choose the grouping level and increment. The increment is the number of columns or rows before the current summary. The default is 1; the maximum is 12. You can use this function only in custom summary formulas and at grouping levels for reports, but not at summary levels. Use: PREVGROUPVAL(summary_field, grouping_level [, increment]) Where summary_field is the name of the grouped row or column, grouping_level is the API name of the peer level group whose summary value for the previous grouping is used, and increment is the number of groupings previous. In reports with multiple grouping levels, you can specify the grouping_level to be the same group level as the formula display level or a group level higher than the formula display level. Example: AMOUNT:SUM - PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE) This formula calculates, for each month, the difference in amount from the previous month shown in the report. In this example, the report is an opportunity matrix with columns grouped by Close Date and rows by Stage. PRIORVALUE Description: Returns the previous value of a field. Use: PRIORVALUE(field) Validation Rule Example: The following validation rule prevents users from changing the expected revenue of an opportunity after it is closed: AND(PRIORVALUE(Amount) > Amount, IsClosed). Tips: • This function is available only in: – Assignment rules – Validation rules – Field updates – Workflow rules if the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited . – Formula criteria for executing actions in Process Builder. • This function does not return default values. • When users create a new record, this function returns the value of the field referenced rather than null. For example, if you create an account named “Acme,” PRIORVALUE(Account.Name) returns Acme. 400 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • When using the ISPICKVAL function to return the previous value of a picklist field, include the PRIORVALUE function inside the ISPICKVAL function as in this example: ISPICKVAL(PRIORVALUE (picklist_field), text_literal) • Use the PRIORVALUE function inside the INCLUDES function to check if the previous value of a multi-select picklist field included a specific value. For example: INCLUDES( PRIORVALUE(multiselect_picklist_field), text_literal ) REGEX Description: Compares a text field to a regular expression and returns TRUE if there is a match. Otherwise, it returns FALSE. A regular expression is a string used to describe a format of a string according to certain syntax rules. Use: REGEX(text, regex_text) and replace text with the text field, and regex_text with the regular expression you want to match. Validation Rule Example: This example ensures that a custom field called SSN matches a regular expression representing a valid social security number format of the form 999-99-9999. NOT( OR( LEN (SSN__c) = 0, REGEX(SSN__c, "[0-9]{3}-[0-9]{2}-[0-9]{4}") ) ) Tips: • Regular expression syntax is based on Java Platform SE 6 syntax. However, backslash characters (\) must be changed to double backslashes (\\) because backslash is an escape character in Salesforce. • The Salesforce regular expression engine matches an entire string as opposed to searching for a match within a string. For example, if you are searching for the name Marc Benioff, use the regular expression, .*Marc Benioff.*, to find a match in a string like the following: According to Marc Benioff, the social enterprise increases customer success. If you use the regular expression, Marc Benioff, the only string that this regular expression will match is: Marc Benioff 401 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • Capture groups and substitutions are ignored. • This function is available everywhere formulas exist except formula fields and custom buttons and links. REQUIRESCRIPT Description: Returns a script tag with source for a URL you specify. Use this function when referencing the Lightning Platform AJAX Toolkit or other JavaScript toolkits. Use: {!REQUIRESCRIPT(url)} and replace url with the link for the script that is required. For the AJAX Toolkit: {!requireScript("/soap/ajax/13.0/connection.js")} Returns: Custom Button Example: {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} var c = new sforce.SObject("Case"); c.id = "{!Case.Id}"; c.Status = "New"; result = sforce.connection.update([c]); window.location.reload(); This example sets the Status of a case to “New” whenever a user clicks a custom button from the case detail page. To set this up in your organization, define a custom button for cases that has the following attributes: • Display Type is “Detail Page Button” • Behavior is “Execute JavaScript” • Content Source is “OnClick JavaScript” Next, paste the content above into your custom button definition and add it to your case page layouts. Tips: • Use global variables to access special merge fields for s-controls. • Use this function when creating custom buttons or links where you have set Behavior to “Execute JavaScript” and Content Source to “OnClick JavaScript” because the script tag must be outside the OnClick code. • This function is only available for custom buttons and links that have Content Source set to “OnClick JavaScript.” • When working in Visualforce, use INCLUDESCRIPT instead. RIGHT Description: Returns the specified number of characters from the end of a text string. 402 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use: RIGHT(text, num_chars) and replace text with the field or expression you want returned; replace num_chars with the number of characters from the right you want returned. Example: TRIM(LEFT(LastName, 5))&"-"&TRIM(RIGHT(SSN__c, 4)) displays the first five characters of a name and the last four characters of a social security number separated by a dash. Note that this assumes you have a text custom field called SSN. Tips: • Reference auto-number fields as text fields in formulas. • If the num_chars value is less than zero, Salesforce replaces the value with zero. ROUND Description: Returns the nearest number to a number you specify, constraining the new number by a specified number of digits. Use: ROUND(number, num_digits) and replace number with the field or expression you want rounded; replace num_digits with the number of decimal places you want to consider when rounding. Example: ROUND (1.5, 0) = 2 ROUND (1.2345, 0) = 1 ROUND (-1.5, 0) = -2 ROUND (225.49823, 2) = 225.50 Simple Discounting ROUND(Amount-Amount* Discount_Percent__c,2) Use this formula to calculate the discounted amount of an opportunity rounded off to two digits. This example is a number formula field on opportunities that uses a custom percent field called Discount Percent. Tips: • Enter zero for num_digits to round a number to the nearest integer. • Salesforce automatically rounds numbers based on the decimal places you specify. For example, a custom number field with two decimal places stores 1.50 when you enter 1.49999. • Salesforce uses the round half-up rounding algorithm. Half-way values are always rounded up. For example, 1.45 is rounded to 1.5. –1.45 is rounded to –1.5. • The decimal numbers displayed depend on the decimal places you selected when defining the field in the custom field wizard. The num_digits represents the number of digits considered when rounding. RPAD Description: Inserts characters that you specify to the right-side of a text string. 403 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use: RPAD(text, padded_length[, 'pad_string']) and replace the variables: • text is the field or expression after which you want to insert characters. • pad_length is the number of total characters in the text string that will be returned. • pad_string is the character or characters to insert. pad_string is optional and defaults to a blank space. If the value in text is longer than pad_string, text is truncated to the size of padded_length. Example: Field Name: Padding Default RPAD(Name, 20) truncates the Name field after 20 characters. For example, if the name is mycompany.com, the value returned is “mycompany.com.” My_Company: No Change RPAD('my_company.com', 14, 'z') returns “my_company.com” without change because it has 14 characters. Field Name: Padding with a Character RPAD(Name, 15, 'z') returns “mycompany.comz” . Field Name: Truncating RPAD(Name, 2) truncates the name after the second character. For example, if the name is mycompany.com, the value returned is “my.” Tips: Ending blank spaces are omitted. SECOND Description: Returns a seconds value in the form of a number from 0 through 60. Use: SECOND(time) and replace time with a time value or value such as TIMENOW(). Examples: SECOND(ClosedDate) displays only the seconds in a time field based on the value of the Time Closed field. SECOND(TIMEVALUE("17:30:45.125")) returns 45. SQRT Description: Returns the positive square root of a given number. Use: SQRT(number) and replace number with the field or expression you want computed into a square root. Example: SQRT(25)returns the square root of 25, which is 5. Amplitude SQRT(Amplitude__c) returns the square root of a custom number field representing the amplitude of an earthquake. 404 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Tips: • Calculating the square root of a negative number results in an error on the detail page. • Avoid division by zero errors by including an IF function such as: IF(Amplitude__c >= 0, SQRT(Amplitude__c), null). SUBSTITUTE Description: Substitutes new text for old text in a text string. Use: SUBSTITUTE(text, old_text, new_text) and replace text with the field or value for which you want to substitute values, old_text with the text you want replaced, and new_text with the text you want to replace the old_text. Example: SUBSTITUTE(Name, "Coupon", "Discount")returns the name of an opportunity that contains the term “Coupon” with the opportunity name plus “Discount” wherever the term “Coupon” existed. SUBSTITUTE(Email, LEFT(Email, FIND("@", Email)), "www.") finds the location of the @ sign in a person's email address to determine the length of text to replace with a “www.” as a means of deriving their website address. Tips: • Each term provided in quotes is case-sensitive. • If the old_text appears more than once, each occurrence is replaced with the new_text value provided, even when that results in duplicates. TEXT Description: Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. Also, converts picklist values to text in approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, validation rules, formula fields, field updates, and custom buttons and links. Use: TEXT(value) and replace value with the field or expression you want to convert to text format. Avoid using any special characters besides a decimal point (period) or minus sign (dash) in this function. Example: Expected Revenue in Text TEXT(ExpectedRevenue) returns the expected revenue amount of an opportunity in text format without a dollar sign. For example, if the Expected Revenue of a campaign is "$200,000," this formula field displays “200000.” Asset ID SerialNumber &"-"& TEXT(Quantity) returns an asset ID number starting with the serial number and ending with the quantity separated by a dash. The Serial Number field is already text but the Quantity field is a number, requiring the TEXT function before it. 405 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use Picklist Values in Math Equations VALUE(LEFT(TEXT(Quantity), 5)) * Unit This formula multiplies the first five numbers of the Quantity picklist by the Unit numeric field. Compare Two Picklists IF(TEXT(bug_status) = TEXT(case_status), “Match”, “Out of Sync”) This formula compares the values of the bug_status picklist with values of the case_status picklist. Display Picklist Values From Parent Records TEXT(Account.Industry) This formula field on opportunities shows the industry of the associated account. Concatenate Picklist Values TEXT(Account.Industry) & " - " & TEXT(Account.SubIndustry__c) This formula field on opportunities shows the industry and subindustry of the associated account. Validation Rule Examples: Block the Save of a Closed Opportunity CONTAINS(TEXT(Status), "Closed") returns TRUE if the Status picklist contains the value “Closed,” such as “Closed Won” and “Closed Lost.” This validation rule formula blocks users from saving changes to a closed opportunity. Use Numeric Functions on Numeric Picklist Values VALUE(LEFT(TEXT(Quantity), 5)) * Unit > 10000 multiplies the first five numbers of the Quantity picklist by the Unit numeric field, and returns TRUE if the result is greater than 10,000. Directly Compare Two Picklists TEXT(bug_status) = TEXT(case_status) compares the values of the bug_status picklist with values of the case_status picklist, and returns TRUE if they are equal. Tips: • The returned text is not formatted with any currency, percent symbols, or commas. • Values are not sensitive to locale. For example, 24.42 EUR is converted into the number 24.42. • Percents are returned in the form of a decimal. • Dates are returned in the form of YYYY-MM-DD, that is, a four-digit year and two-digit month and day. • Date/time values are returned in the form of YYYY-MM-DD HH:MM:SSZ where YYYY is a four-digit year, MM is a two-digit month, DD is a two-digit day, HH is the two-digit hour, MM are the minutes, SS are the seconds, and Z represents the zero meridian indicating the time is returned in UTC time zone. • Picklist fields are supported in TEXT functions used in these kinds of formulas: validation rules, approval rules, approval step rules, workflow rules, escalation rules, assignment rules, auto-response rules, formula fields, field updates, and custom buttons and links. In other formulas, use ISPICKVAL or CASE when referencing a picklist field. 406 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • If the text value you enter is a URL, the text automatically converts as a hyperlink. TIMENOW Description: Returns a time value in GMT representing the current moment. Use this function instead of the NOW function if you only want to track time, without a date. Use: TIMENOW() Example: IF(ISPICKVAL( Rating , "Hot"), TIMENOW(), TIMEVALUE(CreatedDate)) This formula checks to see if a lead is rated “Hot” and if so, returns the current time. Otherwise it returns the time since someone created the lead. Tips: • Do not remove the parentheses. • Keep the parentheses empty. They do not need to contain a value. • Use TODAY if you prefer to use a date field. • The displayed value is based on the organization’s Locale settings. TIMEVALUE Description: Returns the local time value without the date, such as business hours. Use: TIMEVALUE(value) and replace value with a date/time or text value, merge field, or expression. Examples: TIMEVALUE(ClosedDate) displays a time value based on the value of the Date/Time Closed field. TIMEVALUE("17:30:45.125") returns 5:30 PM. Tips: • The displayed value is based on the organization’s Locale settings. • Don’t use TIMEVALUE on a time field. A time field’s value is already in time format. For example, for a time field with API name timefield__c, TIMEVALUE(timefield__c) doesn’t do anything. TODAY Description: Returns the current date as a date data type. Use: TODAY() Example: TODAY()-Sample_date_c calculates how many days in the sample are left. Validation Rule Example: SampleDate < TODAY() This example ensures that users cannot change the Sample Date to any date in the past. 407 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Tips: • Do not remove the parentheses. • Keep the parentheses empty. They do not need to contain a value. • Use a date field with a TODAY function instead of a date/time field. Last Activity Date is a date field whereas Created Date and Last Modified Date are date/time fields. • See NOW if you prefer to use a date/time field. • Dates and times are always calculated using the user’s time zone. • Use addition and subtraction operators with a TODAY function and other date fields to return a number, representing number of days. For example TODAY()-LastActivityDate calculates the number of days since the last activity date. In this example, the formula field data type is a number. • Use addition and subtraction operators with a TODAY function and numbers to return a date. For example TODAY() +5 calculates the date five days ahead of today. In this example, the formula field data type is a date. TRIM Description: Removes the spaces and tabs from the beginning and end of a text string. Use: TRIM(text) and replace text with the field or expression you want to trim. Example: TRIM(LEFT(LastName,5))& "-" & RIGHT(FirstName, 1) returns a network ID for users that contains the first five characters of their last name and first character of their first name separated by a dash. UPPER Description: Converts all letters in the specified text string to uppercase. Any characters that are not letters are unaffected by this function. Locale rules are applied if a locale is provided. Use: UPPER(text, [locale]) and replace text with the field or expression you wish to convert to uppercase, and locale with the optional two-character ISO language code or five-character locale code, if available. Example: MYCOMPANY.COM UPPER("mycompany.com") returns “MYCOMPANY.COM.” MYCOMPANY.COM 123 UPPER("Mycompany.com 123") returns “MYCOMPANY.COM 123.” Applying Turkish Language Locale Rules The Turkish language has two versions of the letter i: one dotted and one dotless. The locale rules for Turkish require the ability to capitalize the dotted i, and allow the dotless I to be lowercase. To correctly use the UPPER() function with the Turkish language locale, use the Turkish locale code tr in the UPPER() function as follows: UPPER(text, "tr") 408 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas This ensures that any dotted i in the text does not transform to a dotless I. URLENCODE Description: Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax. For example, blank spaces are replaced with %20, and exclamation points are replaced with %21. Use: {!URLENCODE(text)} and replace text with the merge field or text string that you want to encode. Example: If the merge field foo__c contains Mark's page, {!URLENCODE(foo_c)} results in: %3CB%3EMark%27s%20page%3C%2Fb%3E Tips: • This function is only available in custom buttons and links, and in Visualforce. • Custom buttons and links with URL content sources have separate encoding settings. If you use the URLENCODE function to encode a custom button or link that has an encoding setting specified, Salesforce first encodes the URL according to the custom button or link setting, then encodes the result. For example, if the URL in a custom link contains a space and its encoding setting is UTF8, Salesforce first encodes the space to a plus sign (+), then the URLENCODE function converts the plus sign to its character code, %2B. • When you include the standard Account field on opportunities (Opportunity.Account) in the URLENCODE function, the value of the field is the account ID, not the account name. To encode the account name, create a custom cross-object formula field on opportunities that spans to the account name, and use that field in the URLENCODE function instead of Opportunity.Account. For example, if the cross-object formula is AccountNameFormula__c, use the following: http://www.google.com/search?q={!URLENCODE (Opportunity.AccountNameFormula__c)} URLFOR Description: Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page. Use: {!URLFOR(target, [id], [inputs], [no override])} and replace target with the URL or action, s-control, or static resource merge variable, id with an optional reference to the record, and inputs with any optional parameters. The no override argument is also optional and defaults to “false.” It applies to targets for standard Salesforce pages such as $Action.Account.New. Replace no override with “true” when you want to display a standard Salesforce page regardless of whether you have defined an override for it elsewhere. The input values can be dynamic. For example, to include an account ID, specify: {!URLFOR($Page.myVisualforcePage, null, [accountId=Account.Id])} 409 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas The resulting URL includes a parameter with the ID, such as: https://instance.salesforce.com/apex/myVisualforcePage?accountId=001B0000002txol You can also use non-string variables, like an SObject variable. For example, if you supply [myAccountParam=Account], the value is converted to a string, and the URL contains ?MyAccountParam=001B0000002txol. You can also use a parameter to supply a static value, such as [param1=55]. Note: Because parameter names are static, you can’t use a variable to determine the parameter name. For example, if you use [myVariable=”value”] and set myVariable to “param1”, the resulting URL includes ?myVariable=value1 and not the param1 value. Visualforce Example: In this example, the Tips: • Use global variables to access special merge fields for actions, s-controls, and static resources. • If an input parameter name begins with any character other than a letter or dollar sign ($), enclose it in quotation marks. • Enclose multiple inputs in brackets to indicate they are together: {!URLFOR($Action.Case.View, Case.Id, [param1="A", param2="B"])} • Set inputs to null if you do not have any to pass yet you want to set the no override argument: {!URLFOR($Action.Case.View, Case.Id, null, true)} • When you override a standard action, that action is no longer available in Salesforce. For example, if you override the new account action, that affects the New button on all pages, such as the account detail page, account related lists on other detail pages, and the Create New dropdown list in the sidebar. To override a standard action yet still access it, use the no override argument in your s-control to reference that action. • When you override the tab home page for a standard or custom tab, use the tab’s $Action global variable as the target value, and the tab’s object type for the id value. For example, URLFOR($Action.Account.Tab, $ObjectType.Account). • This function is only available in custom buttons, links, s-controls, and Visualforce pages. VALUE Description: Converts a text string to a number. 410 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Use: VALUE(text) and replace text with the field or expression you want converted into a number. Example: Lead Number VALUE(Lead_Number__c) returns a number for the text value in the auto-number field Lead Number. This can be useful if you want to use the Lead Number field in a calculation. Note that auto-number fields are actually text fields and must be converted to a number for numeric calculations. Round Robin Lead Assignment MOD(VALUE(Lead_Number__c), 3) This formula is for a custom formula field named Round_Robin_ID that assigns each lead a value of 0, 1, or 2. This formula uses a custom auto-number field called Lead Number that assigns each lead a unique number starting with 1. The MOD function divides the lead number by the number of lead queues available (three in this example) and returns a remainder of 0, 1, or 2. Use the value of this formula field in your lead assignment rules to assign lead records to different queues. For example: • Round_Robin_ID = 0 is assigned to Queue A • Round_Robin_ID = 1 is assigned to Queue B • Round_Robin_ID = 2 is assigned to Queue C Tips: Make sure the text in a VALUE function doesn’t include special characters other than a decimal point (period) or minus sign (dash). If the text in a VALUE function is a non-numerical/invalid format, the formula isn’t calculated and resolves to a blank value. For example, the formula 1 + VALUE(Text_field__c) produces these results: • If Text field is 123, the result is 124. • If Text field is blank, the result is blank. • If Text field is $123, the result is blank. • If Text field is EUR123, the result is blank. VLOOKUP Description: Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function. Use: VLOOKUP(field_to_return, field_on_lookup_object, lookup_value) and replace field_to_return with the field that contains the value you want returned, field_on_lookup_object with the field on the related object that contains the value you want to match, and lookup_value with the value you want to match. Validation Rule Example: This example checks that a billing postal code is valid by looking up the first five characters of the value in a custom object called Zip_Code__c that contains a record for every valid zip code in the US. If the zip code is not found in the Zip_Code__c object or the billing state does not match the corresponding State_Code__c in the Zip_Code__c object, an error is displayed. AND( LEN(BillingPostalCode) > 0, OR(BillingCountry = "USA", BillingCountry = "US"), 411 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas VLOOKUP( $ObjectType.Zip_Code__c.Fields.State_Code__c, $ObjectType.Zip_Code__c.Fields.Name, LEFT(BillingPostalCode,5)) <> BillingState ) Note: • Use this example when the billing country is US or USA. • You can download US zip codes in CSV file format from http://zips.sourceforge.net. Tips: • The field_to_return must be an auto number, roll-up summary, lookup relationship, master-detail relationship, checkbox, date, date/time, email, number, percent, phone, text, text area, or URL field type. • The field_on_lookup_object must be the Record Name field on a custom object. • The field_on_lookup_object and lookup_value must be the same data type. • If more than one record matches, the value from the first record is returned. • The value returned must be on a custom object. • You cannot delete the custom field or custom object referenced in this function. • This function is only available in validation rules. WEEKDAY Description: Returns the day of the week for the given date, using 1 for Sunday, 2 for Monday, through 7 for Saturday. Use: WEEKDAY(date) Example: WEEKDAY(customdate1__c) returns the day of the week for the given date in customdate1__c. YEAR Description: Returns the four-digit year in number format of a given date. Use: YEAR(date) and replace date with the field or expression that contains the year you want returned. Example: YEAR(TODAY())- YEAR(Initial_Meeting__c) returns the number of years since your initial meeting with a client. This example uses a custom date field called Initial Meeting. SEE ALSO: Formula Operators and Functions A–H Formula Operators and Functions 412 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Using Date, Date/Time, and Time Values in Formulas Date formulas are useful for managing payment deadlines, contract ages, or any other features of EDITIONS your organization that are time or date dependent. Two data types are used for working with dates: Date and Date/Time. One data type, Time, is Available in: both Salesforce independent of the date for tracking time such as business hours. Most values that are used when Classic and Lightning working with dates are of the Date data type, which store the year, month, and day. Some fields, Experience such as CreatedDate, are Date/Time fields, meaning they not only store a date value, but also Available in: All Editions a time value (stored in GMT but displayed in the users’ time zone). Date, Date/Time, and Time fields are formatted in the user’s locale when viewed in reports and record detail pages. A Time value’s precision is in milliseconds. A Date/Time value’s precision is in seconds. You can use operations like addition and subtraction on Date, Date/Time, and TIme values to calculate a future date or elapsed time between two dates or times. If you subtract one date from another, for example, the resulting value will be the difference between the two initial values in days (Number data type). The same operation between two Date/Time values returns a decimal value indicating the difference in number of days, hours, and minutes. The same operation between two Time values returns millisecond For example, if the difference between two Date/Time values is 5.52, that means the two values are separated by five days, 12 hours (0.5 of a day), and 28 minutes (0.02 of a day). You can also add numeric values to Dates and Date/Times. For example, the operation TODAY() + 3 returns three days after today’s date. For more information and examples of working with dates, see the list of Sample Date Formulas. Throughout the examples, the variables date and date/time are used in place of actual Date and Date/Time fields or values. Keep in mind that complex date functions tend to compile to a larger size than text or number formula functions, so you might run into issues with formula compile size. See Tips for Reducing Formula Size for help with this problem. TODAY(), NOW() and TIMENOW() The TODAY() function returns the current day, month, and year as a Date data type. This function is useful for formulas where you are concerned with how many days have passed since a previous date, the date of a certain number of days in the future, or if you just want to display the current date. The NOW() function returns the Date/Time value of the current moment. It’s useful when you are concerned with specific times of day as well as the date. The TIMENOW() function returns a value in GMT representing the current time without the date. Use this function instead of the NOW() function if you want the current hour, minute, seconds, or milliseconds. This value is useful for tracking time like work shifts or elapsed time, For details on how to convert between Date values and Date/Time values, see Converting Between Date/Time and Date. The DATE() Function The DATE() function returns a Date value, given a year, month, and day. Numerical Y/M/D values and the YEAR(), MONTH(), and DAY() functions are valid parameters for DATE(). For example DATE( 2013, 6, 1 ) returns June 1, 2013. Similarly, DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 3, 1) returns the Date value of the first day three months from today in the current year, assuming the date is valid (for example, the month falls between 1 and 12). If the inputted Y/M/D values result in an invalid date, the DATE() function returns an error, so error checking is an important part of working with Date values. You can read about methods for handling invalid dates in Sample Date Formulas. 413 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Converting Between Date/Time and Date Date and Date/Time aren’t interchangeable data types, so when you want to perform operations between Date and Date/Time values, you need to convert the values so they are both the same type. Some functions (such as YEAR(), MONTH(), and DAY()) also only work on Date values, so Date/Time values must be converted first. Use the DATEVALUE( date/time ) function to return the Date value of a Date/Time. For example, to get the year from a Date/Time, use YEAR( DATEVALUE( date/time ) ) ). You can convert a Date value to a Date/Time using the DATETIMEVALUE( date ) function. The time will be set to 12:00 a.m. in Greenwich Mean Time (GMT), and then converted to the time zone of the user viewing the record when it’s displayed. For a user located in San Francisco, DATETIMEVALUE( TODAY() ) returns 5:00 p.m. on the previous day (during Daylight Saving Time) rather than 12:00 a.m. of the current day. See A Note About Date/Time and Time Zones for more information. Converting Between Date/Time and Time The TIMEVALUE() function returns a Time data type value in “HH:MM:SS.MS” (hours:minutes:seconds.milliseconds) format using a 24-hour clock. Numerical H/M/S/MS values and the HOUR(), MINUTE(), SECONDS(), and MILLISECONDS() functions are valid parameters for TIMEVALUE(). Use the TIMEVALUE(value) function to return the Time value of a Date/Time type, text, merge field or expression. For example, extract the time from a ClosedDate Date/Time value with TIMEVALUE(ClosedDate). Converting Between Date and Text If you want to include a date as part of a string, wrap the Date value in the TEXT() function to convert it to text. For example, if you want to return today’s date as text, use: "Today's date is " & TEXT( TODAY() ) This returns the date in the format “YYYY-MM-DD” rather than in the locale-dependent format. You can change the format by extracting the day, month, and year from the date first and then recombining them in the format you want. For example: "Today's date is " & TEXT( MONTH( date ) ) & "/" & TEXT( DAY( date ) ) & "/" & TEXT( YEAR( date ) ) ) You can also convert text to a Date so you can use the string value with your other Date fields and formulas. You’ll want your text to be formatted as “YYYY-MM-DD”. Use this formula to return the Date value: DATEVALUE( "YYYY-MM-DD" ) Converting Between Date/Time and Text You can include Date/Time values in a string using the TEXT() function, but you need to be careful of time zones. For example, consider this formula: "The current date and time is " & TEXT( NOW() ) In this formula, NOW() is offset to GMT. Normally, NOW() would be converted to the user’s time zone when viewed, but because it’s been converted to text, the conversion won’t happen. So if you execute this formula on August 1st at 5:00 PM in San Francisco time (GMT-7), the result is “The current date and time is 2013–08–02 00:00:00Z”. 414 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas When you convert a Date/Time to text, a “Z” is included at the end to indicate GMT. TEXT( date/time ) returns “Z” if the field is blank. So if the Date/Time value you’re working with might be blank, check for this before converting to text: IF( ISBLANK( date/time ), "", TEXT( date/time ) ) To convert a string to a Date/Time value, use DATETIMEVALUE() passing in a string in the format “YYYY-MM-DD HH:MM:SS”. This method returns the Date/Time value in GMT. Converting Between Time and Text If you want to include time as part of a string, wrap the Time value in the TEXT() function to convert it to text. For example, if you want to return the current time as text, use: "The time is " & TEXT( TIMENOW() ) This function returns the time in the format “HH:MM:SS.MS”. You can also convert text to a Time data type so you can use the string value with your other Time fields and formulas. Format your text as “HH:MM:SS.MS” on a 24-hour clock. Use the TIMEVALUE() function: TIMEVALUE("17:30:45.125") A Note About Date/Time and Time Zones Date and Date/Time values are stored in GMT. When a record is saved, field values are adjusted from the user’s time zone to GMT, and then adjusted back to the viewer’s time zone when displayed in record detail pages and reports. With Date conversions this doesn't pose a problem, since converting a Date/Time to a Date results in the same Date value. When working with Date/Time fields and values, however, the conversion is always done in GMT, not the user’s time zone. Subtracting a standard Date/Time field from another isn’t a problem because both fields are in the same time zone. When one of the values in the calculation is a conversion from a Text or Date value to a Date/Time value, however, the results are different. Let’s say a San Francisco user enters a value of 12:00 AM on August 2, 2013 in a custom Date/Time field called Date_Time_c. This value is stored as 2013–08–02 07:00:00Z, because the time difference in Pacific Daylight Time is GMT-7. At 12:00 p.m. PDT on August 1st, the user views the record and the following formula is run: Date_Time_c - NOW() In the calculation, NOW() is 2013–08–01 19:00:00Z, and then subtracted from 2013–08–02 07:00:00Z, to return the expected result of 0.5 (12 hours). Suppose that instead of NOW(), the formula converts the string “2013–08–01 12:00:00” to a Date/Time value: Date_Time_c - DATETIMEVALUE( "2013-08-01 12:00:00" ) In this case, DATETIMEVALUE( “2013–08–01 12:00:00” ) is 2013–08–01 12:00:00Z, and returns a result of 0.79167, or 19 hours. There’s no way to determine a user’s time zone in a formula. If all of your users are in the same time zone, you can adjust the time zone difference by adding or subtracting the time difference between the users’ time zone and GMT to your converted values. However, since 415 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas time zones can be affected by Daylight Saving Time, and the start and end dates for DST are different each year, this is difficult to manage in a formula. We recommend using Apex for transactions that require converting between Date/Time values and Text or Date values. SEE ALSO: Tips for Building Formulas Time Custom Field Build a Formula Field Your custom formula fields require special attributes. EDITIONS Note: The Getting Started with Formulas (Salesforce Classic) help video includes a live demo of these steps. Available in: both Salesforce Classic (not available in all 1. Begin building a formula field the same way you create a custom field. See Create Custom Fields orgs) and Lightning on page 218. Experience 2. Select the data type for the formula. Choose the appropriate data type for your formula based Available in: All Editions on the output of your calculation. See Formula Data Types on page 353. 3. Choose the number of decimal places for currency, number, or percent data types. This setting USER PERMISSIONS is ignored for currency fields in multicurrency organizations. Instead, the Decimal Places for your currency setting apply. Salesforce uses the round half up tie-breaking rule for numbers To view formula field details: in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35. • View Setup and 4. Click Next. Configuration 5. Build your formula. Formula fields can contain up to 3,900 characters, including spaces, return To create, change, or delete formula fields: characters, and comments. If your formula requires more characters, create separate formula • Customize Application fields and reference them in another formula field. The maximum number of displayed characters after an evaluation of a formula expression is 1,300 a. If you are building a formula in the Advanced Formula tab or for approvals or rules, such as workflow, validation, assignment, auto-response, or escalation, click Insert Field, choose a field, and click Insert. To create a basic formula that passes specific Salesforce data, select the Simple Formula tab, choose the field type in the Select Field Type drop-down list, and choose one of the fields listed in the Insert Field drop-down list. Build cross-object formulas to span to related objects and reference merge fields on those objects. b. To insert an operator, choose the appropriate operator icon from the Insert Operator drop-down list. c. Optionally, click the Advanced Formula tab to use functions and view other operators and merge fields. Functions are prebuilt formulas that you can customize with your input parameters. d. To insert a function, double-click its name in the list, or select it and click Insert Selected Function. To filter the list of functions, choose a category from the Functions drop-down list. Select a function and click Help on this function to view a description and examples of formulas using that function. e. Consider adding comments to your formula, especially if it is complicated. Comments must begin with a forward slash followed by an asterisk (/*), and conclude with an asterisk followed by a forward slash (*/). Comments are useful for explaining specific parts of a formula to anyone viewing the formula definition. For example: AND( /*competitor field is required, check to see if field is empty */ LEN(Competitor__c) = 0, /* rule only enforced for ABCD record types */ RecordType.Name = "ABCD Value", 416 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas /* checking for any closed status, allows for additional closed picklist values in the future */ CONTAINS(TEXT(StageName), "Closed") ) 6. To check your formula for errors, click Check Syntax. 7. Optionally, enter a description of the formula in the Description box. 8. If your formula references any number, currency, or percent fields, choose an option for handling blank fields. To give any blank fields a zero value, choose Treat blank fields as zeros. To leave these fields blank, choose Treat blank fields as blanks. 9. Click Next. 10. Set the field-level security to determine whether the field should be visible for specific profiles, and click Next. 11. Choose the page layouts that should display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is automatically added to the bottom of the user detail page. 12. Click Save to finish or Save & New to create more custom fields. Note: Because formula fields are automatically calculated, they are read-only on record detail pages and do not update last modified date fields. Formula fields are not visible on edit pages. In account formulas, all business account fields are available as merge fields. However, account fields exclusive to person accounts such as Birthdate and Email are not available. Tips for Building Formulas What Is a Cross-Object Formula? SEE ALSO: Elements of a Formula Merge Fields for Formulas Tips for Building Formulas Formula Operators and Functions Tips for Building Formulas Watch a Demo: Formulas: Tips and Gotchas (Salesforce Classic) EDITIONS • Formula fields that a user can see may reference fields that are hidden or read only using field-level security. If the formula field contains sensitive information, use field-level security to Available in: both Salesforce hide it. Classic and Lightning Experience • You can add activity formula fields to task and event page layouts. Note that a task-related formula field on an event page layout may not be useful. Likewise, event-related formula fields Available in: All Editions on task page layouts may not be useful. • To determine if a record is a task or event, use the IsTask merge field. For example: IF(IsTask, "This is a task", "This is an event") 417 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Tips for Working with Date and Date/Time Formula Fields Tips for Working with Hyperlink Formula Fields Use these tips to understand how links open from formula custom fields that contain a HYPERLINK function. Tips for Using Merge Fields in Formulas Tips for Working with Number Formula Fields Tips for Working with Picklist and Multi-Select Picklist Formula Fields Tips for Referencing Record Types in Formulas Reference record types in formulas if you want different workflow rules, validation rules, and lookup filters to apply to different record types. Tips for Working with Text Formula Fields SEE ALSO: Build a Formula Field Common Formula Errors Tips for Working with Date and Date/Time Formula Fields • Dates and times are always calculated using the user’s time zone. EDITIONS • Date and date/time fields can’t be used interchangeably. The name alone may not indicate if a field is a date or date/time. For example, Created Date and Last Modified Date Available in: both Salesforce are date/time fields whereas Last Activity Date is a date field. Use the DATEVALUE Classic and Lightning function to convert a date/time field into a date field. Experience Note: The Created Date and Last Modified Date fields display only the Available in: All Editions date, not the date and time. • Use addition and subtraction operators with date or date/time fields to calculate duration. For example, subtract a date from another date to calculate the number of days between the two. Likewise, you can subtract the date/time from another date/time to get the number of days between the two as a number. See NOW or TODAY for suggested use. • Use addition and subtraction operators with numbers to return another date or date/time. For example, {!CreatedDate} + 5 calculates the date and time five days after a record’s created date. Note that the expression returns the same data type as the one given; a date field plus or minus a number returns a date, and a date/time field plus or minus a number returns a date/time. • When calculating dates using fractions, Salesforce ignores any numbers beyond the decimal. For example: TODAY() + 0.7 is the same as TODAY() + 0, which is today’s date. TODAY() + 1.7 is the same asTODAY() + 1, which is tomorrow’s date. TODAY() + (-1.8) is the same as TODAY() + (-1), which is yesterday’s date. • To calculate the value of two fractions first, group them within parentheses. For example: TODAY() + 0.5 + 0.5 is the same as TODAY() + 0 + 0, which is today’s date. TODAY() + (0.5+0.5) is the same as TODAY() + 1, which is tomorrow’s date. • Years can’t be zero and must be between -4713 and 9999. SEE ALSO: Tips for Building Formulas 418 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Tips for Working with Hyperlink Formula Fields Use these tips to understand how links open from formula custom fields that contain a HYPERLINK EDITIONS function. If you have formula custom fields that contain a HYPERLINK function, the server generates an Available in: both Salesforce HTML anchor for the link. For example, this function: HYPERLINK("/apex/VF_TEST", Classic and Lightning "VFLINK",'_self') generates this HTML output: VFLINK HYPERLINK . If the function doesn't contain a target Available in: All Editions attribute, it defaults to a value of target="_blank" in the generated HTML. A value of "_blank" opens the link in a new window or tab, outside of Lightning Experience or the Lightning Console. Note: The HYPERLINK function doesn’t support the biztel protocol on record home pages for custom objects in Lightning Experience. The Lightning Experience Honors Target Values for Hyperlinks in Formula Fields critical update ensures that the target value for hyperlinks is honored, whether it's explicitly configured or set by default. If you have enabled the critical update, you can keep the target page within Lightning navigation by adding a value of target="_self" to your formula field HYPERLINK functions. If you specify something other than target="_self", the link opens with standard browser navigation outside of Lightning Experience. If you haven’t enabled the critical update, relative links open in a new tab regardless of the target value. Note: This critical update is automatically enabled in Summer ’20. Both before and after enabling the critical update, external links always open in a new tab, regardless of the target value. Link Type Target Expected Behavior Example Relative Visualforce page or _self The Visualforce page or image HYPERLINK("/apex/VFPAGE", image opens in Lightning Experience "Visualforce Page", or Console inside the same tab. "_self") Relative Visualforce page or _blank The Visualforce page or image HYPERLINK("/img/logo214", image opens outside of Lightning "Logo", "_blank") Experience or Console in a new tab. Note: A critical update that is available in Winter ’19 and automatically enabled in Summer ’19 on May 17, 2019 controls this behavior. If you don’t enable the critical update, these links open inside Lightning Experience or Console in a new tab. External website _self The website opens in a new tab. HYPERLINK("http://salesforce.com", "Salesforce", "_self") 419 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Link Type Target Expected Behavior Example External website _blank The website opens in a new tab. HYPERLINK("http://salesforce.com", "Salesforce", "_blank") Tips for Using Merge Fields in Formulas • Delegated administrators need to have access to custom objects to access the objects’ merge EDITIONS fields from formulas. • In account formulas, all business account fields are available as merge fields. However, account Available in: both Salesforce fields exclusive to person accounts such as Birthdate and Email are not available. Classic and Lightning • You can’t use formula fields that include related object merge fields in roll-up summary fields. Experience • Formulas and roll-up summary fields can’t reference fields on external objects. Available in: All Editions • Using RecordType.Id can make your formula less readable; when you do use it, write in-line comments into the formula to clarify. • To determine if a record is a task or event, use the IsTask merge field. For example: IF(IsTask, "This is a task", "This is an event") • To reference the unique identifier for your Salesforce organization in a formula, insert the $Organization.Id merge field. This merge field can display anywhere formula fields can except in reports. • Some merge fields display as radio buttons but function like picklist fields when referenced in a formula. Use the values “Read,” “Edit,” and “None” in a formula when referencing: – $UserRole.CaseAccessForAccountOwner – $UserRole.OpportunityAccessForAccountOwner – CaseAccessLevel (on Territory) – OpportunityAccessLevel (on Territory) Use the values “Read,” “Edit,” and “All” in a formula when referencing: – AccountAccessLevel (on Territory) • If you create a contacts formula field that references account merge fields, that field can be included in contact page layouts but should not be included in person accounts page layouts. The formula field will display a value of #Error on the person accounts page. SEE ALSO: Tips for Building Formulas 420 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Tips for Working with Number Formula Fields • Use the decimal version of a percent when working with percent fields in formulas. For example, EDITIONS IF(Probability =1...) for 100% probability or IF(Probability =0.9...) for 90% probability. Available in: both Salesforce • Reference auto-number fields as text fields in formulas. Classic and Lightning • The output of your formula must be less than 19 digits. Experience • Formulas can contain a mix of numbers, percents, and currencies as in this example: Available in: All Editions AnnualRevenue / NumberOfEmployees. • Salesforce uses the round half up tie-breaking rule for numbers in formula fields. For example, 12.345 becomes 12.35 and −12.345 becomes −12.35. SEE ALSO: Tips for Building Formulas Tips for Working with Picklist and Multi-Select Picklist Formula Fields • You can use special picklist fields in your formulas, such as IsEscalated for cases and EDITIONS IsWon for opportunities. • Picklist fields can only be used in these functions: Available in: both Lightning – ISPICKVAL—Compares the value of a picklist to a single value. Experience and Salesforce Classic – CASE—Compares the value of a picklist to multiple values. – TEXT—Returns a picklist value’s API Name so that you can work with a reference to the Available in: All Editions value (even if the displayed value changes) in functions that support text values, such as CONTAINS. (Available in only flow formula resources, formula fields, validation rules, and workflow field updates.) • Multi-select picklist fields can only be used in these functions: – CONTAINS (in Process Builder in which the criteria for executing actions is set to Conditions are met) – INCLUDES – ISBLANK – ISNULL – ISCHANGED (Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited) – PRIORVALUE (Only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited) SEE ALSO: Tips for Building Formulas 421 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Tips for Referencing Record Types in Formulas Reference record types in formulas if you want different workflow rules, validation rules, and lookup EDITIONS filters to apply to different record types. For example, you can: Available in: both Salesforce Classic and Lightning • Create a workflow rule on accounts that emails different teams based on the account record Experience type the user selects when creating the account. • Create a validation rule on opportunities that allows only members of the North American sales Available in: All Editions team to save opportunities with the Domestic record type. Record types available in: When possible, use RecordTypeId instead of RecordType.Name to reference a specific Professional, Enterprise, record type. While RecordType.Name makes a formula more readable, you must update the Performance, Unlimited, formula if the name of the record type changes, whereas the ID of a record type never changes. and Developer Editions Also, RecordType.Name requires a cross-object reference to the record type, while RecordTypeId doesn’t. However, if you are deploying formulas across organizations (for example, between sandbox and production), use RecordType.Name because IDs are not the same across organizations. Avoid using $RecordType in formulas, except in default value formulas. Instead, use the RecordType merge field (for example, Account.RecordType.Name) or the RecordTypeId field on the object. SEE ALSO: Tips for Building Formulas Tips for Working with Text Formula Fields • Before using the HYPERLINK function, consider the differences between hyperlinks and custom EDITIONS links. – Hyperlink formula fields are just like other custom fields that you can show in list views and Available in: both Salesforce reports. Classic and Lightning – Custom links appear on detail pages in a predefined section; hyperlink formula fields can Experience appear on a detail page wherever you specify. Available in: All Editions – Using custom links, you can specify display properties such as window position and opening in a separate popup position; hyperlink formula fields open in a new browser window by default or you can specify a different target window or frame. – Your formulas can reference custom links. Before deleting a custom link, make sure that it’s not referenced in a formula field. – Hyperlink formula fields that contain relative URLs to Salesforce pages, such as /rpt/reportwizard.jsp, can be added to list views, reports, and related lists. However, use a complete URL, including the server name and https://, in your hyperlink formula before adding it to a search layout. • To insert text in your formula field, surround the text with quotation marks. For example, to display “CASE: 123,” use this formula "CASE: "& CaseNumber__c. • Use the backslash (\) character before a quote or backslash to insert it as a literal value in your output. For example, "Trouble\\Case \"Ticket\": " in your formula displays Trouble\Case "Ticket": on detail pages. • In Salesforce Classic, Knowledge articles show URLs from Formula (Text) fields as plain text. In Lightning Experience, Knowledge articles show such URLs as clickable links. SEE ALSO: Tips for Building Formulas 422 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas What Is a Cross-Object Formula? A Cross-object formula is a formula that spans two related objects and references merge fields on EDITIONS those objects. A cross-object formula can reference merge fields from a master (“parent”) object if an object is on the detail side of a master-detail relationship. A cross-object formula also works with Available in: both Salesforce lookup relationships. Classic and Lightning You can reference fields from objects that are up to 10 relationships away. A cross-object formula Experience is available anywhere formulas are used except when creating default values. Available in: all editions Note: If you create a formula that references a field on another object and display that formula in your page layout, users can see the field on the object even if they don’t have access to that object record. For example, if you create a formula field on the Case object that references an account field, and display that formula field in the case page layout, users can see this field even if they don’t have access to the account record. You can't include an object as the lookup field in a formula. To reference an object, reference the object's ID field or another field on the object. For example, Account.Owner is invalid because it references the object directly. Account.Owner.FirstName or Account.OwnerId are valid references for your formula. Building Cross-Object Formulas in the Simple Formula Tab Build Cross-Object Formulas in the Advanced Formula Tab Tips for Building Cross-Object Formulas SEE ALSO: Build a Formula Field Building Cross-Object Formulas in the Simple Formula Tab To create a cross-object formula when building a formula in the Simple Formula tab, enter the EDITIONS relationship names of the objects to which you are spanning followed by the field you want to reference. Separate the relationship names of each object and the field with periods. Available in: both Salesforce Example: For example, enter Contact.Account.Name to reference the Account Classic and Lightning Name for a contact associated with a case in a formula field on the Case object. Be sure to Experience use the relationship names of the objects, not the labels. Although the relationship name is Available in: All Editions often the same as the object name, it is technically the field name of the relationship field. To reference the parent account name from Account object, the syntax is Parent.Name, USER PERMISSIONS not Account.Name. When referencing a custom object, add two underscores and the letter r to its name. For example, Position__r.title__c references the Job Title To create or change field (title__c) on a Position custom object. cross-object formulas: • Customize Application Note: If you create a formula that references a field on another object and display that formula in your page layout, users can see the field on the object even if they don’t have access to that object record. For example, if you create a formula field on the Case 423 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas object that references an account field, and display that formula field in the case page layout, users can see this field even if they don’t have access to the account record. SEE ALSO: Build Cross-Object Formulas in the Advanced Formula Tab What Is a Cross-Object Formula? Build Cross-Object Formulas in the Advanced Formula Tab To create a cross-object formula when building a formula in the Advanced Formula tab or for EDITIONS approvals or rules, such as workflow, validation, assignment, auto-response, or escalation rules, click Insert Field, then click the related object to list its fields. Related objects are denoted by a “>” sign. Available in: both Salesforce Note: If you create a formula that references a field on another object and display that Classic and Lightning formula in your page layout, users can see the field on the object even if they don’t have Experience access to that object record. For example, if you create a formula field on the Case object that Available in: All Editions references an account field, and display that formula field in the case page layout, users can see this field even if they don’t have access to the account record. USER PERMISSIONS Example: The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile To create or change cross-object formulas: name, as expected. In list views and reports, the value is the internal value of the associated • Customize Application profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example: IF (OR (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name = "PT2"), "Standard", "Not Standard") None of the above applies to profile names referenced by the $Profile global variable. SEE ALSO: Building Cross-Object Formulas in the Simple Formula Tab What Is a Cross-Object Formula? Tips for Building Cross-Object Formulas • Cross-object formulas that reference currency fields convert the value to the currency of the EDITIONS record that contains the formula. If the referenced currency field is from a custom setting, the field value isn’t converted to the record’s currency. Available in: both Salesforce • Salesforce allows a maximum of 10 unique relationships per object in cross-object formulas. Classic and Lightning The limit is cumulative across all formula fields, rules, and lookup filters. For example, if two Experience different formulas on opportunities reference two different fields of an associated account, only Available in: All Editions one unique relationship exists (from opportunities to accounts). • You can’t reference cross-object formulas in roll-up summary fields. 424 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas • In cross-object formulas, you can’t reference merge fields for objects related to activities. For example, merge fields for contacts and accounts aren’t available in task and event formulas. • In cross-object formulas, you can’t reference fields from contacts through person accounts. For more information, see Using custom formula fields with person accounts. Using the Owner Field Some objects support different object types for the Owner field, such as a User, Queue, or Calendar. On objects that support this behavior, when creating a cross-object formula using Owner, you must be explicit about the owner type you’re referencing. For example, if you need owner email and you don’t use queues, your formula would be Owner:User.Email. If you do use queues, your formula could be IF( ISBLANK( Owner:User.Id ), Owner:Queue.QueueEmail, Owner:User.Email ) Here’s how you would select Owner object fields on a Lead in the Advanced formula tab: Note: • Owner references aren’t supported in Visualforce pages. For example, on a page with Case as a controller, you can’t include {!Case.Owner:User.FirstName}. However, you can include an existing spanning formula on a Visualforce page. For example, if you have a custom text formula MyFormula__c on a Case with value Owner:User.FirstName, you can include {!Case.MyFormula__c} on your Visualforce page. • Owner references aren’t supported on the Queue object. For example, you can't reference Owner:Queue.Owner.Email. • If your formula has Owner:User.fieldname and Owner:Queue.fieldname, both of these count against the limit of 10 unique relationships per object in cross-object formulas. • On objects that don’t support Queues, User is implicit when referencing Owner. Your formula should be Owner.fieldname, not Owner:User.fieldname. Using Profile.Name The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile name, as expected. In list views and reports, the value is the internal value of the associated profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example: IF (OR (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name = 425 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas "PT2"), "Standard", "Not Standard") None of the above applies to profile names referenced by the $Profile global variable. SEE ALSO: Build Cross-Object Formulas in the Advanced Formula Tab What Is a Cross-Object Formula? Formula Field Limits and Restrictions Before you create formula fields, be aware of their limits and limitations. EDITIONS • Formula fields have these limits. – Character limit—Formula fields can contain up to 3,900 characters, including spaces, return Available in: both Salesforce Classic and Lightning characters, and comments. If your formula needs more characters, create separate formula Experience fields and reference them in another formula field. Available in: All Editions Note: The maximum number of displayed characters after an evaluation of a formula expression is 1,300. – Save size limit—Formula fields can’t exceed 4,000 bytes when saved. The save size is different from the number of characters if you use multi-byte characters in your formula. – Compile size limit—Formula fields can’t exceed 5,000 bytes when compiled. The compile size is the size of the formula (in bytes) including all of the fields, values, and formulas it references. There is no direct correlation between the compile size and the character limit. Some functions, such as TEXT, DATEVALUE, DATETIMEVALUE, and DATE significantly increase the compile size. Tip: For tips on how to rework your formulas to avoid these limits, see Tips for Reducing Formula Size • Default value formulas for a record type can only reference fields for that record type. However, formula fields and formulas for approvals or rules for a record type can reference fields for that record type as well as any records that are related through a lookup or master-detail relationship. For example, a formula for a validation rule on opportunities can reference merge fields for accounts and campaigns as well as opportunities, and a formula field on accounts can reference fields for cases. • You can’t use long text area, encrypted, or Description fields in formulas. • The value of a field can’t depend on another formula that references it. • You can’t delete fields referenced in formulas. Remove the field from the formula before deleting it. • Campaign statistic fields can’t be referenced in formulas for field updates, approval processes, workflow rules, or validation rules, but can be referenced in custom formula fields. • The UI escapes HTML tags used in formula fields. To create an HTML element, replace your HTML with a function, like HYPERLINK or IMAGE. • Custom formula fields from contacts can’t be referenced through person accounts. For more information, see Using custom formula fields with person accounts. SEE ALSO: Tips for Building Formulas Build a Formula Field 426 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Formula Best Practices You can use the Formula Editor in Salesforce to construct a simple formula with a few clicks. But EDITIONS what if you want to build something more complex? Use these tips to help you map out formula logic and make it easier to troubleshoot errors. Available in: both Salesforce Thank you: Special thanks to Trailblazer Chris Emmett for contributing this content. Classic and Lightning Experience Available in: All Editions Tip 1: Put Every Function on a Separate Line It’s easy to fall into the habit of keeping an entire formula on a single line, especially when the formula is small. Putting each function on its own line makes the formula easier to read and troubleshoot. These examples show the same formula, first with no line breaks, and then with each function on a separate line. IF(AND(ISBLANK(myDate_c),active_c=true),"Missing Date","Not Applicable") IF( AND( ISBLANK(myDate_c), active_c=true ), "Missing Date", "Not Applicable" ) Tip 2: Indent Sections Within Parentheses When your formula involves multiple functions, indentation helps visually isolate each function and makes it easier to identify errors, such as misplaced characters. In this example, with indentation, you see that the bulk of the formula sits within a single IF statement and that the AND statement contains two functions. Inside the AND statement, the function ISBLANK is enclosed in parentheses. IF( AND( ISBLANK(myDate_c), active_c=true ), "Missing Date", "Not Applicable" ) Indentation can also help you zero in on mistakes. With a flat layout, it’s difficult to see that an extra “)” is included after the ISBLANK statement, and there are no visual clues about how the formula is structured. IF( AND( ISBLANK(myDate_c) ), active_c=true ), "Missing Date", "Not Applicable" ) 427 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas The indented layout makes it easy see the formula’s structure. You can quickly find and remove the extra character so that the AND statement is correctly formatted. IF( AND( ISBLANK(myDate_c) ), active_c=true ), "Missing Date", "Not Applicable" ) Tip 3: Write Statement and Function Names in Uppercase All the examples here use uppercase letters for statement and function names, such as IF, AND, and ISBLANK. Using uppercase for these terms creates a clear distinction between functions and parameters and brings some visual clarity to a complex formula. Tip 4: Handle Null and Required Input Field Values These examples reference a field called myDate__c and use the ISBLANK check to confirm that the field is populated. It’s important to verify the contents of any field in a formula. Without this verification, a formula can fail. For example, if you add a second date to the formula and perform a greater than operation, include the ISBLANK check for the second date to ensure that the formula executes correctly. IF( AND( ISBLANK(myDate__c), ISBLANK(mySecondDate__c), active__c=true, mySecondDate__c > myDate__c ), "Missing Date", "Not Applicable" ) 428 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Examples of Advanced Formula Fields Review examples of formula fields for various types of apps that you can use and modify for your EDITIONS own purposes. This document contains custom formula samples for the following topics. For details about using Available in: both Salesforce the functions included in these samples, see Formula Operators and Functions on page 355. Classic and Lightning Experience Sample Account Management Formulas Available in: All Editions Sample Account Media Service Formulas Sample Case Management Formulas USER PERMISSIONS Sample Commission Calculations Formulas To view formula field details: Sample Contact Management Formulas • View Setup and Configuration Sample Data Categorization Formulas To create, change, or delete Sample Date Formulas formula fields: Sample Discounting Formulas • Customize Application Sample Employee Services Formulas Sample Expense Tracking Formulas Sample Financial Calculations Formulas Sample Image Link Formulas Sample Integration Link Formulas Sample Lead Management Formulas Sample Metric Formulas Sample Opportunity Management Formulas Sample Pricing Formulas Sample Scoring Calculations Formulas SEE ALSO: Formulas: How Do I ... ? Tips for Building Formulas Sample Account Management Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Classic and Lightning Experience Available in: All Editions 429 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Account Rating This formula evaluates Annual Revenue, Billing Country, and Type, and assigns a value of “Hot,” “Warm,” or “Cold.” IF (AND (AnnualRevenue > 10000000, CONTAINS (CASE (BillingCountry, "United States", "US", "America", "US", "USA", "US", "NA"), "US")), IF(ISPICKVAL(Type, "Manufacturing Partner"), "Hot", IF(OR (ISPICKVAL (Type, "Channel Partner/Reseller"), ISPICKVAL(Type, "Installation Partner")), "Warm", "Cold")), "Cold") In addition, you can reference this Account Rating formula field from the contact object using cross-object formulas. Account.Account_Rating__c Account Region This formula returns a text value of “North,” “South,” “East,” “West,” or “Central” based on the Billing State/Province of the account. IF(ISBLANK(BillingState), "None", IF(CONTAINS("AK:AZ:CA:HA:NV:NM:OR:UT:WA", BillingState), "West", IF(CONTAINS("CO:ID:MT:KS:OK:TX:WY", BillingState), "Central", IF(CONTAINS("CT:ME:MA:NH:NY:PA:RI:VT", BillingState), "East", IF(CONTAINS("AL:AR:DC:DE:FL:GA:KY:LA:MD:MS:NC:NJ:SC:TN:VA:WV", BillingState), "South", IF(CONTAINS("IL:IN:IA:MI:MN:MO:NE:ND:OH:SD:WI", BillingState), "North", "Other")))))) Contract Aging This formula calculates the number of days since a contract with an account was activated. If the contract Status is not “Activated,” this field is blank. IF(ISPICKVAL(Contract_Status__c, "Activated"), NOW() - Contract_Activated_Date__c, null) Sample Account Media Service Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce BBC™ News Search Classic and Lightning Experience This formula creates a link to a BBC news search site based on the Account Name. Available in: All Editions HYPERLINK( "http://www.bbc.co.uk/search/news/?q="&Name, "BBC News") 430 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Bloomberg™ News Search This formula creates a link to an account's ticker symbol on the Bloomberg website. HYPERLINK( "http://www.bloomberg.com/markets/symbolsearch?query="&TickerSymbol, "Bloomberg News") CNN™ News Search This formula creates a link to a CNN news search site using the Account Name. HYPERLINK( "http://http://www.cnn.com/search/?query="&Name, "CNN News") MarketWatch™ Search This formula creates a link to an account's ticker symbol on the Marketwatch.com website. HYPERLINK( "http://www.marketwatch.com/investing/stock/"&TickerSymbol, "Marketwatch") Google™ Search This formula creates a link to a Google search site using the Account Name. HYPERLINK( "http://www.google.com/#q="&Name, "Google") Google News Search This formula creates a link to a Google news search site using the Account Name. HYPERLINK( "http://news.google.com/news/search?en&q="&Name, "Google News") Yahoo!™ Search This formula creates a link to a Yahoo! search site using the Account Name. HYPERLINK( "http://search.yahoo.com/search?p="&Name, "Yahoo Search") 431 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Yahoo! News Search This formula creates a link to a Yahoo! news search site using the Account Name. HYPERLINK( "http://news.search.yahoo.com/search/news?p="&Name, "Yahoo News") Sample Case Management Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: Salesforce Autodial Classic This formula creates a linkable phone number field that automatically dials the phone number Available in: All Editions when clicked. In this example, replace "servername" and "call" with the name of your dialing tool and the command it uses to dial. The merge field, Id, inserts the identifier for the contact, lead, or account record. The first Phone merge field tells the dialing tool what number to call and the last Phone merge field uses the value of the Phone field as the linkable text the user clicks to dial. HYPERLINK("http://servername/call?id=" & Id & "&phone=" & Phone, Phone) Case Categorization This formula displays a text value of “RED,” “YELLOW,” or “GREEN,” depending on the value of a case age custom text field. IF(DaysOpen__c > 20, "RED", IF(DaysOpen__c > 10, "YELLOW", "GREEN") ) Case Data Completeness Tracking This formula calculates the percentage of specific custom fields that contain data. The formula checks the values of two custom number fields: Problem Num and Severity Num. If the fields are empty, the formula returns the value “0.” The formula returns a value of “1” for each field that contains a value and multiplies this total by fifty to give you the percentage of fields that contain data. (IF(ISBLANK(Problem_Num__c), 0, 1) + IF(ISBLANK(Severity_Num__c ), 0,1)) * 50 Suggested Agent Prompts This formula prompts an agent with cross-sell offers based on past purchases. CASE(Product_Purch__c, "Printer", "Extra toner cartridges", "Camera", "Memory cards", "Special of the day") 432 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Suggested Offers This formula suggests a product based on the support history for a computer reseller. When the Problem custom field matches a field, the formula field returns a suggestion. CASE(Problem__c, "Memory", "Suggest new memory cards", "Hard Drive failure", "Suggest new hard drive with tape backup", "") Sample Commission Calculations Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Commission Amounts for Opportunities Classic and Lightning Experience The following is a simple formula where commission is based on a flat 2% of the opportunity Amount. Available in: All Editions IF(ISPICKVAL(StageName, "Closed Won"), ROUND(Amount *0.02, 2), 0) This example calculates the commission amount for any opportunity that has a “Closed Won” stage. The value of this field will be the amount times 0.02 for any closed/won opportunity. Open or lost opportunities will have a zero commission value. Commission Deal Size This formula calculates a commission rate based on deal size, returning a 9% commission rate for deals over 100,000 and an 8% commission rate for smaller deals. IF(Amount > 100000, 0.09, 0.08 ) Commission Greater Than or Equal To This formula assigns the YES value with a commission greater than or equal to one million. Note, this is a text formula field that uses a custom currency field called Commission. IF(Commission__c >= 1000000, "YES", "NO") Commission Maximum This formula determines what commission to log for an asset based on which is greater: the user's commission percentage of the price, the price times the discount percent stored for the account or 100 dollars. This example assumes you have two custom percent fields on users and assets. MAX($User.Commission_Percent__c * Price, Price * Account_Discount__c, 100) 433 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Sample Contact Management Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Contact's Account Discount Percent Classic and Lightning Experience This percent formula displays the account's Discount Percent field on the contacts page. Available in: All Editions Account.Discount_Percent__c Contact's Account Name This formula displays the standard Account Name field on the contacts page. Account.Name Contact's Account Phone This formula displays the standard Account Phone field on the contacts page. Account.Phone Contact's Account Rating Use this formula to display the Account Rating field on the contacts page. CASE(Account.Rating, "Hot", "Hot", "Warm", "Warm", "Cold", "Cold", "Not Rated") Contact's Account Website This formula displays the standard Account Website field on the contacts page. Account.Website If the account website URL is long, use the HYPERLINK function to display a label such as “Click Here” instead of the URL. For example: IF(Account.Website="", "", IF( OR(LEFT(Account.Website, 7) = "http://",LEFT(Account.Website, 8) = "https://"), HYPERLINK( Account.Website , "Click Here" ), HYPERLINK( "http://" & Account.Website , "Click Here" ) ) ) This formula also adds the necessary "http://" or "https://" before a URL if neither were included in the URL field. Contact's LinkedIn™ Profile You can configure a link that appears on your contacts' profile page that sends you to their LinkedIn profile. To do so: 1. From the object management settings for contacts, go to Buttons, Links, and Actions. 434 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas 2. Click New Button or Link. 3. Enter a Label for this link, like LinkedInLink. 4. Enter this formula in the content box: http://www.linkedin.com/search/fpsearch?type=people&keywords ={!Contact.FirstName}+{!Contact.LastName} 5. Click Save. Remember to add this link to the Contact page layout in order for it to show up. Contact Identification Numbering This formula displays the first five characters of a name and the last four characters of a social security number separated by a dash. Note that this example uses a text custom field called SSN. TRIM(LEFT(LastName, 5)) & "-" & TRIM(RIGHT(SSN__c, 4)) Contact Preferred Phone This formula displays the contact’s preferred contact method in a contact related list—work phone, home phone, or mobile phone—based on a selected option in a Preferred Phone custom picklist. CASE(Preferred_Phone__c, "Work", "w. " & Phone, "Home", "h. " & HomePhone, "Mobile", "m. " & MobilePhone, "No Preferred Phone") Contact Priority This formula assesses the importance of a contact based on the account rating and the contact's title. If the account rating is Hot or the title starts with Executive, then the priority is high (P1). If the account rating is Warm or the title starts with VP then the priority is medium (P2), and if the account rating is Cold then the priority is low (P3). IF(OR(ISPICKVAL(Account.Rating, "Hot"), CONTAINS(Title, "Executive")), "P1", IF(OR(ISPICKVAL(Account.Rating, "Warm"), CONTAINS(Title, "VP")), "P2", IF(ISPICKVAL(Account.Rating, "Cold"), "P3", "P3") ) ) 435 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Contact Yahoo! ID This formula displays a clickable Yahoo! Messenger icon indicating if the person is logged on to the service. Users can click the icon to launch a Yahoo! Messenger conversation with the person. This example uses a custom text field called Yahoo Name on contacts where you can store the contact's Yahoo! Messenger ID. HYPERLINK("ymsgr:sendIM?" & Yahoo_Name__c, IMAGE("http://opi.yahoo.com/online?u=" & Yahoo_Name__c & "&m;=g&t;=0", "Yahoo")) Dynamic Address Formatting This formula field displays a formatted mailing address for a contact in standard format, including spaces and line breaks where appropriate depending on the country. CASE(ShippingCountry, "USA", ShippingStreet & BR() & ShippingCity & ", " & ShippingState & " " & ShippingPostalCode & BR() & ShippingCountry, "France", ShippingStreet & BR() & ShippingPostalCode & " " & ShippingCity & BR() & ShippingCountry, "etc") Telephone Country Code This formula determines the telephone country code of a contact based on the Mailing Country of the mailing address. CASE(MailingCountry, "USA", "1", "Canada", "1", "France", "33", "UK", "44", "Australia", "61", "Japan", "81", "?") Unformatted Phone Number This formula removes the parentheses and dash characters from North American phone numbers. This is necessary for some auto-dialer software. IF(Country_Code__c = "1", MID( Phone ,2, 3) & MID(Phone,7,3) & MID(Phone,11,4), Phone) 436 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Sample Data Categorization Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Deal Size Large and Small Classic and Lightning Experience This formula displays “Large Deal” for deals over one million dollars or “Small Deal” for deals under one million dollars. Available in: All Editions IF(Sales_Price__c > 1000000, "Large Deal", "Small Deal") Deal Size Small This formula displays Small if the price and quantity are less than one. This field is blank if the asset has a price or quantity greater than one. IF(AND(Price<1,Quantity<1),"Small", null) Product Categorization This formula checks the content of a custom text field named Product_Type and returns Parts for any product with the word “part” in it. Otherwise, it returns Service. Note that the values are case-sensitive, so if a Product_Type field contains the text “Part” or “PART,” this formula returns Services. IF(CONTAINS(Product_Type__c, "part"), "Parts", "Service") Sample Date Formulas EDITIONS Find the Day, Month, or Year from a Date Use the functions DAY( date ), MONTH( date ), and YEAR( date ) to return their Available in: both Salesforce numerical values. Replace date with a value of type Date (for example, TODAY()). Classic and Lightning Experience To use these functions with Date/Time values, first convert them to a date with the DATEVALUE() function. For example, DAY( DATEVALUE( date/time )). Available in: All Editions Find Out If a Year Is a Leap Year This formula determines whether a year is a leap year. A year is only a leap year if it’s divisible by 400, or if it’s divisible by four but not by 100. OR( MOD( YEAR( date ), 400 ) = 0, AND( MOD( YEAR( date ), 4 ) = 0, MOD( YEAR( date ), 100 ) != 0 ) ) 437 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Find Which Quarter a Date Is In For standard quarters, you can determine which quarter a date falls in using this formula. This formula returns the number of the quarter that date falls in (1–4) by dividing the current month by three (the number of months in each quarter) and taking the ceiling. CEILING( MONTH ( date ) / 3 ) The formula for shifted quarters is similar, but shifts the month of the date by the number of months between January and the first quarter of the fiscal year. The following example shows how to find a date’s quarter if Q1 starts in February instead of January. CEILING( ( MONTH ( date ) - 1 ) / 3) ITo check whether a date is in the current quarter, add a check to compare the date’s year and quarter with TODAY()’s year and quarter. AND( CEILING( MONTH( date ) / 3 ) = CEILING( MONTH( TODAY() ) / 3 ), YEAR( date ) = YEAR( TODAY() ) ) Find the Week of the Year a Date Is In To find the number of a date’s week of the year, use this formula: IF( CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7) > 52, 52, CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7) ) To find the current week number, determine the days to date in the current year and divide that value by 7. The IF() statement ensures that the week number the formula returns doesn’t exceed 52. So if the given date is December 31 of the given year, the formula returns 52, even though it’s more than 52 weeks after the first week of January. Find Whether Two Dates Are in the Same Month To determine whether two Dates fall in the same month, say for a validation rule to determine whether an opportunity Close Date is in the current month, use this formula: AND( MONTH( date_1 ) == MONTH( date_2 ), YEAR( date_1 ) == YEAR( date_2 ) ) Find the Last Day of the Month The easiest way to find the last day of a month is to find the first day of the next month and subtract a day. IF( MONTH( date ) = 12, DATE( YEAR( date ), 12, 31 ), DATE( YEAR( date ), MONTH ( date ) + 1, 1 ) - 1 ) 438 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Display the Month as a String Instead of a Number To return the month as a text string instead of a number, use: CASE( MONTH( date ), 1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", 7, "July", 8, "August", 9, "September", 10, "October", 11, "November", "December" ) If your organization uses multiple languages, you can replace the names of the month with a custom label: CASE( MONTH( date ), 1, $Label.Month_of_Year_1, 2, $Label.Month_of_Year_2, 3, $Label.Month_of_Year_3, 4, $Label.Month_of_Year_4, 5, $Label.Month_of_Year_5, 6, $Label.Month_of_Year_6, 7, $Label.Month_of_Year_7, 8, $Label.Month_of_Year_8, 9, $Label.Month_of_Year_9, 10, $Label.Month_of_Year_10, 11, $Label.Month_of_Year_11, $Label.Month_of_Year_12 ) Find and Display the Day of the Week from a Date To find the day of the week from a Date value, use a known Sunday, for example, January 7, 1900, and subtract it from the date, for example, TODAY(), to get the difference in days. The MOD() function finds the remainder of this result when divided by 7 to give the numerical value of the day of the week between 0 (Sunday) and 6 (Saturday). The formula below finds the result and then returns the text name of that day. CASE( MOD( date - DATE( 1900, 1, 7 ), 7 ), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3, "Wednesday", 4, "Thursday", 5, "Friday", "Saturday" ) 439 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas This formula only works for dates after 01/07/1900. If you work with older dates, use the same process with any Sunday before to your earliest date, for example, 01/05/1800. You can adjust this formula if your week starts on a different day. For example, if your week starts on Monday, you can use January 8, 1900 in your condition. The new formula looks like this: CASE( MOD( date - DATE( 1900, 1, 8 ), 7 ), 0, "Monday", 1, "Tuesday", 2, "Wednesday", 3, "Thursday", 4, "Friday", 5, "Saturday", "Sunday" ) Like the formula for getting the name of the month, if your organization uses multiple languages, you can replace the names of the day of the week with a variable like $Label.Day_of_Week_1, and so on. Find the Next Day of the Week After a Date To find the date of the next occurrence of a particular day of the week following a given Date, get the difference in the number of days of the week between a date and a day_of_week, a number 0–6 where 0 = Sunday and 6 = Saturday. By adding this difference to the current date, you can find the date of the day_of_week. The IF() statement in this formula handles cases where the day_of_week is before the day of the week of the date value (for example date is a Thursday and day_of_week is a Monday) by adding 7 to the difference. date + ( day_of_week - MOD( date - DATE( 1900, 1, 7 ), 7 ) ) + IF( MOD( date - DATE( 1900, 1, 7 ), 7 ) >= day_of_week, 7, 0 ) You can substitute either a constant or another field in for the day_of_week value based on your needs. Find the Number of Days Between Two Dates To find the number of days between two dates, date_1 and date_2, subtract the earlier date from the later date: date_1 — date_2 You can alter this slightly if you want to determine a date that’s a certain number of days in the past. For example, to create a formula to return true if some date field is more than 30 days before the current date and false otherwise, use a formula such as the following: TODAY() - 30 > date Find the Number of Business Days Between Two Dates Calculating how many business days passed between two dates is slightly more complex than calculating total elapsed days. The basic strategy is to choose a reference Monday from the past and find out how many full weeks and any additional portion of a week have 440 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas passed between the reference date and your date. These values are multiplied by five for a five-day work week, and then the difference between them is taken to calculate business days. (5 * ( FLOOR( ( date_1 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_1 - DATE( 1900, 1, 8), 7 ) ) ) - (5 * ( FLOOR( ( date_2 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_2 - DATE( 1900, 1, 8), 7 ) ) ) In this formula, date_1 is the more recent date and date_2 is the earlier date. If your work week runs shorter or longer than five days, replace all fives in the formula with the length of your week. Find the Number of Months Between Two Dates To find the number of months between two dates, subtract the year of the earlier date from the year of the later date and multiply the difference by 12. Next, subtract the month of the earlier date from the month of the later date, and add that difference to the value of the first set of operations. ((YEAR(date_1) - YEAR(date_2))*12) + (MONTH(date_1) - MONTH(date_2)) Add Days, Months, and Years to a Date If you want to add a certain number of days to a date, add that number to the date directly. For example, to add five days to a date, the formula is date + 5. Adding years to a date is fairly simple, but do check that the future date is valid. That is, adding five years to February 29 (a leap year) results in an invalid date. The following formula adds num_years to date by checking if the date is February 29 and if the future date is not in a leap year. If these conditions hold true, the formula returns March 1 in the future year. Otherwise the formula sets the Date to the same month and day num_years in the future. IF( AND( MONTH( date ) = 2, DAY( date ) = 29, NOT( OR( MOD( YEAR( date ) + num_years, 400 ) = 0, AND( MOD( YEAR( date ) + num_years, 4 ) = 0, MOD( YEAR( date ) + num_years, 100 ) != 0 ) ) ) ), DATE( YEAR( date ) + num_years, 3, 1), DATE( YEAR( date ) + num_years, MONTH( date ), DAY( date ) ) ) Adding months to a date is slightly more complicated because months vary in length and the cycle of months restart with each year. So a valid day in one month, January 31, might not be valid in another month, February 31. A simple solution is to approximate each month’s length as 365/12 days: date + ( ( 365 / 12 ) * Number_months ) 441 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas This formula is a good estimate but it doesn’t return an exact date. For example, if you add two months to April 30 using this method, the formula will return June 29 instead of June 30. Returning an exact date depends on your organization’s preference. For example, when you add one month to January 31, should it return February 28, the last day of the next month, or March 2, 30 days after January 31? This formula does the following: • Returns March 1 if the future month is a February and the day is greater than 28. This portion of the formula performs the same for both leap and non-leap years. • Returns the first day of the next month if the future month is April, June, September, or November and the day is greater than 30. • Otherwise, it returns the correct date in the future month. This example formula adds two months to a given date. You can modify the conditions on this formula if you prefer different behaviors for dates at the end of the month. DATE( YEAR( date ) + FLOOR( ( MONTH ( date ) + 2 - 1 ) / 12 ), MOD( MONTH ( date ) + 2 - 1 + IF( DAY ( date ) > CASE( MOD( MONTH( date ) + 2 - 1, 12 ) + 1, 2, 28, 4, 30, 6, 30, 9, 30, 11, 30, 31 ), 1, 0 ), 12 ) + 1, IF( DAY( date ) > CASE( MOD( MONTH( date ) + 2 - 1, 12 ) + 1, 2, 28, 4, 30, 6, 30, 9, 30, 11, 30, 31 ), 1, DAY( date ) ) ) If you use these formulas for expiration dates, you can subtract a day from the return value to make sure that some action is completed before the calculated date. Add Business Days to a Date This formula finds three business days from a given date. CASE( MOD( date - DATE( 1900, 1, 7 ), 7 ), 3, date + 2 + 3, 4, date + 2 + 3, 5, date + 2 + 3, 6, date + 1 + 3, date + 3 ) This formula finds the day of the week of the date field value. If the date is a Wednesday, Thursday, or Friday, the formula adds five calendar days, two weekend days, three weekdays, to the date to account for the weekend. If date is a Saturday, you need four 442 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas additional calendar days. For any other day of the week Sunday Tuesday, simply add three days. You can easily modify this formula to add more or fewer business days. The tip for getting the day of the week is useful to use to adjust this formula. Find the Hour, Minute, or Second from a Date/Time To get the hour, minute, and second from a Date/Time field as a numerical value, use the following formulas where TZoffset is the difference between the user’s time zone and GMT. For hour in 24–hour format: VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) For hour in 12–hour format: IF( OR( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 0, VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 12 ), 12, VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) - IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, 0, 12 ) ) For minutes: VALUE( MID( TEXT( date/time - TZoffset ), 15, 2 ) ) For seconds: VALUE( MID( TEXT( date/time - TZoffset ), 18, 2 ) ) And, to get “AM” or “PM” as a string, use: IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, "AM", "PM" ) To return the time as a string in “HH:MM:SS A/PM” format, use the following formula: IF( OR( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 0, VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 12 ), "12", TEXT( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) - IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, 0, 443 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas 12 ) ) ) & ":" & MID( TEXT( date/time - TZoffset ), 15, 2 ) & ":" & MID( TEXT( date/time - TZoffset ), 18, 2 ) & " " & IF( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, "AM", "PM" ) When working with time in formula fields, always consider the time difference between your organization and GMT. See A Note About Date/Time and Time Zones on page 415 for more information about the time zone offset used in this formula. Find the Elapsed Time Between Date/Times To find the difference between two Date values as a number, subtract one from the other like so: date_1 — date_2 to return the difference in days. Finding the elapsed time between two Date/Time values is slightly more complex. This formula converts the difference between two Date/Time values, datetime_1 and datetime_2, to days, hours, and minutes. IF( datetime_1 - datetime_2 > 0 , TEXT( FLOOR( datetime_1 - datetime_2 ) ) & " days " & TEXT( FLOOR( MOD( (datetime_1 - datetime_2 ) * 24, 24 ) ) ) & " hours " & TEXT( ROUND( MOD( (datetime_1 - datetime_2 ) * 24 * 60, 60 ), 0 ) ) & " minutes", "" ) Find the Number of Business Hours Between Two Date/Times The formula to find business hours between two Date/Time values expands on the formula to find elapsed business days. It works on the same principle of using a reference Date/Time, in this case 1/8/1900 at 16:00 GMT, or 9:00 AM PDT, and then finding your Dates’ respective distances from that reference. The formula rounds the value it finds to the nearest hour and assumes an 8–hour, 9:00 AM5:00 PM work day. ROUND( 8 * ( ( 5 * FLOOR( ( DATEVALUE( date/time_1 ) - DATE( 1900, 1, 8) ) / 7) + MIN(5, MOD( DATEVALUE( date/time_1 ) - DATE( 1900, 1, 8), 7) + MIN( 1, 24 / 8 * ( MOD( date/time_1 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1 ) ) ) ) ) - ( 5 * FLOOR( ( DATEVALUE( date/time_2 ) - DATE( 1900, 1, 8) ) / 7) + MIN( 5, MOD( DATEVALUE( date/time_2 ) - DATE( 1996, 1, 1), 7 ) + 444 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas MIN( 1, 24 / 8 * ( MOD( date/time_2 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1) ) ) ) ) ), 0 ) You can change the eights in the formula to account for a longer or shorter work day. If you live in a different time zone or your work day doesn’t start at 9:00 AM, change the reference time to the start of your work day in GMT. See A Note About Date/Time and Time Zones for more information. SEE ALSO: Using Date, Date/Time, and Time Values in Formulas Examples of Advanced Formula Fields Tips for Building Formulas Sample Discounting Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Maintenance and Services Discount Classic and Lightning Experience This formula field uses two custom currency fields: Maintenance Amount and Services Amount. It displays “Discounted” on an opportunity if its maintenance amount and services amount Available in: All Editions do not equal the opportunity Amount standard field value. Otherwise, it displays "Full Price." IF(Maintenance_Amount__c + Services_Amount__c <> Amount, "Discounted", "Full Price") Opportunity Discount Amount This formula calculates the difference of the product Amount less the Discount Amount. Discount Amount is a custom currency field. Amount - Discount_Amount__c Opportunity Discount Rounded Use this formula to calculate the discounted amount of an opportunity rounded off to two digits. This example is a number formula field on opportunities that uses a custom percent field called Discount Percent. ROUND(Amount-Amount* Discount_Percent__c,2) Opportunity Discount with Approval This formula adds a “Discount Approved” checkbox to an opportunity. It uses conditional logic to check the value of the approval flag before calculating the commission. IF(Discount_Approved__c, ROUND(Amount – Amount * DiscountPercent__c, 2), Amount) 445 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Sample Employee Services Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Bonus Calculation Classic and Lightning Experience This example determines an employee's bonus amount based on the smallest of two amounts: the employee's gross times bonus percent or an equally divided amount of the company's performance Available in: All Editions amount among all employees. It assumes you have custom number field for Number of Employees, a custom percent field for Bonus Percent, and currency custom fields for the employee's Gross and company's Performance. MIN(Gross__c * Bonus_Percent__c, Performance__c / Number_of_Employees__c) Employee 401K This example formula determines which amount to provide in employee 401K matching based on a matching program of half of the employee's contribution or $250, whichever is less. It assumes you have custom currency field for Contribution. MIN(250, Contribution__c /2) Hours Worked Per Week This formula uses a custom tab to enable time tracking of hours worked per day. It uses a formula field to sum the hours per week. MonHours__c + TuesHours__c + WedsHours__c + ThursHours__c + FriHours__c Total Pay Amount This formula determines total pay by calculating regular hours multiplied by a regular pay rate, plus overtime hours multiplied by an overtime pay rate. Total Pay = IF(Total_Hours__c <= 40, Total_Hours__c * Hourly_Rate__c, 40 * Hourly_Rate__c + (Total_Hours__c - 40) * Overtime_Rate__c) Sample Expense Tracking Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Expense Identifier Classic and Lightning Experience This formula displays the text Expense- followed by trip name and the expense number. This is a text formula field that uses an expense number custom field. Available in: All Editions "Expense-" & Trip_Name__c & "-" & ExpenseNum__c 446 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Mileage Calculation This formula calculates mileage expenses for visiting a customer site at 35 cents a mile. Miles_Driven__c * 0.35 Sample Financial Calculations Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Compound Interest Classic and Lightning Experience This formula calculates the interest, you will have after T years, compounded M times per year. Available in: All Editions Principal__c * ( 1 + Rate__c / M ) ^ ( T * M) ) Compound Interest Continuous This formula calculates the interest that will have accumulated after T years, if continuously compounded. Principal__c * EXP(Rate__c * T) Consultant Cost This formula calculates the number of consulting days times 1200 given that this formula field is a currency data type and consulting charges a rate of $1200 per day. Consulting Days is a custom field. Consulting_Days__c * 1200 Gross Margin This formula provides a simple calculation of gross margin. In this formula example, Total Sales and Cost of Goods Sold are custom currency fields. Total_Sales__c - Cost_of_Goods_Sold__c Gross Margin Percent This formula calculates the gross margin based on a margin percent. Margin_percent__c * Items_Sold__c * Price_item__c Payment Due Indicator This formula returns the date five days after the contract start date whenever Payment Due Date is blank. Payment Due Date is a custom date field. (BLANKVALUE(Payment_Due_Date__c, StartDate +5) 447 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Payment Status This formula determines if the payment due date is past and the payment status is “UNPAID.” If so, it returns the text “PAYMENT OVERDUE” and if not, it leaves the field blank. This example uses a custom date field called Payment Due Date and a text custom field called Payment Status on contracts. IF( AND(Payment_Due_Date__c < TODAY(), ISPICKVAL(Payment_Status__c, "UNPAID")), "PAYMENT OVERDUE", null ) Sample Image Link Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Yahoo! Instant Messenger™ Image Classic and Lightning Experience This formula displays an image that indicates whether a contact or user is currently logged in to Yahoo! Instant Messenger. Clicking the image launches the Yahoo! Instant Messenger window. This Available in: All Editions formula uses a custom text field called Yahoo Name to store the contact or user’s Yahoo! ID. IF(ISBLANK(Yahoo_Name__c),"", HYPERLINK("ymsgr:sendIM?" & Yahoo_Name__c, IMAGE("http://opi.yahoo.com/online?u=" & Yahoo_Name__c & "&m=g&t=0", " "))) Flags for Case Priority This formula displays a green, yellow, or red flag image to indicate case priority. IMAGE( CASE( Priority, "Low", "/img/samples/flag_green.gif", "Medium", "/img/samples/flag_yellow.gif", "High", "/img/samples/flag_red.gif", "/s.gif"), "Priority Flag") Color Squares for Case Age This formula displays a 30 x 30 pixel image of a red, yellow, or green, depending on the value of a Case Age custom number field. IF( Case_Age__c > 20, IMAGE("/img/samples/color_red.gif", "red", 30, 30), IF( Case_Age__c > 10, IMAGE("/img/samples/color_yellow.gif", "yellow", 30, 30), IMAGE("/img/samples/color_green.gif", "green", 30, 30) )) 448 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Traffic Lights for Status This formula displays a green, yellow, or red traffic light images to indicate status, using a custom picklist field called Project Status. Use this formula in list views and reports to create a “Status Summary” dashboard view. IMAGE( CASE(Project_Status__c, "Green", "/img/samples/light_green.gif", "Yellow", "/img/samples/light_yellow.gif", "Red", "/img/samples/light_red.gif", "/s.gif"), "status color") Stars for Ratings This formula displays a set of one to five stars to indicate a rating or score. IMAGE( CASE(Rating__c, "1", "/img/samples/stars_100.gif", "2", "/img/samples/stars_200.gif", "3", "/img/samples/stars_300.gif", "4", "/img/samples/stars_400.gif", "5", "/img/samples/stars_500.gif", "/img/samples/stars_000.gif"), "rating") Consumer Reports™—Style Colored Circles for Ratings This formula displays a colored circle to indicate a rating on a scale of one to five, where solid red is one, half red is two, black outline is three, half black is four, and solid black is five. IMAGE( CASE(Rating__c, "1", "/img/samples/rating1.gif", "2", "/img/samples/rating2.gif", "3", "/img/samples/rating3.gif", "4", "/img/samples/rating4.gif", "5", "/img/samples/rating5.gif", "/s.gif"), "rating") Horizontal Bars to Indicate Scoring This formula displays a horizontal color bar (green on a white background) of a length that is proportional to a numeric score. In this example, the maximum length of the bar is 200 pixels. IMAGE("/img/samples/color_green.gif", "green", 15, Industry_Score__c * 2) & IMAGE("/s.gif", "white", 15, 200 - (Industry_Score__c * 2)) 449 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Sample Integration Link Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Application API Link Classic (not available in all orgs) and Lightning This formula creates a link to an application outside Salesforce, passing the parameters so that it Experience can connect to Salesforce via the SOAP API and create the necessary event. Available in: All Editions HYPERLINK ("https://www.myintegration.com?sId=" & GETSESSIONID() & "?&rowID=" & Name & "action=CreateTask","Create a Meeting Request") Important: $Api.Session_ID and GETSESSIONID() return the same value, an identifier for the current session in the current context. This context varies depending on where the global variable or function is evaluated. For example, if you use either in a custom formula field, and that field is displayed on a standard page layout in Salesforce Classic, the referenced session is a basic Salesforce session. That same field (or the underlying variable or formula result), when used in a Visualforce page, references a Visualforce session instead. Session contexts are based on the domain of the request. That is, the session context changes whenever you cross a hostname boundary, such as from .salesforce.com to .vf.force.com or .lightning.force.com. Session identifiers from different contexts, and the sessions themselves, are different. When you transition between contexts, the old session is replaced by the new one, and the old session is no longer valid. The session ID also changes at this time. Normally Salesforce transparently handles session hand-off between contexts, but if you’re passing the session ID around yourself, you might need to re-access $Api.Session_ID or GETSESSIONID() from the new context to ensure a valid session ID. Not all sessions are created equal. In particular, sessions obtained in a Lightning Experience context have reduced privileges, and don't have API access. You can't use these session IDs to make API calls. {!$Api.Session_ID} isn’t generated for guest users. Shipment Tracking Integration This formula creates a link to FedEx, UPS, or DHL shipment tracking websites, depending on the value of a Shipping Method custom picklist field. Note that the parameters shown in this example for FedEx, UPS, and DHL websites are illustrative and do not represent the correct parameters for all situations. CASE(Shipping_Method__c, "Fedex", HYPERLINK("http://www.fedex.com/Tracking?ascend_header=1&clienttype =dotcom&cntry_code=us&language=english&tracknumbers= "& tracking_id__c,"Track"), "UPS", HYPERLINK("http://wwwapps.ups.com/WebTracking/processInputRequest?HTMLVersion =5.0&sort_by=status&loc=en_US&InquiryNumber1= "& tracking_id__c & "&track.x=32&track.y=7", "Track") , "DHL", HYPERLINK("http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber=" & tracking_id__c,"Track"), "") 450 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Skype™ Auto Dialer Integration This formula creates a linkable phone number field that automatically dials the phone number via the Skype VOIP phone application. It requires installation of the Skype application (a third-party product not provided by Salesforce) on your desktop. HYPERLINK("callto://+" & Country_Code__c & Phone_Unformatted__c, Phone) Sample Lead Management Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Lead Aging (for open leads) Classic and Lightning Experience This formula checks to see if a lead is open and if so, calculates the number of days it has been open by subtracting the date and time created from the current date and time. The result is the number Available in: All Editions of days open rounded to zero decimal places. If the lead is not open, this field is blank. IF(ISPICKVAL(Status, "Open"), ROUND(NOW()-CreatedDate, 0), null) Lead Data Completeness This formula calculates the percent of certain lead fields that your sales personnel enter. The formula field checks the values of two custom number fields: Phone and Email. If the fields are empty, the formula returns the value “0.” The formula returns a value of “1” for each field that contains a value and multiplies this total by fifty to give you the percentage of fields that contain data. (IF(Phone = "", 0, 1) + IF(Email = "", 0, 1) ) * 50 Lead Numbering This formula returns a number value for the text value in the auto-number field Lead Number. This can be useful if you want to use the Lead Number field in a calculation, such as round-robin or other routing purposes. Note that auto-number fields are text fields and must be converted to a number for numeric calculations. VALUE(Lead_Number__c) Round-Robin Assignment of Cases or Leads The following formula example for leads assumes you have three lead queues and you want to assign an equal number of incoming leads to each queue. You can also assign cases using a similar formula. MOD(VALUE(Lead_Number__c), 3) This formula is for a custom formula field named Round_Robin_ID that assigns each lead a value of 0, 1, or 2. This formula uses a custom auto-number field called Lead Number that assigns each lead a unique number starting with 1. The MOD function divides the lead number by the number of lead queues available (three in this example) and returns a remainder of 0, 1, or 2. Use the value of this formula field in your lead assignment rules to assign lead records to different queues. For example: • Round_Robin_ID = 0 is assigned to Queue A • Round_Robin_ID = 1 is assigned to Queue B • Round_Robin_ID = 2 is assigned to Queue C 451 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Sample Metric Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Temperature Conversion Classic and Lightning Experience This formula converts Celsius degrees to Fahrenheit. Available in: All Editions 1.8 * degrees_celsius__c + 32 Unit of Measure Conversion This formula converts miles to kilometers. Miles__c * 1.60934 Sample Opportunity Management Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Expected Product Revenue Classic and Lightning Experience This formula calculates total revenue from multiple products, each with a different probability of closing. Available in: All Editions ProductA_probability__c * ProductA_revenue__c + ProductB_probability__c * ProductB_revenue__c Maintenance Calculation This formula calculates maintenance fees as 20% of license fees per year. Maintenance Years is a custom field on opportunities. Amount * Maint_Years__c * 0.2 Monthly Subscription-Based Calculated Amounts This formula calculates an opportunity amount based on a monthly subscription rate multiplied by the subscription period. Monthly_Amount__c * Subscription_Months__c Monthly Value This formula divides total yearly value by 12 months. Total_value__c / 12 452 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Opportunity Additional Costs This formula calculates the sum of the product Amount, maintenance amount, and services fees. Maint amount and Service Fees are custom currency fields. Amount + Maint_Amount__c + Services_Amount__c Opportunity Categorization This formula uses conditional logic to populate an Opportunity category text field, based on the value of the Amount standard field. Opportunities with amounts less than $1500 are “Category 1,” those between $1500 and $10000 are “Category 2,” and the rest are “Category 3.” This example uses nested IF statements. IF(Amount < 1500, "Category 1", IF(Amount > 10000, "Category 3", "Category 2")) Opportunity Data Completeness This formula takes a group of fields and calculates what percent of them are being used by your personnel. This formula field checks five fields to see if they are blank. If so, a zero is counted for that field. A “1” is counted for any field that contains a value, and this total is divided by five (the number of fields evaluated). This formula requires you to select the Treat blank fields as blanks option under Blank Field Handling while the Advanced Formula subtab is showing. (IF(ISBLANK(Maint_Amount__c), 0, 1) + IF(ISBLANK(Services_Amount__c), 0,1) + IF(ISBLANK(Discount_Percent__c), 0, 1) + IF(ISBLANK(Amount), 0, 1) + IF(ISBLANK(Timeline__c), 0, 1)) / 5 Opportunity Expected License Revenue This formula calculates expected revenue for licenses based on probability of closing. Expected_rev_licenses__c * Probability Opportunity Revenue Text Display This formula returns the expected revenue amount of an opportunity in text format without a dollar sign. For example, if the Expected Revenue of a campaign is “$200,000,” this formula field displays “200000.” TEXT(ExpectedRevenue) Opportunity Total Deal Size This formula calculates the sum of maintenance and services amounts. Amount + Maint_Amount__c + Services_Amount__c Opportunity Total Price Based on Units This formula generates proposal pricing based on unit price and total volume. Unit_price__c * Volume__c * 20 453 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Professional Services Calculation This formula estimates professional service fees at an average loaded rate of $1200 per day. Consulting Days is a custom field on opportunities. Consulting_Days__c * 1200 Stage-Based Sales Document Selection This formula Identifies a relevant document in the Documents tab based on opportunity Stage. Use document IDs in the form of “00l30000000j7AO.” CASE(StageName, "Prospecting", "Insert 1st Document ID", "Qualification", "Insert 2nd Document ID", "Needs Analysis", "Insert 3rd Document ID", "Value Proposition", ... ) ) Sales Coach This formula creates a hyperlink that opens a stage-specific document stored in the Documents tab. It uses the previously defined custom formula field that identifies a document based on opportunity Stage. See Stage-Based Sales Document Selection on page 454. HYPERLINK("/servlet/servlet.FileDownload?file=" & Relevant_Document__c, "View Document in New Window") Shipping Cost by Weight This formula calculates postal charges based on weight. package_weight__c * cost_lb__c Shipping Cost Percentage This formula calculates shipping cost as a fraction of total amount. Ship_cost__c / total_amount__c Tiered Commission Rates This formula calculates the 2% commission amount of an opportunity that has a probability of 100%. All other opportunities will have a commission value of zero. IF(Probability = 1, ROUND(Amount * 0.02, 2), 0) 454 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Total Contract Value from Recurring and Non-Recurring Revenue This formula calculates both recurring and non-recurring revenue streams over the lifetime of a contract. Non_Recurring_Revenue__c + Contract_Length_Months__c * Recurring_Revenue__c Sample Pricing Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Total Amount Classic and Lightning Experience This formula calculates a total amount based on unit pricing and total units. Available in: All Editions Unit_price__c * Total_units__c User Pricing This formula calculates a price per user license. Total_license_rev__c / Number_user_licenses__c Sample Scoring Calculations Formulas For details about using the functions included in these samples, see Formula Operators and Functions EDITIONS on page 355. Available in: both Salesforce Lead Scoring Classic and Lightning Experience This formula scores leads, providing a higher score for phone calls than website requests. Available in: All Editions CASE(LeadSource, "Phone", 2, "Web", 1, 0) Here's a formula that scores a lead based on his or her rating: CASE(1, IF(ISPICKVAL(Rating, "Hot"), 1, 0), 3, IF(ISPICKVAL(Rating, "Warm"), 1, 0), 2, IF(ISPICKVAL(Rating, "Cold"), 1, 0), 1)) Customer Success Scoring This formula uses a simple scoring algorithm to rank customers a high score for positive survey results in Salesforce. Survey_Question_1__c * 5 + Survey_Question_2__c *2 455 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Formulas: How Do I ... ? EDITIONS Common Math Calculations • Add numbers? Available in: both Salesforce Classic and Lightning • Convert text into a number? Experience • Divide numbers? Available in: All Editions • Multiply numbers? Some How Do I's are not • Round numbers? relevant to Database.com • Subtract numbers? Common Text Functions USER PERMISSIONS • Check if a field contains specified text? To view formula field details: • View Setup and • Check if a picklist field contains a specified value? Configuration • Combine first and last names? To create, change, or delete • Convert numbers into text? formula fields: • Create a hyperlink field? • Customize Application Advanced Formulas • Calculate Commission Amounts for Opportunities? • Set Up Round-Robin Assignment of Cases or Leads? • Set Up Opportunity Discount Rounded? Custom Summary Formulas for Reports • Calculate the sum of all leads that have Email Opt Out and Do Not Call fields selected? • Calculate the difference of all Amount fields and all Discounted Amount fields on opportunities? • Calculate the average age of all opportunities? • Calculate what percent of all opportunities are closed won? • Calculate the number of active Salesforce users to the 2nd power for administration? • Calculate the duration of all activities (minutes) times the number of records per 24 hours? • Calculate the average percent margin on a product-by-product level across many opportunities? • Calculate the percentage of one product compared to all products in closed opportunities? • Calculate the change in revenue from opportunities between months? Cross-Object Formulas • Display a Percent field from a parent object? • Display a text field from a parent object? • Display a phone number field from a parent object? • Display a picklist field from a parent object? • Display a URL field from a parent object? 456 Extend Salesforce with Clicks, Not Code Calculate Field Values With Formulas Common Formula Errors Review common errors that can occur with formulas and how to fix them. EDITIONS • “#Error!” displays for a formula field whenever an error occurs while calculating the value of a formula. To resolve the error, check your formula. Available in: both Salesforce Classic and Lightning – Is the formula dividing by zero? If so, check if the denominator of your expression is zero Experience and provide an alternative value. For example, the following campaign formula field is blank if the number of opportunities is zero: Available in: All Editions IF(NumberOfOpportunities > 0, NumberOfWonOpportunities / NumberOfOpportunities, null) – Is the formula calculating a value larger than the maximum value of the current type? If so, you can append L to numeric values to make them Long so the intermediate products will be Long and no overflow occurs. For example, the following example shows how to correctly compute the amount of milliseconds in a year by multiplying Long numeric values. Long MillsPerYear = 365L * 24L * 60L * 60L * 1000L; Long ExpectedValue = 31536000000L; System.assertEquals(MillsPerYear, ExpectedValue); – Is the formula calculating the square root of a negative number? If so, use an IF function similar to the one above to check if the value is a positive number. – Is the formula calculating the LOG of a negative number? If so, use an IF function similar to the one above to make sure that the number is positive. – Is the formula using the VALUE function with text that contains special characters? For examples of special characters, see Formula Operators and Functions on page 355. – Make sure the formula does not contain a HYPERLINK function within a text function, such as LEFT( HYPERLINK("http://MYCOMPANY.ORG ", "MYCOMPANY ") , 5). – Is the formula disabled or referencing a disabled formula field? Salesforce disables formula fields when they are deleted and they remain disabled after they are restored. To enable disabled formula fields, edit and save the field. For more information on deleted custom fields and restoring them, see Manage Deleted Custom Fields on page 244. • “#Too Big!” displays if your formula output is over 18 digits. When this happens, check your formula for calculations that could result in more than 18 digits. Avoid multiplying large numbers, raising a large number to a power, or dividing by a very small number. • CASE functions return an error whenever any of the expressions return an error, regardless of which one should be returned. For example, CASE(Field__c,"Partner", "P", "Customer", "C", LEFT(Field__c, -5)) returns an error even if the value of the field is “Partner” or “Customer” because the last statement is illogical. • Prevent division by zero errors by including an IF function that determines if the value of a field is zero. For example, IF(Field__c =0,0, 25/Field__c). 457 Extend Salesforce with Clicks, Not Code Generate Emails From Records Generate Emails From Records A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. For example, you can place a merge field in an email template so that the greeting includes the recipient’s name rather than a generic “Hello!”. Available in: both Salesforce You can use merge fields within custom formula fields, s-controls, custom links, custom buttons, Classic and Lightning Visualforce pages, and when you create email or mail merge templates. Experience Merge field names are determined when you create a new custom field or object. Field Name The available merge fields is automatically populated based on what you type into Field Label. You can customize this vary according to which field if you want, but keep in mind that the name must: Salesforce edition you have. • Only use underscores and alphanumeric characters • Begin with a letter and end with a letter • Not include spaces • Not contain two consecutive underscores Important: Ensure that the custom field name and label are unique for that object. • If a standard and custom field have identical names or labels, the merge field displays the custom field value. • If two custom fields have identical names or labels, the merge fieldcan display an unexpected value. If you create a field label called Email and a standard field labeled Email exists, the merge field is unable to distinguish between the fields. Adding a character to the custom field name makes it unique. For example, Email2. To find the merge field name for an object or field in Salesforce, visit the object or field’s detail page and refer to Field Name. To incorporate merge fields, use the editor in the respective feature. Salesforce provides valid merge fields in each editor for all related standard and custom objects. If you’re using the Connect for Office Word add-in to create mail merge templates, you’ll see a complete list of valid merge fields to insert. Merge Field Syntax A merge field’s syntax can vary depending on where you use the field. To make sure that you use the correct syntax, select merge fields from the dropdown list in the editor where you use the merge field. Merge Fields for Validation Rules Merge Fields for Formulas Merge Fields for Cross-Object Formulas A Cross-object formula is a formula that spans two related objects and references merge fields on those objects. Merge Field Tips Here are a few pointers for getting the most out of merge fields. 458 Extend Salesforce with Clicks, Not Code Generate Emails From Records Merge Field Syntax A merge field’s syntax can vary depending on where you use the field. To make sure that you use EDITIONS the correct syntax, select merge fields from the dropdown list in the editor where you use the merge field. Available in: both Salesforce Custom objects and fields are always appended with __c when referenced. The object precedes Classic and Lightning field labels, and all spaces convert to underscores. For example, Account.CreatedDate Experience Created Date references the standard field for the account object. The available merge fields In standard relationships, the name of the relationship is the master object. For example, you can vary according to which reference the account name from a contact validation rule using Account.Name. You can Salesforce edition you have. reference the phone number of the account creator from an opportunity product formula field using Opportunity.Account.CreatedBy.Phone. In custom relationships, the name of the relationship is the value specified in Field Name with __r appended to it. For example, you can reference contact email from a custom object validation rule using Contact__r.Email. Merge Fields for Validation Rules A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. Available in: both Salesforce Syntax and Formatting Classic and Lightning Experience When you insert a merge field in a validation rule, the syntax consists of the object, a period, and the field name. For example, $User.State corresponds with a user’s state or province. Available in: Essentials, Contact Manager, Group, A merge field’s syntax can vary depending on where you’re using the field. To make sure you’re Professional, Enterprise, using the correct syntax, select merge fields from the drop-down list in the editor where you’re Performance, Unlimited, using the merge field. The merge fields for validation rules correspond directly with the fields in Developer, and your app. Database.com Editions For a list of fields in an object, from the management settings for the object, go to the fields section. Important: • If two or more custom objects have matching names or labels, only one of the objects appears when you select from available merge fields. Make sure that all custom objects have unique names and labels so that you can select merge fields from any of the objects. Limitations Validation rules can’t reference merge fields for: • Auto number fields, such as Requisition Number • Compound fields, such as addresses, first and last names, dependent picklists, and dependent lookups Note: Validation rules can reference merge fields individual address fields, such as Billing City. • Campaign statistic fields, including statistics for individual campaigns and campaign hierarchies Tips • Some merge fields display as radio buttons but function like picklist fields when referenced in a formula. 459 Extend Salesforce with Clicks, Not Code Generate Emails From Records Use the values “Read,” “Edit,” and “None” in a formula when referencing: – $UserRole.CaseAccessForAccountOwner – $UserRole.OpportunityAccessForAccountOwner – CaseAccessLevel (on Territory) – OpportunityAccessLevel (on Territory) Use the values “Read,” “Edit,” and “All” in a formula when referencing: – AccountAccessLevel (on Territory) • Use the RecordType.Id merge field in your formula to apply different validations for different record types. SEE ALSO: Find Object Management Settings Merge Fields for Formulas A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. Available in: both Salesforce Syntax and Formatting Classic (not available in all orgs) and Lightning Merge fields for formulas aren’t enclosed in curly braces or preceded by an exclamation point, nor Experience are they preceded by the type of record. For example: AccountNumber. To ensure you’re using the correct syntax, use the Insert Field button or the drop-down list in the formula editor. Available in: All Editions SEE ALSO: Tips for Using Merge Fields in Formulas Build a Formula Field Merge Fields for Cross-Object Formulas A Cross-object formula is a formula that spans two related objects and references merge fields on EDITIONS those objects. A merge field is a field you can put in an email template, mail merge template, custom link, or Available in: Salesforce formula to incorporate values from a record. Classic (not available in all orgs) A cross-object formula can reference merge fields from a master (“parent”) object if an object is on the detail side of a master-detail relationship. A cross-object formula also works with lookup Available in: All editions relationships. For example, you can write a cross-object formula that references the Account Name for a contact associated with a case. In this example, you would type Contact.Account.Name in a formula on the Case object. Syntax and Formatting Merge fields for formulas aren’t enclosed in curly braces or preceded by an exclamation point. Use the relationship names of the objects, not the labels. Although the relationship name is often the same as the object name, it is technically the field name of the relationship field. 460 Extend Salesforce with Clicks, Not Code Manage Your Notifications with Notification Builder To reference the parent account name from Account object, the syntax is Parent.Name, not Account.Name. When referencing a custom object, add two underscores and the letter r to its name. For example, Position__r.title__c references the Job Title field (title__c) on a Position custom object. Limitations You can’t reference: • Merge fields for objects related to activities. For example, merge fields for contacts and accounts are not available in task and event formulas. • The $RecordType global variable—it only resolves to the record containing the formula, not the record to which the formula spans. Starting with the Spring ’13 release, when you create a new formula the $RecordType global variable is only available for default value formulas. The value of the Profile.Name merge field differs depending on the context of the cross-object formula field that references it. On detail pages, the value is the profile name, as expected. In list views and reports, the value is the internal value of the associated profile instead. If you use Profile.Name in a formula, use it within an OR function to ensure that the formula always returns the intended result. For example: IF (OR (LastModifiedBy.Profile.Name = "Standard User", LastModifiedBy.Profile.Name = "PT2"), "Standard", "Not Standard") None of the above applies to profile names referenced by the $Profile global variable. Merge Field Tips Here are a few pointers for getting the most out of merge fields. EDITIONS To make sure you’re using the correct syntax, select merge fields from the merge field picker. • To use a merge field as the destination of a link, insert the merge field after http://. Available in: both Salesforce Classic and Lightning • Salesforce rounds decimal values referenced in merge fields on email templates to three digits Experience regardless of locale. The available merge fields • You can store the name of an account, contact, or lead in your organization’s default language vary according to which (the local name), in addition to the account or user’s default language (the standard name). If Salesforce edition you have. the local name is blank, the standard merge field name is used. • To reference a stand-alone file, use $Resource. Manage Your Notifications with Notification Builder Keep your users in the know with timely notifications, whether they’re at their desks or on the go. Choose whether standard Salesforce notifications, like Chatter notifications, appear on desktop, mobile, or at all. Create custom notifications to give your users new information and reminders, or replace a standard notification. 461 Extend Salesforce with Clicks, Not Code Send Custom Notifications Send Custom Notifications Send custom notifications when important events occur. Alert an account owner if a new support case is logged while trying to close a deal. Send a notification for a workflow built entirely with custom objects. Or replace a standard notification with a custom notification to include a message and recipients tailored to your needs. Manage Notification Delivery Settings Choose the desktop and mobile delivery channels for custom and standard notification types. The delivery channels for custom types can be edited for supported Salesforce-provided apps and apps installed from a managed package. The delivery channels for standard types can be edited for supported Salesforce-provided apps only. Considerations for Notification Builder Before you begin managing your desktop and mobile notifications, learn about the considerations specific to custom notifications and notification delivery settings. SEE ALSO: Salesforce Mobile App Notification Types Send Custom Notifications Send custom notifications when important events occur. Alert an account owner if a new support case is logged while trying to close a deal. Send a notification for a workflow built entirely with custom objects. Or replace a standard notification with a custom notification to include a message and recipients tailored to your needs. 1. Create a Notification Type Create notification types to send custom notifications via a process in Process Builder, a flow in Flow Builder, Apex code, or the invocable action API. You can create multiple custom notifications from a notification type. Note: If you create a custom notification type with a mobile delivery channel in Winter ’20 or later, you must manually enable the Salesforce mobile app and any other supported apps in Notification Delivery Settings. 2. Send a Custom Notification from a Process Add the Send Custom Notification action to a process, then add recipients and content. or Learn about Other Ways to Send a Custom Notification We’ve made it easy to build notifications using clicks, not code. But if your business needs are more complex, we also support flows and programmatic solutions. 462 Extend Salesforce with Clicks, Not Code Send Custom Notifications Create a Notification Type Create notification types to send custom notifications via a process in Process Builder, a flow in Flow EDITIONS Builder, Apex code, or the invocable action API. You can create multiple custom notifications from a notification type. Available in: Lightning 1. Enter Notification Builder in the Quick Find box in Setup, then select Custom Experience Notifications. Available in: all editions, 2. Click New and add your Custom Notification Name and API Name, and supported channels. except Database.com Channel Description USER PERMISSIONS Desktop Sends a notification to the desktop notification tray. Mobile Sends an in-app and push notification to enabled supported apps. To view notification types: • View Setup and Configuration Note: Mobile in-app notifications require the Enable in-app notifications setting. Mobile push notifications depend on a user’s device-level and, if available, app-level push To create and edit notification types: notification settings. Push notifications for the Salesforce mobile app require the Enable • Customize Application push notifications setting. Note: If you created a custom notification type with a mobile delivery channel before Winter ’20, your notification is automatically delivered to the Salesforce mobile app. If you create a custom notification type with a mobile delivery channel in Winter ’20 or later, you must manually enable the Salesforce mobile app and any other supported apps in Notification Delivery Settings. 3. Save your notification type. 4. If you enable the mobile channel, you must enable the supported apps for your notification type. a. From Setup, enter Notification Builder in the Quick Find box, then select Notification Delivery Settings. b. Choose your custom notification type, and select Edit from the dropdown menu. c. Select the supported applications for your notification type and save. 463 Extend Salesforce with Clicks, Not Code Send Custom Notifications Send a Custom Notification from a Process Add the Send Custom Notification action to a process, then add recipients and content. EDITIONS • Before you begin, make sure that the custom notification type you want to call from your process exists. If not, create the notification type on page 463. Available in: both Salesforce • Before you can add an action to your process, you must define the process properties, configure Classic and Lightning the process trigger, and add process criteria. If you’re new to creating processes, learn more in Experience Process Builder help. Available in: Essentials, After you’ve created an action and selected Send Custom Notification for the type, fill in the Professional, Enterprise, relevant fields to add the action to your process. Performance, Unlimited, and Developer Editions 1. Enter an easily recognizable name for this action. The name appears on the canvas and helps you differentiate this action from others in your USER PERMISSIONS process. The name truncates to fit on the canvas. 2. Select a notification type. To create, edit, or view processes: 3. Select a recipient category, and designate or find a recipient ID. • Manage Flow • Current User — The user who initiated the record change, platform event, or process that AND triggered the process. This option is useful for confirmation notifications, such as a successful View All Data submission of a form. • Find User — The user who receives the notification each time this action is executed. • User Field from a Record — A user referenced via UserId on the record that initiated the process or on a related record. • Find Group — All users in the group that receives the notification each time this action is executed. • Find Queue — All users in the queue that receives the notification each time this action is executed. • Account Field from a Record — All users on the account team for an account referenced via AccountId on the record that initiated the process or on a related record. This option is available if you’ve enabled account teams for your org. • Opportunity Field from a Record — All users on the opportunity team for an opportunity referenced via OpportunityId on the record that initiated the process or a related record. This option is available if you’ve enabled team selling for your org. • Owner Field from a Record — An owner or queue referenced via OwnerId on the record that initiated the process or a related record. With this option, you can send a notification to all record owners, regardless of whether the owner is an individual owner or a queue. 4. Write a helpful notification title and body using text and merge fields. Note: The content of custom push notifications depends on the Display full content push notifications setting. If full content push notifications are not enabled, only the notification title is sent. 5. Save the action. Other Ways to Send a Custom Notification We’ve made it easy to build notifications using clicks, not code. But if your business needs are more complex, we also support flows and programmatic solutions. Tip: To see how to specify the target using JSON, see pageReference. 464 Extend Salesforce with Clicks, Not Code Send Custom Notifications Flow Builder Flow Core Action: Send Custom Notification The Send Custom Notification action is available in Flow Builder. Add it to your flow, then add recipients and content. Some tips specific to custom notifications: • To query for the Notification Type ID directly from a flow, add the Get Record element to your flow and filter by API name. If you’ve installed a notification type via a managed package, filter by the namespace prefix as well as the API name. • To add recipients, define Recipient ID as a resource. Then add values to your Recipient ID collection by adding the Assignment element to your flow. If you’re new to creating flows, learn even more in Flow help. Apex CustomNotification Use the CustomNotification Apex class to create, configure, and send custom notifications from Apex code, such as a trigger. When possible, create and send custom notifications from Apex rather than via API call. It’s less code, and more efficient. API CustomNotificationType Use the CustomNotificationType object to create notification types and query for your Custom Notification Type ID. It’s available for the following APIs: • Metadata • Tooling • Lightning Platform REST and SOAP customNotificationAction Invocable Action Use the customNotificationAction action to send custom notifications to desktop and delivery channels. 465 Extend Salesforce with Clicks, Not Code Manage Notification Delivery Settings Manage Notification Delivery Settings Choose the desktop and mobile delivery channels for custom and standard notification types. The EDITIONS delivery channels for custom types can be edited for supported Salesforce-provided apps and apps installed from a managed package. The delivery channels for standard types can be edited for Available in: Lightning supported Salesforce-provided apps only. Experience 1. From Setup, enter Notification Builder in the Quick Find box, then select Available in: all editions, Notification Delivery Settings. except Database.com 2. Choose the notification type, and select Edit from the dropdown menu. Notification Delivery Settings shows you only the notification types available for your org. USER PERMISSIONS 3. Select the channels and applications for your notification type, and save. To view notification delivery Only the delivery channels and mobile applications supported for the notification type are settings: listed. • View Setup and Configuration If a channel for a custom notification type created in your org is listed but unavailable, enable it in Custom Notifications in Setup. To edit notification delivery settings: Note: Mobile in-app notifications require the Enable in-app notifications setting. Mobile • Customize Application push notifications depend on a user’s device-level and, if available, app-level push notification settings. Push notifications for the Salesforce mobile app require the Enable push notifications setting. SEE ALSO: Connect REST API Developer Guide: Notification Settings Resources Metadata API Developer Guide: NotificationTypeConfig Considerations for Notification Builder Before you begin managing your desktop and mobile notifications, learn about the considerations specific to custom notifications and notification delivery settings. Custom Notifications • In orgs created in Winter ’21 or later, the Send Custom Notifications user permission is required to trigger the Send Custom Notification action in flows that run in user context, REST API calls, and Apex callouts. The Send Custom Notifications user permission isn’t required to trigger the Send Custom Notification action in process or flows that run in system context. • If you created a custom notification type with a mobile delivery channel before Winter ’20, your notification is automatically delivered to the Salesforce mobile app. If you create a custom notification type with a mobile delivery channel in Winter ’20 or later, you must manually enable the Salesforce mobile app and any other supported apps in Notification Delivery Settings. • You can create up to 500 custom notification types. • Each notification can have up to 10,000 users as recipients. However, you can add an action to the same process within Process Builder or to the same flow in Flow Builder to have more recipients. • Your org saves your most recent 1 million custom notifications for view in notification trays. Your org can save up to 1.2 million custom notifications, but it trims the amount to the most recent 1 million notifications when you reach the 1.2 million limit. • An org can execute up to 10,000 notification actions per hour. When you exceed this limit, no more notifications are sent in that hour, and all unsent notifications are lost. Notification actions resume in the next hour. 466 Extend Salesforce with Clicks, Not Code Considerations for Notification Builder For example, your notification action processes are triggered 10,250 times between 4:00 and 4:59. Salesforce executes the first 10,000 of those actions. The remaining 250 notifications aren’t sent and are lost. Salesforce begins executing notification actions again at 5:00. • When you send a custom notification from a process, the Target ID for the notification is the record that started the process. However, target records that don't have their own detail page (for example, a case comment, which appears only in a Case Comment related list) don't support direct navigation. Use Flow Builder to send the notification from a flow and specify either a different Target ID or Target Page Reference. Tip: To see how to specify the target using JSON, see pageReference. • Custom notification title and body fields support plain text only. • The content of custom push notifications depends on the Display full content push notifications setting. If full content push notifications aren’t enabled, only the notification title is sent. Notification Delivery Settings • When you disable a delivery channel for a standard or custom notification type, you pause the delivery of a notification. However, a notification is still created and stored whenever an existing notification type is triggered. If you enable a delivery channel for an existing notification type, the stored notifications become visible in the notification tray for that delivery channel. • Mobile in-app notifications require the Enable in-app notifications setting. Mobile push notifications depend on a user’s device-level and, if available, app-level push notification settings. • In the Salesforce mobile app: – Mobile push notifications require the Enable push notifications setting. – A push notification for an individual notification type depends on a user’s app-level Push Notification Settings. If the mobile channel is enabled for a notification type, but a user disables push notifications for that type, the user doesn’t receive a push notification. – If you enable the mobile delivery channel for a notification type after you’ve disabled it, users’ Push Notification Settings for that type default to enabled. • A desktop notification can be delivered in real time to up to 1,000 concurrently logged-in recipients. Additional concurrently logged-in recipients must refresh their Salesforce page to see their latest notifications. Recipients who aren't logged in see their notifications as expected upon login. SEE ALSO: Considerations for Salesforce Mobile App Notifications 467 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events Define and Manage Platform Events Use platform events to connect business processes in Salesforce and external sources through the EDITIONS exchange of real-time event data. Platform events are secure and scalable. Define fields to customize your platform event data. Available in both Salesforce By using platform events, publishers can send custom event data through Apex, a process, a flow, Classic and Lightning or an API. Subscribers can receive custom event messages from Salesforce or an external system Experience using Apex, CometD clients, processes, or flows. Based on the event message data, subscribers can Available in: Performance, process custom business logic, such as sending an email or logging a case. For example, a software Unlimited, Enterprise, and system monitoring a printer can make an API call to publish an event when the ink is low. The Developer Editions custom printer event can contain custom fields for the printer model, serial number, and ink level. The event is processed in Salesforce by an Apex trigger that places an order for a new cartridge. USER PERMISSIONS Platform events simplify the process of communicating changes and responding to them without writing complex logic. Publishers and subscribers communicate with each other through events. To create and edit platform Multiple subscribers can listen to the same event and carry out different actions. event definitions: • Customize Application Define Your Platform Event To define a platform event in Salesforce Classic or Lightning Experience: 1. From Setup, enter Platform Events in the Quick Find box, then select Platform Events. 2. On the Platform Events page, click New Platform Event. 3. Complete the standard fields, and optionally add a description. 4. For Publish Behavior, choose when the event message is published in a transaction. • Publish After Commit to have the event message published only after a transaction commits successfully. Select this option if subscribers rely on data that the publishing transaction commits. For example, a process publishes an event message and creates a task record. A second process that is subscribed to the event is fired and expects to find the task record. Another reason for choosing this behavior is when you don't want the event message to be published if the transaction fails. • Publish Immediately to have the event message published when the publish call executes. Select this option if you want the event message to be published regardless of whether the transaction succeeds. Also choose this option if the publisher and subscribers are independent, and subscribers don't rely on data committed by the publisher. For example, the immediate publishing behavior is suitable for an event used for logging purposes. With this option, a subscriber might receive the event message before data is committed by the publisher transaction. 5. Click Save. 6. To add a field, in the Custom Fields & Relationships related list, click New. 7. Follow the custom field wizard to set up the field properties. Note: • If you change the publish behavior, expect up to a 5-minute delay for the change to take effect. • In Lightning Experience, platform events aren’t shown in the Object Manager’s list of standard and custom objects and aren’t available in Schema Builder. A platform event is a special kind of Salesforce entity, similar in many ways to an sObject. An event message is an instance of a platform event, similar to how a record is an instance of a custom object. Unlike custom objects, you can’t update or delete event records. You 468 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events also can’t view event records in the Salesforce user interface, and platform events don’t have page layouts. When you delete a platform event definition, it’s permanently deleted. Standard Fields Platform events include standard fields. These fields appear on the New Platform Event page. Field Description Label Name used to refer to your platform event in a user interface page. Plural Label Plural name of the platform event. Starts with a vowel sound If it’s appropriate for your org’s default language, indicate whether the label is preceded by “an” instead of “a.” Object Name Unique name used to refer to the platform event when using the API. In managed packages, this name prevents naming conflicts with package installations. Use only alphanumeric characters and underscores. The name must begin with a letter and have no spaces. It cannot end with an underscore or have two consecutive underscores. Description Optional description of the object. A meaningful description helps you remember the differences between your events when you view them in a list. Deployment Status Indicates whether the platform event is visible to other users. Custom Fields In addition to the standard fields, you can add custom fields to your custom event. Platform event custom fields support only these field types. • Checkbox • Date • Date/Time • Number • Text • Text Area (Long) The maximum number of fields that you can add to a platform event is the same as for a custom object. See Salesforce Features and Edition Allocations. ReplayId System Field Each event message is assigned an opaque ID contained in the ReplayId field. The ReplayId field value, which is populated by the system when the event is delivered to subscribers, refers to the position of the event in the event stream. Replay ID values are not guaranteed to be contiguous for consecutive events. For example, the event following the event with ID 999 can have an ID of 1,025. A subscriber can store a replay ID value and use it on resubscription to retrieve events that are within the retention window. For example, 469 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events a subscriber can retrieve missed events after a connection failure. Subscribers must not compute new replay IDs based on a stored replay ID to refer to other events in the stream. EventUuid System Field A universally unique identifier (UUID) that identifies a platform event message. This field is available in API version 52.0 and later. The API version corresponds to the version that an Apex trigger is saved with, or the version specified in a CometD subscriber endpoint. API Name Suffix for Custom Platform Events When you create a platform event, the system appends the __e suffix to create the API name of the event. For example, if you create an event with the object name Low Ink, the API name is Low_Ink__e. The API name is used whenever you refer to the event programmatically, for example, in Apex. API names of standard platform events, such as AssetTokenEvent, don’t include a suffix. Event Subscribers The Subscriptions related list shows all triggers, processes, and platform event–triggered flows that are subscribed to a platform event. CometD subscribers, such as your own CometD client or the empApi Lightning component, aren't listed in this page. The list shows the replay ID of the event that the system last processed (Last Processed Id field) and the event last published (Last Published Id field). Knowing which replay ID was last processed is useful when there’s a gap in the events published and processed. For example, if a trigger contains complex logic that causes a delay in processing large batches of incoming events. Note: For high-volume platform events, the Last Published Id value is not available and is always shown as Not Available. Also, the Subscriptions list shows the state of each subscriber, which can be one of the following. • Running—The subscriber is actively listening to events. If you modify the subscriber, the subscription continues to process events. • Error— The subscriber was disconnected and stopped receiving published events. A trigger reaches this state when it exceeds the number of maximum retries with the EventBus.RetryableException. Trigger assertion failures and unhandled exceptions don’t cause the error state. We recommend limiting the retries to fewer than nine times to avoid reaching this state. When you fix and save the trigger, or for a managed package trigger, if you redeploy the package, the trigger resumes automatically from the tip, starting from new events. Also, you can resume a trigger subscription in the subscription detail page that you access from the platform event page. • Suspended—The subscriber is disconnected and can’t receive events because a Salesforce admin suspended it or due to an internal error. You can resume a trigger subscription in the subscription detail page that you access from the platform event page. To resume a process, deactivate it and then reactivate it. If you modify the subscriber, the subscription resumes automatically from the tip, starting from new events. Note: Only one “Process” subscriber appears in the Subscriptions related list for all paused flow interviews that are subscribed to the platform event. Processes and platform event–triggered flows are listed individually. Also, information about event subscribers is exposed in the EventBusSubscriber object. You can query this object to obtain details about subscribers. Suspend or Resume an Apex Trigger Subscription Resume a suspended trigger subscription where it left off, starting from the earliest available event message that is stored in the event bus. If you want to bypass event messages that are causing errors or are no longer needed, you can resume a subscription from the tip, starting from new event messages. 470 Extend Salesforce with Clicks, Not Code Define and Manage Platform Events To manage a trigger subscription: 1. In the Subscriptions related list, click Manage next to the Apex trigger. 2. In the subscription detail page, choose the appropriate action. • To suspend a running subscription, click Suspend. • To resume a suspended subscription, starting from the earliest event message that is available in the event bus, click Resume. • To resume a suspended subscription, starting from new event messages, click Resume from Tip. You can’t manage subscriptions for flows and processes through the Subscriptions related list. Note: • After you modify a subscriber, the subscription resumes automatically. For more information, see the Event Subscribers section. • If you click Resume for a trigger that is in the error state, the trigger skips the events that were retried with EventBus.RetryableException. The subscription starts with the unprocessed events sent after the error state and that are within the retention window. Platform Event Considerations Field-Level Security All platform event fields are read only by default, and you can’t restrict access to a particular field. Field-level security permissions don’t apply and the event message contains all fields. Enforcement of Field Attributes Platform event records are validated to ensure that the attributes of their custom fields are enforced. Field attributes include the Required and Default attributes, the precision of number fields, and the maximum length of text fields. Permanent Deletion of Event Definitions When you delete an event definition, it’s permanently removed and can’t be restored. Before you delete the event definition, delete the associated triggers. Published events that use the definition are also deleted. Renaming Event Objects Before you rename an event, delete the associated triggers. If the event name is modified after clients have subscribed to this event, the subscribed clients must resubscribe to the updated topic. To resubscribe to the new event, add your trigger for the renamed event object. No Associated Tab Platform events don’t have an associated tab because you can’t view event records in the Salesforce user interface. No SOQL Support You can’t query event messages using SOQL. No Record Page Support in Lightning App Builder When creating a record page in Lightning App Builder, platform events that you defined show up in the list of objects for the page. However, you can’t create a Lightning record page for platform events because event records aren’t available in the user interface. Platform Events in Package Uninstall When uninstalling a package with the option Save a copy of this package's data for 48 hours after uninstall enabled, platform events aren’t exported. Event Volume in Package Installations and Upgrades Installing a managed or unmanaged package that contains a standard-volume platform event causes the event type to be saved as high volume in the subscriber org. Upgrading a managed package doesn't change the event volume in the subscriber org. 471 Extend Salesforce with Clicks, Not Code Manage Your Domains No Support in Professional and Group Editions Platform events aren’t supported in Professional and Group Edition orgs. Installation of a package that contains platform event objects fails in those orgs. SEE ALSO: Platform Events Developer Guide Manage Your Domains You can configure domains and their site associations to suit your organization’s unique needs. For EDITIONS example, you can set up a single domain to host your Experience Cloud, Lightning Platform, and Site.com sites. Or perhaps you want a single site on more than one domain. Available in: both Salesforce Sites and domains can have a many-to-many relationship. Each domain can have up to 200 sites, Classic and Lightning and each site can be associated with up to 500 domains. Each Experience Cloud site has two sites. Experience Hosting your Experience Cloud, Lightning Platform, and Site.com sites on one domain can simplify Available in: Professional, your domain requirements. For Site.com sites, consider hosting them on the same domain as your Enterprise, Performance, Salesforce Sites because you can access Visualforce pages and access Apex code more easily. and Unlimited Editions There are also reasons why you would have a site on more than one domain. For example, let’s say you have a parent company with two distinct brands. Each brand has its own registered domain, USER PERMISSIONS but you want them both to point to the parent website. Because you can have a site exist on more than one domain, you can point both brand domains to a single parent website. To manage domains: To host one or more sites on a domain, you must set up custom URLs for each site. Custom URLs • You must have Site.com, uniquely distinguish the sites within that domain. Let’s say you have a domain called Salesforce Sites, or Experience Cloud Sites www.ourdomain.com and you want to host two sites called siteone and sitetwo. You enabled. create custom URLs by associating ourdomain.com to each site using a custom path. This results in two custom URLs: http://www.ourdomain.com/siteone and http://www.ourdomain.com/sitetwo. When web users access the domain using one of the URLs, the custom path determines which site within the domain they see. Add a Domain Add a domain and choose how it’s going to be served. Options to Serve a Custom Domain Salesforce supports multiple options to configure how your domain is served. Whether you serve content for your domain through one of Salesforce’s content delivery networks (CDNs), or an external provider, we strongly recommend using HTTPS. Enable External HTTPS on a Domain Enabling External HTTPS lets you tell Salesforce that a non-Salesforce host or service serves your domain. Use this option if you route your domain through your own server or content delivery network (CDN) account instead of routing it through Salesforce. Naked Domains A naked domain is a domain name server (DNS) name that can’t be a canonical name record (CNAME). An example is hello.com, without the “www” subdomain. You can set up a naked domain in a Salesforce org, but it can require work on your part to maintain and optimize it. Add a Custom URL Define your domain and site relationships by creating custom URLs, which consist of domains and custom path prefixes. 472 Extend Salesforce with Clicks, Not Code Add a Domain Manage Domains and Custom URLs You can add a custom URL to an existing domain, rename a domain, update its HTTPS service option, activate changes to a domain, or delete a custom URL from a particular domain. Test Your Custom Domains in a Sandbox Develop and test your custom domains for Salesforce Sites and Experience Cloud sites within a sandbox before deploying them to production. Delete a Domain You can delete domains from your org, but you can’t delete a domain that is attached to a published site. Deleting Custom URLs You can delete custom URLs from your organization using the Domain Management page. Add a Domain Add a domain and choose how it’s going to be served. EDITIONS Before you add a domain in your org, we recommend evaluating the available domain configuration options. Available in: both Salesforce Classic and Lightning 1. From Setup, enter Domains in the Quick Find box, then select Domains. Experience 2. Click Add a Domain. Available in: Professional, 3. Enter the domain name. Enterprise, Performance, 4. Choose the HTTPS domain configuration option you want to serve this domain with. Optionally, and Unlimited Editions specify a CNAME value if you’re using a non-Salesforce provider to serve your domain. Note: In Professional Edition orgs with Pardot, you must choose Salesforce serves the USER PERMISSIONS domain over HTTPS using a Salesforce content delivery network (CDN) partner. To view a domain: 5. To avoid vulnerabilities during HTTP redirects and to have supported web browsers always use • View Setup and secure HTTPS connections for your domain, select Allow HSTS preloading registration. This Configuration setting adds the preload directive to the HSTS header. After you enable this setting, you To add a domain: must submit your domain at https://hstspreload.org. • Customize Application OR View Setup and Note: This setting applies only to domains that are eligible for HSTS preloading. Domain Configuration plus either names can consist of a public suffix plus one additional label, For example, a Site.com Publisher example.com and example.co.uk are eligible, but www.example.com, license or Create and Set www.example.co.uk, and sub.example.com aren’t eligible. Up Experiences To edit or delete a domain: 6. Add a certificate if you have already set up a CA-signed certificate that supports this domain. • Customize Application 7. Click Save. To add another domain, click Save & New. Salesforce validates ownership based on the fully qualified domain name (FQDN) you use when adding a domain to your org. Salesforce has three different ways to validate an FQDN using the domain name system (DNS). Only one method is required to add the domain to your org. You can find the 18-character org ID at the top of the Domain Edit page. • Your FQDN in DNS is a canonical name (CNAME) record that points to [YourFQDN].[Your18charOrgId].live.siteforce.com. – For example, let’s say you’re adding www.example.com to your org and your 18-character org ID is 00dxx0000001ggceai. The CNAME record in DNS points to www.example.com.00dxx0000001ggceai.live.siteforce.com. – Your domain name must be a CNAME record for Salesforce to serve your domain, except for the special case of a naked domain. 473 Extend Salesforce with Clicks, Not Code Add a Domain • Your FQDN in DNS has a TXT record that equals your 18-character org ID. – After the FQDN is added to your org, you can delete this TXT record because it’s needed only for adding the domain to your org. – This option is useful when setting up a custom domain for an FQDN that points to another service or server with A or AAAA records in DNS. This option allows the domain, its custom URLs, and its sites to be ready to take over the domain’s live service before you update your FQDN record in DNS to a CNAME pointing to [YourFQDN].[Your18charOrgId].live.siteforce.com. • Your FQDN is a subdomain of another domain in your org. – This option is useful when setting up a custom domain for an FQDN that points to another service or server with a CNAME record in DNS. Updating the DNS CNAME to point to [YourFQDN].[Your18charOrgId].live.siteforce.com takes down the existing website until you have the domain fully set up in your org. Instead, you can add the parent domain to your org using the TXT record validation. Then add the FQDN as a subdomain, which automatically validates because it’s now a subdomain of another domain in your org. Your FQDN in DNS updates to point to [YourFQDN].[Your18charOrgId].live.siteforce.com only after you have the domain, its custom URLs, and its sites fully set up in your org. This process gives your web users a smoother transition. With the exception of sandbox orgs, a single FQDN is meant to exist in only one org. In some circumstances, the Salesforce service allows adding an FQDN to more than one org, but that isn’t a supported capability. Before pointing your domain name’s CNAME to a new target name, ensure that the target name exists in the DNS by using dig or nslookup. The target of your CNAME depends on when you create your domain name. • To use HTTPS for domain names added before the Summer ’13 release, adjust your CNAME to point to the FQDN followed by .live.siteforce.com instead of to the org’s force.com subdomain. For example, if your pre-Summer ’13 domain is www.example.com, its CNAME target is www.example.com.live.siteforce.com instead of example.force.com. • Domain names added in Summer ’13 or earlier don’t have the 18-character org ID in the CNAME target. • Domain names added in Summer ’13 or later point to the location for setting up HTTPS in a custom domain. • Domain names added in Winter ’14 or later use a CNAME that points to the FQDN followed by your org’s 18-character ID and .live.siteforce.com. For example, if your domain name is www.example.com and your 18-character org ID is 00dxx0000001ggxeay, its CNAME target is www.example.com.00dxx0000001ggxeay.live.siteforce.com. Every custom domain that you want Salesforce to serve must exist in an org that you control. The FQDN must be a CNAME that points to its own unique [YourFQDN].[Your18charOrgId].live.siteforce.com target or alternative. Configuration errors can prevent your domain from functioning properly. For the changes to take effect, activate the domain after its provisioning status becomes Awaiting Activation. If you receive notice requiring you to enroll in CDN, activate your domain. When setting up HTTPS or renaming a domain, the domain’s live traffic doesn’t use the provisioned HTTPS option or new domain name until the domain is activated. Until activation occurs, the domain’s live traffic uses its previously provisioned HTTPS option and domain name. Important: Salesforce is unable to serve a top-level domain, such as example.com, using the built-in CDN. We can only serve subdomains, such as www.example.com or parts.example.com. If your site needs a top-level domain served from CDN, host it on a CDN outside of Salesforce. Note: Only orgs allowed to use the Salesforce CDN partner HTTPS option must activate changes to a domain. SEE ALSO: Naked Domains 474 Extend Salesforce with Clicks, Not Code Options to Serve a Custom Domain Options to Serve a Custom Domain Salesforce supports multiple options to configure how your domain is served. Whether you serve EDITIONS content for your domain through one of Salesforce’s content delivery networks (CDNs), or an external provider, we strongly recommend using HTTPS. Available in: both Salesforce Each option represents a unique way to configure your domain. Dashed lines in the images represent Classic and Lightning DNS configurations, and solid lines represent user traffic flow through HTTP and HTTPS. Experience Salesforce serves the domain over HTTPS on Salesforce’s servers using your HTTPS Available in: Professional, certificate. Enterprise, Performance, This option requires a CA-signed certificate using Certificate and Key Management for your and Unlimited Editions domain. Use a wildcard or Subject Alternative Name certificate to support all domains hosted by sites in your org. Note: This option is unavailable in Hyperforce orgs. This image represents how user traffic is routed when you use Salesforce to serve your domain with your HTTPS certificate, where: 1. Your custom domain This is the custom domain you want to add to your org. You control the DNS configuration through your DNS vendor. The domain name is also referred to as the fully qualified domain name (FQDN). Point your domain to the Salesforce internal CNAME (2). 2. Salesforce’s internal CNAME When you add a custom domain to your org, Salesforce creates a CNAME for you, so you have a unique, consistent, and reliable DNS entry point to your org. The CNAME is in the format of:[YourFQDN].[Your18charOrgId].live.siteforce.com. [YourFQDN] is the name of your custom domain. [Your18charOrgId] is your unique 18-character org ID, which is found at the top of the Add Domain page. 3. Salesforce secure server This server hosts your HTTPS certificate and creates secure connections for users. 4. Salesforce content Content that Salesforce is hosting for you in Salesforce sites or Experience Cloud sites. Salesforce serves the domain over HTTPS using a Salesforce content delivery network (CDN) partner. This option allows only Experience Cloud sites to be linked to the domain. New custom domains selecting this option use a single certificate. Only one domain is displayed on the certificate. Ten single certificates are available with the purchase of an Experience Cloud license. Contact your account representative if more certificates are needed. 475 Extend Salesforce with Clicks, Not Code Options to Serve a Custom Domain In Summer ’21 and earlier, you could choose to use a shared certificate. Shared certificates aren’t recommended. With Experience Cloud shared certificates for CDN, the certificate that your domain uses is shared with other customers. Also, the list of domains on the same certificate can change at any time and without notice. Important: Professional Edition orgs with Pardot must use this option when serving a custom domain. This image represents how Salesforce routes traffic for a custom domain over a partner CDN network, where: 1. Your custom domain that points to the Salesforce internal CNAME. 2. Salesforce’s internal CNAME that points to the Salesforce CDN partner 3. Salesforce’s content delivery network partner (CDN) User traffic is pointed to the CDN partner, which acts as an intermediary for your Salesforce content. 4. Salesforce content on Experience Cloud sites. Note: If you enable the Experience Cloud CDN feature, this domain uses Akamai, a third-party CDN service, to optimize its content delivery. All information sent to or returned by this domain, which includes data submitted to the domain, web page content returned from the domain, data tables on those pages, images, files, JavaScript code, style sheets, and static resources, are stored and transmitted by Akamai. Akamai can offer different privacy and security protections for such data than that offered by Salesforce. Salesforce isn’t responsible for the privacy and security of the data that is shared with Akamai as a result of your decision to enable this feature. A non-Salesforce host or service serves this domain over HTTPS. This option allows you to serve the domain using a non-Salesforce host or service. Specify the hostname of the external server or host so Salesforce’s CNAME can point to it. Note: Make sure your CDN setup honors origin caching headers. 476 Extend Salesforce with Clicks, Not Code Options to Serve a Custom Domain This diagram represents how Salesforce routes traffic when you use a non-Salesforce host or service to serve your domain, where: 1. Your custom domain that points to the Salesforce internal CNAME. 2. Salesforce’s internal CNAME that points to the non-Salesforce service provider or host. 3. Non-Salesforce host or service Typically, the third-party CDN service or your external server has a hostname (external CNAME). Specify this hostname in the external hostname field on the domain configuration page. 4. Salesforce content on Salesforce sites or Experience Cloud sites. Temporary non-HTTPS domain Salesforce serves your domain using HTTP instead of HTTPS. Attempting to use HTTPS typically displays a certificate mismatch error in the user’s web browser and users can also experience a connection timeout. Note: As a security best practice, we recommend that you select one of the HTTPS options. However, if you’re in the process of configuring DNS or adding a subdomain whose CNAME points to another service, you can select this option. Previously, this option was named Salesforce serves the domain over HTTP without support for HTTPS access. This diagram represents how Salesforce serves your domain and content over HTTP, where: 1. Your custom domain that points to the Salesforce internal CNAME. 2. Salesforce’s internal CNAME that points to a secure Salesforce server. 477 Extend Salesforce with Clicks, Not Code Enable External HTTPS on a Domain 3. Salesforce server, which is secure but it doesn’t host an HTTPS certificate for your custom domain. We don’t recommend using this HTTPS configuration. 4. Salesforce content on Salesforce sites or Experience Cloud sites. Enable External HTTPS on a Domain Enabling External HTTPS lets you tell Salesforce that a non-Salesforce host or service serves your EDITIONS domain. Use this option if you route your domain through your own server or content delivery network (CDN) account instead of routing it through Salesforce. Available in: both Salesforce Note: Before enabling External HTTPS on a domain, note these important considerations. Classic and Lightning Experience • This option is only for domains that use your own server or CDN to serve HTTPS. You can’t set the HTTPS options on domains managed by Salesforce, such as subdomains of Available in: Professional, force.com, my.salesforce-sites.com, and my.site.com. Enterprise, Performance, and Unlimited Editions • To enable a custom domain for testing in a sandbox org and enable HTTPS on it, you must create the custom domain in Salesforce production. See Test Your Custom Domains in a Sandbox. To enable External HTTPS on a domain, click Edit from the domain list page or from a domain’s detail page, and then select A non-Salesforce host or service serves this domain over HTTPS. Dashed lines in diagrams represent DNS configurations, and solid lines represent user traffic flow through HTTP and HTTPS. In this image: 1. Your custom domain To use External HTTPS, configure your domain's CNAME to point to the internal CNAME that Salesforce creates for your domain. Work with your DNS vendor to update your domain’s CNAME. 2. Salesforce’s internal CNAME that points to the non-Salesforce service provider or host. When you add a custom domain to your org, Salesforce creates a CNAME for you, so that you have a unique, consistent, and reliable DNS entry point to your org. The CNAME is in the format of:[YourFQDN].[Your18charOrgId].live.siteforce.com. [YourFQDN] is the name of your custom domain. [Your18charOrgId] is your unique 18-character org ID, shown at the top of the Add Domain page. 3. Non-Salesforce host or service Typically, the third-party CDN service has a unique CNAME. Specify this hostname in the external hostname field in your domain configuration. If you’re hosting the domain yourself, then specify the public hostname of your host. 4. Salesforce content on Salesforce sites or Experience Cloud sites. 478 Extend Salesforce with Clicks, Not Code Enable External HTTPS on a Domain If the domain for which you’re enabling External HTTPS has only Site.com custom URLs unrelated to Experience Cloud sites, manually publish the affected Site.com sites via the Site.com Studio to implement the changes. If at least one Experience Cloud site or a Salesforce site exists on the same domain as a Site.com site related to an Experience Cloud site, publishing the changes to enable External HTTPS is automatic on that domain. For more ways to configure custom domains, see Options to Serve a Custom Domain. Note: To maximize the security of connections to your domain, we recommend that you submit your HTTPS domain for HTTP Strict Transport Security (HSTS) preloading. Enable the Allow HSTS preloading registration setting, then submit your domain at https://hstspreload.org. Caching When caching responses, your CDN must honor the Salesforce Cache-Control response header. Specifically, make sure that your CDN follows these rules when it operates as a reverse-proxy server. • Your CDN must cache responses only when public exists in the Salesforce Cache-Control response header. • If private, no-store, or no-cache exists in the Salesforce Cache-Control response header, the CDN must not cache that response. • To determine the cache duration, the CDN must use s-maxage, if present in the Salesforce Cache-Control response header. If s-maxage isn’t present, then the CDN must use max-age. The CDN must never increase the cache duration, regardless of whether it’s derived from s-maxage or max-age. Request Configuration To use the External HTTPS option, configure your proxy or CDN service so that the requests sent to Salesforce contain the originally requested Host HTTP header. This means that your custom domain name must be used as the Host HTTP header value, which is the domain that users see in their original web browser request. When processing an incoming request without a cached response, your proxy or CDN service must forward (proxy) the request to the Salesforce Host using HTTPS while passing through the incoming request's originally requested Host HTTP header value. If enhanced domains are enabled, forward your proxy or CDN requests to these hostnames, based on your configuration. Hyperforce Target Hostname Yes Your Salesforce Site’s my.salesforce-sites.com subdomain. • Production org example: MyDomainName.my.salesforce-sites.com • Sandbox example: MyDomainName--SandboxName.sandbox.my.salesforce-sites.com No Your org’s instanced URL, in the format InstanceName.force.com. • Production org example: na87.force.com • Sandbox example: cs34.force.com If enhanced domains aren’t enabled, forward your proxy or CDN requests to these hostnames, based on your configuration. Experience Salesforce Target Hostname Cloud sites Sites Yes Yes or no Your Experience Cloud site’s force.com subdomain. • Production org example: ExperienceCloudSitesSubdomain.force.com 479 Extend Salesforce with Clicks, Not Code Enable External HTTPS on a Domain Experience Salesforce Target Hostname Cloud sites Sites • Sandbox example: SandboxName-ExperienceCloudSitesSubdomainName.InstanceName.force.com No Yes Your Salesforce Site’s secure.force.com subdomain or force.com subdomain. • Production org example: SalesforceSitesSubdomain.secure.force.com • Sandbox example: SandboxName-SalesforceSitesSubdomain.InstanceName.force.com No No Your org’s instanced URL, in the format InstanceName.force.com. • Production org example: na87.force.com • Sandbox example: cs34.force.com Tip: You can find your org’s instance name on the Company Information page in Setup. As an example, let’s say you have a custom domain of www.example.com, which is served by an external host or CDN. When a web browser requests https://www.example.com/hello/world, your external host sends the request to Salesforce at https://MyDomainName.my.salesforce-sites.com/hello/world, while setting the Host header to www.example.com. Salesforce then processes the request at MyDomainName.my.salesforce-sites.com as a request for www.example.com with a path of /hello/world. If the Host header isn’t set to a known custom domain, such as if it's set to www.unknown-domain.com, then Salesforce doesn’t process the request properly. SEE ALSO: Manage Domains and Custom URLs Manage Your Domains 480 Extend Salesforce with Clicks, Not Code Naked Domains Naked Domains A naked domain is a domain name server (DNS) name that can’t be a canonical name record EDITIONS (CNAME). An example is hello.com, without the “www” subdomain. You can set up a naked domain in a Salesforce org, but it can require work on your part to maintain and optimize it. Available in: both Salesforce You can’t set a CNAME record on a naked domain because of a DNS limitation. This limitation creates Classic and Lightning complications because normally you would configure your domain’s CNAME to point to your Experience internal Salesforce CNAME, Available in: Professional, [YourFQDN].[Your18CharOrgId].live.siteforce.com. Enterprise, Performance, To bypass this limitation, a few DNS vendors have implemented a CNAME behavior for naked and Unlimited Editions domains to mimic the standard CNAME behavior. If you want to use naked domains, we recommend that you use a DNS vendor that supports this workaround. It makes it easier to maintain your USER PERMISSIONS domain’s DNS configuration by eliminating the need to dynamically monitor and update your naked domain's “A” records. It also avoids unexpected downtime events related to certificate updates To view a domain: or infrastructure adjustments. Plus, this behavior allows each end user around the world to get • View Setup and directed automatically to an IP address that is geographically closest. Configuration This workaround is a relatively new feature. The industry hasn’t agreed what to call it yet, so each To add a domain: vendor has their own proprietary name for it. Here are some examples of vendors that provide this • Customize Application CNAME behavior for naked domains and how they refer to it. OR View Setup and Configuration plus either • Akamai: Zone Apex Mapping a Site.com Publisher • Amazon Route 53: Alias record license or Create and Set Up Experiences • Cloudflare: CNAME Flattening To edit or delete a domain: • Dyn: Alias record • Customize Application • NS1: ALIAS record • UltraDns: Apex Alias There are two different techniques for configuring naked domains based on the functionality provided by your DNS provider. My DNS Provider Supports CNAME Behavior for Naked Domains If your DNS provider supports bypassing the DNS limitation, use their DNS configuration system to point your naked domain to your domain’s internal Salesforce CNAME. Use the format [YourFQDN].[Your18CharOrgId].live.siteforce.com. My DNS Vendor Doesn’t Support CNAME Behavior for Naked Domains If your DNS vendor doesn’t support bypassing the DNS limitation, you must add “A” records for the fully qualified domain name (FQDN) to your DNS. You must also comply with the following requirements. • To add the naked domain to your Salesforce org as a custom domain, you must add a TXT record that contains the 18-character org ID to your DNS. • To use HTTPS with a naked domain, use one of the following options: Salesforce serves the domain over HTTPS, on Salesforce's servers, using your HTTPS certificate or A non-Salesforce host or service serves this domain over HTTPS. – If you use the Salesforce serves the domain over HTTPS, on Salesforce's servers, using your HTTPS certificate option, the IP addresses that you can use in “A” DNS records are enumerated in the Certificate IP Addresses related list on the domain’s certificate. If you change the domain to use another certificate, the IP addresses aren’t the same IP addresses that the previous certificate used. 481 Extend Salesforce with Clicks, Not Code Add a Custom URL – Although the IP addresses of a certificate typically don’t change, they can change when Salesforce adjusts the infrastructure that handles custom HTTPS domains. Periodically monitor the list of IP addresses associated with your certificate and modify your DNS “A” records to stay synchronized with that list. – If you return all the IP addresses of a certificate during DNS lookups, some users of your naked domain probably don’t connect to their closest endpoint. Some DNS services support setting up a global server load balancer (GSLB) configuration with these IP addresses. A GSLB can maximize the performance of your naked domain around the world. If the GSLB includes monitoring, that can prevent or minimize regional outages when the active Salesforce endpoints serving your certificate go down, whether scheduled or unscheduled. • If your naked domain doesn’t use HTTPS, you can use the IP addresses that your org’s Salesforce Sites MyDomainName.my.salesforce-sites.force.com DNS entry resolves to. You can also use the IP addresses that your org’s Experience Cloud sites MyDomainName.my.site.com DNS entry resolves to. These IP addresses change without notice, so monitor your website’s functionality. When changes occur, for example during maintenance, quickly update your naked domain’s DNS “A” records to the new IP addresses. Note: If you’re not using enhanced domains, your org’s Salesforce Sites and Experience Cloud sites URLs are different. For details, see My Domain URL Formats in Salesforce Help. Except for sandbox orgs, a single FQDN is meant to exist in only one org. In some circumstances, the Salesforce service allows adding a single FQDN to more than one org, but that isn’t a supported capability. SEE ALSO: My Domain URL Formats Add a Custom URL Define your domain and site relationships by creating custom URLs, which consist of domains and EDITIONS custom path prefixes. You can use the same path prefix for more than one domain, but not more than once within the Available in: both Salesforce same domain. When adding a custom URL, the first character of the path must be a slash (/) to Classic and Lightning indicate the root. You can extend the path after the slash. For example, if the domain name is Experience https://oursite.com and the path prefix is /products, the site URL is Available in: Professional, https://oursite.com/products. If you add the custom URL to the root, the URL is Enterprise, Performance, https://oursite.com. and Unlimited Editions If you want to set a preferred custom URL for authenticated pages and email that links to the Salesforce site or Experience Cloud site, select Site Primary Custom URL. This option is available USER PERMISSIONS for the root path for Lightning Platform and Experience Clouds sites, but not for Site.com sites. For Experience Cloud sites and Salesforce Sites, if you don’t select a primary URL, the first https To view custom URLs: custom URL in the site, determined alphabetically, is used for authenticated pages and email. If • View Setup and there’s no https custom URL, your Salesforce Sites domain is used. Configuration 1. From Setup, enter Custom URLs in the Quick Find box, then select Custom URLs. To add, edit, and delete custom URLs: 2. Click New Custom URL. • Customize Application 3. Enter a domain name. OR View Setup and Configuration plus either Important: Avoid entering personal information in your domain name. Instead, enter a Site.com Publisher only public information. license or Create and Set Up Experiences 4. Enter a site name. 482 Extend Salesforce with Clicks, Not Code Manage Domains and Custom URLs 5. Enter a unique path. 6. Click Save. Example: In the Custom URLs table, even though the domain name and path are in separate columns, the URLs consist of the combination of the two. Manage Domains and Custom URLs You can add a custom URL to an existing domain, rename a domain, update its HTTPS service EDITIONS option, activate changes to a domain, or delete a custom URL from a particular domain. On the Domain Detail page, you can: Available in: both Salesforce Classic and Lightning • Edit the domain name, HTTPS service option, and certificate—Click Edit in the Domain Detail Experience section. • Delete the domain—Click Delete in the Domain Detail section. Available in: Professional, Enterprise, Performance, • Activate provisioned changes to the domain—Click Activate, if available, in the Domain Detail and Unlimited Editions section. • Add a custom URL—Click New Custom URL. USER PERMISSIONS • Edit a custom URL— Click Edit on a custom URL row. • Delete a custom URL— Click Del on a custom URL row. To view a domain: • View the site if it is published—Click View on a custom URL row. • View Setup and Configuration • Jump to a site—Click the site name below the site label. To add a domain: • Jump to an attached certificate—Click the certificate name next to Certificate and Key. • Customize Application • Check whether the domain has External HTTPS enabled. Only domains that don’t point to the OR View Setup and yourdomain.your18characterOrgId.live.siteforce.com CNAME target Configuration plus either have this option available. a Site.com Publisher license or Create and Set Note: You can’t edit a domain record whose name ends with .force.com, Up Experiences *.my.site.com, or *.salesforce-sites.com. To rename the domain, contact To edit or delete a domain: Salesforce Customer Support. • Customize Application To access the Domain Detail page: 1. From Setup, enter Domains in the Quick Find box, then select Domains. USER PERMISSIONS 2. In the Domain Name column, click the domain name. To view custom URLs: Note: If your domain is set to http and you edit the domain to use https instead, you • View Setup and Configuration must republish the Site.com sites that are attached to the domain and unrelated to Experience Cloud sites. To add, edit, and delete custom URLs: • Customize Application OR View Setup and Configuration plus either a Site.com Publisher license or Create and Set Up Experiences 483 Extend Salesforce with Clicks, Not Code Test Your Custom Domains in a Sandbox Test Your Custom Domains in a Sandbox Develop and test your custom domains for Salesforce Sites and Experience Cloud sites within a EDITIONS sandbox before deploying them to production. Note: Government Cloud, Public Cloud, and Hyperforce orgs are currently excluded from Available in: both Salesforce Custom Domains in Sandbox. Classic (not available in all orgs) and Lightning Experience Set Up Your Sandbox Custom Domain Available in: Enterprise, Create a custom domain and use it for testing Salesforce Sites and Experience Cloud sites in Performance, Unlimited, your sandbox. and Developer Editions Activate Your Custom Domain in Production After developing and testing your custom domains for Salesforce Sites and Experience Cloud sites within a sandbox, deploy them to production. Considerations for Custom Domains in Sandboxes Review how to prevent errors when you refresh, clone, or delete a sandbox associated with a custom domain. Set Up Your Sandbox Custom Domain Create a custom domain and use it for testing Salesforce Sites and Experience Cloud sites in your EDITIONS sandbox. Note: Government Cloud, Public Cloud, and Hyperforce orgs are currently excluded from Available in: both Salesforce Custom Domains in Sandbox. Classic (not available in all orgs) and Lightning Before setting up your custom domain in your sandbox, create the Salesforce Sites and Experience Experience Cloud sites that you want to access from the custom domain in your sandbox. Available in: Enterprise, 1. Create the custom domain in Salesforce production. Performance, Unlimited, a. From Setup in production, enter Domains in the Quick Find Box and select Domains. and Developer Editions b. To add a domain, click Add or, to edit an existing domain, click Edit next to the domain name. USER PERMISSIONS c. On the Domain screen, select an HTTPS option other than the Salesforce CDN. To add a domain: Note: See Enable External HTTPS on a Domain for configuration advice when selecting • View Setup and A non-Salesforce host or service that serves this domain over HTTPS as the Configuration HTTPS Option for your sandbox custom domain. To edit or delete a domain: • Customize Application d. Select your sandbox in the Associated Org field. To view custom URLs: e. Click Save. • View Setup and After you save your changes, the domain is provisioned. Once the provisioning process is Configuration complete, you receive an email and the domain status changes to Awaiting Activation. To add, edit, and delete custom URLs: 2. To finish adding your custom domain, activate the provisioned custom domain. • Customize Application a. From Setup in production, enter Domains in the Quick Find Box and select Domains. If OR View Setup and Configuration plus either the provisioning process is complete, your custom domain’s status is Awaiting Activation. a Site.com Publisher b. Click Activate next to your custom domain. license or Create and Set Up Experiences 484 Extend Salesforce with Clicks, Not Code Test Your Custom Domains in a Sandbox 3. Log in to the sandbox to finish updating the sandbox Saleforce Sites and Experience Cloud sites domains. a. From Setup in your sandbox org, enter Custom URLs in the Quick Find Box and select Custom URLs. b. Click New Custom URL. c. On the Custom URL screen, select your custom domain in the Domain field. d. Optional: specify a path in the Path field. e. Select your Salesforce Site or Experience Cloud site in the Sites field. f. Click Save. Your custom domain is ready for testing. Once you complete your testing, you can activate the custom domain in production. SEE ALSO: Enable External HTTPS on a Domain Setting Up Salesforce Sites Set Up an Experience Cloud Site Activate Your Custom Domain in Production Activate Your Custom Domain in Production After developing and testing your custom domains for Salesforce Sites and Experience Cloud sites EDITIONS within a sandbox, deploy them to production. Before activating your custom domain in production, Set Up Your Sandbox Custom Domain on Available in: both Salesforce page 484 and complete testing. Also, create the Salesforce Sites and Experience Cloud sites that Classic (not available in all you want to access from the custom domain in production. orgs) and Lightning Experience 1. Update the custom domain. a. From Setup in production, enter Domains in the Quick Find Box and select Domains. Available in: Enterprise, Performance, Unlimited, b. Select Add to add a domain or Edit to edit an existing domain. and Developer Editions c. On the Domain screen, select an HTTPS option other than the Salesforce CDN. d. Select your Production in the new Associated Org field. USER PERMISSIONS e. Click Save. To add a domain: After you save your changes, the domain is provisioned. Once the provisioning process is • View Setup and complete, you receive an email and the domain status changes to Awaiting Activation. Configuration To edit or delete a domain: 2. Update your production Salesforce Sites and Experience Cloud sites domains. • Customize Application Custom URLs a. From Setup in your production org, enter in the Quick Find Box and select To view custom URLs: Custom URLs. • View Setup and b. Click New Custom URL. Configuration c. On the Custom URL screen, select your custom domain in the Domain field. To add, edit, and delete custom URLs: d. Optional: specify a path in the Path field. • Customize Application e. Select your Salesforce Site or Experience Cloud site in the Sites field. OR View Setup and Configuration plus either f. Click Save. a Site.com Publisher license or Create and Set Up Experiences 485 Extend Salesforce with Clicks, Not Code Test Your Custom Domains in a Sandbox Note: To create Custom URLs with different paths for other Salesforce Sites and Experience Cloud sites, repeat this step. 3. Activate the provisioned custom domain. a. From Setup in production, enter Domains in the Quick Find Box and select Domains. If the provisioning process is complete, your custom domain’s status is Awaiting Activation. b. Click Activate next to your custom domain. SEE ALSO: Setting Up Salesforce Sites Set Up an Experience Cloud Site Considerations for Custom Domains in Sandboxes Review how to prevent errors when you refresh, clone, or delete a sandbox associated with a custom EDITIONS domain. Available in: both Salesforce Feature Exclusions Classic (not available in all orgs) and Lightning Government Cloud, Public Cloud, and Hyperforce orgs are currently excluded from Custom Domains Experience in Sandbox. Available in: Enterprise, Performance, Unlimited, Sandbox Refreshes from Production and Developer Editions When you refresh a sandbox from its owning production Salesforce org, the custom domain remains associated with the sandbox in a provisioned but inactive state. After you activate the refreshed sandbox, log in and validate the sandbox Salesforce Sites and Experience Cloud sites domains from the Custom URLs Setup page. Cloning a Sandbox You can create a sandbox by cloning an existing sandbox rather than using your production org as the source. When you activate a cloned sandbox, any custom domains associated with the sandbox remain associated with the inactive source sandbox. Until it’s reassociated with the cloned sandbox, any calls to the custom domain return an error. To associate your custom domain with the cloned sandbox, after the cloned sandbox is activated, log in to your production org. From the Domains Setup page, edit the custom domain and change the associated org to an org other than your sandbox. Save your changes and activate the domain. Then edit the custom domain again, and update the associated org to your sandbox. Save and activate your domain. After you reactivate the custom domain for your sandbox, log in to the sandbox and validate the sandbox Salesforce Sites and Experience Cloud sites domains from the Custom URLs Setup page. Custom Domains Pointing to a Sandbox Experience Builder Site You must republish sandbox Experience Builder sites after refreshing or cloning a sandbox. Calls to a custom domain pointing to an Experience Builder site return an error until the site is published. 486 Extend Salesforce with Clicks, Not Code Delete a Domain Deleting a Sandbox Before deleting a sandbox, log in to production and associate any custom domains for that sandbox with a different org. If you don’t update the domain in production, calls to the custom domain URL return an error. SEE ALSO: Create, Clone, or Refresh a Sandbox Delete a Domain You can delete domains from your org, but you can’t delete a domain that is attached to a published EDITIONS site. Remove all custom URLs from the domain before you delete it. For Lightning Platform sites and Available in: both Salesforce Experience Cloud sites, the domain is deleted immediately, and users no longer have access to any Classic and Lightning site connected to that domain. For Site.com sites unrelated to Experience Cloud sites, the domain Experience remains active until you republish or unpublish the site. Available in: Professional, 1. From Setup, enter Domains in the Quick Find box, then select Domains. Enterprise, Performance, and Unlimited Editions 2. Next to the domain name, click Del. 3. Click OK. USER PERMISSIONS When you delete a domain with an unpublished site attached, it also deletes the custom URL associated with that site. To delete domains: • Customize Application SEE ALSO: Manage Your Domains 487 Extend Salesforce with Clicks, Not Code Deleting Custom URLs Deleting Custom URLs You can delete custom URLs from your organization using the Domain Management page. EDITIONS You can’t delete a URL that is attached to a published site. You’ll need to unpublish the site attached to the custom URL before you can delete it. For Lightning Platform sites, the URL is deleted Available in: both Salesforce immediately, and users no longer have access to any site connected to that URL. But with Site.com Classic and Lightning sites, the URL remains active until you republish the site. Experience To delete a URL from a domain: Available in: Professional, 1. From Setup, enter Custom URLs in the Quick Find box, then select Custom URLs. Enterprise, Performance, and Unlimited Editions 2. Click Del next to the URL name. 3. Click OK. USER PERMISSIONS SEE ALSO: To view custom URLs: • View Setup and Manage Your Domains Configuration To add, edit, and delete custom URLs: • Customize Application OR View Setup and Configuration plus either a Site.com Publisher license or Create and Set Up Experiences Build Your Own Web Site You can use Experience Builder or Salesforce Sites to build out your Salesforce organization with custom pages and apps. Site.com Site.com is a web content management system (CMS) that makes it easy to build dynamic, data-driven web pages quickly, edit content in real time, and manage your websites. Salesforce Sites Salesforce Sites enables you to create public websites and applications that are directly integrated with your Salesforce organization—without requiring users to log in with a username and password. You can publicly expose any information stored in your organization through a branded URL of your choice. And you can make the site's pages match the look and feel of your company’s brand. 488 Extend Salesforce with Clicks, Not Code Site.com Site.com Site.com is a web content management system (CMS) that makes it easy to build dynamic, EDITIONS data-driven web pages quickly, edit content in real time, and manage your websites. Note: If you’re a new customer who’d like to create a site, portal, or community, Communities Available in: Salesforce are a great way to share information and collaborate with people outside your company, Classic (not available in all such as customers, partners, or employees. See Set Up and Manage Experience Cloud Sites orgs) to learn more. Available for purchase in: From the Site.com tab in the Site.com app, you can launch Site.com Studio, which provides a Enterprise, Performance, separate, dedicated environment for creating and editing pixel-perfect, custom websites. Site and Unlimited Editions administrators and designers can create and style web pages, and add features such as navigation Available (with limitations) menus, images, and text areas using drag-and-drop page elements, while ensuring the site's pages in: Developer Edition match the look and feel of the company's brand. And content contributors, such as marketing users, can browse and update website content directly in a simplified Site.com Studio environment. Additionally, websites built with Site.com benefit from running on Salesforce’s trusted global infrastructure. Note: The features available in Site.com Studio vary depending on whether you're a site administrator, designer, or contributor. The following examples illustrate a few ways to use Site.com: • Create an event site—Advertise upcoming events, such as grand openings, launches, or sales kick-offs on a public event site. • Promote new products—Launch new products into the market with a promotional website that helps drive sales. • Publish a support FAQ—Provide helpful information on a public website where customers can view solutions to their issues. • Create microsites and landing pages—Create temporary landing pages or targeted microsites for marketing campaigns. • Create a recruiting website—Post job openings to a public site and allow visitors to submit applications and resumes. • Publish a catalog of products—List all of your company's products on a public website, with model numbers and current prices pulled dynamically from your organization. • Post company press releases—Publish your company’s press releases and sort by publication date. System Requirements To use Site.com Studio, we recommend: • Mozilla® Firefox® or Google® Chrome for best performance. Note: Microsoft® Edge is supported, but it is strongly recommended that you do not use Internet Explorer®. • Disabling the Firebug extension for Firefox, if installed, as it can impact performance. • A minimum browser resolution of 1024x768. About Site.com Feature Licenses Planning and Implementing a Site.com Website Create a Site.com Community Creating a Site.com Site Importing and Managing Assets Editing Site.com Pages as a Designer or Site Administrator Site.com Page Elements 489 Extend Salesforce with Clicks, Not Code Site.com Setting Up the Contributor’s Studio View Control what your contributors can do in Site.com Studio. Cascading Style Sheets Overview Site Branding Overview Branding provides a flexible way for you to define different aspects of your website’s brand. Once branding properties are defined, your editors can easily customize everything in one centralized place, the Branding Editor. When your website editors customize the properties, they get a preview of their branding changes immediately. Custom Site Properties Overview With custom site properties, you can define and store frequently occurring content on your site. For example, you can store your address and phone number as a custom property so that it can be reused by anyone who is editing your site. You can apply stored properties to pages, headers and footers, and widgets quickly by using expression language syntax. Site.com Data Services Overview Site.com data services combine many features that let you connect to standard and custom Salesforce objects. Retrieve data from your organization’s objects and dynamically display it on your site pages, or alternatively, gather and submit data from your customers. And when you update data in your Salesforce object, the changes are reflected automatically on the live site—no site updates required! Widgets Overview Widgets let you save time by building custom page elements that you and your team can reuse throughout the site. Multilingual Sites Overview Site.com Studio lets you to create different language versions of your site. And because all languages are maintained within the site, you don’t need to create and manage a separate site for each language. Content Lists and Categories Overview Events Overview Understanding the Contributor’s Page Editing View Previewing How Pages Appear on Mobile Devices With live mode, site administrators, designers, and contributors can preview how pages and templates appear on devices such as cell phones and tablets. Previewing Site.com Sites Site.comIP Restrictions Overview Managing Domains in Site.com Before you can publish your site to the Internet, you must set the site's domain information. SEE ALSO: Setting Up Site.com Users Planning and Implementing a Site.com Website Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor 490 Extend Salesforce with Clicks, Not Code Site.com About Site.com Feature Licenses To access Site.com, each user in your organization must have a Site.com feature license. EDITIONS • The Site.com Publisher feature license allows the user to access Site.com Studio to create and style websites, control the layout and functionality of pages and page elements, and add and Available in: Salesforce edit content. Classic (not available in all • The Site.com Contributor feature license allows the user to access Site.com Studio to edit site orgs) content only. Available for purchase in: Consider what your users need to do in a site and purchase feature licenses accordingly. See the Enterprise, Performance, Site.com feature table for a complete list of the capabilities that come with each feature license. and Unlimited Editions After you purchase feature licenses, you can set up Site.com users. Available (with limitations) in: Developer Edition You can view the number of assigned feature licenses on your organization's profile. Note: Organizations using Performance, Unlimited, or Enterprise Editions must purchase Site.com Publisher and Site.com Contributor feature licenses separately. Additionally, a Site.com Published Site license is required for each site that’s published to the Internet. For information on purchasing Site.com licenses, contact Salesforce. Developer Edition organizations contain two Site.com Publisher feature licenses and one Site.com Contributor feature license. Developer Edition organizations can’t publish sites. Communities users with the “Create and Set Up Communities” permission are assigned the role of site administrator in a community’s Site.com site. To let users who don’t have this permission edit the site, you must purchase and assign a Site.com Publisher or a Site.com Contributor feature license. Then you must assign a user role at the site level. Setting Up Site.com Users About Site.com User Roles Managing Site.com Users and Roles About Site.com Features SEE ALSO: About Site.com User Roles Managing Site.com Users and Roles 491 Extend Salesforce with Clicks, Not Code Site.com Setting Up Site.com Users Before users can access Site.com, you must allocate a Site.com feature license to each user and EDITIONS assign a user role at the site level. The features available when editing a site in Site.com Studio vary depending on these settings. Available in: Salesforce First, review the Site.com feature table for detailed information on the feature license, permissions, Classic (not available in all and role required for each user. orgs) After you’ve determined the appropriate access level required: Available for purchase in: 1. Allocate a feature license to the user by editing the user’s profile. To allocate: Enterprise, Performance, and Unlimited Editions • A Site.com Publisher feature license, select the Site.com Publisher User Available (with limitations) checkbox. in: Developer Edition • A Site.com Contributor feature license, select the Site.com Contributor User checkbox. After you allocate a feature license, users can access Site.com in the Lightning Platform app USER PERMISSIONS menu in the Salesforce header. To create or edit users: Note: If the checkboxes don't appear, verify that Site.com is enabled for your organization. • Manage Internal Users See About Site.com Feature Licenses on page 491. 2. Ensure the “View Setup and Configuration” permission is enabled. All users who create or edit websites in Site.com Studio need this permission. 3. Additionally, ensure that at least one user in your organization has both a Site.com feature license and the “Manage Users” permission. This way, someone can always reallocate user roles if a site’s users are accidentally deleted. Warning: The “Manage Users” permission is powerful. It allows a user to manage all other users in your organization and not just Site.com. 4. Add users and assign user roles within a site. (When a user with the Site.com Publisher feature license creates a site, the user is automatically allocated the role of site administrator at the site level.) The feature license, permissions, and user role all determine what a user can do in each site. For example, to create an administrative user who can manage all sites in your organization, assign a Publisher feature license and assign the role of site administrator at the site level. For users who need only limited access to edit site content, but no administrative access, assign a Contributor feature license and a contributor role at the site level. Alternatively, to create a user who can manage roles in a site, but without the ability to publish, assign a Publisher feature license, the “Manage Users” permission, and the designer role at the site level. Note: Any records created by unauthenticated guest users via a Site.com Site has the Site Guest User as the record's owner. Each site has one Site Guest User. SEE ALSO: About Site.com User Roles 492 Extend Salesforce with Clicks, Not Code Site.com About Site.com User Roles Each Site.com user must have a user role assigned at the site level, which controls what each user EDITIONS can do in a site. Users can have only one role per site, but their roles can vary between sites. For example, a person can be a site administrator on one site and a contributor on another. Available in: Salesforce To manage user roles in a site, you must either be the site administrator for that site, or have a Classic (not available in all Site.com feature license and the “Manage Users” permission. orgs) Note: Users with the “Create and Set Up Experiences” permission are assigned the role of Available for purchase in: site administrator in a community’s Site.com site. However, they don’t appear in the User Enterprise, Performance, Roles section on the Overview tab of Site.com Studio. and Unlimited Editions Users can have one of three roles at the site level: Available (with limitations) in: Developer Edition • Site administrator—Site administrators are users who can create and manage all site content. They can create sites, templates, style sheets, and pages, and also set up domains, publish sites, and assign user roles. This role requires the Site.com Publisher feature license. • Designer—Designers have the same control over site content as site administrators, but they can’t manage domains or publish sites. By default, they can’t assign roles unless they have the “Manage Users” permission. This role requires the Site.com Publisher feature license. • Contributor—Contributors have the most restricted access to content and can typically just edit page text and images. By default, they can’t assign roles unless they have the “Manage Users” permission. This role requires the Site.com Contributor feature license. See the Site.com feature table on page 495 for a detailed list each user role’s capabilities. SEE ALSO: Managing Site.com Users and Roles Setting Up Site.com Users Setting Up the Contributor’s Studio View About Site.com Feature Licenses 493 Extend Salesforce with Clicks, Not Code Site.com Managing Site.com Users and Roles After you create a site, you can add other users and assign roles to them. If you haven’t assigned EDITIONS Site.com feature licenses to your users, you won’t be able to add them to a site. Note: Communities users with the “Create and Set Up Communities” permission are assigned Available in: Salesforce the role of site administrator in a community’s Site.com site. However, they don’t appear in Classic (not available in all the User Roles section on the Overview tab of Site.com Studio. orgs) When assigning a user role, be sure to add one that’s compatible with the user’s Site.com license. Available for purchase in: When users log into Site.com, their licenses are checked against the role assigned to them at the Enterprise, Performance, site level. If the license doesn’t allow the permissions associated with the role, then the user is given and Unlimited Editions the permissions associated with the license. For example, if a user has a Site.com Contributor feature Available (with limitations) license, but is assigned a role of site administrator, they will only have Contributor permissions in: Developer Edition regardless of the assigned role. To add users and assign roles: USER PERMISSIONS 1. On the Overview tab in Site.com Studio, click Site Configuration > User Roles. To manage Site.com users: 2. Click Add Users. • Site.com 3. In the Available Users section, highlight the user you want to add. Publisher User field enabled on the user 4. Select the role from the Add as drop-down list. detail page 5. Click the arrow to move the user to the Selected Users section. AND 6. Click Save. Site administrator role To delete users: assigned at the site level 1. In the User Roles view, select the user. 2. Click > Remove. 3. Click OK. To change a user’s role: 1. In the User Roles view, hover over the user’s role. 2. Click the arrow to display all the roles. 3. Select the new role. To delete or change the role of a group of users at the same time, use Bulk Actions. 1. In the User Roles view, select the check box beside each user’s name. 2. Click Bulk Actions. 3. Select the action. 4. Click Apply. 494 Extend Salesforce with Clicks, Not Code Site.com Note: When updating the roles of several users at once, you can only assign the same role to all selected users. SEE ALSO: Setting Up Site.com Users Setting Up the Contributor’s Studio View Planning and Implementing a Site.com Website About Site.com Features About Site.com Features The features available when editing a site in Site.com Studio vary depending on your Site.com EDITIONS feature license and also your user role for that particular site. This table lists the required feature licenses, permissions, and roles for many of the Site.com Studio Available in: Salesforce features. Classic (not available in all orgs) Note: Available for purchase in: • Communities users with the “Create and Set Up Communities” permission are assigned Enterprise, Performance, the role of site administrator in a community’s Site.com site. and Unlimited Editions • You can’t create, delete, or duplicate community sites in Site.com. Available (with limitations) in: Developer Edition Site.com Studio Feature Requirements Feature Feature Site.com Studio User Permissions License Role Assign feature license to user “Manage Internal profile Users” Add users and roles at the site Publisher Site administrator Additionally, any level user with a Site.com feature license and the “Manage Users” permission. Enable contributors to create Publisher Site administrator or pages, add content blocks and designer widgets, and edit content blocks and graphics Create websites Publisher Users who create a site are automatically added to that site as a site administrator. Delete websites Publisher Site administrator or designer Import websites Publisher Users who import a site are automatically added to the 495 Extend Salesforce with Clicks, Not Code Site.com Site.com Studio Feature Requirements Feature Feature License Site.com Studio User Role Permissions new site as a site administrator. Export websites Publisher Site administrator or designer Duplicate websites Publisher Site administrator or designer Manage domains Publisher Site administrator (Unavailable for Developer Edition) Add and edit IP restrictions Publisher Site administrator Publish changes to the live website Publisher Site administrator (Unavailable for Developer Edition) Create page templates Publisher Site administrator or designer Create website pages Publisher or Site administrator or designer Contributor Contributor only if enabled by the site administrator or designer in the page template’s Properties pane. Create and modify style sheets Publisher Site administrator or designer Modify layout and design Publisher Site administrator or designer Add page elements Publisher or Site administrator or designer Contributor Contributor can add content blocks and widgets only if enabled by the site administrator or designer. Add data repeaters and other data-bound page Publisher Site administrator or designer elements Modify the Guest User profile to set public Publisher Site administrator or designer “Manage Profiles and access permissions to Salesforce objects Permission Sets” and “Customize Application” Import assets, such as images and files Publisher or Any assigned role Contributor Edit content and images Publisher or Site administrator or designer Contributor Contributor only if enabled by the site administrator or designer in the page template’s Properties pane. Preview website pages Publisher or Any assigned role Contributor 496 Extend Salesforce with Clicks, Not Code Site.com Planning and Implementing a Site.com Website There are many approaches to building a website. The process that best suits you depends on many EDITIONS factors, such as the size of your team and the tasks you're responsible for. If you're a site administrator or designer, you may be involved in every stage, including adding and Available in: Salesforce maintaining the site's content. Alternatively, you may have contributors who add, edit, and maintain Classic (not available in all this content. And if you're a contributor, you may be responsible for editing and updating all of the orgs) site's content, or you may work with other contributors, designers, and site administrators to bring Available for purchase in: the site to completion. Enterprise, Performance, This topic describes the various stages involved in creating a site with Site.com. and Unlimited Editions • Plan the Site Design and Page Layout (Site administrator or designer)—Before building the Available (with limitations) pages of the site, spend time planning the site design and basic layout. This stage is key to in: Developer Edition ensuring a consistent look and feel with the minimum amount of effort. From a hierarchical point of view, think about how many pages you need and whether they'll have subpages. Also consider how you want site visitors to navigate around your site. USER PERMISSIONS Next, plan the layout of the pages and identify the common elements that every page will have. To create or import Site.com In this example, the site has a header section that includes the company's logo and menu (1), sites: and a footer section (2). However, the main section of the home page (3) differs from the rest • Site.com of the site pages (4). Take note of these similarities and differences, because they will affect Publisher User how you create your site pages. field enabled on the user detail page To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level To edit only content in Site.com sites: • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level 497 Extend Salesforce with Clicks, Not Code Site.com • Create the Site (Site administrator or designer)—Once you've completed the planning stage, you're ready to get started! Log into the Site.com app and go to the Site.com tab, where you can create your first site. Your new blank site opens in Site.com Studio, a powerful environment for building the pages of your site. Note: Only users with the Site.com Publisher User field enabled on their user detail page can create and import sites. • Import Assets (Site administrator or designer)—If you're working with a design agency, they may provide all of the files and assets you need, including a CSS style sheet. If you've created your own design, cut up the design and collect the assets, images, and files you plan to use in the site. Import the assets into Site.com Studio, where they appear in the Assets section of the Overview tab. • Create a Page Template (Site administrator or designer)—Once you've decided on the layout, the quickest and most effective method is to use page templates to build the basic layout and then base your site pages on it. Try to keep the design of your main page template simple to make it easier to modify in the future. For more complicated site designs, such as the example graphic, you can use the main page template as the basis for a child template to achieve maximum flexibility. When you create your page template, you can choose from predesigned layouts that include headers, footers, and columns, or you can create a blank page template. • Lay Out the Page (Site administrator or designer)—After you create the page template, you can modify the layout further to match the design of your site. • Create the Site Pages (Site administrator or designer)—Using the template as a base, you can quickly create the site pages, which automatically inherit all the elements of the page template. Or if you need a standalone page that doesn't follow the site's overall design, you can create a blank page instead. • Add Features and Page Elements (Site administrator or designer)—Use Site.com's prebuilt page elements to add features such as navigation menus, images, and data services, and include content blocks that contributors can edit. And add interactive, animated effects using events and actions. • Make Your Website Look Good (Site administrator or designer)—Take advantage of cascading style sheets (CSS) to develop the look and feel of your website. If you're not completely up to speed with CSS, the Style pane provides an easy, visual way to create and manage styles. Or if you're a CSS expert who likes to get straight into the code, you can hand-code the site's style sheets. • Add and Edit Content (Contributor)—At this stage, if you're a contributor, the site is usually ready for you to add and edit content such as text, images, videos, and hyperlinks. And as you work, you can upload any images or files you need. • Review and Test the Site (Contributor, designer, or site administrator)—Testing the changes to the pages of your site happens throughout the development cycle. As a contributor, designer, or site administrator, you should always preview your changes to ensure they display as expected in a browser. And if you're a site administrator or designer, you can send a preview link to the site's reviewers so they can review the finished product before it goes live. • Publish the Site (Site administrator only)—After testing is complete, you're ready to go live with your new site. Just set the site's domain information and then publish your changes to make your site live! Site.com Tab Overview 498 Extend Salesforce with Clicks, Not Code Site.com Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor Understanding the Site Administrator and Designer's Overview Tab Understanding the Contributors's Overview Tab SEE ALSO: Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor Setting Up the Contributor’s Studio View 499 Extend Salesforce with Clicks, Not Code Site.com Site.com Tab Overview If you can't see the Site.com tab, go to the Site.com app. It's available in the Lightning Platform app EDITIONS menu in the Salesforce header. Then click the Site.com tab to view the list of your Site.com sites. From this page you can: Available in: Salesforce • Click New to create or import a site. Only users with the Site.com Publisher User Classic (not available in all field enabled on their user detail page can create and import sites. orgs) • Filter the sites you see by selecting a predefined list from the drop-down list. My Sites shows Available for purchase in: the sites you can access and your role. All Sites shows all the sites in your organization even if Enterprise, Performance, you don’t have access to some of them. and Unlimited Editions • Click Edit next to a site to open it in Site.com Studio. Available (with limitations) • Click Preview next to a site to see how it looks when rendered in a browser window. in: Developer Edition • Click next to a site to duplicate, export, or delete it. Only users with the Site.com Publisher User field enabled on their user detail page and the role of site administrator USER PERMISSIONS or designer can duplicate, export, and delete sites. If a site has been published, you can't delete it until you take it offline. To create or import Site.com • See the status of your site. sites: • Site.com – In Development—The site has never been published. Publisher User – Published—The site has been published at least once. field enabled on the user detail page • Click the title of any column to sort your site list. By default, sites are sorted by name. To build, edit, and manage Note: You can’t create, delete, or duplicate community sites in Site.com. Site.com sites: • Site.com Publisher User SEE ALSO: field enabled on the user detail page Using Site.com Studio as a Site Administrator or Designer AND Using Site.com Studio as a Contributor Site administrator or Planning and Implementing a Site.com Website designer role assigned at the site level To edit only content in Site.com sites: • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level 500 Extend Salesforce with Clicks, Not Code Site.com Using Site.com Studio as a Site Administrator or Designer Site.com Studio provides a dedicated site-building environment for site administrators and designers. EDITIONS Using the many features available, you can: • Create page templates to base your site pages on. Available in: Salesforce • Create site pages. Classic (not available in all orgs) • Import assets, such as images and files. • Edit the site’s style sheet or create new style sheets. Available for purchase in: Enterprise, Performance, • View and edit a page or template. and Unlimited Editions • Add page elements to your site pages to provide features and functionality. Available (with limitations) • Use data services to connect to Salesforce objects to retrieve and display, or to submit data. in: Developer Edition • Create custom widgets that you and other users can reuse throughout the site. • Create a multilingual site that lets site visitors choose their preferred language. USER PERMISSIONS • Create events to add interactive and animated effects to your website. • Add IP restrictions to control site visitors’ access to the pages, page templates, folders, and To build, edit, and manage sites Site.com sites: assets in your site. • Site.com • Add URL redirects to inform users and search engines if site content has moved. Publisher User • Create folders to organize your site content. field enabled on the user detail page • Preview your site or generate an anonymous preview link to send to other users. AND • Manage the domain information for your site. Site administrator or • Publish your recent changes to the live site. designer role assigned • Duplicate, import, and export sites. at the site level Note: To manage domains and • Designers can’t manage domains or publish content. publish Site.com sites: • Site.com • You can’t create, delete, or duplicate community sites in Site.com. Publisher User field enabled on the user detail page SEE ALSO: AND Understanding the Site Administrator and Designer's Overview Tab Site administrator role Planning and Implementing a Site.com Website assigned at the site level Setting Up the Contributor’s Studio View Site.com Tab Overview 501 Extend Salesforce with Clicks, Not Code Site.com Using Site.com Studio as a Contributor Site.com Studio provides a dedicated content-editing environment for contributors, where you EDITIONS can: • Open a page to edit it. Available in: Salesforce • Create site pages, if your site administrator or designer has enabled page creation. Classic (not available in all orgs) • Edit the page text. • Add images and hyperlinks to pages. Available for purchase in: Enterprise, Performance, • Add page elements to pages. and Unlimited Editions • Import assets, such as images and files. Available (with limitations) • Preview the site in a browser window. in: Developer Edition SEE ALSO: USER PERMISSIONS Understanding the Contributors's Overview Tab Planning and Implementing a Site.com Website To edit only content in Site.com sites: Site.com Tab Overview • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level 502 Extend Salesforce with Clicks, Not Code Site.com Understanding the Site Administrator and Designer's Overview Tab As a site administrator or designer, when you open a site in Site.com Studio, it opens on the Overview EDITIONS tab. Here you can access and manage the site’s components and configure the site’s properties. Available in: Salesforce Classic (not available in all orgs) Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition USER PERMISSIONS To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level To manage domains and publish Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator role assigned at the site level To manage user roles: • Site.com Publisher User field enabled on the user detail page AND Site administrator role assigned at the site level OR Manage Users 503 Extend Salesforce with Clicks, Not Code Site.com • Select a view (1) on the Overview tab to view its contents (2). – All Site Content—Create folders to organize your site content. In this view, you can also create pages, templates, and style sheets, and import assets. – Site Pages—Create site pages, open and edit pages, access page options, create site map links, and organize the site map. You can also switch between the default site map view ( ) and the list view ( ). – Page Templates—Create page templates to base your site pages on, open and edit existing templates, and access template options. – Style Sheets—Edit the site’s style sheet or create new style sheets. – Assets—Import and manage assets, such as images and files. – Widgets—Build custom widgets that can you and your team can reuse throughout the site. – Trash Can—Retrieve deleted items. When you delete a page, template, style sheet, or asset, it goes into the trash can. Deleted items remain in the trash can indefinitely. Retrieved items are restored to their original location. If the original location no longer exists, they are restored to the top-level root directory. – Change History—View information about recently published files. – Site Configuration—Configure site properties, add IP restrictions, create URL redirects, manage domain information, manage user roles, and add and manage site languages. • Use the toolbar (3) to: – Import assets, such as images and files. – Publish recent changes. – Preview your site or generate an anonymous preview link to send to other users. – Duplicate or export the site, overwrite the site with a version from sandbox, or create a new site ( ). • Use the site's pull-down menu (4) to: 504 Extend Salesforce with Clicks, Not Code Site.com – Open recently accessed sites. – View Site.com Studio as your contributors see it to ensure that you set up the view correctly. – Exit Site.com Studio and return to Salesforce. – Create a new site. – Duplicate the site. Note: You can’t create, delete, or duplicate community sites in Site.com. SEE ALSO: Using Site.com Studio as a Site Administrator or Designer Planning and Implementing a Site.com Website Site.com Understanding the Contributors's Overview Tab As a contributor, when you open a site in Site.com Studio, it opens on the Overview tab. Here you EDITIONS can access and edit the site’s pages and content, and import images and files. Available in: Salesforce Classic (not available in all orgs) Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition USER PERMISSIONS To edit only content in Site.com sites: • Site.com Contributor User field enabled on the user detail page AND Contributor role assigned at the site level 505 Extend Salesforce with Clicks, Not Code Site.com • Select a view (1) on the Overview tab to view its contents (2). – All Site Content—View all of the site’s pages, images, and files. – Site Pages—View and edit pages or create site pages, if available. – Assets—Import assets, such as images and files. – Site Configuration—Manage user roles in the site. This is available only if you have the “Manage Users” perm. • Use the toolbar (3) to: – Import assets, such as images and files. – Preview the site in a browser window. • Use the site's pull-down menu (4) to: – Open recently accessed sites. – Exit Site.com Studio and return to Salesforce. SEE ALSO: Using Site.com Studio as a Contributor Site.com Create a Site.com Community Each community has one associated Site.com site that lets you add custom, branded pages to your community. By default, Site.com pages are publicly available and don’t require login, but you can also create private pages that only community members can access. Note: As of Spring ’15, the Community Template is no longer available for creating communities. If you already have a Site.com community that’s based on the Community Template, it will continue to work. For information on creating a community with a new Lightning Community template, see Create an Experience Cloud Site. 506 Extend Salesforce with Clicks, Not Code Site.com Before You Begin Communities users with the “Create and Set Up Communities” permission automatically have full site administrator access to a community’s Site.com site. To let users who don’t have the permission edit the site, you must purchase and assign a Site.com Publisher or a Site.com Contributor feature license. And then you must assign a user role at the site level. See About Site.com User Roles on page 493. Tips and Considerations • Users with the “Create and Set Up Experiences” permission are assigned the role of site administrator in a community’s Site.com site. However, they don’t appear in the User Roles section on the Overview tab of Site.com Studio. • You can’t create, delete, or duplicate community sites in Site.com. • When working with data-bound components, such as data repeaters and forms, keep in mind that the objects listed may not be available to site visitors. For authenticated visitors, their user profiles control object access on public and private pages. For unauthenticated visitors, the site’s guest user profile controls object access on public pages. • When adding forms to authenticated community pages in Site.com, set the current user for Salesforce objects that require the Owner ID field. Setting the current user (as opposed to the default guest user) lets you identify the authenticated user when the form is submitted. To set the current user for the Owner ID field, select the field in the form, and click Configure. Under Field Properties in the Properties pane, select Global Property as the source, and select Current userID as the value. • The home page, 404 page, login page, and self-registration page that you specify for Site.com Community sites in Site Configuration set the default pages for the Site.com Community site. These default URLs are used unless you specify different URLs in Community Management under Administration Pages and Administration Login & Registration . Community error pages are specified in Lightning Platform Setup, under Error Pages. • When your Site.com Community site is inactive, users are redirected to the Service Not Available page defined in Community Management under Pages. • The contributor’s view is not available by default for Site.com Community sites. However, you can use a Site.com Contributor license to grant contributor access to a specific user. See About Feature Licenses in the Site.com help for details. Alternatively, a user can preview the Site.com Community site as a contributor by appending ?iscontrib to the site’s URL. For example: MyDomainName.builder.salesforce-experience.com/?iscontrib Use Site.com to Customize Your Community Create Branded Pages Overview When you create a Community site, Salesforce automatically creates a new Site.com site and associates it with your community. Site.com Authorization Overview Display Current Community User Information Site.com designers creating authenticated pages for a community site can display the current user’s information by accessing CurrentUser namespace expressions. Expressions Available for Displaying Current User Information Determine the URL of a Site.com Page Add Authenticated Site.com Pages to Community Tabs After you create a private Site.com page, you can add the page to a tab in your community. Add Chatter News or Group Feeds to Community Site.com Pages Use the Chatter News Feed to display a Chatter feed on your site pages, or display the feeds of a particular group using the Chatter Group Feed. 507 Extend Salesforce with Clicks, Not Code Site.com Improve Performance with HTML Page Caching for Communities in Site.com HTML caching lets you improve the performance and page rendering of your community’s Site.com site by controlling how often the generated markup of the page is reloaded. SEE ALSO: Use Site.com to Customize Your Community Set Up and Manage Experience Cloud Sites Use Site.com to Customize Your Community Communities users can use Site.com to build custom, branded pages for a community. There are EDITIONS many approaches to building custom pages for your community, but these are some of the typical stages involved: Available in: Salesforce • Import Assets—Collect the assets, images, and files you plan to use on your custom page. Classic (not available in all Import the assets into Site.com Studio, where they appear in the Assets section of the Overview orgs) tab. Available for purchase in: • Create Branded Pages—The quickest and easiest way to create branded pages is to use the Enterprise, Performance, Community Template, which is automatically included with all Site.com community sites. When and Unlimited Editions you create a new page based on the Community Template, the page includes all of the branded Available (with limitations) styles in your community, including the community’s header and footer. If you want even more in: Developer Edition control over the look and feel of your community page, you can create your own page template, drag community headers and footers to it from the Widgets section of the Page Elements pane, and add other community styles. USER PERMISSIONS Note: As of Spring ’15, the Community Template is no longer available for creating To build, edit, and manage communities. If you already have a Site.com that’s based on the Communities Template, a community’s Site.com it will continue to work. For information on creating a community with a new Lightning custom pages: Community template, see Create an Experience Cloud Site. • Create and Set Up Communities • Use Branded CommunityStyles—Develop the look and feel of your custom pages by using OR the CommunityBranding style sheet, or by creating branded community styles in your own cascading style sheets (CSS). If you're not completely up to speed with CSS, the Style pane Site.com Publisher User provides an easy, visual way to create and manage styles. Or if you're a CSS expert who likes to field enabled on the user get straight into the code, you can hand-code community styles right in your own style sheets. detail page • Create Public Pages—Using the template as a base, you can quickly create pages, which AND automatically inherit all the elements of the page template. Or if you need a standalone page that doesn't follow the overall design, you can create a blank page instead. Site administrator or designer role assigned • Make Pages Private—By default, any page you create in Site.com Studio is publicly available. at the site level However, you can make pages private so that only logged-in Communities users can access them. • Add Features, Page Elements, and Community Widgets—Use Site.com's prebuilt page elements to add features such as navigation menus, images, content blocks, and community widgets. Retrieve data from your organization’s objects and dynamically display it on your site pages using data repeaters and data tables. Alternatively, gather and submit data from visitors using forms. • Add and Edit Content—At this stage, the page is usually ready for you to add and edit content such as text, images, videos, and hyperlinks. And as you work, you can upload any images or files you need. 508 Extend Salesforce with Clicks, Not Code Site.com • Review and Test the Page—Testing the changes to your page happens throughout the development cycle. You should always preview your changes to ensure they display as expected in a browser. You can also send a preview link to reviewers so they can review the finished product before it goes live. • Publish the Page—After testing is complete, you're ready to make the page available to your community by publishing your changes. • Add Authenticated Pages to Your Community’s Tab—Now that the page is tested and published, if you’re working with authenticated pages, the final step is to add the page to a tab in your community. • Use Site.com in Sandbox—Site.com is now available on sandbox. When you create a sandbox copy from a production organization, you can include your Site.com sites. You can also copy your sandbox site back to production using the overwrite feature. SEE ALSO: Create a Site.com Community Set Up and Manage Experience Cloud Sites Brand Your Salesforce Tabs + Visualforce Site Create Branded Pages Overview When you create a Community site, Salesforce automatically creates a new Site.com site and EDITIONS associates it with your community. With Site.com Community sites you can: Available in: Salesforce Classic (not available in all • Use the branded Community template to create Site.com pages for your community. orgs) Note: As of Spring ’15, the Community Template is no longer available for creating Available for purchase in: communities. If you already have a Site.com that’s based on the Communities Template, Enterprise, Performance, it will continue to work. For information on creating a community with a new Lightning and Unlimited Editions Community template, see Create an Experience Cloud Site. Available (with limitations) • Use the CommunityBranding style sheet to style Site.com pages by using CSS. in: Developer Edition • Create your own community CSS styles using a number of available Network namespace expressions. Create Branded Pages from the Community Template Site.com Community sites include a branded template that you can use to create new community site pages. Apply Community Styles from the CommunityBranding Style Sheet The CommunityBranding style sheet contains a set of CSS styles created from Network namespace expressions. Create Styles in a CSS Style Sheet Branded styles are available in Site.com sites through Network namespace expressions. Expressions Available for Community Branding View the CommunityBranding Style Sheet The CommunityBranding style sheet contains a set of branded styles from your community. 509 Extend Salesforce with Clicks, Not Code Site.com Create Branded Pages from the Community Template Site.com Community sites include a branded template that you can use to create new community EDITIONS site pages. Note: As of Spring ’15, the Community Template is no longer available for creating Available in: Salesforce communities. If you already have a Site.com community that’s based on the Community Classic (not available in all Template, it will continue to work. For information on creating a community with a new orgs) Lightning Community template, see Create an Experience Cloud Site. Available for purchase in: The styles for the Community Template come from the CommunityBranding style Enterprise, Performance, sheet, which is automatically included for all new Site.com Community sites. and Unlimited Editions To create branded pages from the Community Template: Available (with limitations) in: Developer Edition 1. On the Site.com Overview tab, hover over Site Pages and click New. 2. Type the new community page name. Page names can’t include spaces or special characters, such as #, ?, or @. USER PERMISSIONS 3. Make sure Community Template is selected for the page template. To build, edit, and manage a community’s Site.com 4. Click Create. custom pages: Note: • Create and Set Up Communities • Community branding options, such as headers, footers, and page colors, are set from the OR Administration > Branding section on the Experience Management page. Site.com • Empty community headers and footers, or headers that contain only images, won’t work Publisher User in Site.com. Be sure to specify customized HTML blocks for your community headers and field enabled on the user footers if you’re creating Site.com pages from the Community Template, or creating detail page community headers and footers using Network namespace expressions. AND • Community headers and footers are available as widgets in Site.com community pages. Site administrator or To add a community header or footer to a blank page, drag it to the page from the Widgets designer role assigned section of the Page Elements pane. at the site level SEE ALSO: Create Branded Pages Overview View the CommunityBranding Style Sheet Site.com Page Templates Overview Creating Site.com Page Templates 510 Extend Salesforce with Clicks, Not Code Site.com Apply Community Styles from the CommunityBranding Style Sheet The CommunityBranding style sheet contains a set of CSS styles created from Network EDITIONS namespace expressions. Note: As of Spring ’15, the Community Template is no longer available for creating Available in: Salesforce communities. If you already have a Site.com community that’s based on the Community Classic (not available in all Template, it will continue to work. For information on creating a community with a new orgs) Lightning Community template, see Create an Experience Cloud Site. Available for purchase in: The CommunityBranding style sheet is attached to the Community Template, and is Enterprise, Performance, responsible for the template’s branded look and feel. You can access the styles in the and Unlimited Editions CommunityBranding style sheet and apply them directly to elements on any page. Available (with limitations) in: Developer Edition To apply community styles using the CommunityBranding style sheet: 1. Make sure the CommunityBranding style sheet is attached to the Site.com page you want to brand. USER PERMISSIONS Note: All Site.com pages based on the Community Template automatically have To build, edit, and manage the CommunityBranding style sheet attached to them. a community’s Site.com custom pages: 2. Select the element on the page you want to style. • Create and Set Up 3. Open the Style pane. Communities OR 4. Select Class. Site.com 5. Start typing “brand”. Publisher User A list of all of the available styles in the CommunityBranding styles sheet appears. field enabled on the user 6. Select the style you want to apply. detail page AND SEE ALSO: Site administrator or designer role assigned Create Branded Pages Overview at the site level Create Branded Pages from the Community Template View the CommunityBranding Style Sheet Creating and Using CSS Style Sheets 511 Extend Salesforce with Clicks, Not Code Site.com Create Styles in a CSS Style Sheet Branded styles are available in Site.com sites through Network namespace expressions. EDITIONS You can access a full list of available Network namespace expressions to create new community styles in any CSS style sheet. When you add an expression to a CSS rule, Site.com “pulls in” the style Available in: Salesforce as it’s defined in the community, and displays it on your page. Classic (not available in all orgs) To create community styles in a CSS style sheet: 1. Open an existing style sheet or create a new style sheet. (See Creating and Using CSS Style Available for purchase in: Sheets on page 584.) Enterprise, Performance, and Unlimited Editions 2. Click Edit Style Sheet Code. Available (with limitations) 3. Add a new community style rule by using any of the available Network expressions. You can in: Developer Edition create both ID styles and class styles. For example: USER PERMISSIONS To build, edit, and manage a community’s Site.com custom pages: • Create and Set Up Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level #main_content_block { background-color: {!Network.primaryColor}; color: {!Network.primaryComplementColor}; } .secondary_content_blocks{ background-color: {!Network.zeronaryColor}; color: {!Network.zeronaryComplementColor}; } 4. Apply the new styles to elements on other pages. 512 Extend Salesforce with Clicks, Not Code Site.com Note: Remember, the style sheet that contains your community styles must be attached to the page containing your styled elements. SEE ALSO: Create Branded Pages Overview Expressions Available for Community Branding Creating and Using CSS Style Sheets Expressions Available for Community Branding You can use the Network namespace expressions listed on this page to create your own EDITIONS Community styles. Community branding options, such as headers, footers, and page colors, are set from the Available in: Salesforce Administration > Branding section on the Experience Management page. Classic (not available in all orgs) Note: Available for purchase in: • Empty community headers and footers, or headers that contain only images, won’t work Enterprise, Performance, in Site.com. Be sure to specify customized HTML blocks for your community headers and and Unlimited Editions footers if you’re creating Site.com pages from the Community Template, or creating community headers and footers using Network namespace expressions. Available (with limitations) in: Developer Edition • Community headers and footers are available as widgets in Site.com community pages. To add a community header or footer to a blank page, drag it to the page from the Widgets section of the Page Elements pane. Network Expression Corresponding Community Branding Page Element {!Network.header} Custom content of the community header. {!Network.footer} Custom content of the community footer. {!Network.zeronaryColor} The background color for the community header. {!Network.zeronaryComplementColor} The font color used with zeronaryColor. {!Network.primaryColor} The color used for active tabs in the community. {!Network.primaryComplementColor} The font color used with primaryColor. {!Network.secondaryColor} The color used for the top border of lists and tables in the community. {!Network.tertiaryColor} The background color for section headers on edit and detail pages in the community. {!Network.tertiaryComplementColor} The font color used with tertiaryColor. {!Network.quaternaryColor} The background color for pages in the community. 513 Extend Salesforce with Clicks, Not Code Site.com Network Expression Corresponding Community Branding Page Element {!Network.quaternaryComplementColor} The font color used with quaternaryColor. SEE ALSO: Create Branded Pages Overview Create Styles in a CSS Style Sheet View the CommunityBranding Style Sheet The CommunityBranding style sheet contains a set of branded styles from your community. EDITIONS Community branding options, such as headers, footers, and page colors, are set from the Administration > Branding section on the Experience Management page. Available in: Salesforce Classic (not available in all To see the Community styles in the CommunityBranding style sheet, on the Site.com Overview orgs) tab, click Style Sheets, and click the CommunityBranding style sheet. The Community styles are listed on the left. To see the code for the style sheet, click Edit Style Sheet Code. Available for purchase in: Enterprise, Performance, A total of fourteen Community class styles are provided. These are the default contents of the style and Unlimited Editions sheet: Available (with limitations) in: Developer Edition .brandZeronaryBgr { background-color: {!Network.zeronaryColor} !important; } .brandZeronaryFgr { color: {!Network.zeronaryComplementColor} !important; } .brandPrimaryBgr { background-color: {!Network.primaryColor} !important; } .brandPrimaryFgr { color: {!Network.primaryComplementColor} !important; } .brandPrimaryBrd2 { border-color: {!Network.primaryComplementColor} !important; } .brandPrimaryFgrBrdTop { border-top-color: {!Network.primaryComplementColor} !important; } .brandPrimaryBrd { border-top-color: {!Network.primaryColor} !important; } .brandSecondaryBrd { border-color: {!Network.secondaryColor} !important; } .brandSecondaryBgr { background-color: {!Network.secondaryColor} !important; } .brandTertiaryFgr { 514 Extend Salesforce with Clicks, Not Code Site.com color: {!Network.tertiaryComplementColor} !important; } .brandTertiaryBgr { background-color: {!Network.tertiaryColor} !important; color: {!Network.tertiaryComplementColor} !important; background-image: none !important; } .brandTertiaryBrd { border-top-color: {!Network.tertiaryColor} !important; } .brandQuaternaryFgr { color: {!Network.quaternaryComplementColor} !important; } .brandQuaternaryBgr { background-color: {!Network.quaternaryColor} !important; } SEE ALSO: Create Branded Pages Overview Create Branded Pages from the Community Template Site.com Authorization Overview As part of your site design, you might want to control what content is public and private to your EDITIONS site visitors. New sites are initially set so that all site resources, such as folders and pages, are public. You can change the default setting from the Authorization view found under Site Configuration. Available in: Salesforce The global site authorization options are: Classic • No Authorization (default)—All resources are public. Available in: Enterprise, • Requires Authorization—All resources are private. Performance, Unlimited, and Developer Editions • Custom—All resources are public by default, but can be made private. The No Authorization and Requires Authorization options let you quickly make your site either all public or all private. But, if you want to control access to individual pages, folders, and other resources, use the Custom option. Selecting Custom enables a Requires Authorization checkbox on the Actions menu for all resources throughout the site. You can define authorization at the site, folder, page, and individual resource level. As you mark items for authorization, a lock icon appears on them. After a resource, like a page, is marked as private, users who aren’t logged into Salesforce are asked to log in when they try to access it. Resources can inherit their privacy setting from folders. For example, when a resource, such as a site folder, is marked for authorization, anything placed in that folder inherits the folder’s authorization setting and becomes private. If you drag that resource into a public folder, it becomes public again. But, if you explicitly mark a resource as private using the Actions menu, and then drag it into a public folder, it still remains private because the privacy setting at the resource level dominates. When you use the Custom option, an authorization table appears in the Authorization view that lets you manage your private resources/items marked as private. You can remove authorization from a resource by either deleting it from the authorization table, or by deselecting the Requires Authorization box on the item itself. Setting Custom Authorization 515 Extend Salesforce with Clicks, Not Code Site.com Removing Site.com Authorization SEE ALSO: Setting Custom Authorization Removing Site.com Authorization Setting Custom Authorization When you select Custom authorization, you get a great deal of flexibility in controlling access to EDITIONS your site. Not only can you control who has access to top level resources, like folders and pages, but you can also set access at the individual resource level. Available in: Salesforce Using Custom authorization at the folder level is a great way to make a large number of resources Classic private without having to mark them individually. Let’s say you periodically run sale offers for your Available in: Enterprise, paid users. If you drag all the sale pages into a special folder you mark for authorization, they instantly Performance, Unlimited, inherit the folder’s setting. Users will need to log in to access them. Plus, if you decide to make one and Developer Editions of the sale pages available to everyone, you can simply drag it back into a public folder, or to the root of the All Site Content area. USER PERMISSIONS 1. Open you site for editing. 2. Click Site Configuration > Authorization. To manage authorization: • You must be an 3. Select Custom. administrative user on 4. Click All Site Content. the site 5. Create a folder to hold the private pages if it doesn’t already exist. 6. From the folder’s Actions menu, select Requires Authorization. You’ll see the lock appear on the folder. It is now private. 7. Drag any pages you want to make private into the folder. A lock appears on them too. Example: Let’s take another example. If you have a page that you’d like to keep private no matter where it resides, you can set its authorization using the Actions menu. After you set it at the individual resource level, it remains private even if you drag it into a folder that isn’t set to private. In other words, an resource marked private is always private until you deselect Requires Authorization on the Actions menu. If you check the Authorization page, you’ll see all folders and resources marked private are listed in the authorization table where you can view and delete them. SEE ALSO: Removing Site.com Authorization 516 Extend Salesforce with Clicks, Not Code Site.com Removing Site.com Authorization You can remove authorization for a resource by either deleting it from the authorization table under EDITIONS Site Configuration, or by deselecting Requires Authorization from the menu. 1. Open your site for editing. Available in: Salesforce Classic 2. Click Site Configuration > Authorization. 3. From the authorization table, click Delete next to the item you want to remove. Alternatively, Available in: Enterprise, Performance, Unlimited, navigate to the All Site Content view. Select the resource. From the Actions menu, deselect and Developer Editions Requires Authorization. Example: If a resource is explicitly marked as private using the Actions menu, then you must USER PERMISSIONS remove authorization from it using the Actions menu. For example, if a page marked private is dragged into a folder that’s public, it remains private. Likewise, if you drag it into a folder To manage authorization: that’s already private, and remove the authorization on that folder, the page will still be private. • You must be an administrative user on the site SEE ALSO: Setting Custom Authorization Display Current Community User Information Site.com designers creating authenticated pages for a community site can display the current user’s EDITIONS information by accessing CurrentUser namespace expressions. 1. Open the page on which you want to display the current community user's information. Available in: Salesforce Classic (not available in all 2. From the Page Elements pane, drag a Content Block or Custom Code page element onto orgs) the page. 3. Type {!CurrentUser. and the value that you want to display. Available for purchase in: For example, {!CurrentUser.firstName}. Enterprise, Performance, and Unlimited Editions Check the list of available expressions for displaying current user information. Available (with limitations) 4. Add any additional text you require. in: Developer Edition For example, Welcome back {!CurrentUser.firstName}!. 5. If you’re in a Content Block, click Save. If you’re in a Custom Code element, click Save and USER PERMISSIONS Close. To build, edit, and manage Note: If an unauthenticated user views a page that contains CurrentUser expressions, a community’s Site.com the current user information does not appear. For example, if an unauthenticated user viewed custom pages: a page that contained the above example, the user would see “Welcome back !” as the • Create and Set Up welcome message. Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level 517 Extend Salesforce with Clicks, Not Code Site.com Expressions Available for Displaying Current User Information Use these CurrentUser namespace expressions to display authenticated user information on EDITIONS a Site.com community page. Available in: Salesforce CurrentUser Expression Displays Classic (not available in all {!CurrentUser.name} Combined first and last name of the user, as orgs) displayed on the user detail page. Available for purchase in: Enterprise, Performance, {!CurrentUser.firstName} First name of the user, as displayed on the user and Unlimited Editions edit page. Available (with limitations) {!CurrentUser.lastName} Last name of the user, as displayed on the user in: Developer Edition edit page. {!CurrentUser.userName} Administrative field that defines the user’s login. {!CurrentUser.email} Email address of the user. {!CurrentUser.communityNickname} Name used to identify the user in a community. {!CurrentUser.accountId} The account Id associated with the user. It shows a valid account id for Partner and Customer users. For all others, it is empty '000000000000000'. {!CurrentUser.effectiveAccountId} The account Id associated with the effective account. It shows a valid account id for Partner and Customer users. For all others, it is empty '000000000000000'. 518 Extend Salesforce with Clicks, Not Code Site.com Determine the URL of a Site.com Page After you create a Site.com page, you can determine the page’s URL to: EDITIONS • Provide your users with a URL that lets them access a public page directly. • Create a link to the page from other pages, including Salesforce Sites and Visualforce pages. Available in: Salesforce Classic (not available in all • Make it the home page for your community using a URL redirect in Salesforce Sites. orgs) and Lightning • Add a private page to a web tab in your community. Experience 1. To determine the correct URL for the page: Available in: Enterprise, • From the Create Community wizard, click Customize. Performance, Unlimited, and Developer Editions • If you navigated away from the Create Community wizard, click Customize > Communities > All Communities, then click the Manage button next to the community name. USER PERMISSIONS 2. Click Administration Settings. To build, edit, and manage 3. Copy the URL displayed on the page and paste it into a text editor. a community’s Site.com custom pages: 4. To create a URL that points to: • Create and Set Up • The Site.com site’s home page, append /s/ to the URL. For example, Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level https://MyDomainName.my.site.com/ExperienceCloudSiteName/s/. • A specific Site.com page, append /s/ Note: If you’re not using enhanced domains, your org’s Experience Cloud sites URL is different. For details, see My Domain URL Formats in Salesforce Help. SEE ALSO: Add Authenticated Site.com Pages to Community Tabs Salesforce Sites URL Redirects 519 Extend Salesforce with Clicks, Not Code Site.com Add Authenticated Site.com Pages to Community Tabs After you create a private Site.com page, you can add the page to a tab in your community. EDITIONS In this case, you need to create a Web tab that points to your Site.com page. 1. In the Properties pane for your page, select Show Salesforce Header. Available in: Salesforce Classic (not available in all Selecting this option ensures that you see tabs in your community. orgs) and Lightning 2. Enter the tab name as it should appear on the tab in your community. Experience The web tab you create must have the same name. Available in: Enterprise, Performance, Unlimited, 3. Determine the correct URL for the page. and Developer Editions The URL must be in the following format https://MyDomainName.my.site.com/mycommunity/s/ 520 Extend Salesforce with Clicks, Not Code Site.com Add Chatter News or Group Feeds to Community Site.com Pages Use the Chatter News Feed to display a Chatter feed on your site pages, or display the feeds of a EDITIONS particular group using the Chatter Group Feed. 1. Drag the News Feed or Group Feed from the Widgets section of the Page Elements pane Available in: Salesforce onto the page. Classic (not available in all When you add a widget to a page, it creates a copy or instance of the widget. You can’t edit orgs) and Lightning the content of a widget, but you can edit the properties. Experience 2. If you’re adding a group feed, enter the Group ID in the Properties pane. Available in: Enterprise, The Group ID determines which group feed is displayed on your page. You can include more Performance, Unlimited, than one group feed on a page if you want to show the feeds for multiple groups. and Developer Editions 3. Preview the page to test the feed, or use Live Mode to see how the feed renders in different USER PERMISSIONS mobile devices. Consider the following limitations when using a news or group feed in your community Site.com To build, edit, and manage sites: a community’s Site.com custom pages: • Chatter news and group feeds only appear if a user is logged in to the community. They don’t • Create and Set Up appear to guest users or in anonymous preview mode. Communities • Chatter news and group feeds may not render appropriately on pages less than 700px wide. OR We recommend a minimum page width of 700px to view full content. We also recommend Site.com using a white background. Publisher User • Chatter news and group feeds only inherit some page branding elements. field enabled on the user detail page AND Site administrator or designer role assigned at the site level 521 Extend Salesforce with Clicks, Not Code Site.com Improve Performance with HTML Page Caching for Communities in Site.com HTML caching lets you improve the performance and page rendering of your community’s Site.com EDITIONS site by controlling how often the generated markup of the page is reloaded. Lets say 100 people visit the page at the same time. Without caching, the page makes 100 separate Available in: Salesforce requests for the same markup, slowing performance considerably. However, with caching enabled, Classic (not available in all the page markup is requested and retrieved only once—the first time someone visits the page. orgs) Any subsequent page requests during a set time period are returned from the cache. When the Available for purchase in: specified time period expires, the cache is refreshed. Enterprise, Performance, Note: The caching duration applies only to community pages that are accessed by guest and Unlimited Editions users. When a user logs in to access the page, caching is disabled. Available (with limitations) in: Developer Edition 1. In Site.com Studio, open the page. 2. In the Cache Duration (Minutes) field of the Cache section of the Properties tab, specify the length of time to cache the page. USER PERMISSIONS By default, the caching duration of a page is set to 30 minutes. To build, edit, and manage To disable caching, set the page’s caching duration to 0. a community’s Site.com custom pages: • Create and Set Up Communities OR Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level 522 Extend Salesforce with Clicks, Not Code Site.com Creating a Site.com Site To get started with Site.com, create a new blank site: EDITIONS 1. On the Site.com tab in the Site.com app, click New. Alternatively, in Site.com Studio, click Create a New Site in the site's drop-down menu. Available in: Salesforce Classic (not available in all 2. Click Create a Blank Website. orgs) 3. Enter the site name. Available for purchase in: 4. Click Create. Your new website opens in Site.com Studio, where you can create page templates Enterprise, Performance, and site pages, and add functionality to it. and Unlimited Editions Note: You can’t create, delete, or duplicate community sites in Site.com. Available (with limitations) in: Developer Edition Deleting a Site.com Site Duplicating a Site.com Site USER PERMISSIONS Exporting a Site.com Site To create or import Site.com sites: Importing a Site.com Site • Site.com Configuring Site Properties Publisher User Enable Clickjack Protection in Site.com field enabled on the user detail page Clickjacking is a type of attack that tricks users to click something, such as a button or link, because they perceive they are clicking something safe. Instead, the button or link performs malicious actions on your site, leading to data intrusion, unauthorized emails, changed credentials, or other site-specific results. Site.com Versioning Overview Each time you publish your site, it’s tracked as a version. You can restore your site back to one of the previously published versions. You can’t select individual components when restoring; you must restore the complete site. Creating URL Redirects in Site.com If you move or reorganize pages in your site, search engines may have trouble finding the new page locations. To avoid this, set up URL redirects to inform users and search engines that site content has moved. Importing External Websites into Site.com With Site.com Studio, you can import your existing website and recreate it automatically as a Site.com site. This saves you the time of having to re-code existing HTML pages. Copying and Overwriting a Site Sometimes, you might want to copy and replace your current production Site.com or Site.com community site with another site. Using the Metadata API to Deploy a Site As a user, you can migrate a site from sandbox to production. You can use the Metadata API to create a deployable package for Site.com sites and Site.com Communities sites. SEE ALSO: Creating Site.com Page Templates Creating Site.com Pages Editing Site.com Pages as a Designer or Site Administrator 523 Extend Salesforce with Clicks, Not Code Site.com Deleting a Site.com Site You can delete any site that isn’t published. If the site is published, you must first unpublish it before EDITIONS you can delete it. See Taking a Site Offline on page 669. 1. On the Site.com tab in the Site.com app, select the site and click > Delete. Available in: Salesforce Classic (not available in all 2. Click OK. orgs) Note: You can’t create, delete, or duplicate community sites in Site.com. Available for purchase in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Exporting a Site.com Site Available (with limitations) in: Developer Edition USER PERMISSIONS To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level 524 Extend Salesforce with Clicks, Not Code Site.com Duplicating a Site.com Site To create a copy of a site: EDITIONS 1. On the Site.com tab in the Site.com app, select the site and click > Duplicate. Alternatively, Available in: Salesforce on the Overview tab in Site.com Studio, click > Duplicate This Site. Classic (not available in all 2. Enter a name for the site. orgs) 3. Click Create. Available for purchase in: Enterprise, Performance, Note: and Unlimited Editions • If you’re creating a copy of a site that uses data services, you must set the data access Available (with limitations) permissions in the new site’s guest user profile. in: Developer Edition • You can’t create, delete, or duplicate community sites in Site.com. USER PERMISSIONS SEE ALSO: To build, edit, and manage Creating a Site.com Site Site.com sites: Exporting a Site.com Site • Site.com Importing a Site.com Site Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level 525 Extend Salesforce with Clicks, Not Code Site.com Exporting a Site.com Site You can export your site from Site.com to your hard drive. The site is exported in a packaged format EDITIONS with a .site extension, which you can import into another Salesforce organization. The maximum site size you can import is 2 GB. Available in: Salesforce 1. On the Site.com tab in the Site.com application, select the site and click > Export. Classic (not available in all orgs) Alternatively, on the Overview tab in Site.com Studio, click > Export This Site. Available for purchase in: 2. If the site is: Enterprise, Performance, • Smaller than 100 MB, select a location to save the exported .site file on your hard drive and and Unlimited Editions click Save. Available (with limitations) • Larger than 100 MB, you’ll receive an email when the export process has completed. Click in: Developer Edition the link in the email to download the exported .site file. Note: USER PERMISSIONS • Exporting a site doesn’t remove it from the current organization. To build, edit, and manage Site.com sites: • Site.com SEE ALSO: Publisher User Creating a Site.com Site field enabled on the user detail page Importing a Site.com Site AND Site administrator or designer role assigned at the site level Importing a Site.com Site You can import an exported Site.com site into your organization. The maximum site size you can EDITIONS import is 2 GB. When you import a site, you are given the site administrator role in the site. 1. On the Site.com tab in the Site.com app, click New. Alternatively, in Site.com Studio, click Create Available in: Salesforce a New Site in the site's drop-down menu. Classic (not available in all orgs) 2. Select Import a Site or Template. 3. Enter the site name. Available for purchase in: Enterprise, Performance, 4. Click Browse to locate the exported site on your hard drive. Exported sites have a .site extension. and Unlimited Editions 5. Click Create. Available (with limitations) in: Developer Edition Note: • If you’re importing a site that uses data services, you must set the data access permissions in the imported site’s guest user profile. Additionally, any data repeaters, data tables, data USER PERMISSIONS functions, or forms may need to be reconfigured. To create or import Site.com sites: • Site.com Publisher User field enabled on the user detail page 526 Extend Salesforce with Clicks, Not Code Site.com • You can’t create, delete, or duplicate community sites in Site.com. SEE ALSO: Creating a Site.com Site Exporting a Site.com Site Configuring Site Properties Set properties for the site, such as the home page, site name, and error page, and create an EDITIONS anonymous preview URL that allows other users to review the site before it goes live. The URL is always valid (unless you disable it) and shows the latest work in progress. It’s only available to the Available in: Salesforce people you send it to, and can’t be found by search engines. Classic (not available in all 1. On the Overview tab, click Site Configuration. orgs) 2. Click Edit. Available for purchase in: 3. In the Site Configuration view, you can: Enterprise, Performance, and Unlimited Editions • Replace the name in the Site Name field to rename the site. Available (with limitations) • See the Developer Name of the site. This read-only field may differ from the Site in: Developer Edition Name. The Developer Name is used by the Metadata API. • Select Enable Anonymous Preview to create a URL that allows other users to preview the site before it goes live. (Click the View Anonymous Preview option that appears in USER PERMISSIONS the Preview menu to access the preview URL, which you can copy and send to other users To build, edit, and manage to review and test your changes.) Enable Anonymous Preview is also available from the Site.com sites: Preview menu on the Overview tab. • Site.com • Access the site’s guest user profile. Publisher User • Set the clickjack protection level. field enabled on the user detail page • Determine whether guest users can view features available only in Lightning. If you disable Lightning Features for Guest Users, Lightning features don’t load. AND Site administrator or • Enable Content Sniffing Protection to force the browser to use the Content-Type header designer role assigned only. at the site level • Enable Browser Cross Site Scripting Protection to protect against reflected cross-site scripting attacks. • Select Referrer URL Protection to have the referrer header shows only Salesforce.com rather than the entire URL when loading pages. • Select the home page for your website in the Home Page drop-down list. • Site.com Community sites only: – Select the login page for your Site.com Community site in the Login Page drop-down list. – Select the page that you’ve set up for Site.com Community site users who don’t have accounts yet from the Registration Page drop-down list. – Select the Forgot Password page you’ve set up for your community using Site.com. • Select a user-friendly error page in the 404 Page drop-down list to display when a page can't be found. It's a good idea to create a user-friendly error page to assist site visitors if they encounter a broken link. 4. Click Save. 527 Extend Salesforce with Clicks, Not Code Site.com Note: • The home page, 404 page, login page, and self-registration page that you specify for Site.com Community sites in Site Configuration set the default pages for the Site.com Community site. These default URLs are used unless you specify different URLs in Community Management under Administration Pages and Administration Login & Registration . Community error pages are specified in Lightning Platform Setup, under Error Pages. • When your Site.com Community site is inactive, users are redirected to the Service Not Available page defined in Community Management under Pages. SEE ALSO: Creating a Site.com Site Using Site.com Studio as a Site Administrator or Designer Enable Clickjack Protection in Site.com Enable Clickjack Protection in Site.com Clickjacking is a type of attack that tricks users to click something, such as a button or link, because EDITIONS they perceive they are clicking something safe. Instead, the button or link performs malicious actions on your site, leading to data intrusion, unauthorized emails, changed credentials, or other site-specific Available in: Salesforce results. Classic (not available in all Hidden iframes can be placed maliciously on site pages and entice users to click a button or link orgs) that appears below the hidden iframe. With clickjack protection, you can configure whether your Available for purchase in: browser allows frames over your site pages. The default clickjack level for Site.com is set to Allow Enterprise, Performance, framing by the same origin only. and Unlimited Editions You can set the clickjack protection for a site to one of these levels: Available (with limitations) • Allow framing by any page (no protection): The least secure level. in: Developer Edition • Allow framing of site pages on external domains (good protection): Allows framing of your site pages by pages on external domains that are added to the Trusted Domains for Inline USER PERMISSIONS Frames list. • Allow framing by the same origin only (recommended): The default level for sites. Allows To build, edit, and manage framing of site pages by pages with the same domain name and protocol security. Site.com sites: • Site.com • Don’t allow framing by any page (most protection): The most secure level, but it can cause Publisher User certain pages to appear as blank pages. To avoid this issue, use the default setting instead. field enabled on the user 1. In Site.com Studio, click Site Configuration > Edit. detail page 2. Select your preferred level of clickjack protection and save your changes. AND 3. If you chose to allow framing of your site pages on your external domains, specify the domains Site administrator or designer role assigned that you want to allow. at the site level a. From Setup in Salesforce Classic, enter Sites in the Quick Find box, and then select Sites. b. Click the site label to open the Site Details page. c. Click Add Domain in the Trusted Domains for Inline Frames section and enter the domain you want to allow iframes on. You can add up to 512 domains. Tip: Added domains take effect only when Allow framing of site pages on external domains is selected. 528 Extend Salesforce with Clicks, Not Code Site.com Note: Internet Explorer supports clickjack protection through the legacy X-Frame-Options HTTP Header only. This header supports sameorigin, deny (none), allowall, and allow-from uri. In particular, allow-from uri supports only one URI. To support a list for IE users, the framing site must identify itself to the site domain by passing in a query parameter in the iframe tag. For example, if you add https://example.com as a trusted external domain and your site URL is https://MyDomainName.my.site.com, then the page on https://example.com must make its iframe as follows: You can also set the trusted external domain in the iframeDomain cookie. This method allows iframes if the _iframeDomain URL variable isn’t saved when navigating between pages in IE. Cookie iframeDomainCookie = ApexPages.currentPage().getCookies().get('iframeDomain'); if (iframeDomainCookie == null) { iframeDomainCookie = new Cookie('iframeDomain','www.example.com'); // Set the new cookie for the page ApexPages.currentPage().setCookies(new Cookie[]{iframeDomainCookie}); } SEE ALSO: Configuring Site Properties Enable Clickjack Protection in Experience Cloud Sites Create and Edit Salesforce Sites Site.com Versioning Overview Each time you publish your site, it’s tracked as a version. You can restore your site back to one of EDITIONS the previously published versions. You can’t select individual components when restoring; you must restore the complete site. Available in: Salesforce When working in Site.com Studio, you’re always working on an unpublished version of your site. Classic (not available in all It’s your working copy. When you restore a version, you overwrite your working copy, not your live orgs) site. You must publish the restored version before you see the change on your live site. Available for purchase in: In Site.com Studio, you’ll find your site versions in the Change History view on the Overview tab. Enterprise, Performance, Not all items in a site are reverted when you restore a version. Some things, like user roles, remain and Unlimited Editions unchanged even when you restore from a previous version. Everything in a site is under version Available (with limitations) control except: in: Developer Edition • Site name • Anonymous preview setting • Guest User Profile settings • Clickjack protection level • Domains and path prefixes • User role settings 529 Extend Salesforce with Clicks, Not Code Site.com Restoring to a Previous Site Version The Change History list in Site.com Studio tracks all published versions of your site. You can select any previously published version and restore it. You can only restore an entire site, not parts of a site. SEE ALSO: Restoring to a Previous Site Version Restoring to a Previous Site Version The Change History list in Site.com Studio tracks all published versions of your site. You can select EDITIONS any previously published version and restore it. You can only restore an entire site, not parts of a site. Available in: Salesforce Note: The restore version feature is not available in Communities. Classic (not available in all orgs) When working in Site.com Studio, you’re always working on an unpublished version of your site. Available for purchase in: It’s your working copy. When you restore a version, you overwrite your working copy, not your live Enterprise, Performance, site. You must publish the restored version before you see the change on your live site. and Unlimited Editions Warning: You can’t restore the working copy of your site after you revert to a previous Available (with limitations) version. Therefore, it’s a good idea to back up the working copy of the site before reverting in: Developer Edition to ensure you don’t lose any unpublished changes. To revert to a previously published site version: USER PERMISSIONS 1. Select the Overview tab. To build, edit, and manage 2. From the Change History view, select the version you want to restore. Site.com sites: 3. Click > Restore Version. • Site.com Publisher User 4. Click OK at the confirmation message. field enabled on the user After you restored your working site to a previous version, you can continue to make additional detail page changes until you’re ready to publish the site. AND Site administrator or designer role assigned at the site level 530 Extend Salesforce with Clicks, Not Code Site.com Creating URL Redirects in Site.com If you move or reorganize pages in your site, search engines may have trouble finding the new EDITIONS page locations. To avoid this, set up URL redirects to inform users and search engines that site content has moved. Available in: Salesforce You can use URL redirects to: Classic (not available in all orgs) • Maintain search engine ranking. For example, if you change a page’s name from “Gadgets” to “Widgets,” creating a redirect rule from /Gadgets to /Widgets lets you restructure the Available for purchase in: site without affecting your page ranking. Enterprise, Performance, • Make URLs more readable and memorable. For example, site visitors will find long or numeric and Unlimited Editions page names, such as /widget65AD890004ab9923, difficult to remember. Instead, you Available (with limitations) can provide them with a short, friendly URL, such as /widget, and create an alias that redirects in: Developer Edition to the correct page when the user uses the short URL alias. • Assist with migration from another system to Site.com if you’re still using the same domain. USER PERMISSIONS For example, if your old site ran on PHP, you can create a redirection rule from an old page, such as /index.php, to a new page in Site.com, such as /myNewPage. To build, edit, and manage To assign a redirect to a site page: Site.com sites: • Site.com 1. On the Overview tab, click Site Configuration > URL Redirects. Publisher User 2. Click Create a Redirect. field enabled on the user detail page 3. Specify the Redirect type: AND Option Description Site administrator or designer role assigned Permanent (301) Select this option if you want users and search at the site level engines to update the URL in their systems when visiting the page. Users visiting a page redirected with this type are sent seamlessly to the new page. Using a permanent redirect ensures that your URLs retain their search engine popularity ratings, and that search engines index the new page and remove the obsolete source URL from their indexes. Temporary (302) Select this option if you want users and search engines to keep using the original URL for the page. Search engines interpret a 302 redirect as one that could change again at any time, and though they index and serve up the content on the new target page, they also keep the source URL in their indexes. Alias Select this option if you don’t want the URL to change in the user’s browser, but you want to redirect to a different page. Search engines won’t be aware of the change or update their records. 531 Extend Salesforce with Clicks, Not Code Site.com Option Description Alias redirects only work when you redirect from one Site.com page to another. You can’t create an alias to an external address. 4. Specify the former page location in the Redirect from field. • The page location must be a relative URL. • The page can have any valid extension type, such as .html or .php, and can contain parameters. Parameter order is irrelevant. • The URL can’t contain anchors, such as /siteprefix/page.html#target. • You can create just one redirection rule from a particular URL. If you create a new rule with the same Redirect From information, the old rule is overwritten. 5. Specify the new page location in the Redirect to field. This can be a relative URL or a fully-qualified URL with an http:// or https:// prefix. Unlike pages you’re redirecting from, pages you’re redirecting to can contain anchors. 6. To immediately enable the redirection rule, ensure Active is selected. To enable it at a later stage, deselect the property. 7. Click Save. The URL Redirects section displays all URL redirection rules you've created for your site. • Edit an assigned redirect rule by clicking > Edit Redirect. • Delete a redirect rule by clicking > Delete Redirect. Importing External Websites into Site.com With Site.com Studio, you can import your existing website and recreate it automatically as a EDITIONS Site.com site. This saves you the time of having to re-code existing HTML pages. Create a zipped file of your website and the content with the desired folder structure. Create a new Available in: Salesforce Site.com site and then import your zipped file. Classic (not available in all orgs) During the creation of the new Site.com site, all your HTML pages and assets are copied into the new site in the same locations they are in the zipped file. Here are some guidelines for importing Available for purchase in: assets. Enterprise, Performance, and Unlimited Editions • Some code in style sheets may not convert properly to the Site.com format. If this happens, you’ll receive a warning message. You can continue to import the zipped file or stop the import. Available (with limitations) If you continue, the style sheet imports and you can then manually attach it to your pages. in: Developer Edition • You can edit the SEE ALSO: Importing a Site.com Site 532 Extend Salesforce with Clicks, Not Code Site.com Copying and Overwriting a Site Sometimes, you might want to copy and replace your current production Site.com or Site.com EDITIONS community site with another site. You’ll first need to export a copy of your site from your . Once you have an exported .site file, Available in: Salesforce import that file into your production organization using the overwrite feature. Overwrite replaces Classic (not available in all your production site with the imported site. You can only overwrite sites that are the same type. orgs) For example, you can’t overwrite a Site.com site with a Site.com community site. Available for purchase in: 1. Create your .site file using the export feature in Site.com Studio. Enterprise, Performance, and Unlimited Editions 2. From Site.com Studio in your production site, click Site Actions > Overwrite This Site. Alternatively, if you have access to the Site.com tab in your organization, you can click next Available (with limitations) to the site name to find Overwrite. in: Developer Edition 3. Click Browse to find the .site file you exported. 4. Click OK at the overwrite warning. USER PERMISSIONS Warning: You can’t revert once you have overwritten a site. To overwrite sites: • Site administrator or Here are a few tips when using overwrite. designer role assigned at the site level • You’ll need to publish the site you overwrote before changes take effect. • When copying a site, the production site is overwritten. So, be sure to backup your production site by exporting a .site file. • Overwrite does not copy data changes. For example, if you created a custom object to use in a repeater in the site you are copying from, that repeater won’t work in the production site until you create the same custom object. • If there are assets that exist in the production site that do not exist in the site you are copying from, they are moved to the trash can during the overwrite process so you can restore them if needed. • If your copied site has a different name than your production site, the production name is preserved and only the contents are changed. For example, if your site is called Site One and you overwrite your production site called Site Two, the production site is still called Site Two. SEE ALSO: Exporting a Site.com Site Using the Metadata API to Deploy a Site Using the Metadata API to Deploy a Site As a user, you can migrate a site from sandbox to production. You can use the Metadata API to EDITIONS create a deployable package for Site.com sites and Site.com Communities sites. Note: For information on deploying a Lightning community or a Salesforce Tabs + Visualforce Available in: Salesforce community, see Deploy a Community from Sandbox to Production. Classic (not available in all orgs) There are several tools that you can use to create a package: Available for purchase in: • Change sets (for Site.com and Site.com Communities sites only). The component type is called Enterprise, Performance, Site.com . and Unlimited Editions • Workbench, which works for creating all site types. The metadata type is called SiteDotCom. Available (with limitations) • Lightning Platform Migration Tool for Ant, which works for creating all site types. The metadata in: Developer Edition type is called SiteDotCom. 533 Extend Salesforce with Clicks, Not Code Site.com If using change sets, select Site.com from the list and follow the prompts to create your package. If using Workbench or Lightning Platform as your tool, you must create a package.xml file. That file is submitted to the Metadata API to create a package. Note: You can include a Guest User Profile in your package.xml file. If you do so, that Guest User Profile is linked to the site during deployment. The packaging process generates a folder that contains a content file and a metadata xml file. The content file name is [sitename].site. The metadata .xml file name is [sitename].site-meta.xml. If you deploy a package that doesn’t include a .site file, an empty site is created. If the package contains a site file, and the organization already contains a site with the same name, the site is updated. Note: There is a file size limitation when using the Metadata API to deploy a site from sandbox to production. The assets in the .site file can’t be larger than 40 MB. The site gets created, but the assets show in the new site as broken. To fix the assets, export the assets from the sandbox environment separately and then import them into your new site. For help with the Metadata API, see the Metadata API Developer Guide. You can find help for change sets in the online help and for the Migration Tool Guide at https://developer.salesforce.com/page/Migration_Tool_Guide. Sample Package.xml Files Here are some sample Site.com package.xml files. SEE ALSO: Change Sets Sample Package.xml Files Sample Package.xml Files Here are some sample Site.com package.xml files. EDITIONS Here is a sample package.xml file for a Site.com site. Available in: Salesforce Classic (not available in all orgs) Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition 534 Extend Salesforce with Clicks, Not Code Site.com Here is an example of a package.xml for a Salesforce Communities site. The package also includes a Guest User Profile. 535 Extend Salesforce with Clicks, Not Code Site.com Importing and Managing Assets Contributors, publishers, and site administrators can import a variety of assets, such as images, EDITIONS HTML pages, and PDFs, to use in a website. You can import assets and files individually, or use a zipped file. When importing entire websites or large numbers of assets, it’s easier to create a zipped Available in: Salesforce file of the content with the desired folder structure. When importing the zipped file for a website, Classic (not available in all Site.com recreates your website and places everything in the same folder structure. orgs) Note: Available for purchase in: • The maximum file size you can import is 50 MB unless you import and unzip a .zip file. In Enterprise, Performance, that case, you can import a .zip file of up to 200 MB if you select Unzip files during the and Unlimited Editions import process. Available (with limitations) in: Developer Edition The quickest way to import one or more files is to: 1. Select the files from your computer and drag them directly onto the Studio interface. This is supported for Mozilla® Firefox® and Google® Chrome only. You can drag individual files, or a USER PERMISSIONS zipped file. To build, edit, and manage 2. Depending on the types of files you’re importing, a dialog box may appear that lets you: Site.com sites: • Site.com • Select Unzip files to extract the contents of a .zip file. If the .zip file includes folders, this Publisher User structure is maintained in your site. field enabled on the user • Select Overwrite existing files to replace a file that already exists in the site. detail page • Select Convert CSS files into style sheets, if you're a site administrator or designer, to AND convert a CSS file into a style sheet that you can use to style your website. Site administrator or designer role assigned Note: If you import a .zip file that includes CSS files, and they fail to convert, they at the site level may not be valid. Try unchecking this option and then re-importing the .zip file. To edit only content in • Select Convert HTML files into pages to import HTML pages into your website. The Site.com sites: structure of the HTML page is maintained in your site, but the HTML is not validated during • Site.com import. Contributor User Alternatively, to import a single file: AND 1. Click Import.... Contributor role assigned at the site level 2. Click Browse... to locate the file. 3. Select the file and click Open. 4. Depending on the type of file you’re importing, you can: • Select Unzip files to extract the contents of a .zip file. If the .zip file includes folders, this structure is maintained in your site. • Select Overwrite existing files to replace a file that already exists in the site. • Select Convert CSS files into style sheets, if you're a site administrator or designer, to convert a CSS file into a style sheet that you can use to style your website. Note: If you import a .zip file that includes CSS files, and they fail to convert, they may not be valid. Try unchecking this option and then re-importing the .zip file. • Select Convert HTML files into pages to import HTML pages into your website. The structure of the HTML page is maintained in your site, but the HTML is not validated during import. 5. Click Import. A message appears indicating whether the file was imported successfully. 536 Extend Salesforce with Clicks, Not Code Site.com 6. Click . You can add images and videos to the text areas of your site pages, or create a hyperlink to any imported asset. If you're a site administrator or designer, you can add also add images directly to the page. View the list of imported assets in the Assets view on the Overview tab. You can also access assets in the All Site Content view, which displays the folder hierarchy of your site. • To view a thumbnail of an imported image, hover over it. • To save an asset to your computer, hover over or select it and click > Download. • To remove an asset from your site if you're a site administrator or designer, hover over or select it and click > Delete. If the asset is being used in your site, you see a confirmation message with a list of locations where that asset is in use. After an asset file is deleted, it exists in the Salesforce cache for up to 24 hours. After this it is permanently deleted from our systems. Note: An asset may still be accessible if it's cached locally by a browser, or cached by an external system. • To rename an asset on your site if you're a site administrator or designer, hover over the asset and click > Rename. Exporting Assets Designers and site administrators can export all site assets separately from the .site file. You can export assets together or individually. Creating and Managing Folders As a site administrator or designer, you can create folders to manage your pages, style sheets, templates, and assets. SEE ALSO: Adding Site.com Page Elements Using Site.com Studio as a Site Administrator or Designer Using Site.com Studio as a Contributor Exporting Assets 537 Extend Salesforce with Clicks, Not Code Site.com Exporting Assets Designers and site administrators can export all site assets separately from the .site file. You EDITIONS can export assets together or individually. When you export all assets, the assets are exported to a zipped file that is named after the site Available in: Salesforce name—for example, sitename-Assets.zip. Classic (not available in all orgs) Export your assets from the Overview tab by clicking > Export Site Assets. Available for purchase in: To export a single asset, hover over the asset and select Download from the Actions menu. Enterprise, Performance, and Unlimited Editions Note: There is a file size limitation when using the Metadata API to deploy a site from sandbox to production. The assets in the .site file can’t be larger than 40 MB. The site gets created, Available (with limitations) in: Developer Edition but the assets show in the new site as broken. To fix the assets, export the assets from the sandbox environment separately and then import them into your new site. USER PERMISSIONS SEE ALSO: To build, edit, and manage Importing and Managing Assets Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level 538 Extend Salesforce with Clicks, Not Code Site.com Creating and Managing Folders As a site administrator or designer, you can create folders to manage your pages, style sheets, EDITIONS templates, and assets. To create new folders: Available in: Salesforce Classic (not available in all 1. In the All Site Content view on the Overview tab, click New Folder. orgs) 2. Type in the folder name. Available for purchase in: 3. Click Create. Enterprise, Performance, Folders are created at the top level of the folder tree. Once created, you can drag them anywhere and Unlimited Editions in the tree structure. Likewise, you can drag and drop files into the folders you create. To rename, Available (with limitations) delete, and create sub-folders, right-click the folder or use the Actions menu ( ). in: Developer Edition Note: The site map remains the same regardless of how you arrange folders in the All Site Content view. USER PERMISSIONS SEE ALSO: To build, edit, and manage Site.com sites: Understanding the Site Administrator and Designer's Overview Tab • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level 539 Extend Salesforce with Clicks, Not Code Site.com Editing Site.com Pages as a Designer or Site Administrator When working with page templates and site pages, you can add content, structure, and style, all EDITIONS in one place. Open a page or template on the Overview tab by double-clicking it or hovering over it and clicking > Edit. The page opens as a new tab. Available in: Salesforce Classic (not available in all orgs) Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition USER PERMISSIONS To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level • Using the Page Elements and Page Structure panes (1), you can search for and add page elements to a page, and reorder the page element hierarchy. 540 Extend Salesforce with Clicks, Not Code Site.com • Using the Properties, Style, and Events panes (2), you can set properties, add style, and create events for a selected page or element. • Using the toolbar (3), you can: – Undo and redo your actions. – Cut, copy, or paste page elements. – Import assets, such as images and files. – Preview pages to see how they’ll appear when live on different devices. – Preview your site or generate an anonymous preview link to send to other users. – Publish your recent changes. – Access other page actions ( ), such as renaming or deleting the page. • On the page canvas (4), you can lay out the page and select, edit, and move page elements. Tip: • Hide the side panes to increase the canvas size by clicking and . To reopen a pane, click its icon. • As you edit a page, your changes are saved and the status icon ( ) on the page tab is updated automatically. • If the site page or page template is based on another template, editable page elements are highlighted with a blue border on the page. Site.com Page Templates Overview Creating Site.com Page Templates Creating Editable Template Areas As the template creator, you specify which elements users can edit in pages based on the template. About Editable Page Elements When you mark a page element as Editable on a page template, that page element becomes editable in any child pages or templates derived from the parent template. Creating Site.com Pages Identifying Which Template a Site.com Page Uses Renaming, Duplicating, and Converting Pages Changing a Page’s Doctype Property The Document Type Definition (DTD) or doctype of a page defines which version of HTML it’s using. This information is used by some browsers to trigger a standard rendering mode. By default, each page’s doctype is set to HTML5, which is the latest version, but you can change it to XHTML 1.0. SEE ALSO: Using Site.com Studio as a Site Administrator or Designer 541 Extend Salesforce with Clicks, Not Code Site.com Site.com Page Templates Overview Before you begin building the pages of your website, take some time to plan the pages you need, EDITIONS and in particular, which pages will have a similar layout. Once you've decided on the layout, the quickest method is to use a page template to build the basic layout. Available in: Salesforce Classic (not available in all About Page Templates orgs) A page template lets you define the layout and functionality of site pages in one location. By adding Available for purchase in: common page elements to the template and then basing site pages on it, you can achieve a Enterprise, Performance, consistent look and feel throughout your site. Page templates don't appear on your public site. and Unlimited Editions As the template creator, you specify which elements users can edit in pages based on the template. Available (with limitations) By default, a page element in a template is “locked,” so users can't edit its contents in any in: Developer Edition template-based page unless you mark the page element as “editable.” Conversely, when users edit an editable page element in a template-based page, their changes are specific to that page and don't affect your template. For example, this main page template contains a non-editable header and navigation menu that are common to all the pages in the site (1). The main template also has an editable center panel (2) to house the page-specific content of each page that's based on it. Note: • Page templates must contain at least one editable page element. Otherwise, users can't edit site pages that are based on the template. • Panels are ideal for adding editable areas to page templates. You can use page templates to: • Save time and effort by laying out the page structure and using it as a starting point when you create site pages. For example, you could design a template with a fixed header panel and side menu, and an editable center panel, to which you add page-specific page elements and content. • Quickly make global updates to the layout or style of your website, as any changes you make to the template's design are reflected immediately in all the pages that use it. • Control how other users (such as contributors or other site administrators and designers) can modify site pages. For example, you may allow contributors to edit specific content blocks only. • Ensure your template design remains pixel-perfect. When users edit a page that's based on a template, their changes don't affect your template. • Reuse common design elements by creating child templates. • Allow contributors to create site pages that are based on the template. 542 Extend Salesforce with Clicks, Not Code Site.com About Child Templates Child templates are a useful way to reuse common design elements for more complicated page layouts. For example, your website will probably have elements that are the same on every page in your site, such as a navigation menu. However, several pages may have elements that are common only to them, such as pages in a subsection of your site that include a subsection header. By using a child template, which is a template that's based on another template, you can reuse the main template design. Using our main page template as a base, the child template inherits the non-editable header and navigation menu (1), and an editable center panel (2) where we add the non-editable subsection header (3). We also need to add a new editable center panel (4) because the center panel of the main template is editable only in pages directly based on the main template. Now, any page based on the child template includes the non-editable main header, navigation menu, and subsection header, and an editable center panel (5) for that page's content. Best Practices • Plan your site structure and the layout of your pages. Taking the time to plan your website first saves time when you build your site. • Identify which elements are common to all the pages of your site, such as navigation menus or headers, as these are the elements you can add to the page template. • Use page templates wherever possible to promote content reuse and save time. • Try to keep the design of your main page template as simple as possible to make it easier to modify in the future. For more complicated site designs, use child templates to achieve maximum flexibility. SEE ALSO: Creating Site.com Page Templates Creating Site.com Pages Setting Up the Contributor’s Studio View Identifying Which Template a Site.com Page Uses 543 Extend Salesforce with Clicks, Not Code Site.com Creating Site.com Page Templates A page template lets you define the layout and functionality of site pages in one location. By adding EDITIONS common page elements to the template and then basing site pages on it, you can achieve a consistent look and feel throughout your site. And because a template-based page inherits the Available in: Salesforce template's elements, you can make site-wide changes from one location. Classic (not available in all You can create a page template from a layout, or if you've already created a template, you can use orgs) it as a base to create a child template, which lets you reuse the design of the main template. Available for purchase in: Enterprise, Performance, Creating a Page Template from a Layout and Unlimited Editions To start from scratch with a completely blank template or use a basic page layout: Available (with limitations) in: Developer Edition 1. Hover over Page Templates on the Overview tab and click New, or click New Page Template in the Page Templates view. 2. Enter the page template name. Template names can’t include special characters, such as #, ?, USER PERMISSIONS or @. To build, edit, and manage 3. Click Layouts and select either a blank page or a predefined page layout, such as a page with Site.com sites: a header and footer. • Site.com Publisher User Note: Predefined page layouts use panels to create columns, headers, and footers. These field enabled on the user panels use inline CSS to set their position, so you can easily modify the layout after the detail page page is created. However, if you're familiar with CSS and prefer using CSS rules, you can AND remove the inline style by selecting the panel, deleting the code from the Code tab in Site administrator or the Style pane ( ), and clicking Apply. designer role assigned at the site level 4. Choose a layout mode: • To expand the page to fill the width of the browser window, click Full width. • To set the page width, click Fixed width and enter the width. 5. Click Create. The page template opens. Next, you must complete the template. Tip: • By default, any template you create is only available to other site administrators and designers in your organization. To let contributors create pages based on the template, select Available to Contributor in the Properties pane ( ). • You can also create templates by converting or duplicating other pages. Creating a Child Template To use an existing template as a base for a child template: • The quickest option is to: 1. Select the template in the Page Templates view on the Overview tab and click > Create Child Template. Alternatively, click Page Actions > Create Child Template if the template is open. 2. Enter the page template name. Template names can’t include special characters, such as #, ?, or @. 3. Click Create. The child template opens. • Alternatively: 544 Extend Salesforce with Clicks, Not Code Site.com 1. Hover over Page Templates on the Overview tab and click New, or click New Page Template in the Page Templates view. 2. Enter the page template name. Template names can’t include special characters, such as #, ?, or @. 3. Click Page templates and select the page template. 4. Click Create. The child page template opens. Completing Your Template Once you've created a template, you must take the next steps to complete it: • Lay out the page template • Add other page elements to the template • Create editable areas • Create template-based site pages SEE ALSO: Creating Editable Template Areas Identifying Which Template a Site.com Page Uses Site.com Page Templates Overview Setting Up the Contributor’s Studio View Creating Editable Template Areas As the template creator, you specify which elements users can edit in pages based on the template. EDITIONS To make a page element editable in derived pages or child templates, select it on the page template or in the Page Structure pane ( ) and click > Make Editable, or select Editable in the Available in: Salesforce Classic (not available in all Properties pane ( ). orgs) When the page template is open, editable page elements are highlighted with a blue border on Available for purchase in: the page. They also display a pencil icon ( ) in the Page Structure pane and in the information Enterprise, Performance, popup that appears when you hover over the element on the page. and Unlimited Editions Available (with limitations) in: Developer Edition USER PERMISSIONS To build, edit, and manage SEE ALSO: Site.com sites: About Editable Page Elements • Site.com Setting Up the Contributor’s Studio View Publisher User field enabled on the user Creating Site.com Page Templates detail page AND Site administrator or designer role assigned at the site level 545 Extend Salesforce with Clicks, Not Code Site.com About Editable Page Elements When you mark a page element as Editable on a page template, that page element becomes EDITIONS editable in any child pages or templates derived from the parent template. Consider these tips when creating editable page elements. Available in: Salesforce Classic (not available in all • Editable page elements are highlighted with a blue border in child pages and templates. orgs) • If you make a page element within a panel editable, you can’t also make the container panel editable. Available for purchase in: Enterprise, Performance, • Users can't alter the events, style, or properties of an editable page element in pages based on and Unlimited Editions the template. Available (with limitations) • Users can't resize, reposition, or delete editable page elements in pages based on the template. in: Developer Edition However, if the element's Auto Height property is enabled in the template, its height will adjust to fit the content of the template-based page. • Deleting an editable element from a page template removes it from all child pages and templates. • When you enable the Editable property of a page element, any pages or child templates based on the template also inherit the enabled status. In turn, the enabled status in the child template cascades to any of its children, and so on. If you don’t want its editability to cascade to any lower levels, disable the Editable property of a page element in a child template. Editable Page Elements for Contributors • Contributors can modify editable content blocks in site pages based on the template. They can also edit content blocks that you place in an editable panel in template-based site pages. Tip: To add a content block that only other site administrators or designers can edit, use custom code instead. • Contributors can add content blocks to editable panels in site pages based on the template. If you make widgets available to contributors, they can also add them to editable panels. • Site administrators and designers can edit any page element you make editable. Default Content in Editable Page Elements The content of all editable page elements on a child page or template is linked to the content of the editable elements on its parent page template. When you update the content of an editable page element on the parent template, the changes are pushed down to any child pages or page templates. However, if you modify the content of an editable page element at the child page or template level, you break the link between the elements, and any subsequent changes made to the page element on the parent template won't trickle down to its children. (To return control of the content to the parent template, select the editable page element on the page or in the Page Structure pane and click > Revert to Parent Content. When you do this, any custom content in the editable page element is lost.) Disabling the Editable property of a panel in a parent template overrides any changes made to that panel in child pages or templates. Changes to the panel at the child level disappear, and the panel reflects only the content from the parent template. However, the changes 546 Extend Salesforce with Clicks, Not Code Site.com at the child level aren’t lost. Re-enabling the Editable property of the panel in the parent template restores the custom content previously added to its children. Any changes made to the element at the parent level will no longer show up. SEE ALSO: Creating Editable Template Areas Setting Up the Contributor’s Studio View Creating Site.com Page Templates Editing and Working With Site.com Page Elements Creating Site.com Pages As a site administrator or designer, when you create a site page, you can choose to base it on a EDITIONS page template. If you're creating several site pages that have common page elements, such as a navigation menu, you can save time and effort and achieve a consistent look and feel by creating Available in: Salesforce a page template first and then basing your site pages on it. Alternatively, if none of your site pages Classic (not available in all have a similar structure or if you need to create a one-off site page that doesn't follow the overall orgs) site design, such as a home page, you can create a page based on a basic layout. Available for purchase in: Enterprise, Performance, Creating Site Pages from a Layout and Unlimited Editions Start from scratch with a completely blank page or use a basic page layout. Available (with limitations) 1. Hover over Site Pages on the Overview tab and click New, or click New > Site Page when in: Developer Edition the Site Pages view is open. 2. Enter the site page name. Page names can’t include spaces or special characters, such as #, ?, USER PERMISSIONS or @. To build, edit, and manage 3. Click Layouts and select either a blank page or a predefined page layout, such as a page with Site.com sites: a header and footer. • Site.com Note: Predefined page layouts use panels to create columns, headers, and footers. These Publisher User panels use inline CSS to set their position, so you can easily modify the layout after the field enabled on the user detail page page is created. However, if you're familiar with CSS and prefer using CSS rules, you can remove the inline style by selecting the panel, deleting the code from the Code tab in AND the Style pane ( ), and clicking Apply. Site administrator or designer role assigned 4. Choose a layout mode: at the site level • To expand the page to fill the width of the browser window, click Full width. • To set the page width, click Fixed width and enter the width. 5. Click Create. The site page opens. Creating Site Pages from a Page Template If you created a page template, you can base your site pages on it. The quickest option is to: 1. Select the template in the Page Templates view and click > Create Page from Template. Alternatively, click Page Actions > Create Page from Template if the template is open. 547 Extend Salesforce with Clicks, Not Code Site.com 2. Enter the site page name. Page names can’t include spaces or special characters, such as #, ?, or @. 3. Click Create. The site page opens. Alternatively: 1. Hover over Site Pages on the Overview tab and click New, or click New > Site Page when the Site Pages view is open. 2. Enter the site page name. Page names can’t include spaces or special characters, such as #, ?, or @. 3. Click Page templates and select the page template. 4. Click Create. The site page opens. Tip: You can also create pages by converting or duplicating other pages. SEE ALSO: Editing Site.com Pages as a Designer or Site Administrator Adding Site.com Page Elements Identifying Which Template a Site.com Page Uses When you edit a template-based page, you can't modify its non-editable page elements. You also EDITIONS can't reposition, resize, or delete editable page elements, or alter the events, properties, or style associated with them. To update these elements or properties, you must edit them in the template Available in: Salesforce the page is based on. Classic (not available in all To identify which page template a site page is based on: orgs) • Hover over the site page in the Sites Pages view on the Overview tab. An information popup Available for purchase in: appears that displays the page template's name. Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition USER PERMISSIONS To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user • Examine the Page Structure pane when the page is open. The template's name is displayed as detail page a link that you can click to open the template. AND Site administrator or designer role assigned at the site level 548 Extend Salesforce with Clicks, Not Code Site.com Tip: To view and open the site pages associated with a particular page template, select or hover over the page template in the Page Templates view of the Overview tab and click > Edit Pages Based on Template. Click a listed site page to open it. SEE ALSO: Creating Site.com Page Templates Site.com Page Templates Overview Renaming, Duplicating, and Converting Pages When working with pages and templates, you can perform common tasks, such as renaming, EDITIONS deleting, or duplicating pages. To access more page options, select or hover over a page on the Site Pages view of the Overview Available in: Salesforce tab and click . Classic (not available in all orgs) To access more template options, select or hover over a template in the Page Templates view of the Overview tab and click . Available for purchase in: Enterprise, Performance, Alternatively, if the page or template is open, click on the toolbar. and Unlimited Editions The available options vary for pages and templates: Available (with limitations) in: Developer Edition Select To... Edit Open the page or template for editing. Alternatively, double-click the USER PERMISSIONS page or template. To build, edit, and manage Rename Change the page or template name. Site.com sites: • Site.com Preview View the page in a browser window. Publisher User Duplicate Create a copy of the page or template. field enabled on the user detail page Duplicating a page template doesn’t duplicate the pages or templates AND based on it. Site administrator or Delete Remove a page or template. You can't delete a template that has designer role assigned at the site level pages based on it. 549 Extend Salesforce with Clicks, Not Code Site.com Select To... Create Child Template Create a child template based on the selected template. Create Page from Template Create a page based on the template. Convert Site Page to Template Change the page into a template. Convert Template to Site Page Change the template into a page. You can't convert a template that has pages based on it. Edit Pages Based on Template View and open the site pages that are based on the selected page template. Add IP Restrictions Control access to the page or template by restricting the range of permitted IP addresses. When you create a page that’s based on a template with IP restrictions, the page inherits the IP restrictions. SEE ALSO: Editing Site.com Pages as a Designer or Site Administrator Using Site.com Studio as a Site Administrator or Designer Changing a Page’s Doctype Property The Document Type Definition (DTD) or doctype of a page defines which version of HTML it’s using. EDITIONS This information is used by some browsers to trigger a standard rendering mode. By default, each page’s doctype is set to HTML5, which is the latest version, but you can change it to XHTML 1.0. Available in: Salesforce When the page is open: Classic (not available in all orgs) 1. Select the page in the Page Structure pane. 2. In the Properties pane, select an option in the Doctype drop-down list. Available for purchase in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Available (with limitations) Changing a Page Element’s HTML Tag in: Developer Edition Adding Custom HTML Attributes HTML5 Semantic Page-Layout Tags USER PERMISSIONS To build, edit, and manage Site.com sites: • Site.com Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level 550 Extend Salesforce with Clicks, Not Code Site.com Site.com Page Elements Page elements are the building blocks of your site pages and page templates. Combined, they EDITIONS provide the page's structure and content. When a site page or page template is open in Site.com Studio, these page elements are available Available in: Salesforce to site administrators and designers. Classic (not available in all orgs) Page Element Description Available for purchase in: Content Block Contains the page text, and can also house Enterprise, Performance, images, media, and hyperlinks. Also available to and Unlimited Editions contributors if the page has editable areas. Available (with limitations) in: Developer Edition Custom Code Lets you customize your site by adding markup, such as HTML and JavaScript for elements that aren't provided in Site.com Studio. Image Adds images directly to the page. Breadcrumb Adds a breadcrumb navigation element to the page. Menu Creates a menu that lets users navigate through the pages of your site. Panel Adds structure to the page and lets you group other page elements together. Button Adds a button to the page. You can use the actions in the Events pane to add functionality to the button. Form Lets you create web-to-lead forms or gather customer feedback, and submit the data to Salesforce objects. Input Fields Provides several field types to add to forms or pages. When added to a form, binds to fields in the form’s object. See Input Field Types. Data Element Must be contained in a data repeater. Binds to a field in the data repeater’s object and acts as a placeholder that shows the content of a specified field for the current record. Data Function Connects to a standard or custom Salesforce object, performs calculations on the returned results, and displays the calculation on the page. Data Repeater Connects to a Salesforce object and returns a dataset based on filters that you specify. Combines with data elements or custom code page elements to display the results on the page. 551 Extend Salesforce with Clicks, Not Code Site.com Page Element Description Data Table Connects to a standard or custom Salesforce object, retrieves a data set based on the filter criteria that you specify, and displays one or more record as rows in the table. Adding Site.com Page Elements Editing and Working With Site.com Page Elements Laying Out Site.com Pages Using Panels Positioning Panels Using CSS Adding Images Directly to the Page Adding Content Blocks to Pages Content blocks contain the text of your website pages, and can also house images, videos, and hyperlinks. Designers and site administrators can add content blocks to pages when in Design Mode. Adding Custom Code to Pages Custom code lets you customize your site using markup, such as HTML and JavaScript. About the Site Map and Page Hierarchy Adding Custom HTML Attributes You can add custom HTML attributes to pages and page elements, which are rendered on the HTML tag of the page element. For example, this is useful when working with third-party frameworks that render page elements differently based on certain attributes. Changing a Page Element’s HTML Tag By default, panels, data repeaters, data elements, custom code, and content blocks are each defined as a div, but you can change this to any other HTML tag using the HTML Tag property. This gives you greater flexibility and control over how the page element is displayed on the page. HTML5 Semantic Page-Layout Tags SEE ALSO: Adding Site.com Page Elements Editing and Working With Site.com Page Elements 552 Extend Salesforce with Clicks, Not Code Site.com Adding Site.com Page Elements Page elements are the building blocks of your site pages and page templates. Panel elements add EDITIONS structure to your pages. You can think of both pages and panels as “containers” for the page elements that you add to them. Available in: Salesforce If a site page or page template is based on another page template, you can only add page elements Classic (not available in all to editable panels, which are highlighted with a blue border on the page. orgs) Pages, panels, data repeaters, and forms are “container” page elements, so you can add other page Available for purchase in: elements to them when the page is open. Enterprise, Performance, and Unlimited Editions • In the Page Elements pane ( ), either: Available (with limitations) – Drag the page element onto the page canvas or container page element. in: Developer Edition – Click the page element, select where to place it in the popup that appears, and click Apply. • In the Page Structure pane ( ), hover over a container page element and click > Add USER PERMISSIONS Page Elements. Click the item you want to add or drag it onto the container page element. To build, edit, and manage • Select a container page element on the page and click > Add Page Elements. Click the Site.com sites: item you want to add or drag it into the container page element. • Site.com When you drag a page element into an editable panel, the page element displays a permitted icon Publisher User and a green border shows where you're placing the element. field enabled on the user detail page AND Site administrator or designer role assigned at the site level If you try dragging a page element into a panel that isn't editable, the page element displays a not-permitted icon. SEE ALSO: Editing and Working With Site.com Page Elements Adding Images Directly to the Page Adding Content Blocks to Pages Adding Custom Code to Pages Adding a Navigation Menu 553 Extend Salesforce with Clicks, Not Code Site.com Editing and Working With Site.com Page Elements The Page Structure pane ( ) displays the hierarchy of all elements on the page and is a very EDITIONS useful way of selecting, moving, and reordering elements, particularly for more complicated page designs. Available in: Salesforce Classic (not available in all • To select a page element, either click it on the page, or select it in the Page Structure pane. This orgs) highlights the element on the page and displays the item's selector bar and Actions menu ( ). Available for purchase in: • To edit a page element, such as a content block, image, or custom code, either: Enterprise, Performance, and Unlimited Editions – Double-click the element on the page. Available (with limitations) – Select the element on the page and click > Edit on its selector bar. in: Developer Edition – Select or hover over the element in the Page Structure pane and click > Edit. – Click Edit Content on the toolbar (for content blocks only). USER PERMISSIONS • To move a page element, either: To build, edit, and manage – Select the element on the page and drag it to the correct position, or click > Move Site.com sites: on its selector bar. • Site.com – Drag the item to your preferred location in the Page Structure pane, or select it and click Publisher User > Move > Direction. You can also drag all page elements other than panels to field enabled on the user your preferred location in the Page Structure pane. detail page AND • To resize a page element, select it and drag the resize handles to the correct size. If the corner Site administrator or resize handles are grayed out, it means the item's Auto Height property is enabled, which adjusts designer role assigned the height depending on its contents. To resize it to a set height, disable the property by either at the site level deselecting Auto Height in the Properties pane ( ), or by clicking one of the bottom resize handles and clicking Disable Auto Height in the popup message that appears. Tip: If you disable the Auto Height property on an image, but you want it to retain its aspect ratio—the relationship of height to width—press and hold down the SHIFT key while you drag to resize it. Alternatively, if you're using CSS to style the page element, adjust the style of the class or ID that styles it. • To delete an element, select it and either: – Click > Delete on the item's selector bar. – Press DELETE. – Click on the toolbar. – In the Page Structure pane, click > Delete. If a site page or page template is based on another page template: • The content of all editable page elements on a child page or template is linked to the content of the editable elements on its parent page template. When you update the content of an editable page element on the parent template, the changes are pushed down to any child pages or page templates. However, if you modify the content of an editable page element at the child page or template level, you break the link between the elements, and any subsequent changes made to the page element on the parent template won't trickle down to its children. • You can't reposition or resize its page elements. However, if the element's Auto Height property is enabled in the template, the height will adjust to fit the content in the template-based page. To edit the page element, you must edit it in the page template. • You can't delete its page elements. To delete the page element, you must delete it from the page template. 554 Extend Salesforce with Clicks, Not Code Site.com • You can't alter the events, properties, or style of an editable page element, such as its color, position, and size. SEE ALSO: Site.com Page Elements Adding Site.com Page Elements Adding Content Blocks to Pages Laying Out Site.com Pages Using Panels About Editable Page Elements Laying Out Site.com Pages Using Panels A panel is a useful layout tool that defines the logical divisions of your page and lets you group EDITIONS page elements together for easy movement and positioning. Think of it as a container for other page elements, including other panels, or as a div that wraps around the content placed within Available in: Salesforce it. Panels are ideal for adding editable areas to page templates. Classic (not available in all When you create a page template or site page, you can use predefined page layouts that include orgs) headers, footers, and columns, which are created using panels. Once created, you can then further Available for purchase in: modify the layout to match your site's design. Enterprise, Performance, If you need to add more divisions to the page and you're not familiar with CSS, the easiest method and Unlimited Editions is to use row and column panels. This feature adds panels with predefined CSS positioning to ensure Available (with limitations) they align correctly on the page. in: Developer Edition Note: Predefined page layouts, and row and column panels use inline CSS to set their position. If you're familiar with CSS and are using CSS rules to style your site, you can remove the inline USER PERMISSIONS CSS by deleting it from the Code tab in the Style pane ( ) and clicking Apply. To build, edit, and manage To add row and column panels to a page: Site.com sites: • Site.com 1. Select the page (the top folder icon) in the Page Structure pane ( ). Publisher User 2. Click > Add Rows and Column Panels. field enabled on the user detail page 3. Select the number of row or column panels you require. If the page already contains content, it is placed in the first new panel. AND To add a row panel: Site administrator or designer role assigned • Above a panel, select the panel on the page or in the Page Structure pane and click > at the site level Add Rows and Column Panels > Insert Row Above • Below a panel, select the panel on the page or in the Page Structure pane and click > Add Rows and Column Panels > Insert Row Below To add row and column panels to another panel: 1. Select the panel on the page or in the Page Structure pane. 2. Click > Add Rows and Column Panels. 3. Select the number of row or column panels you require. If the page already contains content, it is placed in the first new panel. To add a single panel, drag a Panel from the Page Elements pane ( ) onto the page. 555 Extend Salesforce with Clicks, Not Code Site.com By default, the height of a panel automatically adjusts when you add content to it because its Auto Height property is enabled. You can disable the property to resize and reposition panels. If you hover over a panel on the page, an information popup appears that displays the width and height of the panel. When you drag a page element onto a panel, the edges change color, indicating that the element is now grouped within it. To remove the element from the group, drag it outside the panel. SEE ALSO: Adding Site.com Page Elements Positioning Panels Using CSS Changing a Page Element’s HTML Tag Positioning Panels Using CSS A panel is a useful layout tool that defines the logical divisions of your page. Using CSS, you can EDITIONS position panels and improve the layout of the page. Available in: Salesforce Adding Padding and Margins to Panels Classic (not available in all orgs) Two CSS properties—margins and padding—can help with your page layout by creating space between the rows and columns, and the content within. The margin property controls the space Available for purchase in: outside the panel between its border and outer edge, while the padding property controls the Enterprise, Performance, space between the panel's content and border. and Unlimited Editions To add margins and padding: Available (with limitations) in: Developer Edition 1. Select the panel. 2. Open the Dimensions section of the Style pane. USER PERMISSIONS 3. In the Margins section, either: • Set the margin width for all four sides by entering a value in the All text box and selecting To build, edit, and manage the unit of measurement. Site.com sites: • Site.com • Set the margin widths for the top, right, bottom, or left sides independently by entering a Publisher User value in the appropriate text box and selecting the unit of measurement. field enabled on the user detail page 4. Similarly, in the Padding section, set the padding widths as required. Adding padding increases the total width of the panel. For example, if you have a panel with a width of 500px and you AND add padding of 20px to all sides, the total width of the panel will be 540px. Site administrator or designer role assigned Tip: You can center a panel or block page element using the margin property. Enter 0 in at the site level the All text box and select Auto in the drop-down list. Creating Column Panels Using the Float Property If you need to add more divisions to the page and you're not familiar with CSS, the easiest method is to use row and column panels. Alternatively, using the CSS float property, you can position panels to the left or right to create columns. (When you add panels using 556 Extend Salesforce with Clicks, Not Code Site.com the row and column panels feature, they're automatically positioned using the float property.) For example, you could add two single panels to a container panel and set both panel's float and width properties to create a two-column page layout. To create a column panel: 1. Select the panel. 2. Open the Layout section of the Style pane. 3. Click to float the panel to the left, or click to float the panel to the right. If you're creating a two-column layout, for example, ensure you set the float property of both panels. 4. Adjust the width of the panel to ensure the panels align correctly by either setting the width in the Dimensions section or dragging the panel's border on the page. For example, if you're creating two columns of equal width, set the width of both panels to 50%. Tip: When you use the float property, remember to set the overflow property of the container panel to “hidden.” This allows the container panel to grow as the height of the column panels increase. Select the container panel and in the Layout section of the Style pane, select Hidden in the Overflow drop-down list. SEE ALSO: Cascading Style Sheets Overview Laying Out Site.com Pages Using Panels Adding Images Directly to the Page As a site administrator or designer, you can add images directly to your site pages and page templates EDITIONS or you can add images to content blocks. To add an image directly to the page: Available in: Salesforce Classic (not available in all 1. Open the site page or page template. orgs) 2. Drag an Image from the Page Elements pane onto the page. Available for purchase in: 3. In the Add an Image dialog box, either: Enterprise, Performance, • Find an existing image by typing its name in the Search Image text box and selecting and Unlimited Editions it from the list. Available (with limitations) • Upload an image from your computer in the Upload tab by browsing to the image, clicking in: Developer Edition Upload, and selecting it from the list. 4. Click Apply. The image is added to the page. USER PERMISSIONS 5. Enter a brief description of the image in the Alternative Text field in the Properties To build, edit, and manage pane. The description is used by screen reader users or as a substitute if the browser can’t display Site.com sites: the image. It can also help with search engine optimization (SEO). • Site.com Publisher User SEE ALSO: field enabled on the user detail page Adding Site.com Page Elements AND Editing and Working With Site.com Page Elements Site administrator or designer role assigned at the site level 557 Extend Salesforce with Clicks, Not Code Site.com Adding Content Blocks to Pages Content blocks contain the text of your website pages, and can also house images, videos, and EDITIONS hyperlinks. Designers and site administrators can add content blocks to pages when in Design Mode. Available in: Salesforce To add a content block when the page is open, either drag it from the Page Elements pane onto Classic (not available in all the page or target a container page element. orgs) To edit a content block, double-click it. For greater control over the text, you can edit the HTML Available for purchase in: directly by selecting the content block and clicking > Edit HTML. Enterprise, Performance, and Unlimited Editions If you make a content block in a page template editable, contributors can edit the content block in any page based on the template. To add a content block that only other site administrators or Available (with limitations) designers can edit, use custom code instead. in: Developer Edition Understanding the Content Editing Toolbar USER PERMISSIONS Editing Content Blocks in Design Mode To build, edit, and manage Designers and site administrators can edit content blocks on the page. Content blocks contain Site.com sites: the text for site pages, and can also house images, videos, and hyperlinks. • Site.com Adding Images to Content Blocks in Design Mode Publisher User field enabled on the user Adding Video to Content Blocks in Design Mode detail page Attaching Hyperlinks to Text and Images in Design Mode AND Adding Anchors to Pages in Design Mode Site administrator or designer role assigned at the site level SEE ALSO: Adding Images to Content Blocks in Design Mode Attaching Hyperlinks to Text and Images in Design Mode Understanding the Content Editing Toolbar Designers and site administrators can edit content blocks when in Design mode. Content blocks EDITIONS contain the site page's text, along with images, videos, and hyperlinks. Available in: Salesforce Classic (not available in all orgs) Available for purchase in: Enterprise, Performance, and Unlimited Editions Available (with limitations) in: Developer Edition 558 Extend Salesforce with Clicks, Not Code Site.com When in Design Mode, you can use the content editing toolbar to: • Undo and redo your edits, and remove the formatting of text copied and pasted from Microsoft® Office, which can often include hidden formatting (1). • Cut, copy, and paste text (2). • Apply direct formatting (3), such as: – Font family and size – Bold, italic, underline, subscript, superscript, and strikethrough – Font and highlight color • Control the text style and layout (4) by: – Applying paragraph and heading styles – Setting paragraph indentation – Left-aligning, centering, right-aligning, or justifying text – Inserting numbered or bulleted lists • Insert a table, and add rows, columns, and spacing (5). • Add images, videos, and special characters (6). • Add and remove hyperlinks and anchors (7). Tip: Avoid applying formatting, such as different fonts or highlighting, directly to text whenever possible. Instead, it’s best practice to use the paragraph and heading styles to quickly apply consistent formatting throughout the site. This also ensures that all page text is updated automatically if a site administrator or designer modifies the site's paragraph and heading styles. 559 Extend Salesforce with Clicks, Not Code Site.com Editing Content Blocks in Design Mode Designers and site administrators can edit content blocks on the page. Content blocks contain the EDITIONS text for site pages, and can also house images, videos, and hyperlinks. When the page is open in Design Mode: Available in: Salesforce Classic (not available in all 1. Double-click the content block on the page. orgs) 2. Add or edit text and format it using the content editing toolbar. Available for purchase in: Tip: Enterprise, Performance, and Unlimited Editions • If you copy and paste text from Microsoft® Office, highlight the text and click to remove any hidden formatting, which can adversely affect how the text appears on Available (with limitations) the page. in: Developer Edition • Avoid applying formatting, such as different fonts or highlighting, directly to text whenever possible. Instead, it’s best practice to use the paragraph and heading styles USER PERMISSIONS to quickly apply consistent formatting throughout the site. This also ensures that all page text is updated automatically if a site administrator or designer modifies the To build, edit, and manage site's paragraph and heading styles. Site.com sites: • Site.com 3. Add images, videos, hyperlinks, or anchors as required. Publisher User field enabled on the user 4. Click Save. detail page Note: The content of all editable page elements on a child page or template is linked to the AND content of the editable elements on its parent page template. When you update the content Site administrator or of an editable page element on the parent template, the changes are pushed down to any designer role assigned child pages or page templates. However, if you modify the content of an editable page at the site level element at the child page or template level, you break the link between the elements, and any subsequent changes made to the page element on the parent template won't trickle down to its children. 560 Extend Salesforce with Clicks, Not Code Site.com Adding Images to Content Blocks in Design Mode Designers and site administrators can add images to content blocks when viewing a page in Design EDITIONS Mode. When the page is open: Available in: Salesforce Classic (not available in all 1. Double-click the content block on the page. orgs) 2. Position your cursor where you want to insert the image and click . Available for purchase in: 3. In the Image Properties dialog box, either: Enterprise, Performance, • Enter a URL to an image in the Image URL field. and Unlimited Editions • Select an image from your website by clicking From Website and selecting the image in Available (with limitations) the list that appears. in: Developer Edition • Upload an image from your computer by opening the Upload tab, browsing to the image, and clicking Upload. USER PERMISSIONS 4. Enter a brief description of the image in the Alternative text field. The description is To build, edit, and manage used by screen reader users or as a substitute if the browser can’t display the image. It can also Site.com sites: help with search engine optimization (SEO). • Site.com Publisher User 5. Optionally, preview how the image appears in relation to the text on the page and set: field enabled on the user • The width and height of the image detail page • How much space surrounds the image (which is controlled by the HSpace and VSpace AND properties) Site administrator or • How it aligns with the text on the page designer role assigned at the site level • The image border (for example, to set a dotted green border that's 10 pixels wide, you enter 10px dotted green in the Border field) To edit only content in Site.com sites: 6. Click Apply. • Site.com 7. Click Save. Contributor User AND SEE ALSO: Contributor role Editing Content Blocks in Design Mode assigned at the site level Understanding the Content Editing Toolbar Importing and Managing Assets 561 Extend Salesforce with Clicks, Not Code Site.com Adding Video to Content Blocks in Design Mode ® ® ® ® ® Designers and site administrators can add YouTube , Google , Adobe Flash , Windows Media , EDITIONS and Apple QuickTime® videos to content blocks when viewing a page in Design Mode. When the page is open: Available in: Salesforce Classic (not available in all 1. Double-click the content block on the page. orgs) 2. Position your cursor where you want to insert the video and click . Available for purchase in: 3. In the Video Properties dialog box, select the video type and either: Enterprise, Performance, • Enter the URL to the video in the Video URL text box—for example, and Unlimited Editions http://www.youtube.com/watch?v=123abc. Available (with limitations) • Select a video from your website by clicking From Website and selecting the video in the in: Developer Edition list that appears. • Upload a video from your computer by opening the Upload tab, browsing to the image, USER PERMISSIONS and clicking Upload. To build, edit, and manage Note: You can only select or upload Flash, Windows Media, and QuickTime videos. Site.com sites: • Site.com 4. To specify how the video is displayed on the page, you can set: Publisher User field enabled on the user • The width and height of the video detail page • How much space surrounds the video (which is controlled by the HSpace and VSpace AND properties) Site administrator or • How it aligns with the text on the page designer role assigned at the site level You can also preview the video. 5. Click Apply. The video appears as an icon in the content block. To edit only content in Site.com sites: 6. Click Save. • Site.com Note: You can view all video types, other than Windows Media videos, when you preview Contributor User a page. AND Contributor role SEE ALSO: assigned at the site level Editing Content Blocks in Design Mode Understanding the Content Editing Toolbar 562 Extend Salesforce with Clicks, Not Code Site.com Attaching Hyperlinks to Text and Images in Design Mode When viewing a page in Design Mode, designers and site administrators can create hyperlinks to: EDITIONS • External Web pages or websites • Pages and assets in the site Available in: Salesforce Classic (not available in all • Email messages orgs) • Anchors on the page Available for purchase in: When the page is open: Enterprise, Performance, 1. Double-click the content block on the page. and Unlimited Editions Available (with limitations) 2. Select the text or image that you want to attach a hyperlink to and click . in: Developer Edition 3. Select the link type in the Link to drop-down list. To link to: • A Web page: USER PERMISSIONS a. Select A URL. To build, edit, and manage b. Type the address in the URL field—for example, Site.com sites: http://www.externalsite.com. • Site.com c. Go to step 4. Publisher User field enabled on the user • A page or item in your site: detail page a. Select An item in your site. AND b. Select the item type, such as a page or image. Site administrator or designer role assigned URL c. Select the item. (If you can’t see the list of items, place your cursor in the field and at the site level press the DOWN key on your keyboard.) d. Go to step 4. • An anchor that you previously added to the page: a. Select An anchor on the page. b. Select the anchor in the drop-down list. Alternatively, enter a new anchor name and create the anchor afterwards. c. Go to step 5. • An email message: a. Select An email. b. Enter the recipient's email address and the message information. c. Go to step 5. Note: For content blocks in a data repeater, you can use expressions to add a custom link, such as a URL query string, to an item in your site or to a Web page. 4. To select which window the item should open in, select an option in the Target drop-down list: • Popup window loads the item into a popup window. When you select this option, you can set the title for the popup and control its appearance and size with the options that appear. • New window (_blank) loads the item into a new, unnamed browser window. • Same window (_self) loads the item into the same frame or window as the link. This is the default setting. • Topmost window (_top) loads the item into the topmost parent frameset or window of the frame that contains the link. 563 Extend Salesforce with Clicks, Not Code Site.com • Parent window (_parent) loads the item into the parent frameset or window of the frame that contains the link. 5. Optionally, enter a tooltip description for the link. The tooltip displays as a pop-up when the user hovers over the link. 6. Click Apply. 7. Click Save. To delete a hyperlink, select it and click . SEE ALSO: Editing Content Blocks in Design Mode Understanding the Content Editing Toolbar Adding Anchors to Pages in Design Mode An anchor is an invisible marker that identifies a particular location on a page. If you’re a designer EDITIONS or site administrator, you can add an anchor to the page and then create a hyperlink that jumps to that specific location. This can be useful if a page is particularly long; for example, if your page has Available in: Salesforce several sections, you could add links to each section at the top of the page to aid navigation. Classic (not available in all When the page is open in Design Mode: orgs) 1. Double-click the content block on the page. Available for purchase in: 2. Enterprise, Performance, Place your cursor at the beginning of the line where you want to link to and click . and Unlimited Editions 3. Enter a name for the anchor and click Apply. Ideally, use a name that helps identify the anchor’s Available (with limitations) location on the page—for example, top. in: Developer Edition 4. Now create a hyperlink that links to the anchor. USER PERMISSIONS SEE ALSO: Attaching Hyperlinks to Text and Images in Design Mode To build, edit, and manage Site.com sites: Editing Content Blocks in Design Mode • Site.com Understanding the Content Editing Toolbar Publisher User field enabled on the user detail page AND Site administrator or designer role assigned at the site level To edit only content in Site.com sites: • Site.com Contributor User AND Contributor role assigned at the site level 564 Extend Salesforce with Clicks, Not Code Site.com Adding Custom Code to Pages Custom code lets you customize your site using markup, such as HTML and JavaScript. EDITIONS • Add markup to a specific location on a page using the Custom Code page element. JavaScript added using the Custom Code page element loads when that part of the page loads. Available in: Salesforce • Add markup to the page head. JavaScript in the page head loads first. Classic (not available in all orgs) • Add JavaScript to the page body. JavaScript added to the page body is positioned at the end of the body tag and only loads when the DOM is ready. Available for purchase in: Enterprise, Performance, • Add a reference to a JavaScript file or library in the page head or body. and Unlimited Editions Tip: Available (with limitations) • Scripts can't execute while you're editing a page in Site.com Studio. To test your code, in: Developer Edition preview the page. • If you are building a Site.com site from an existing HTML site, avoid using the Custom USER PERMISSIONS Code page element to paste large chunks HTML from the original site. Instead, use the available page elements, such as panels, content blocks, and data tables. This will let you To build, edit, and manage make future updates and design changes much more easily. Site.com sites: • Site.com Publisher User Adding Markup Directly to the Page field enabled on the user detail page 1. Drag a Custom Code page element from the Page Element pane onto the page. AND 2. Enter the code in the Edit Code dialog box. Site administrator or 3. Click Save and Close to add the code directly to the page. designer role assigned at the site level Adding Markup to the Page Head 1. In the Scripts section of the Properties pane, click Configure in the Edit Head Markup section. 2. Enter the markup in the Edit HTML Code dialog box. 3. Click Save and Close to insert the markup into the page head. Adding JavaScript to the Page Body 1. In the Scripts section of the Properties pane, click Configure in the Edit Body Scripts section. 2. Enter the code in the Edit JavaScript Code dialog box. Don't add oncomplete="refreshFeed();"/> Note: When you redirect to a URL internal to your org, the action dialog closes upon completion or programmatically navigating away. If you set up the redirect to point to an external URL, the behavior can vary because an external URL opens in a new browser tab. 732 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Requirements for Refreshing Host Pages If you want an object-specific or global custom action to refresh the feed on the page that hosts it, the Visualforce page you create to use as that action must: • Reference the publisher JavaScript file: . (Creating custom Visualforce actions doesn’t require the Canvas SDK.) • Include this JavaScript call: Sfdc.canvas.publisher.publish({name : 'publisher.refresh', payload : {feed:true}});. Visualforce Pages as Global Custom Actions Visualforce pages used as global actions can be invoked in many different places and don’t have a specific record associated with them. They have complete “freedom of action,” which means it’s up to you to write the code. Hide the Action Header for Visualforce Custom Actions When creating a Visualforce page to use as a custom action, you can choose to hide the action’s header. Hiding the action header helps prevent user confusion, especially if you have your own buttons specified in the Visualforce page. SEE ALSO: Visualforce Pages as Global Custom Actions Create Object-Specific Quick Actions Quick Actions Visualforce Pages as Global Custom Actions Visualforce pages used as global actions can be invoked in many different places and don’t have a EDITIONS specific record associated with them. They have complete “freedom of action,” which means it’s up to you to write the code. Available in: both Salesforce Visualforce pages you create to use as global actions can’t use a standard object controller. You Classic (not available in all must write a custom controller to handle the page. orgs) and Lightning Experience When a global action completes, the user should be either redirected to a parent record created as part of the action or returned to where they started. Available in: Group, Professional, Enterprise, This code sample shows a Visualforce page designed to be used as a custom action on any object Performance, Unlimited, that supports actions. This action lets users create cases from record detail pages, Chatter, Chatter Contact Manager, groups (except customer groups), or the home page. It has a different user interface from standard Database.com, and create actions. As with all global actions, the records created through this action aren’t associated Developer Editions with other records. 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(); 733 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links 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(); } } } 734 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links style="width:500px;height:92px;margin-top:4px;" /> Requirements for Refreshing Host Pages To have an object-specific or global custom action refresh the feed on the page that hosts it, the Visualforce page you create to use as that action must: • Reference the publisher JavaScript file: . (Creating custom Visualforce actions doesn’t require the Canvas SDK.) • Include this JavaScript call: Sfdc.canvas.publisher.publish({name : 'publisher.refresh', payload : {feed:true}});. SEE ALSO: Visualforce Pages as Object-Specific Custom Actions Create Global Quick Actions Quick Actions Hide the Action Header for Visualforce Custom Actions When creating a Visualforce page to use as a custom action, you can choose to hide the action’s EDITIONS header. Hiding the action header helps prevent user confusion, especially if you have your own buttons specified in the Visualforce page. Available in: both Salesforce To hide the header, add showQuickActionVfHeader=“false” to the 735 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links The showQuickActionVfHeader attribute isn’t supported in Experience Cloud sites. SEE ALSO: Visualforce Pages as Object-Specific Custom Actions Visualforce Pages as Global Custom Actions Prerequisites for Using Canvas Apps as Custom Actions Using canvas apps as custom actions makes it easy to give users access to the functionality of your EDITIONS apps in Chatter and elsewhere in Salesforce. You can use as a custom action any canvas app that uses Publisher as a location. For example, you Available in: both Salesforce might use an expense report app as a custom action to make it easy for salespeople to submit Classic (not available in all expense reports directly from feeds. A custom action that includes a video conferencing canvas orgs) and Lightning app could help support agents communicate with customers visually for easier troubleshooting of Experience technical issues. Quick actions available in: Before creating a custom action with a canvas app, be sure the app uses Publisher as a location, Group, Professional, and be sure to give the users you want to be able to use the action access to the app. Enterprise, Performance, Unlimited, Contact SEE ALSO: Manager, Database.com, and Developer Editions Visualforce Pages as Object-Specific Custom Actions Custom canvas actions Quick Actions available in: Professional (with Canvas enabled), Enterprise, Performance, Unlimited, and Developer Editions Enable Actions in the Chatter Publisher Enabling actions in the publisher lets you add actions that you’ve created to the Chatter publisher. USER PERMISSIONS Actions appear on the Home page, on the Chatter tab, in Chatter groups, and on record detail pages. To enable actions in the Chatter publisher: Available in: Salesforce Classic (not available in all orgs) • Customize Application Available in: Group, Professional, Enterprise, Performance, Unlimited, Contact Manager, Database.com, and Developer Editions By default, the Salesforce Classic Chatter publisher includes the standard actions Post, File, Link, Poll, Question, and Thanks. With the actions in the publisher setting enabled, you can include nonstandard actions in the Chatter publisher too. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. In organizations created after the Winter ‘14 release, actions in the publisher is enabled automatically. 1. From Setup, enter Chatter Settings in the Quick Find box, then select Chatter Settings. 2. Click Edit. 3. Select Enable Actions in the Publisher. 736 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Although the Enable Actions setting appears in Lightning Experience, it has no effect there. 4. Click Save. Note: You aren’t required to enable actions in the publisher to use them in the Salesforce app or in third-party apps. See Actions With and Without Chatter for more information. Set Up Actions with Chatter Enabled Global and object-specific actions enhance the Chatter experience for your users in Salesforce Classic and in the Salesforce app. Set Up Actions Without Chatter Enabled You can set up object-specific and global actions for the Salesforce mobile app or third-party apps, even if your org doesn’t have Chatter enabled. Actions With and Without Chatter Use actions regardless of whether Chatter or actions in the publisher are enabled. Set Up Actions with Chatter Enabled Global and object-specific actions enhance the Chatter experience for your users in Salesforce EDITIONS Classic and in the Salesforce app. Chatter must be enabled for your organization. Available in: both Salesforce Classic (not available in all By default, the Chatter publisher in Salesforce Classic includes the standard actions Post, File, Link, orgs) and Lightning Poll, Question, and Thanks. To set up more actions in Chatter: Experience 1. Enable feed tracking for the objects for which you want to make actions available. Available in: Group, 2. Enable actions in the publisher if you want to see both standard actions and non-standard Professional, Enterprise, actions in the Chatter publisher. Performance, Unlimited, 3. Optionally, enable feed updates for related records to display feed items on a record detail page Contact Manager, when related records are created. Database.com, and Developer Editions 4. Create object-specific actions or global actions. 5. Customize the action layout with the fields that you want users to see when they use the action. USER PERMISSIONS 6. Add the actions to page layouts or global publisher layouts. Salesforce automatically adds default actions to the page layouts for account, case, contact, To set up actions: • Customize Application lead, and opportunity, and to the global publisher layout in organizations that were created after Winter ‘14. SEE ALSO: Enable Actions in the Chatter Publisher Create Object-Specific Quick Actions 737 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Set Up Actions Without Chatter Enabled You can set up object-specific and global actions for the Salesforce mobile app or third-party apps, EDITIONS even if your org doesn’t have Chatter enabled. When Chatter is disabled in an org, only the nonstandard actions appear in the action bar in the Available in: both Salesforce Salesforce mobile app or in third-party apps that use action lists. Nonstandard actions include Classic (not available in all Create, Update, Log a Call, custom actions, and Mobile Smart Actions. orgs) and Lightning Experience Note: You can create actions in Salesforce Classic when Chatter is disabled. Those actions don’t appear in Salesforce Classic, but can appear in Lightning Experience and the Salesforce Available in: Group, mobile app if you don’t customize the Salesforce Mobile and Lightning Experience Actions Professional, Enterprise, section of the page layout editor. Performance, Unlimited, Contact Manager, Follow these steps to set up actions for use in the Salesforce mobile app or third-party apps. Database.com, and 1. Create object-specific actions or global actions. Developer Editions 2. Customize the action layout with the fields that you want users to see when they use the action. USER PERMISSIONS 3. Add the actions to page layouts or global publisher layouts. Salesforce automatically adds default actions to the page layouts for account, case, contact, To set up actions: lead, and opportunity, and to the global publisher layout in organizations that were created • Customize Application after Winter ‘14. SEE ALSO: Create Object-Specific Quick Actions Create Global Quick Actions Customize Actions with the Enhanced Page Layout Editor Actions With and Without Chatter Use actions regardless of whether Chatter or actions in the publisher are enabled. EDITIONS The actions that are available in the full Salesforce site (Salesforce Classic and Lightning Experience) or in the Salesforce mobile app depend on your org’s settings. To enable or disable Chatter for your Available in: both Salesforce organization, from Setup, enter Chatter Settings in the Quick Find box, then select Classic (not available in all Chatter Settings. If Chatter is enabled, the Enable Actions in the Publisher option orgs) and Lightning controls whether the actions that you create display in the Chatter publisher. Experience Chatter Off, Chatter On, Chatter On, Quick actions available in: Actions Off Actions Off Actions On Group, Professional, Enterprise, Performance, You can create global actions Yes Yes Yes Unlimited, Contact and customize global action Manager, Database.com, lists and Developer Editions You can create Yes Yes Yes Custom canvas actions object-specific actions and available in: Professional (with Canvas enabled), customize object-specific Enterprise, Performance, action lists Unlimited, and Developer Actions appear on the Home No Yes1 Yes Editions page and Chatter home 738 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Chatter Off, Actions Off Chatter On, Actions Off Chatter On, Actions On page in the full Salesforce site Actions appear in object feeds in the full No Yes1,2 Yes2 Salesforce site The action bar is available in the No3 Yes4 Yes Salesforce mobile app feed The action bar is available on the record Yes5 Yes6 Yes6 view in the Salesforce mobile app The action bar is available on Lightning Yes5 Yes Yes pages in the Salesforce mobile app Footnotes: 1. If actions in the publisher aren’t enabled, only standard Chatter actions (Post, File, Link, Poll, and Thanks) appear in the Chatter publisher in the full Salesforce site. 2. The Chatter feed appears on an object’s detail page in the full Salesforce site only for objects that have feed tracking enabled. 3. When Chatter is disabled, the Feed item isn’t available in the Salesforce mobile app. 4. When Chatter is enabled but actions in the publisher aren’t, standard Chatter actions and nonstandard actions appear in the Salesforce mobile app action bar and in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. 5. When Chatter and actions in the publisher are disabled, only nonstandard actions appear in the action bar in the Salesforce mobile app or in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. 6. If feed tracking isn’t enabled on an object, only nonstandard actions appear in the Salesforce mobile app action bar and in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. SEE ALSO: Set Up Actions with Chatter Enabled Set Up Actions Without Chatter Enabled Quick Actions 739 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Action Layout Editor Just as object record pages have page layouts that can be customized, actions have action layouts EDITIONS that can be customized. When you create an action, Salesforce populates its layout with a default set of fields. You can add, remove, or reorder fields on the action layout to present only the essential Available in: both Salesforce items your users need when they’re taking the action. Classic (not available in all For example, a Post action needs just one large text area for user input. By contrast, an object-related orgs) and Lightning Create action must include multiple fields; otherwise, Salesforce can’t create the record. Experience The first time you view the layout for an action you’ve created, certain fields are prepopulated: Available in: Group, target object default fields, standard required fields, and any custom universally required fields. Professional, Enterprise, Default actions (available in organizations created after Winter ’14) have predefined sets of fields. Performance, Unlimited, Contact Manager, The upper part of the action layout editor is the palette, and below the palette is the action layout. Database.com, and The palette contains fields from the action’s target object that you can add to the action layout, Developer Editions except for the following unsupported field types: • Record type fields • Read-only field types such as roll-up summary, formula, and auto-number fields • Read-only system fields such as Created By or Last Modified By Inactive Fields Fields that are already on the action layout still appear on the palette but are inactive. When you select an inactive field on the palette, Salesforce highlights the field on the action layout. Field Type Conversion If you convert a field’s type from one that is supported for actions to a type that isn’t supported, Salesforce removes the field from the action layout. If you convert the field back to a supported type without changing the action layout, Salesforce automatically adds the field back to the layout. If you edit the layout, and then convert the field back to a supported type, add the field back to the layout manually. Layouts Used for Log a Call Actions A Log a Call action takes the active task page layout except under the following conditions: • Suppose that your organization has a custom Log a Call action for an object. The custom action takes the custom action layout defined for it. • Now suppose that your organization has a custom Log a Call global action. That action takes the custom layout defined for it, unless you also have a custom Log a Call action for an object. (A custom action on an object overrides a custom global action.) To display the simpler New Task form to Salesforce mobile app users, enable the form in Activity Settings and ensure that the layout used includes a subject field. Layout Auditing Salesforce tracks action layout customization in the setup audit trail history. To view and edit the layouts for global actions in Setup, enter Actions in the Quick Find box, then select Global Actions and then click Layout next to the action’s name. To view and edit the layouts for object-specific actions, find the object in Setup, then go to Buttons, Links, and Actions. 740 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Action Layout Editor Considerations When you create an action, Salesforce populates its layout with a default set of fields. You can add, remove, or reorder fields on the action layout to present only the essential items your users need when they’re taking the action. SEE ALSO: Quick Actions Action Layout Editor Considerations When you create an action, Salesforce populates its layout with a default set of fields. You can add, EDITIONS remove, or reorder fields on the action layout to present only the essential items your users need when they’re taking the action. Available in: both Salesforce • There is no hard limit to the number of fields you can add to an action layout. However, for Classic (not available in all optimum usability, we recommend a maximum of 8 fields. Adding more than 20 fields can orgs) and Lightning severely impact user efficiency. To reduce the number of fields in your layout, you can create Experience predefined values for the required fields, and then remove those fields from your layout. You Available in: Group, can set predefined field values from the action detail page. Professional, Enterprise, • By default, the Call productivity action in the Salesforce mobile app action bar uses the global Performance, Unlimited, Log A Call action layout. If you create one Log a Call action on an object, users see that custom Contact Manager, Log a Call action’s layout when they tap Call from the action bar for that object. If you create Database.com, and more than one Log a Call action for the same object, the Call action on that object doesn’t know Developer Editions which layout to use, so it uses the global Log a Call action layout. • Mobile smart actions are populated with all your org’s required fields on the relevant object, regardless of how many fields there are. For example, the New Case action in the mobile smart action bundle includes all required case fields. You can’t edit the fields on mobile smart actions. The fields that appear change only if you change which fields on an object are required. • You can remove a required field from the action layout, but make sure that the field has a predefined value. Otherwise, users can’t create records. • Rich text area fields are supported only when you add them to one-column layouts, or as fields that span both columns in two-column layouts. If you add a rich text area field to only one column in a two-column layout, it appears as a plain text area, because there’s not enough space to display the full rich text editor. Custom Success Messages for Quick Actions For Create a Record, Update a Record, and Log a Call action types, you can create a custom message EDITIONS that displays when the action executes successfully. Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience Available in: Group, Professional, Enterprise, Performance, Unlimited, Contact Manager, Database.com, and Developer Editions 741 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links In the Salesforce mobile app and Lightning Experience, when a create, update, or Log a Call action is completed, a default success message displays, regardless of whether the action created a feed item. If you add a custom success message to one of these actions, your custom success message displays instead of the default message. In Salesforce Classic, custom success messages have slightly different behavior. If you select Create Feed Item for a Create a Record or Log a Call action, no success message displays in Salesforce Classic. The feed item itself is the confirmation that the action executed successfully. You can configure translations for custom success messages through the Translation Workbench. From Setup, enter Translate in the Quick Find box, and then select Translate. Choose Action for the Setup Component, and choose Informational Message for the Aspect. Note: If you have All Related Objects selected under feed tracking for a particular object, when a quick action creates related objects, a feed item is always created, regardless of the status of Create Feed Item. SEE ALSO: Create Object-Specific Quick Actions Create Global Quick Actions 742 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Customize Actions with the Enhanced Page Layout Editor Use the page layout editor to customize which actions show up in Salesforce and in the Salesforce EDITIONS mobile app. Tip: To manage the actions for global pages, such as Home, Chatter Home, and Chatter Available in: both Salesforce groups, see Global Publisher Layouts. Classic (not available in all orgs) and Lightning From the management settings for the object whose actions you want to manage, go to Page Experience Layouts. Available in: Group, You can add actions to two sections on a page layout: Professional, Enterprise, Quick Actions in the Salesforce Classic Publisher Performance, Unlimited, This section can contain actions only from the Quick Actions category in the palette. Actions Contact Manager, in this section appear in the Chatter publisher in Salesforce Classic. Database.com, and Developer Editions Salesforce Mobile and Lightning Experience Actions This section can contain actions only from the Mobile & Lightning Actions category in the palette. On object page layouts, the Mobile & Lightning Actions category contains all available USER PERMISSIONS types of actions for the object, including quick actions, productivity actions, Lightning component actions, and standard and custom buttons. Actions in this section appear in the action bar and To create actions: action menu in the Salesforce mobile app and in various areas of Lightning Experience. • Customize Application To customize action layouts Tip: Hover over an action in the palette to see its label, API name, and action type. and page layouts: • Customize Application • To override the action defaults for an action section that you haven’t customized, either click the override text or hover over the section and click . To view page layouts: • View Setup If you haven’t customized the Quick Actions in the Salesforce Classic Publisher section of a page layout, the actions that appear in the publisher for that object default to the actions that are assigned to the global publisher layout. Upon overriding, the actions default to the standard actions—Post, File, Link, Poll, Question, and Thanks—regardless of what actions were assigned to the global publisher layout. If you haven’t customized the Salesforce Mobile and Lightning Experience Actions section of a page layout, the actions for that object default to a set of predefined actions. If you have customized actions in the Quick Actions in the Salesforce Classic Publisher section, and have saved the layout, the Salesforce Mobile and Lightning Experience Actions section inherits the actions from the Quick Actions in the Salesforce Classic Publisher section, plus any standard or custom buttons present on the layout, when you click to override. • To revert the actions in either section to the defaults for that section, hover over the section and click . SEE ALSO: Set Up Actions with Chatter Enabled Actions in Lightning Experience Send Email Action Considerations for Cases Mobile Smart Actions Customize Page Layouts with the Enhanced Page Layout Editor Find Object Management Settings 743 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Set Predefined Field Values for Quick Action Fields When you create actions, use predefined field values to set a value for a field. Predefined values can EDITIONS help ensure consistency and make it faster and easier for users to create records. When you configure action layouts, it’s better to use fewer fields. Most users, especially mobile Available in: both Salesforce users, don’t like to fill in a lot of required fields. They want to get things done and move on to their Classic (not available in all next task. A good way to use fewer fields in action layouts is to set predefined values for as many orgs) and Lightning fields as possible. The more fields you can set predefined values for, the more you can remove from Experience the layout and make the action easier and quicker to use. Balance ease of use with the need for Available in: Group, required information. However, don’t remove required fields from an action layout without setting Professional, Enterprise, a predefined value for those fields, or when a user applies that action, the record won’t save properly. Performance, Unlimited, If you set predefined values for fields on object records created through an action, you don’t need Contact Manager, to add those fields to the action layout. For example, when you configure an action that lets users Database.com, and create opportunities, set Prospecting as the predefined value for the Stage field. All new opportunities Developer Editions users create through that action are automatically assigned to the prospecting stage. You can remove the Stage field from the action’s layout, because the field is going to be assigned a value USER PERMISSIONS automatically. To set predefined field Tip: Predefined values for fields on actions are different from default values that you can set values: for fields on records. If a field is included in an action, it can have both a predefined value set • Customize Applications for the action and a default value set. 1. Click the name of an action in the Buttons, Links, and Actions list or the Global Actions list. 2. On the action detail page, click New in the Predefined Field Values list. 3. Select the field you want to predefine a value for. 4. Specify the value for the field. For single-select picklists, you can specify both a specific value and a formula value. If you set both, the formula value takes precedence over the specific value. 5. Click Save. Tip: On object-specific actions, the predefined value can include references to the source object and its related objects. Notes on Predefined Field Values for Quick Actions SEE ALSO: Notes on Predefined Field Values for Quick Actions 744 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Notes on Predefined Field Values for Quick Actions Setting predefined field values for quick actions is especially important if you remove required or EDITIONS Always on Layout fields from the action layout. • You can set predefined values for any field available in the action layout editor, with these Available in: both Salesforce exceptions. Classic (not available in all orgs) and Lightning – Dependent picklists Experience – Multi-select picklists Available in: Group, – Read-only field types like auto-number, formula, and roll-up summary fields Professional, Enterprise, – Lookup fields Performance, Unlimited, Contact Manager, • You can’t use a dependent picklist to set a predefined value. Database.com, and • If a field on an action has both a predefined value and a default value set, the action uses the Developer Editions predefined value, not the default value. • If a picklist field on a quick action has both a predefined specific value and predefined formula value, the formula value takes precedence over the specific value. • If you set a predefined value for a field and leave it on the action layout, that value displays as the default value for the field. • If you use a rich text field as a predefined field value, any text formatting that was applied in the rich text field is removed in the new field. • When you have a required field with a predefined value and remove the field from the action layout, you must add the required field back to the action layout if you later delete the field’s predefined value. Otherwise, users can’t save the record. • Formulas can’t reference fields on external objects, so you can’t reference an external object field to set a predefined field value for a quick action. • You can use a TEXT(picklist) value in a predefined value field. • To set the value for an email action’s recipient, predefine the To, CC, or BCC fields. You can use ID fields, such as Contact.Id, or string fields, such as Contact.custom_email_field to predefine the value. – Contact, lead, and person account IDs are supported. – Use an ID field if you want to log the email on the recipient’s record. – Use a string field to predefine an email recipient for a custom object or custom field. – If you use a string field, the email isn’t logged on the recipient’s record. SEE ALSO: Set Predefined Field Values for Quick Action Fields 745 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Global Publisher Layouts Global publisher layouts determine the global actions that appear in the various Salesforce interfaces. EDITIONS In Salesforce Classic and Lightning Experience, these layouts customize the actions on global pages (like the Home page) and on the Chatter page. Lightning Experience also uses these layouts to Available in: both Salesforce populate the Global Actions menu. And in the Salesforce mobile app, these layouts drive the actions Classic (not available in all that appear in the action bar on the Feed and People pages. Global publisher layouts can include orgs) and Lightning global actions only. Experience In Salesforce for Outlook, global publisher layouts drive the actions that Group, Contact Manager, Available in: Group, and Professional Edition users see when they click the Salesforce Side Panel Publisher. Professional, Enterprise, Salesforce for Outlook users working in all other editions can set up their side panel publishers using Performance, Unlimited, Outlook Side Panel Publisher Layouts. Contact Manager, Database.com, and Note: Chatter groups without customers display the global publisher layout by default, Developer Editions unless you override it with a customized group publisher layout. In Chatter groups that allow customers, the publisher displays standard actions only, such as Post, File, Link, and Poll. You can assign different global publisher layouts to different user profiles to customize which actions USER PERMISSIONS users see by default on global pages. To create actions: Note: Changes to user layouts override the global publisher layout on user profile pages • Customize Application and the Chatter home page. To customize action layouts and page layouts: These are the steps involved in working with global publisher layouts. • Customize Application To view page layouts: 1. Create Global Publisher Layouts • View Setup Global publisher layouts determine the global actions that appear in the various Salesforce interfaces. In Salesforce Classic and Lightning Experience, these layouts customize the actions on global pages (like the Home page) and on the Chatter page. Lightning Experience also uses these layouts to populate the Global Actions menu. And in the Salesforce mobile app, these layouts drive the actions that appear in the action bar on the Feed and People pages. Global publisher layouts can include global actions only. 2. Add Actions to Global Publisher Layouts Actions you add to the global publisher layouts appear on pages such as the Home and Chatter pages. They also appear on the action bar and action menu on the Feed and People pages in the Salesforce mobile app. 3. Assign Global Publisher Layouts to User Profiles Once you finish creating a global publisher layout, you can assign it to different user profiles. For example, a Marketing User and a Standard User might need different actions in the Chatter publisher or in the Salesforce mobile app. Create multiple global publisher layouts and assign them to different user profiles to customize the actions for each profile. SEE ALSO: Create Global Quick Actions 746 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Create Global Publisher Layouts Global publisher layouts determine the global actions that appear in the various Salesforce interfaces. EDITIONS In Salesforce Classic and Lightning Experience, these layouts customize the actions on global pages (like the Home page) and on the Chatter page. Lightning Experience also uses these layouts to Available in: both Salesforce populate the Global Actions menu. And in the Salesforce mobile app, these layouts drive the actions Classic and Lightning that appear in the action bar on the Feed and People pages. Global publisher layouts can include Experience global actions only. Available in: Enterprise, Publisher Layouts Quick Find 1. From Setup, enter in the box, then select Publisher Performance, Unlimited, Layouts. Database.com, and 2. To create a new global publisher layout, click New. Developer Editions 3. To clone a publisher layout, select one from the Existing Global Publisher Layout drop-down list. USER PERMISSIONS 4. Enter a name for the new global publisher layout. To create actions: 5. Click Save. • Customize Application To customize action layouts SEE ALSO: and page layouts: • Customize Application Assign Global Publisher Layouts to User Profiles To view page layouts: Global Publisher Layouts • View Setup Add Actions to Global Publisher Layouts Actions you add to the global publisher layouts appear on pages such as the Home and Chatter EDITIONS pages. They also appear on the action bar and action menu on the Feed and People pages in the Salesforce mobile app. Available in: both Salesforce Arrange the actions so that the frequently used actions appear first in each list. Classic (not available in all orgs) and Lightning You can add actions to two sections on a page layout: Experience Quick Actions in the Salesforce Classic Publisher This section can contain actions only from the Quick Actions category in the palette. Actions Available in: Group, Professional, Enterprise, in this section appear in the Chatter publisher in Salesforce Classic. Performance, Unlimited, Salesforce Mobile and Lightning Experience Actions Contact Manager, This section can contain actions only from the Mobile & Lightning Actions category in the Database.com, and palette. On object page layouts, the Mobile & Lightning Actions category contains all available Developer Editions types of actions for the object, including quick actions, productivity actions, Lightning component actions, and standard and custom buttons. Actions in this section appear in the action bar and USER PERMISSIONS action menu in the Salesforce mobile app and in various areas of Lightning Experience. Note: Changes to user layouts override the global publisher layout on user profile pages To create actions: and the Chatter home page. Actions on the user profile page come from the Quick Actions • Customize Application in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter To customize action layouts actions appear on the user profile page, regardless of which actions are present in the User and page layouts: Page Layout or the global publisher layout. • Customize Application 1. From Setup, enter Publisher Layouts in the Quick Find box, then select Publisher To view page layouts: Layouts. • View Setup 747 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links 2. To add or remove actions, drag them to and from the palette. To reorder actions, select an action and drag it to a new position. 3. Click Save when you’re done, or click Quick Save to save your changes and continue working on the layout. If you navigate away without saving, you lose your changes. Note: Before using the personal email setting When you click an email address to compose an email, which email editor do you want to use?, confirm that the Global Publisher Layout has the email action in the Salesforce Mobile and Lightning Experience Action section. Example: Let’s add the New Account action to the publisher on the Home and Chatter pages in Salesforce Classic. The New Account action lets users create an account directly from the publisher. Drag the New Account action to the Quick Actions in the Salesforce Classic Publisher section and save your changes. Go to the Chatter tab in Salesforce Classic. Now the New Account action shows up in the publisher. Note: The Chatter page in Lightning Experience supports only the standard Chatter actions Post, Poll, and Question, and if you have Groups, the Announcement action. SEE ALSO: Actions in Lightning Experience Send Email Action Considerations for Cases Assign Global Publisher Layouts to User Profiles Email Application Publisher Layouts 748 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Assign Global Publisher Layouts to User Profiles Once you finish creating a global publisher layout, you can assign it to different user profiles. For EDITIONS example, a Marketing User and a Standard User might need different actions in the Chatter publisher or in the Salesforce mobile app. Create multiple global publisher layouts and assign them to different Available in: both Salesforce user profiles to customize the actions for each profile. Classic (not available in all 1. From Setup, enter Publisher Layouts in the Quick Find box, then select Publisher orgs) and Lightning Layouts. Experience 2. Click Publisher Layout Assignment. Available in: Group, Professional, Enterprise, 3. Click Edit Assignment. Performance, Unlimited, 4. Select a user profile by clicking anywhere on its row in the table. Contact Manager, 5. From the Publisher Layout to Use drop-down, select the global publisher layout that you want Database.com, and to assign to the highlighted profile. Developer Editions 6. Save the layout. USER PERMISSIONS SEE ALSO: To create actions: Add Actions to Global Publisher Layouts • Customize Application Global Publisher Layouts To customize action layouts and page layouts: • Customize Application To view page layouts: • View Setup Quick Actions and Record Types Using record types in your organization can affect the availability of quick actions for your users. EDITIONS If users don’t have access to a particular record type, actions that are assigned to that record type aren’t available to them. For example, let’s say that you have a page layout that contains a mix of Available in: both Salesforce actions—some have no record type assigned and some are assigned to Record Type A. Users Classic (not available in all without access to Record Type A see only the nonassigned actions when they visit the page. orgs) and Lightning Experience Important: Don’t assign actions to the Master record type. The Master record type is a placeholder record type that’s assigned when your organization is created. Quick actions available in: Group, Professional, Enterprise, Performance, Default Global Actions: A Special Case Unlimited, Contact If you have default global actions in your organization and you’re using record types, your users Manager, Database.com, might not be able to see all the default actions that are assigned to a page layout. and Developer Editions Default global actions are assigned to the Master record type, which isn’t accessible to most profiles. Custom canvas actions As a result, default global actions with the Master record type that are associated with target objects available in: Professional that have record types configured aren’t available for most users. To fix this issue, edit the default (with Canvas enabled), global actions associated with those objects and reassign them to a different record type. Enterprise, Performance, Unlimited, and Developer For example, the New Contact default global action has Contact as its target object. Let’s say you Editions have record types set up for the Contact object, and you add the New Contact default global object to a page layout. Users who visit records based on that page layout don’t see the New Contact action because the action is assigned to the Master record type by default. Editing the New Contact 749 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links default global action and assigning it to a record type other than Master makes it available for all users who have access to its assigned record type. Actions Best Practices Use these tips as you set up actions. EDITIONS Tips for Creating Actions Actions available in: both Salesforce Classic and • Action labels longer than approximately 12–14 characters are shortened when they’re displayed Lightning Experience in the Chatter publisher. Keep names short and descriptive. • Give your actions task-oriented names that tell your users what they do. Use terms such as New, Publisher available in: Create, Share, Update, or Import. Salesforce Classic • Use the Description field to create notes for yourself about each action. Notes are especially Available in: Essentials, useful if you’re creating several similar actions for different record types, for example. The Group, Professional, description appears in the list of buttons, links, and actions for object-specific actions, or in the Enterprise, Performance, list of global actions, as well as on the detail page for the action. Your notes aren’t visible to Unlimited, Contact users. Manager, Database.com, and Developer Editions • 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. 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 necessary for them and for whomever handles 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, when you configure an action that lets users create opportunities, set Prospecting as the predefined value for the Stage field. All new opportunities users create through that action are automatically assigned to the prospecting stage. You can remove the Stage field from the action’s layout, because the field is going to be assigned a value automatically. If you set 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 appears to different user profiles. 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 Salesforce Classic, if you include five or more actions in the actions section of a page layout, 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 the Salesforce mobile app, the first three actions show up in the action bar, and the full set of actions are accessed by tapping . SEE ALSO: Quick Action Considerations Troubleshooting Actions Set Up Actions with Chatter Enabled 750 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Quick Action Considerations Keep these considerations in mind when working with quick actions. EDITIONS • If you’re using record types in your org, sometimes quick actions aren't visible to your users. For more information, see Quick Actions and Record Types on page 749. Actions available in: both • To see an object-specific action on a page layout, a user must have both Read and Edit Salesforce Classic and permissions on the action’s relationship field. The relationship field is the field that’s automatically Lightning Experience populated on the target object when a user creates a record using an action. For example, for Available in: Essentials, an action on a case that lets users create child cases, the default relationship field is Parent Group, Professional, Case. To be sure that users can see the Create Child Case action, check that they have both Enterprise, Performance, Read and Edit permissions on the Parent Case field. Unlimited, Contact Manager, Database.com, Field-level security sets the Account parent field on the Case object to read-only by default, and Developer Editions which means it’s not visible to non-system administrator users. Therefore, actions on accounts that have Case as the target object are also not visible to users without the System Administrator profile. To let users see actions on accounts that have Case as the target object, remove the Read Only setting. • In quick action layouts: – A blank space inserted on the same line as another field in the quick action layout causes that field to stretch to the full page width. The field is left justified on the page, regardless of its position in the quick action layout editor. – Two blank spaces inserted on the same row in the quick action layout editor don't create a blank line on the page. The two blank spaces are ignored. – If there's an uneven number of fields on the quick action layout, the final field stretches to the full page width and is left justified. The behavior is the same if a blank space is inserted on the same row as the final field. • Custom actions can be defined for person accounts but with these exceptions. – Person account-specific fields, including Email and Mobile, aren’t available in action layouts when using object-specific custom actions to update accounts. – To set up object-specific custom quick actions that create person account records, define a custom lookup field for Account on the Account or Contact object. Global custom quick actions can be used without defining this field. – Actions that create business account records from a person account detail page must be global, not object-specific. • If you delete an action, the action is removed from all layouts that it’s assigned to. • Automatic triggers that change record ownership can affect what object details are visible to users. In some cases, a user can enter information that is then immediately hidden from them if an automatic trigger changes the object's owner. For example, if you use a global create quick action to create an object and an automatic trigger changes the object ownership, some information about the object isn't visible to you. • My Domain must be deployed in your org for Lightning component actions to work properly. • Chatter groups without customers display the global publisher layout by default, unless you override it with a customized group publisher layout. In Chatter groups that allow customers, the publisher displays standard actions only, such as Post, File, Link, and Poll. Actions and Master-Detail Object Relationships • Actions to create records for an object that is the detail object in a master-detail relationship must be object-specific, not global. • If you create an action on a detail object in a master-detail relationship, the action’s target object can’t be a different detail object of the same master. 751 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links For example, master object A has two detail objects, B and C. You can create actions on object A with B or C as the target object. However, when creating an action on object B, the target object can’t be object C because B and C have the same master. To create an action on B with C as the target, you can do one of the following: – Change the relationship between B and C to master-detail so that A is the master of B, and B is the master of C. – Change the relationship between C and A to a lookup relationship. Note that A is still the master of B with this option, so you can’t create a quick action on B with a target object of A. Troubleshooting Actions EDITIONS I don’t see feeds on record detail pages for a certain object. Feeds appear only for objects for which you’ve enabled feed tracking. Available in: both Salesforce Classic (not available in all orgs) and Lightning I see the feed on a record detail page, but I don’t see a publisher. Experience If there are no actions in the Quick Actions in the Salesforce Classic Publisher section on a page Available in: Group, layout, the publisher in Salesforce Classic doesn't appear. Add at least one action to the page layout Professional, Enterprise, for the publisher to appear. Performance, Unlimited, Contact Manager, I can create actions, but I can’t add them to publishers. Database.com, and Developer Editions Enable actions in the publisher to add nonstandard actions to publishers in Salesforce Classic. I’m using Internet Explorer 10 and all the actions I’ve created appear in the publisher with the same icon, even though the actions are for different types of objects. Internet Explorer version 10 doesn’t support the techniques Salesforce uses to show icons that correspond to the type of object an action is associated with. Consider using Chrome, Firefox, Safari, or an earlier version of Internet Explorer. I’ve added an action to a page layout, but a user assigned to the profile that uses that page layout can’t see the action. Be sure that the user has both Read and Edit permissions on the action’s relationship field. The relationship field is the field that’s automatically populated on the target object when a user creates a record using an action. For example, for an action on a case that lets users create child cases, the default relationship field is Parent Case. To be sure that users can see the Create Child Case action, check that they have both Read and Edit permissions on the Parent Case field. I don’t see a relationship field on my global create actions. Relationship fields apply only to object-specific create actions, not to global actions. I don’t see some of the actions in my Chatter groups. Which actions you see depends on your role in the group, the type of group, and how your administrator has configured the publisher layout for groups. Chatter groups without customers display the global publisher layout by default, unless you override it with a customized group publisher layout. In Chatter groups that allow customers, the publisher displays standard actions only, such as Post, File, Link, and Poll. 752 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links I see an error when I select a custom create account action from a person account. Although your administrator can add the custom create account action to the page layout, this action isn’t supported for person accounts. SEE ALSO: Actions Best Practices Set Up Actions with Chatter Enabled Action Limits and Limitations Actions can work differently than you expect in certain situations and for different objects. Keep EDITIONS these limits and limitations in mind when working with actions. • Custom actions aren’t available in Experience Builder sites. Available in: Essentials, • You can display up to 10 actions in Lightning view. Group, Professional, Enterprise, Performance, • Custom images used for action icons must be less than 1 MB in size. Unlimited, Contact • Custom actions can be defined for person accounts but with these exceptions. Manager, Database.com, – Person account-specific fields, including Email and Mobile, aren’t available in action and Developer Editions layouts when using object-specific custom actions to update accounts. – To set up object-specific custom quick actions that create person account records, define a custom lookup field for Account on the Account or Contact object. Global custom quick actions can be used without defining this field. – Actions that create business account records from a person account detail page must be global, not object-specific. • Actions associated with objects that aren’t supported in Lightning Experience don’t appear in the Global Actions menu. Also, the Global Actions menu doesn’t support standard Chatter actions. • Mobile smart actions don’t appear in the full Salesforce site, regardless of which page layouts you add them to. They appear only to users in the Salesforce mobile app. • The Chatter page in Lightning Experience supports only the standard Chatter actions Post, Poll, and Question, and if you have Groups, the Announcement action. • The palette in the action layout editor doesn’t support: – Record type fields – Read-only field types such as roll-up summary, formula, and auto-number fields – Read-only system fields such as Created By or Last Modified By • Actions on the user profile page come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on the user profile page, regardless of which actions are assigned to the User Page Layout or the global publisher layout. • Actions on reports come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on reports, regardless of which other actions are assigned to the global publisher layout. • Chatter groups with customers don’t support global create, log a call, or custom actions and display only standard Chatter actions, such as Post, File, Link, and Poll. • External objects support quick actions, except when the actions involve features or functionality that are incompatible with external objects. For example: – Formulas can’t reference fields on external objects, so you can’t reference an external object field to set a predefined field value for a quick action. – Log a Call actions create tasks, which aren’t available for external objects. 753 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links • When you create an object-specific action, you can choose as a target object an event, a task, or any object that has a parent-child or lookup relationship to the host object. You can’t choose Quote as a target object from Opportunity. However, you can still create quotes from an opportunity by going to the opportunity’s Quotes related list and clicking New. • The Account Contact Relationship object supports custom actions, but with limitations. – Custom actions must be specific to the Account Contact Relationship object. Global actions aren’t supported. – You can create actions that update records or invoke Lightning components or Visualforce pages. But you can’t create actions that create records. – You can’t create actions that send emails or log calls because you can't associate activities to the Account Contact Relationship object. – You can’t override the default actions on the Account Contact Relationship object. – Only custom actions that are created on the Contact object can use the Account Contact Relationship object as a target object. – Chatter standard actions aren’t supported because the Account Contact Relationship object doesn’t have a Chatter feed. Actions in Lightning Experience In Lightning Experience, actions appear in the Global Actions menu in the header, on related lists, EDITIONS and on list view items. Actions also appear on a record page, in one of several places depending on the action’s type. Available in: both Salesforce Note: Quick actions aren’t the only action type covered here. Standard and custom buttons Classic (not available in all are also considered actions. orgs) and Lightning Experience Actions in the Global Actions Menu Quick actions available in: Group, Professional, The Global Actions menu displays a subset of global actions from the Salesforce Mobile and Lightning Enterprise, Performance, Experience Actions section of the global publisher layout. Unlimited, Contact Manager, Database.com, and Developer Editions Custom canvas actions available in: Professional (with Canvas enabled), Enterprise, Performance, Unlimited, and Developer Editions The items in the menu appear in the order that they’re listed in the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout. Actions associated with objects that aren’t supported in Lightning Experience don’t appear in the Global Actions menu. Also, the Global Actions menu doesn’t support standard Chatter actions. 754 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Actions on List Views and List View Items Custom buttons, list view actions, and certain standard buttons are supported on all list views, except Recently Viewed. To have a custom button appear on a list view, add the button to the object’s List View search layout. In the Kanban view, only the standard New action is supported. List view items support only specific standard actions, like Edit, Delete, or Change Owner. For Tasks, table format list views and the Kanban view support only standard buttons. Tasks list view items in table view and the task item detail pane in split view contain the complete list of available actions for tasks. Actions on the Home Page On the Home page, you can find actions on recommendations in the Assistant. For example, imagine that a sales rep receives an update that an opportunity doesn’t have any open activity. The rep can create a task or event directly from the recommendation. The actions that appear depend on the type of recommendation. To appear in the Assistant, actions must be added to the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout. Supported actions include: • New Task • New Event • Edit • Email After you complete an action, the related recommendation disappears from the Assistant. 755 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Actions on the Chatter Page The Chatter page, like the Chatter tab on record pages, contains only standard Chatter actions. By default, only the Post, Poll, and Question actions are supported, and if you have Groups, the Announcement action. You can add, remove, or reorder the actions on the Chatter page from the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout. Actions on Record Pages Here’s a sample contact page in Lightning Experience. Note: The opportunity and leads workspaces have different structures, but actions appear in the same way on those pages. The page-level action menu in the record’s highlights panel (1) contains: • Productivity actions • Global and object-specific quick actions, except for those actions related to creating tasks, creating events, and logging calls • Standard buttons • Custom object-specific Lightning component quick actions • Custom flow actions • Custom Visualforce quick actions • Custom Visualforce buttons 756 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links • Canvas actions The actions that appear in the page-level action menu are listed in the order that they appear in the Salesforce Mobile and Lightning Experience Actions section of the page layout. Note: You can enable dynamic actions in the highlights panel on an object’s record page using the Lightning App Builder. Dynamic actions for custom objects on desktop and mobile and for the standard objects Account, Case, Contact, Lead, and Opportunity on desktop are generally available. Dynamic actions for other standard objects on desktop are beta. Add, remove, and reorder actions directly in the Lightning App Builder and control action visibility based on filters that you apply. When you enable dynamic actions in the Lightning App Builder, highlights panel actions for the record page no longer come from the object’s page layout. The Activity tab (2) contains Create a Record quick actions that point to the Event and Task objects. It also contains Log A Call and Send Email actions. The Chatter tab (3) contains standard Chatter actions. By default, only the Post, Poll, and Question actions are supported, and if you have Groups, the Announcement action. Some objects support other standard Chatter actions predefined by Salesforce. Note: Actions on user profiles, cases, and work orders can appear in a different way than on other records. • Actions on the user profile page come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on the user profile page, regardless of which actions are assigned to the User Page Layout or the global publisher layout. • When feed tracking is enabled for cases or work orders, the page-level action menu on those records contains only custom buttons and supported standard buttons. Quick actions appear on the Chatter tab. On Experience Builder sites, quick actions for work orders appear on the page-level action menu. Actions on Related Lists Related lists in Lightning Experience (4) show custom list buttons and supported standard buttons assigned to the related list. Not all related list standard buttons are supported in Lightning Experience. Actions on Reports Actions on reports come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on reports, regardless of which other actions are assigned to the global publisher layout. Example: Let’s say you have these actions on your Contact page layout in the Salesforce Mobile and Lightning Experience Actions section. You have quick actions (New Account, New Event, New Task), a productivity action (Call), standard buttons (Edit, Delete, Clone, Send an Email), and Chatter actions (Poll, Post). Here’s how those actions appear on a contact record page in Lightning Experience. • The actions in the page-level action menu are a combination of the quick actions, productivity actions, and standard buttons. These actions appear in the order that they’re listed on the page layout. Although they’re quick actions, New Event and New Task don’t show up here. 757 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links • The Chatter actions from the front of the action list are on the Chatter tab. • The Activities-related actions—Email, New Event, New Task—display on the Activity tab. How Actions Are Ordered in Lightning Experience In Lightning Experience, the actions on record pages are derived from the list of actions in the Salesforce Mobile and Lightning Experience Actions section of the page layout for that object. The same section on global publisher layouts determines the global actions that appear in the Global Actions menu. SEE ALSO: Quick Actions Quick Action Considerations Set Up Cases for Lightning Experience 758 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links How Actions Are Ordered in Lightning Experience In Lightning Experience, the actions on record pages are derived from the list of actions in the EDITIONS Salesforce Mobile and Lightning Experience Actions section of the page layout for that object. The same section on global publisher layouts determines the global actions that appear in the Global Available in: both Salesforce Actions menu. Classic (not available in all If you haven’t customized the Salesforce Mobile and Lightning Experience Actions section of an orgs) and Lightning object’s page layout, the quick actions that appear on the object’s record pages are derived from: Experience • The actions on the global publisher layout Quick actions available in: • Standard and custom buttons in the buttons section of the object page layout Group, Professional, However, the order of the actions from the global page layout aren’t respected on those record Enterprise, Performance, Unlimited, Contact pages. Manager, Database.com, When you click to override the predefined actions in the Salesforce Mobile and Lightning Experience and Developer Editions Actions section, the custom buttons in the buttons section of the page layout aren’t automatically Custom canvas actions included in the action list. You must add the custom buttons as actions from the Mobile & Lightning available in: Professional Actions category in the palette. (with Canvas enabled), After you customize the Salesforce Mobile and Lightning Experience Actions section of an object’s Enterprise, Performance, page layout, the actions in each section of the record page respect the ordering of its types of Unlimited, and Developer actions on the page layout. For example, actions in the page-level actions menu appear in the order Editions that you configure them in the Salesforce Mobile and Lightning Experience Actions section on the page layout. And actions in the Chatter and Activity tabs reflect the order of the actions supported for those tabs on the page layout. The Global Actions menu ( ) in the Lightning Experience header displays all global quick actions from the Salesforce Mobile and Lightning Experience Actions section of the global publisher layout, except the standard Chatter actions Post, File, Poll, Link, Question, and Thanks. SEE ALSO: Actions in Lightning Experience Send Email Action Considerations for Cases Quick Actions Salesforce Mobile App Action Bar Salesforce mobile app users have a one-stop place to find actions, so there’s no confusion about where to go to do something. The action bar and its associated action menu collect actions from different places in the app into a single, unified home. The productivity actions, standard and custom record buttons, and quick actions appear in the action bar and the action menu ( ). The action bar and action menu show all the available actions for a given page. 759 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Salesforce Mobile App Actions in the Action Bar and Action Menu The action bar appears in most places in the mobile app, including the feed, groups, user profiles, dashboards and reports, standard and custom object record views, related lists, and search results. The actions that are available depend on where a user is in the app and on how you’ve configured page layouts and publisher layouts for your organization. Users may see some or all of these kinds of actions in the action bar (including the action menu). • Productivity actions—The Send Email, Call, Map, View Website, and Read News actions are available on accounts, contacts, leads, and person accounts. The Quick Message, Join Conference Call, and Map actions are available on mobile calendar events in Salesforce Today. Tip: In most cases, a productivity action displays only if a record includes the information that the action is keyed to. For example, the Send Email action depends on the record including an email address. The View Website action requires the record to include a website URL. • Custom and standard buttons—Buttons (such as Edit, Delete, or Clone) that are included in the Buttons section on an object’s page layout are available in the mobile app as actions in the action bar on record pages. If you haven’t customized the action order, the button order in the button section of the page layout is used. However, the Edit button is in a fixed position. Note: Custom links, custom buttons that are added to list views, and custom buttons that define the content source as OnClick JavaScript aren’t supported and don’t appear in the Salesforce mobile app. • Quick actions—If you add, remove, or reorder actions in the action bar in the global publisher layout or an object’s page layout, the changes are reflected in the Salesforce mobile app. • Standard Chatter actions—Actions unique to Chatter, such as Post, File, Link, or Poll. What are the exceptions? • On accounts, the Call action appears even when there isn’t a phone number on the record. • On record feeds, the Follow/Unfollow button remain in the highlights area on the page. 760 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links • On public and private group feeds, the Join Group and Ask to Join buttons remain in the highlights area, but the Leave Group button is in the action bar. What does this mean for custom branding? There can be only one version of a custom icon. Custom action icons that you created before Winter ’15 are still supported, but they are truncated in the action bar. To optimize your custom action icons for display in the action bar, use these guidelines. • The icon should be 72 x 72 pixels. Use the full pixel area for the image—don’t leave spacing around the image like before. • Make the image a PNG with a transparent background, with a file size that is less than 10k. • Have a resolution of 72 dpi. • Make the icon graphic white or lighter than the background color. • Avoid heavy inner or outer shadows. • Use simple and flat styling resembling the Salesforce mobile app icon family. How Actions Are Ordered in the Salesforce Mobile App Action Bar The Salesforce Mobile and Lightning Experience Actions section of a page layout and global publisher layout drives which actions appear in the Salesforce mobile app action bar. It also enables you to customize the order of quick actions, productivity actions, and standard and custom buttons that are available as actions. List Item Actions in the Salesforce Mobile App List item actions give you access to your actions in list views, task lists, and related record lists. You can use list item actions to update records directly from lists. How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions Your org’s page layouts and publisher layouts control the order in which actions appear in the Salesforce mobile app action bar and list item actions. If you don’t customize the actions in the action bar on a page layout or global publisher layout, Salesforce predefines the location of key actions. Considerations for Actions in the Salesforce Mobile App How Actions Are Ordered in the Salesforce Mobile App Action Bar The Salesforce Mobile and Lightning Experience Actions section of a page layout and global publisher EDITIONS layout drives which actions appear in the Salesforce mobile app action bar. It also enables you to customize the order of quick actions, productivity actions, and standard and custom buttons that Available in: both Salesforce are available as actions. Classic (not available in all If you customize the Salesforce Mobile and Lightning Experience Actions section of a layout, the orgs) and Lightning mobile app reflects your customizations. Experience If you customize the Quick Actions in the Salesforce Classic Publisher section but not the Salesforce Available in: Group, mobile app section, the actions in the mobile app action bar are a combination of those in the Professional, Enterprise, Quick Actions in the Salesforce Classic Publisher section plus any standard or custom buttons present Performance, Unlimited, on the page layout. Contact Manager, Database.com, and When you click to override the predefined actions in the Salesforce Mobile and Lightning Experience Developer Editions Actions section, the custom buttons in the buttons section of the page layout aren’t automatically included in the action list. You must add the custom buttons as actions from the Mobile & Lightning Actions category in the palette. If neither section is customized, the action bar inherits a default set of actions predefined by Salesforce. The sets of actions differ between objects based on the most common or typical activities required for each object. 761 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Note: You can enable dynamic actions for custom object record pages for the Salesforce mobile app. When you enable dynamic actions, you assign actions in the Lightning App Builder instead of the page layout and apply filters to control when and where actions appear for users. You can assign the same dynamic actions for desktop and mobile, or assign a different set of dynamic actions for mobile. SEE ALSO: How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions Salesforce Mobile App Action Bar Considerations for Actions in the Salesforce Mobile App List Item Actions in the Salesforce Mobile App List item actions give you access to your actions in list views, task lists, and related record lists. You can use list item actions to update records directly from lists. To access list item actions, navigate to a list view or task list or open a related list from an object’s related information page. Then swipe left on the desired record. Hide list item actions by swiping the list item back to the right or by tapping another item in the list. List Views List item actions in list views don’t have the same actions that are available in the action bar when viewing an object’s record. For example, when a user visits an opportunity record in the Salesforce mobile app, the actions in its action bar reflect the actions in the Salesforce Mobile and Lightning Experience Actions section of the Opportunity page layout. However, when the user swipes left on an opportunity from a list view, as you can see below, the actions that display come from the list of predefined actions for opportunities. See How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions for the breakdown of predefined actions for each object. Swipe a list item to the left to reveal list item Tap to show the action menu, with the Here’s the All Opportunities list view. actions. full list of actions available for the list item. 762 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Related Lists List item actions on related lists in the app reflect the same actions as the related list in Lightning Experience. Usually, these are the standard actions Edit and Delete, but can vary by object. For example, in Lightning Experience, the actions available in the dropdown menu on an Opportunity related list item are the same set of actions that Salesforce mobile app users see when swiping left on the same record in the related list. Note: Even if your org doesn’t have Lightning Experience enabled, the actions on related lists that you see in the Salesforce mobile app still match the actions that would appear on the related list items in Lightning Experience if it was enabled. 763 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Note: Task and event list items are different than other objects when they display in related lists. In the mobile app, when you tap the Tasks item from the menu, you can swipe left on an item in the My Tasks list view and see the predefined actions for tasks. However, tasks and events in the Open Activities or Activity History related lists in the mobile app have no actions and aren’t swipe-able. How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions Your org’s page layouts and publisher layouts control the order in which actions appear in the Salesforce mobile app action bar and list item actions. If you don’t customize the actions in the action bar on a page layout or global publisher layout, Salesforce predefines the location of key actions. Important: Predefined actions apply to the Salesforce mobile app action bar only if you haven’t customized the Salesforce Mobile and Lightning Experience Actions section of an object’s page layout or a global publisher layout. Predefined actions are derived from the Quick Actions in the Salesforce Classic Publisher section of the object page layout or global publisher layout. On object page layouts, when the Salesforce mobile app section isn’t customized: If you customized the Quick Actions in the Salesforce Classic Publisher section, the quick actions in the action bar reflect those customizations. If you didn’t customize either section, the quick actions in the action bar come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. 764 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links On global publisher layouts, when the Salesforce mobile app section isn’t customized: If you customized the Quick Actions in the Salesforce Classic Publisher section, the quick actions in the action bar reflect those customizations. If you didn’t customize either section, the quick actions in the action bar for global pages default to a Salesforce predefined set. Here’s the breakdown of which actions are contained in each group for each object or page. Keep in mind these considerations: • The predefined actions in the action bar, list item actions, and associated action menus are divided into groups. The arrangement of these groups is fixed. • Unless they’re in an ordered list, the order of actions within the groups can vary based on the object and the actions present on the global publisher layout or on an object’s page layout. • Some actions are in fixed positions. For actions in a numbered list, this is the fixed order that they appear in the action bar, list item actions, and in the respective action menus. – For example, for the Account object, the standard Chatter Post action is in the fourth position. This position is fixed. Regardless of where you put the Post action in the account page layout, Post always displays in the fourth position. – However, deletion of actions is respected. So in our example, if you delete the Post action from the account page layout, the remaining actions move up and you see Edit in the fourth position. • Some action groups aren’t supported for every object or page. Note: Actions on list view items reflect only the predefined set of actions for that object. For example, let’s say you’re viewing the All Accounts list in the Salesforce mobile app. If you swipe left on an account item in the list, you see a set of actions. Those actions come from the predefined list of actions for accounts in this chart. You always see Call, Edit, and Delete. The other actions on the list view item follow the order and rules defined for the action groups in the chart. Table 2: Account Object Action Predefined Actions Group 1 1. Call, 2. New Task, 3. New Event, 4. Post 2 Edit 3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Account page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. 4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.* 5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout. 6 Send Text (if the Phone field is populated), View Website (if the Website field is populated) Table 3: Case Object Action Predefined Actions Group 1 Actions from the Quick Actions in the Salesforce Classic Publisher section of the Case page layout. If that section isn’t customized, quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout 765 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Action Predefined Actions Group 2 Edit 3 Action group 3 isn’t supported for the Case object. 4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.* 5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout. 6 Productivity actions aren’t supported for this object. Table 4: Contact Object Action Predefined Actions Group 1 1. Call, 2. Send Email, 3. New Task, 4. New Event 2 Edit 3 Remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Contact page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. 4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.* 5 Remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout. 6 Send Text Table 5: Custom Objects Action Predefined Actions Group 1 The first four actions in the order defined on the page layout. If the Quick Actions in the Salesforce Classic Publisher section of the page layout isn’t customized, then the first four actions in the order defined on the global publisher layout. 2 Edit 3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the page layout. If that section isn’t customized, remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. 4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the page layout.* 5 Remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout. 6 Action group 6 isn’t supported for custom objects. 766 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Table 6: Event Object Action Predefined Actions Group 1 Quick actions in the order defined on the layout. Standard Chatter actions aren’t supported. 2 Edit, Delete 3–6 Action groups 3 to 6 aren’t supported for the Event object. Table 7: Feed Object Action Predefined Actions Group 1 Quick actions in the order defined on the global publisher layout 2–6 Action groups 2 to 6 aren’t supported for the Feed object. Table 8: Group Object Action Predefined Actions Group 1 Actions from the Quick Actions in the Salesforce Classic Publisher section of the Group page layout. If that section isn’t customized, quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. 2–4 Action groups 2 to 4 aren’t supported for the Group object. 5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout. 6 Action group 6 isn’t supported for the Group object. Table 9: Lead Object Action Predefined Actions Group 1 1. Log a Call, 2. New Task, 3. Convert (if enabled), 4. Post 2 Edit 3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Lead page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. 4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Lead page layout.* 5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the Lead page layout. 6 In order: Call, Send Text, Send Email 767 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Table 10: “App Page” Lightning Page Action Predefined Actions Group 1 Global actions in the order defined in the Lightning page. 2–6 Action groups 2 to 6 aren’t supported for “App Page” Lightning pages. Table 11: List View Action Predefined Actions Group 1 New 2–6 Action groups 2 to 6 aren’t supported for list views. Table 12: Object Home Page (Tablet Only) Action Predefined Actions Group 1 1. New, 2. Sort 2–6 Action groups 2 to 6 aren’t supported for object home pages. Table 13: Opportunity Object Action Predefined Actions Group 1 1. Log a Call, 2. New Task, 3. New Event, 4. Post 2 Edit 3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Opportunity page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. 4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Opportunity page layout.* 5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the Opportunity page layout. 6 Action group 6 isn’t supported for the Opportunity object. Table 14: Person Object Action Predefined Actions Group 1 1. Call, 2. Send Email, 3. Post 2 Action group 2 isn’t supported for the Person object. 768 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Action Predefined Actions Group 3 The remaining actions in the order defined on the global publisher layout 4–6 Action groups 4 to 6 aren’t supported for the Person object. Table 15: Person Account Object Action Predefined Actions Group 1 1. Call, 2. Send Email, 3. New Task, 4. New Event 2 Edit 3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Person Account page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. 4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Person Account page layout.* 5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the page layout. 6 Read News, Send Text, View Website Table 16: Related List (for Standard Objects) Action Predefined Actions Group 1 New 2–6 Action groups 2 to 6 aren’t supported for related lists. Table 17: Salesforce Today—Main Page Action Predefined Actions Group 1 Quick actions in the order defined on the global publisher layout 2–6 Action groups 2 to 6 aren’t supported for the Salesforce Today main page. Table 18: Salesforce Today—Mobile Calendar Event Action Predefined Actions Group 1 1. Quick Message, 2. Join Conference Call, 3. Map 2 Action group 2 isn’t supported for Salesforce Today mobile calendar events. 769 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Action Predefined Actions Group 3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Event page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. 4–6 Action groups 4 to 6 aren’t supported for Salesforce Today mobile calendar events. Table 19: Task Object Action Predefined Actions Group 1 1. Edit Comments, 2. Change Date, 3. Change Status, 4. Change Priority 2 Edit 3 The remaining quick actions from the Quick Actions in the Salesforce Classic Publisher section of the Task page layout. If that section isn’t customized, the remaining quick actions are inherited from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Standard Chatter actions aren’t supported. 4 Custom buttons that are supported in the Salesforce mobile app, in the order defined on the Task page layout.* 5 The remaining standard buttons that are supported in the Salesforce mobile app, in the order defined on the Task page layout. 6 Action group 6 isn’t supported for the Task object. * Custom buttons that are added to the Button section of a page layout and that define the content source as URL or Visualforce are supported in the Salesforce mobile app. Remember that Visualforce pages must be enabled for use in the Salesforce mobile app. Custom links, custom buttons that are added to list views, and custom buttons that define the content source as OnClick JavaScript aren’t available in the Salesforce mobile app. SEE ALSO: How Actions Are Ordered in the Salesforce Mobile App Action Bar Salesforce Mobile App Action Bar Considerations for Actions in the Salesforce Mobile App 770 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Considerations for Actions in the Salesforce Mobile App • Most actions, including quick actions, productivity actions, and standard and custom buttons, EDITIONS are displayed in the action bar in the Salesforce mobile app. • The Save & New action button isn’t available in the Salesforce mobile app. Available in: both Salesforce • The Delete action is available on record pages only, not record detail pages. Classic (not available in all orgs) and Lightning • In most cases, a productivity action appears only if a record includes the information that the Experience action is keyed to. For example, the Send Email action depends on the record including an email address. The View Website action requires the record to include a website URL. On Available in: Group, accounts, the Call action appears even when there isn’t a phone number on the record. Professional, Enterprise, • By default, the Call productivity action in the mobile app action bar uses the global Log A Call Performance, Unlimited, Contact Manager, action layout. If you create one Log a Call action on an object, users see that custom Log a Call Database.com, and action’s layout when they tap Call from the object's action bar. If you create more than one Developer Editions Log a Call action for the same object, the Call action on that object uses the global Log a Call action layout. • There are a few differences between the Send Email quick action in Salesforce and the standard Email action in Case Feed: – Users can’t switch between the rich text editor and the plain text editor in a Send Email action. – Templates aren’t supported in the Send Email action. – Quick Text isn’t available in the Send Email action. – The Send Email action doesn’t support attachments. – Users can’t save messages as drafts when using the Send Email action. – Users can’t edit or view the From field in the Send Email action. • If feed tracking isn’t enabled on an object, only nonstandard actions appear in the Salesforce mobile app action bar and in third-party apps that use action lists. Nonstandard actions include Create, Update, Log a Call, custom actions, and Mobile Smart Actions. • If you’re using record types in your org, sometimes quick actions aren't visible to your users. For more information, see Quick Actions and Record Types on page 749. • The Mobile Smart Actions element appears as a single action element in the page layout editor, but it expands to several actions when it appears in the Salesforce mobile app. If the Mobile Smart Actions element is in Quick Actions in the Salesforce Classic Publisher section when you customize the action bar section, the actions in the app use your action bar customizations. In this case, the Mobile Smart Actions element in the Quick Actions in the Salesforce Classic Publisher section becomes irrelevant. • To customize the actions in the Salesforce mobile app action bar for standard and custom objects, first override the predefined actions. You can then add or remove actions from the Salesforce Mobile and Lightning Experience Actions section. For instance, to move the Join Group, Edit Group, or Leave Group actions on groups in the Salesforce mobile app, override the predefined actions in the Groups page layout. • Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. • If you add a custom button to the Salesforce Mobile and Lightning Experience Actions section of a page layout, it has a lightning bolt icon in the Salesforce mobile app action bar. If the Salesforce Mobile and Lightning Experience Actions section isn't customized, the icon in the app action bar is a wrench. SEE ALSO: How Actions Are Ordered in the Salesforce Mobile App Action Bar How Predefined Actions Are Ordered in the Salesforce Mobile App Action Bar and List Item Actions 771 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Set Up a Mass Quick Action A mass quick action is a quick action that gets added to an object’s search layout. After a mass quick EDITIONS action is set up, you can select up to 100 records in a list view and perform mass updates. You can use a mass quick action with cases, leads, accounts, campaigns, contacts, opportunities, work orders, Available in: Lightning and custom objects that support quick actions and have a search layout in Lightning Experience. Experience You can’t perform mass quick actions on a Recently Viewed list. Available in: Essentials, Important: You can perform a mass quick action on only the following quick action types: Group, Professional, • Create a Record Enterprise, Performance, Unlimited, and Developer • Update a Record Editions Before setting up a mass quick action: • Set up quick actions for your objects. These actions are the ones that you want users to perform USER PERMISSIONS on multiple records in a list view. To set up mass quick actions • Review Mass Quick Action Considerations. for Lightning Experience: To set up mass quick actions, customize an object’s search layout. • Customize Application 1. From Setup, click the Object Manager tab. 2. Select the object you want to allow mass quick actions on. 3. Select Search Layout. 4. Edit the List View layout. 5. In the List View Actions in Lightning Experience section, add the actions that you want your users to be able to perform on list views for multiple records. Here’s an example of the List View Actions for the case object. 6. Click Save. The list view for the object you updated now displays buttons for the actions you added. Users can select multiple records in the list view and use the mass quick action button to perform bulk updates. To help users understand the changes they’re making, a “Fields to update” section is included in the quick action layout. 772 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Mass Quick Action Considerations Review these guidelines and considerations before setting up and using mass quick actions in list views. SEE ALSO: Mass Quick Action Considerations Mass Quick Action Considerations Review these guidelines and considerations before setting up and using mass quick actions in list EDITIONS views. Setting Up a Mass Quick Action Available in: Lightning Experience • Mass quick actions are available only in Lightning Experience apps, including apps with standard and console navigation. Available in: Essentials, • You can’t perform mass quick actions in Experience Cloud sites, or on notes or users. Personal, Group, Enterprise, Performance, • You can’t use the Tooling API, AppExchange, and Changesets to add mass quick actions to Unlimited, Developer, and an object’s search layout. Professional Editions • If you want to set up predefined field values for a quick action, we recommend not including those fields on the quick action’s layout. If a predefined field value is included in the quick action’s layout, it’s only updated if the user manually selects it. If a predefined field value isn’t included in the quick action’s layout, the predefined value is updated, but the user isn't notified of the change. The “Fields to update” section includes only predefined field values that are specified in the layout. Using a Mass Quick Action • When using a mass quick action, only the fields you manually modify are changed. Some fields show a default value, but changes aren’t made unless you manually select them. The “Fields to update” section shows the changes you’re making. • You can’t perform a mass quick action on a Recently Viewed list view. • You can’t undo changes performed by a mass quick action—so be careful when making your changes. • Mass actions in split view use the same logic as mass actions in table view. • If you use a mass quick action on only one record, the “Fields to update” section isn’t displayed. Example: This mass quick action updates the owner on cases. The Case Owner field displays Awesome Admin because the user modified this field. The Status field displays New because that was the value of all the selected records. The changes to make are listed in the “Fields to update” section. 773 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Note: If the selected records had different statuses, such as one was set to New and one was set to Escalated, the Status field would display None. SEE ALSO: Set Up a Mass Quick Action Custom Buttons and Links Custom buttons and links help you integrate Salesforce data with external URLs, applications, your EDITIONS company’s intranet, or other back-end office systems. Salesforce supports these custom links and custom buttons. Available in: Salesforce Classic Type of Custom Link or Custom Button Setup Page Where It’s Configured Available in: All Editions Bookmark-style links defined in the standard Home Page Components except Database.com custom links home page component Full-featured custom links included in custom Custom Links USER PERMISSIONS home page components To create or change custom Full-featured custom links or custom buttons Buttons, Links, and Actions (in the object’s buttons or links: on objects management settings) • Customize Application Custom links can link to an external URL, such as www.google.com, a Visualforce page, or your company’s intranet. Custom links can also link to a custom s-control in the custom s-control library, such as a Java applet or Active-X control. Custom buttons can: • Connect users to external applications, such as a web page that displays a map to a contact’s address. • Run an s-control from the s-control library, such as an s-control that escalates a case from the case detail page. • Launch custom links. You can choose the display window properties that determine how the target of a link or button is displayed to your users. Custom links and s-controls can include Salesforce fields as tokens within the URL or custom s-control. For example, you can include an account name in a URL that searches Yahoo: http://search.yahoo.com/bin/search?p={!Account_Name}. You can override the default action of some standard buttons and customize the behavior of tab home pages to suit your org’s needs. Define Custom Buttons and Links Define the action that occurs when a user clicks a custom button or link. Custom buttons and links can streamline actions within Salesforce or integrate Salesforce data with external URLs, applications, or systems. Override Standard Buttons and Tab Home Pages You can override the behavior of standard buttons—like New, View, or Edit—in Salesforce Classic, Lightning Experience, and mobile independently. You can also override the tab home page that displays when a user clicks a standard, custom, or external object tab. Custom Button and Link Samples Use samples of custom Salesforce buttons and links to determine whether they can work for you. Custom Button and Link Considerations Keep these considerations in mind when working with custom buttons and links. 774 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Viewing References to Salesforce Components SEE ALSO: Define Custom Buttons and Links Adding Default Custom Links Customize Salesforce Classic Home Tab Page Layouts Define Custom Buttons and Links Define the action that occurs when a user clicks a custom button or link. Custom buttons and links EDITIONS can streamline actions within Salesforce or integrate Salesforce data with external URLs, applications, or systems. Available in: Salesforce Watch a Demo (English only) Classic (not available in all orgs) If you want the button or link to launch a custom page or other code, consider a Visualforce page. 1. From the management settings for the object that you want to edit, go to Buttons, Links, and Custom buttons and links are available in: All Editions Actions. Visualforce pages and Note: Custom buttons aren’t available on the User object or custom home pages. Custom s-controls are available in: buttons and links are available for activities under the individual object management Contact Manager, Group, settings for tasks and events. To override a standard button that applies to both tasks and Professional, Enterprise, events, go to the object management settings for activities. Performance, Unlimited, and Developer Editions 2. Click New Button or Link. Alternatively, click Default Custom Links to add a predefined custom link. 3. For Display Type, select Detail Page Link, Detail Page Button, or List Button. USER PERMISSIONS Note: If you select List Button, and your list button requires users to select individual To create or change custom records in a list, then select Display Checkboxes (for Multi-Record Selection). When buttons or links: you select this option, a checkbox appears next to each list item to let users select records, • Customize Application and the list button action is applied to those records. Don’t select Display Checkboxes (for Multi-Record Selection) if your list button doesn’t require users to select individual records in the list. For example, your list button links to a URL that doesn’t support POST operations, such as a URL that links to a Lightning component. In Lightning Experience, when you select Display Checkboxes (for Multi-Record Selection), the related list type must be set to Enhanced List. You can set the related list type for a related list on a record page in the Lightning App Builder. 4. Enter the button or link attributes. Here’s an example of the attributes for a button that performs a web search for an account’s name. 775 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links 5. To validate all Salesforce merge fields and functions, click Check Syntax. 6. Click Save when you’re finished, or click Quick Save to save and continue editing. Saving validates the URL you defined if you set the content source to URL. 7. To open a button or link using settings other than the user’s default browser settings, click Window Open Properties on the button or link’s detail page. 8. To view all references to the new button or link, click Where is this used? on its detail page. Custom links for users are automatically added to the Custom Links section of the user detail page. You can add page buttons only to the Button section of a page layout. Note: A link URL can be up to 2,048 bytes. When data is substituted for the tokens in the URL, the link can exceed 3,000 bytes. Some browsers enforce limits on the maximum URL length. Before you can use your custom buttons and links, add them to an object’s page layout. You can then see and use the button or link on a record detail page. Custom Button and Link Fields This table defines the fields that are available when you create a custom button or link. Constructing Effective Custom URL Buttons and Links Use these methods to construct effective custom URL buttons and links. Editing Window Open Properties 776 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Merge Fields for Custom Buttons and Links Adding Default Custom Links Custom Link Best Practices Custom buttons and links can streamline actions within Salesforce, or integrate Salesforce data with external URLs, applications, or systems. Use these best practices to get the most out of your custom links. SEE ALSO: Find Object Management Settings Custom Button and Link Considerations Custom Button and Link Samples Custom Button and Link Fields This table defines the fields that are available when you create a custom button or link. EDITIONS Attribute Name Description Available in: Salesforce Label Enter the text that displays in the user interface for the custom button or Classic link. Custom buttons and links are available in: All Editions Name Accept or enter the unique name to use for the button or link when it’s except Database.com referenced from a merge field. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must Visualforce pages and begin with a letter, not include spaces, not end with an underscore, and s-controls are available in: not contain two consecutive underscores. Contact Manager, Group, Professional, Enterprise, Namespace Enter the prefix that uniquely identifies your package. In a packaging Performance, Unlimited, Prefix context, a namespace prefix is a one to 15-character alphanumeric identifier and Developer Editions that distinguishes your package and its contents from packages of other developers on AppExchange. Namespace prefixes are case-insensitive. For example, ABC and abc are not recognized as unique. Your namespace prefix must be globally unique across all Salesforce organizations. It keeps your managed package under your control exclusively. Protected Optionally limit use in a subscriber org. Protected components can’t be Component linked to or referenced by components created in a subscriber org. A developer can delete a protected component in a future release without worrying about failing installations. However, once a component is marked as unprotected and is released globally, the developer can’t delete it. Description Enter text that distinguishes the button or link from others. This text displays only to administrators when setting up buttons and links. Display Type Determine where the button or link appears on page layouts. Detail Page Link Adds the link to the Custom Links section of your page layouts. Detail Page Button Adds the custom button to a record’s detail page. You can add detail page buttons to the Button section of a page layout. 777 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Attribute Name Description List Button Adds the custom button to a list view, search result layout, or related list. You can add list buttons to the Related List section of a page layout or the List View and Search Result layouts. For list buttons, Salesforce selects the Display Checkboxes (for Multi-Record Selection) option to include a checkbox next to each record in the list. Users can select the records they want applied to the action on the list button. If your custom button doesn’t require the user to select records, deselect this option. Behavior Choose the outcome of clicking the button or link. When applicable, some settings have default values. For example, if you choose Display in new window, the default height of a new window is 600 pixels. See Editing Window Open Properties. Note: Custom button links open in a new tab in Experience Builder sites, even if any of the Display in existing window options is selected. Content Source Choose whether to use a URL, s-control, JavaScript action, or Visualforce page as the content of the button or link. Salesforce checks the correctness of URLs in custom links and custom buttons. When you create or edit custom links or buttons that contain invalid URL markup, such as scripts, Salesforce blocks the links from rendering. Instead, an error message is shown on hover. Reconfigure the URLs to be valid and well formed. The URL can be a relative URL or an absolute http://, https://, file://, ftp://, or mailto:// address. Invalid URLs in custom links or custom buttons created before Spring ’13 aren’t checked for correctness until you edit them. Content Enter the content of the button or link for buttons and links of type URL or OnClick JavaScript. • To insert a field, choose the field type from Select Field Type and choose a field from Insert Field. • To insert activity merge fields, select Event or Task from Select Field Type. • To insert an operator, choose the appropriate operator icon from the Insert Operator drop-down list. • To insert a function, double-click its name in the list, or select it and click Insert Selected Function. To filter the list of functions, choose a category from the Functions drop-down list. Select a function and click Help on this function to view a description and examples of formulas using that function. Tip: Internet standards require special encoding for URLs. Salesforce encodes the text from any merge field you insert into a link. Encode extra text in your link manually. For example, to generate the following URL: http://www.google.com/search?q={!user.name} Steve Mark 50% Use this content: http://www.google.com/search?q={!user.name}+Steve+Mark+50%25 Salesforce strips double quotes from URLs when the content source is a URL. If you must use double quotes, encode them manually. For example, to generate the URL http://www.google.com/search?q="salesforce+foundation", use this 778 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Attribute Name Description content: http://www.google.com/search?q=%22salesforce+foundation%22 Link Encoding Choose the encoding setting. Encoding defaults to Unicode (UTF-8). Change the default encoding setting if the target of a link requires data in a different format. Encoding is available if your Content Source is URL. Constructing Effective Custom URL Buttons and Links Use these methods to construct effective custom URL buttons and links. EDITIONS Use merge fields to pass Salesforce data. You can add merge fields to a custom link to pass data from your Salesforce records, user Available in: Salesforce information, or company information to another website or application. Classic (not available in all orgs) For example, you can create custom links that search Google for an account name or look up an address on a map. Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions http://google.com/search?q={!Account.Name} http://maps.google.com?q={!Account.ShippingStreet} {!Account.ShippingCity} {!Account.ShippingState} {!Account.ShippingPostalCode} Note: Custom links don’t support data type conversion. When creating custom links to pass data from one Salesforce field to another, the data must match the data type of the fields in which you are placing it. For example, if you have numeric data, you must pass it to a numeric field. Substitute symbols for certain characters or use URLENCODE(). Due to URL encoding standards set forth by the World Wide Web Consortium (W3C), certain “unsafe” characters, such as spaces and punctuation marks, can’t be passed through a URL. Custom buttons and links escape these characters, so you don’t have to URL-encode them. If you need to encode your URL, use the URLENCODE() function in the merge field like so: {!URLENCODE(text)} and replace text with the merge field or text string that you want to encode. For example: If the merge field foo__c contains Mark's page, {!URLENCODE(foo_c)} results in: %3CB%3EMark%27s%20page%3C%2Fb%3E. 779 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Use URLFOR() to link to Visualforce pages. To link to a Visualforce page, use URLFOR() with the relative path to the page, which is /apex/PageName. For example, to link to a Visualforce page called MissionList that isn’t associated with a record, use the following syntax. {! URLFOR( “/apex/MissionList” ) } When you use URLFOR() with a Visualforce page, and you want to pass a record ID into the page, you must pass the ID in as a parameter. {! URLFOR( “/apex/Mission”, null, [id=Mission__c.Id] ) } Use the $Action global variable and URLFOR() to point to Salesforce pages. When creating a custom button or link that points to a page in Salesforce, use the $Action global variable to construct the link, instead of pasting in the path to the page. Then, if your organization is moved to another server or the URL to the page changes, the link still points to the right place. To construct the link, use the URLFOR() formula function with the $Action variable. {!URLFOR( $Action.Case.NewCase, Account.Id )} This custom link on the Account object opens the New Case form, creating the case as a child of the account record. You can use this process for any object that has a lookup to the Account object. To create a record that isn’t a child of another record, or if two objects have no relationship, you can use $ObjectType.ObjectName as the second argument. For example: {!URLFOR( $Action.Case.NewCase, $ObjectType.Case )} $Action global variables expect either a record ID or the $ObjectType. For example, these formulas create links to the tab and detail page for an account, respectively. {!URLFOR( $Action.Account.Tab, $ObjectType.Account )} {!URLFOR( $Action.Account.View, Some_Account_Lookup__c.Id )} The URLFOR() function takes additional optional arguments that get passed into the destination as query string parameters. You can use these arguments when overriding a standard action with a Visualforce page to pass in the additional parameters needed by the Visualforce page or its controller. For example, if when closing a case you want to change the value of a custom field on the case called Actual Delivery Date to today, you could use: {!URLFOR($Action.Case.CloseCase, Case.Id, [ actualDeliveryDate=TODAY()] )} You can then override the Close Case action with a Visualforce page and handle setting the value of the Actual Delivery Date field either in that Visualforce page or its controller. See Using Query String Parameters in a Visualforce Page for more information. Use these Lightning-friendly URL button and link methods to point to other pages in Lightning Experience. Custom URL Button or Link Lightning Experience Behavior External URL URL opens in new tab www.google.com Relative Salesforce URL, View Record home page opens in existing tab /{!Account.Id} Relative Salesforce URL, Edit Edit overlay pops up on the existing page 780 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Custom URL Button or Link Lightning Experience Behavior /{!Account.Id}/e Relative Salesforce URL, List Object home page opens in existing tab /001/o $Action URL, View Record home page opens in existing tab {!URLFOR($Action.Account.View, Account.Id)} $Action URL, Edit Edit overlay pops up on the existing page {!URLFOR($Action.Account.Edit, Account.Id)} Note: Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. SEE ALSO: Custom Link Example: Link to Documents Custom Link Example: Link to Files in Chatter Custom Link Example: Link to Reports Editing Window Open Properties Custom buttons and links can open in different types of windows. If you have selected a custom EDITIONS button or link to open in a popup window, set the window properties. If you leave the window properties blank, the custom button or link will use the default settings of the user’s browser. Available in: Salesforce To edit the window open properties: Classic 1. From the management settings for the object whose button or link you want to edit, go to Available in: All Editions Buttons, Links, and Actions, and then click the button or link name. Custom buttons are not except Database.com available on the user object. S-controls are available in: 2. Click Window Open Properties. Contact Manager, Group, Professional, Enterprise, 3. Edit the following properties. Performance, Unlimited, and Developer Editions Window Property Description Width The width (in pixels) of the popup. USER PERMISSIONS Height The height (in pixels) of the popup. To edit custom button or link Window Position The location on the screen where the popup properties: should open. • Customize Application Resizeable Allow users to resize the popup window. 781 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Window Property Description Show Address Bar Show the browser’s address bar which contains the URL. Show Scrollbars Show browser scrollbars for the popup. Show Toolbars Show the browser toolbars. Toolbars normally contain navigation buttons like Back, Forward, and Print. Show Menu Bar Show the browser menus. The menus typically contain option like File and Edit. Show Status Bar Show the status bar at the bottom of the browser. Note: Some properties may not be available depending on the behavior of the custom button or link. For example, if you chose Execute JavaScript, no window open properties are available. 4. Save your changes. SEE ALSO: Define Custom Buttons and Links Merge Fields for Custom Buttons and Links A merge field is a field you can put in an email template, mail merge template, custom link, or EDITIONS formula to incorporate values from a record. Available in: Salesforce Syntax and Formatting Classic When you insert a merge field in a custom button or link, the syntax consists of an open curly brace Custom buttons and links and exclamation point, followed by the object name, a period, the field name, and a closing curly are available in: All Editions brace. except Database.com Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions {!Object_Name.Field_Name} To ensure that you’re using the correct syntax, select merge fields from the dropdown list in the editor for custom buttons and links. Note: Custom objects named “Org”, can’t be used in a merge field. Objects named “org’ are explicitly filtered from the Select Field Type list for a custom button. Tips • To insert activity merge fields, select Event or Task from the Select Field Type dropdown list. 782 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links • You can add links quickly to the sidebar by using the standard home page’s Custom Links component. Warning: The standard home page’s Custom Links component doesn’t support – Merge fields – Functions, such as URLFOR – JavaScript execution – Customizable window opening properties SEE ALSO: Generate Emails From Records Custom Button and Link Considerations Adding Default Custom Links 1. From the management settings for the appropriate object, go to Buttons, Links, and Actions EDITIONS or to Buttons and Links. 2. Click Default Custom Links. Available in: Salesforce Classic 3. Next to a sample link you want to add, click Add Now!. 4. Change the default data for the link, as necessary. Available in: All Editions except Database.com 5. Choose Save. 6. Edit the page layout for the appropriate tab to display the new link. USER PERMISSIONS SEE ALSO: To create or change custom links: Define Custom Buttons and Links • Customize Application Custom Link Best Practices Custom buttons and links can streamline actions within Salesforce, or integrate Salesforce data with EDITIONS external URLs, applications, or systems. Use these best practices to get the most out of your custom links. Available in: Salesforce Note: Salesforce checks the correctness of URLs in custom links and custom buttons. When Classic (not available in all you create or edit custom links or buttons that contain invalid URL markup, such as scripts, orgs) Salesforce blocks the links from rendering. Instead, an error message is shown on hover. Custom buttons and links Reconfigure the URLs to be valid and well formed. The URL can be a relative URL or an absolute are available in: All Editions http://, https://, file://, ftp://, or mailto:// address. Invalid URLs in Visualforce pages and custom links or custom buttons created before Spring ’13 aren’t checked for correctness until s-controls are available in: you edit them. Contact Manager, Group, Professional, Enterprise, Best Practices for Advanced Users Performance, Unlimited, and Developer Editions Salesforce has no plans to change field names; however, that doesn’t guarantee that field names won’t change in the future. Therefore, custom links that include Salesforce fields may change how they are mapped. 783 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Pass Session IDs with SSL Never pass session IDs to an “http” URL. Instead, pass session IDs with a secure sockets layer (SSL) “https” URL. Any data that is passed to other applications hosted on the Internet should always use SSL since the URL may contain sensitive customer information. Single Sign-On Use custom links to pass a session ID to support Single Sign-On (SSO), so users can avoid multiple logins to web applications that your organization hosts to manage Salesforce data. Construct your custom link to pass the {!User_Session_ID} merge field, which allows users to access all authorized resources during a single authentication. External systems can access Salesforce resources using a web service, which allows organizations to communicate data without intimate knowledge of each other's IT systems behind a firewall. Send the Server Date in the URL Some integration projects need custom links to include a server date to know the Salesforce initiation date. The Salesforce server date can be passed to external systems using custom links. For example, http://someurl.com/somepath?current_date={!Today}. Dates use the Pacific time zone. Avoid Double Sets of Tabs in a Browser Unlimited Edition and Enterprise Edition users can build a custom link to perform an action that keeps users in the same browser window and doesn’t display a double set of tabs. Create a Visualforce page that contains the following code, replacing 784 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Override Standard Buttons and Tab Home Pages You can override the behavior of standard buttons—like New, View, or Edit—in Salesforce Classic, EDITIONS Lightning Experience, and mobile independently. You can also override the tab home page that displays when a user clicks a standard, custom, or external object tab. Available in: Salesforce Button overrides are global. For example, if you override the New button on opportunities, your Classic (not available in all replacement action takes effect wherever that action is available, such as: orgs) and Lightning Experience • Opportunities home page • Any opportunities related lists on other objects, such as accounts Available in: Enterprise, Performance, Unlimited, • Create New dropdown list in the Salesforce Classic sidebar and Developer Editions • Any browser bookmarks for this Salesforce page Visualforce overrides also 1. From the object management settings for the object you want to set an override for, go to available in: Contact Buttons, Links, and Actions. Manager, Group, and 2. Click Edit next to the button or tab home page you want to override. Professional Editions Record types available in: 3. For each experience—Salesforce Classic, Lightning Experience, or mobile—click the type of Professional, Enterprise, override you want associated with the action. Performance, Unlimited, • No override (use default)—Use a custom override provided by an installed package. If and Developer Editions there isn't one installed, the standard Salesforce behavior is used. • Standard page—This option is available only for subscribers who are overriding the actions on an installed custom object. If selected, the standard Salesforce behavior is used. USER PERMISSIONS • Custom s-control—Use the behavior from an s-control. This option isn’t supported for To override standard buttons mobile. and tab home pages: • Customize Application Important: Visualforce pages supersede s-controls. Organizations that haven’t previously used s-controls can’t create them. Existing s-controls are unaffected, and To reset button and tab home page overrides: can still be edited. • Customize Application • Lightning component—Use the behavior from a Lightning component. Supported only for the Edit, New, New Event, Tab and View actions. This option isn’t supported for Salesforce Classic. • Lightning page—Use the behavior from the Lightning record page assigned as the org default for the object. This option is available only for the View action in Lightning Experience. • Visualforce page—Use the behavior from a Visualforce page. • Use the Salesforce Classic override—Inherits the behavior from the Salesforce Classic Override setting. Important: Before you override a standard button with a Lightning component or Visualforce page, review implementation details in the respective developer guides. 4. Select the name of the s-control, Lightning component, Lightning page, or Visualforce page you want to run when users click the button or tab. When overriding the New button with a Visualforce page, you can choose to skip the record type selection page. If you do, new records you create aren’t forwarded to the record type selection page. Salesforce assumes that your Visualforce page is already handling record types. Important: When a Salesforce mobile app user clicks New to create a product, the user must select a record type even if the Skip record type selection page option is selected in Setup. 5. Click Save. 785 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Note: A standard button (New, Edit, View, Delete, and Clone) overridden with a Visualforce page doesn’t show up in the Salesforce mobile app unless the Visualforce page is enabled for Salesforce mobile apps. Overriding standard list and tab controls isn’t supported in mobile. Standard Action Overrides For standard actions, such as Delete, Edit, List, New, Tab, and View, you can provide a custom user interface for the action, called an action override. Use action overrides when your business model requires a more customized user experience than the Salesforce standard page provides. Considerations for Overriding Standard Buttons Before you override a standard button, review these considerations. Remove Overrides for Standard Buttons and Tab Home Pages SEE ALSO: Considerations for Overriding Standard Buttons Remove Overrides for Standard Buttons and Tab Home Pages Visualforce Developer Guide : Overriding Buttons, Links, and Tabs with Visualforce Lightning Aura Components Developer Guide : Standard Actions and Overrides Basics Standard Action Overrides For standard actions, such as Delete, Edit, List, New, Tab, and View, you can provide a custom user EDITIONS interface for the action, called an action override. Use action overrides when your business model requires a more customized user experience than the Salesforce standard page provides. Available in: Salesforce You can specify a different override for each user experience, with the following guidelines. Classic (not available in all orgs) and Lightning • Salesforce Classic—Use a Visualforce page as the action override. Experience • Lightning Experience and the Salesforce mobile app —You can override the Edit, New, Tab, and View standard actions on most standard and all custom objects. Available in: Enterprise, Performance, Unlimited, • Lightning Experience—Use a Lightning component as the action override for the Edit, New, and Developer Editions and Tab actions. Use a Lightning page or a Lightning component as the action override for the View action. Visualforce overrides also available in: Contact • Experience Builder sites—Use a custom Lightning component to replace standard forms when Manager, Group, and users click the New or Edit button. The action you choose in Lightning Experience is the same Professional Editions action that you use to override actions in Experience Builder sites. Record types available in: • Salesforce app—Use a Lightning component as the action override. Professional, Enterprise, • Managed packages—Developers can include action overrides as package defaults, and managed Performance, Unlimited, package subscribers can specify local overrides as alternatives to the default overrides. and Developer Editions Note: For Salesforce Classic, usually a Visualforce page is the only supported override option. Under certain conditions, you can use existing s-controls as overrides for Salesforce Classic. USER PERMISSIONS However, s-controls have been deprecated since the Spring ’09 release. We recommend using Visualforce pages instead. To override standard buttons: • Customize Application 786 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Assign Action Overrides To assign a Visualforce page or Lightning component as an override, first create the page or component (or use one created by a Salesforce developer in your org). It’s important to understand the action override options for each user experience and how your selections for each one can affect the others. Assign a Lightning Record Page Override for the View Action When you create an override for the View action for Lightning Experience, you can use either a Lightning record page or a Lightning component. To use a Lightning record page as an override, you must activate the page as the org default in the Lightning App Builder. Action Overrides in Managed Packages In a managed package, overrides specified by the package developer are included as default overrides. The package subscriber can specify local overrides for each user experience to use instead of the package default overrides. Package default overrides impact the options and behaviors of local overrides. Action Overrides in Experience Builder Sites Personalize your Experience Builder site users’ experience by adding a custom Lightning component to replace standard forms when users click the New or Edit button. Use action overrides when your site and portal users require a more customized user experience than the Salesforce standard page provides. SEE ALSO: Trailhead: Introduction to Creating Visualforce Pages Trailhead: Build a Lightning Component to Override a Standard Action Assign Action Overrides To assign a Visualforce page or Lightning component as an override, first create the page or EDITIONS component (or use one created by a Salesforce developer in your org). It’s important to understand the action override options for each user experience and how your selections for each one can Available in: Salesforce affect the others. Classic (not available in all When assigning overrides, keep in mind the following requirements. orgs) and Lightning Experience • Salesforce Classic—To use a Visualforce page to override an action, the Visualforce page must use the standard controller for the object on which the action appears. To use a Visualforce Available in: Enterprise, page to override a tab, the Visualforce page must use the standard list controller for that tab’s Performance, Unlimited, associated object. and Developer Editions • Lightning Experience and the Salesforce mobile app—To make a Visualforce page available Visualforce overrides also for use as an override, select Available for Lightning Experience, Experience Builder sites, available in: Contact and the mobile app in the Visualforce Pages setup panel. Manager, Group, and Professional Editions 1. Click Setup, select Object Manager, and select the object that you want to modify. Record types available in: 2. In the Object Manager settings list, select Buttons, Links, and Actions. Professional, Enterprise, 3. In the row for the action you want to modify, select Edit from the dropdown menu. Performance, Unlimited, and Developer Editions 4. Specify the override option for each user experience. USER PERMISSIONS To override standard buttons: • Customize Application 787 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Example: This Override Properties panel specifies a Visualforce page for Salesforce Classic and a Lightning component for Lightning Experience. The mobile override specifies the Salesforce Classic override, so mobile users see the Visualforce page. SEE ALSO: Trailhead: Introduction to Creating Visualforce Pages Trailhead: Build a Lightning Component to Override a Standard Action Assign a Lightning Record Page Override for the View Action When you create an override for the View action for Lightning Experience, you can use either a EDITIONS Lightning record page or a Lightning component. To use a Lightning record page as an override, you must activate the page as the org default in the Lightning App Builder. Available in: Salesforce 1. Click Setup, enter Lightning App in the Quick Find box, and select Lightning App Classic (not available in all Builder. orgs) and Lightning Experience 2. In the Setup panel for the Lightning App Builder, click Edit next to the Lightning page that you want to use as an override. Available in: Enterprise, Performance, Unlimited, 3. In the Lightning App Builder, click Activation. and Developer Editions 4. On the Activation page, select Org Default and click Close. After you activate the Lightning Visualforce overrides also page as the org default, the page is selected as the Lightning Experience override for the View available in: Contact action in the Override Properties panel. Manager, Group, and 5. To remove the Lightning page as the override, return to the Activation page in the Lightning Professional Editions App Builder, click Remove as Org Default, and click Close.. Record types available in: Professional, Enterprise, Performance, Unlimited, and Developer Editions USER PERMISSIONS To override standard buttons: • Customize Application 788 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Example: In this Override Properties panel, the Lightning page Account_Lightning_Page_Test is the specified Lightning Experience override for the View action. SEE ALSO: Create and Configure Lightning Experience Record Pages Action Overrides in Managed Packages In a managed package, overrides specified by the package developer are included as default EDITIONS overrides. The package subscriber can specify local overrides for each user experience to use instead of the package default overrides. Package default overrides impact the options and behaviors of Available in: Salesforce local overrides. Classic (not available in all Several rules determine local override behaviors in a managed package. orgs) and Lightning Experience • For each user experience—When a package subscriber specifies a local override, the local override takes precedence over the package default override. If no local override is specified Available in: Enterprise, for a user experience, the package default override for that user experience is used. Performance, Unlimited, • For Lightning Experience and the Salesforce mobile app—If no local override is specified and and Developer Editions no package default override is specified, the local override inherits from Salesforce Classic. Either Visualforce overrides also the Salesforce Classic local override (if it is specified) is used, or the Salesforce Classic package available in: Contact default override (if no Salesforce Classic local override is specified) is used. Manager, Group, and Professional Editions • A package developer can remove or replace the default overrides when updating a managed package. The new default overrides are available for package subscribers when they install the Record types available in: updated package. Professional, Enterprise, Performance, Unlimited, Example: The Override Properties panel for a managed package identifies the override and Developer Editions defaults and the local override options for each user experience. The available local override options vary based on the override defaults. • No override (use default)—Uses either the override default Visualforce page or the USER PERMISSIONS Salesforce standard page if no Visualforce page is specified. To override standard • Standard page—Available for package subscribers only if the package default override buttons: for the given user experience is a Visualforce page or Lightning component. • Customize Application • Lightning component—The specified component takes precedence over the package default override for the given user experience. 789 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links • Use the package default override—Available for package subscribers only if the package default override for the given user experience is a Lightning component. • Use the Salesforce Classic override—Available for package subscribers only if the package default override for the given user experience is the Salesforce standard page. Option inherits from the local Salesforce Classic override. Action Overrides in Experience Builder Sites Personalize your Experience Builder site users’ experience by adding a custom Lightning component EDITIONS to replace standard forms when users click the New or Edit button. Use action overrides when your site and portal users require a more customized user experience than the Salesforce standard page Available in: Salesforce provides. Classic (not available in all To override actions in an Experience Builder site: orgs) and Lightning Experience 1. In Salesforce Setup, enter Digital Experiences in the Quick Find box and select All Sites. Available in: Essentials,Enterprise, 2. Next to the site that you want to override, click Workspaces. Performance, Unlimited, 3. Click Administration. and Developer Editions 4. Select Override standard actions with the Lightning component. 5. Click Save. USER PERMISSIONS Note: The action you choose in Lightning Experience is the same action that you use to To override standard override actions in Experience Builder sites. buttons: • Customize Application 790 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Considerations for Overriding Standard Buttons Before you override a standard button, review these considerations. EDITIONS Implementation Tips Available in: Salesforce Classic (not available in all Important: Before you override a standard button with a Lightning component or Visualforce orgs) and Lightning page, review implementation details in the respective developer guides. Experience • If you override a standard button in Salesforce, that button is still available in Connect Offline, Available in: Enterprise, but it retains its original behavior. Performance, Unlimited, • The View standard button refers to all links in Salesforce that display the detail page for a record. and Developer Editions Overriding the View standard button reroutes all these links. Visualforce overrides also • The View action is the only one that supports overrides with a Lightning record page. To make available in: Contact a Lightning record page available for a View action override, assign the page as the org default Manager, Group, and for its associated object by activating it in the Lightning App Builder. Professional Editions • If you have the View action overridden with a Visualforce page in Salesforce Classic, the Setup Record types available in: menu on that object record page in Lightning Experience displays the Edit Page option. Selecting Professional, Enterprise, Edit Page in Lightning Experience on an object page that’s overridden with a Visualforce page Performance, Unlimited, in Salesforce Classic lets you create a custom Lightning Experience record page for that object and Developer Editions in the Lightning App Builder. • If a button isn’t available for overrides, you can still hide it on the page layout. USER PERMISSIONS • Button overrides affect everywhere that action or behavior is available. For example, overriding the New button on an account also overrides the account option in the Create New drop-down To override standard list in the Salesforce Classic sidebar. buttons: • Customize Application • Person Account records use any standard button overrides you make for accounts. Person Account records also use any overrides for the View Self-Service and Enable Self-Service buttons you make for contacts. • If your organization uses the Console tab, overrides for the Edit and View buttons for an object don’t affect the Edit and View buttons in the mini page layouts. Pages that display due to overrides display in the console without the header or sidebar. • To replace a standard button with a custom button, first define the custom button, then customize the page layout to hide the standard button and display the custom one in its place. • When you override the Edit button with a Visualforce page, you’re also overriding default logic that checks whether the record has been locked for approval. However, you can perform the same check by implementing the Approval.lock Apex method. Limitations • You can override buttons on the detail page but not the edit page of a record. • You can only override these standard buttons: New, View, Edit, and Delete. • For tasks and events in Salesforce Classic, you can only override standard buttons and links, with the exception of the New Event button. Overrides for that button aren’t supported in Salesforce Classic. In Lightning Experience, you can override the New Event button on the Calendar page with a Lightning component for a custom object, but clicking a timeslot always creates a standard event. • You can’t change buttons on lookup dialogs, reports, or tabs. However, you can change the buttons on list view and search result layouts under search layouts. • Action overrides on the New standard button don't work on New Object links in lookup searches. 791 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links • Action overrides on the New standard button for objects with multiple record types aren’t supported in the Outlook and Gmail integrations unless you choose to skip the record type selection page. • You can’t relabel or relocate standard buttons on a record detail page. • When overriding tabs or buttons with a Lightning component, you can select only Lightning components that implement the lightning:actionOverride interface. • A standard button (New, Edit, View, Delete, and Clone) overridden with a Visualforce page doesn’t show up in the Salesforce mobile app unless the Visualforce page is enabled for Salesforce mobile apps. Overriding standard list and tab controls isn’t supported in mobile. • When overriding tabs with a Visualforce page, you can select only Visualforce pages that use the standard list controller for that tab’s associated object, pages with a custom controller, or pages with no controller. • When overriding lists with a Visualforce page, you can select only Visualforce pages that use a standard list controller. • When overriding buttons with a Visualforce page, you can select only Visualforce pages that use the standard controller for the object on which the button appears. For example, if you want to use a page to override the Edit button on accounts, the page markup must include the standardController="Account" attribute on the ... page content here ... SEE ALSO: Override Standard Buttons and Tab Home Pages Visualforce Developer Guide : Overriding Buttons, Links, and Tabs with Visualforce Lightning Aura Components Developer Guide : Standard Actions and Overrides Basics 792 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Remove Overrides for Standard Buttons and Tab Home Pages To remove overrides for actions that support overrides for Classic, Lightning, and mobile web: EDITIONS 1. From the management settings for the object whose button you want to edit, go to Buttons, Links, and Actions. Available in: Salesforce Classic (not available in all 2. Click Edit next to the overridden button or tab link. orgs) and Lightning 3. Select No override (use default) for the Salesforce Classic override Experience 4. To also remove overrides for Lightning Experience or Mobile, select Use the Salesforce Classic Available in: Enterprise, override. Performance, Unlimited, 5. Click Save and Developer Editions Visualforce overrides also available in: Contact Manager, Group, and Professional Editions Record types available in: Professional, Enterprise, Performance, Unlimited, and Developer Editions USER PERMISSIONS To override standard buttons and tab home pages: • Customize Application To reset button and tab home page overrides: • Customize Application To remove overrides for actions that support only Classic: 1. From the management settings for the object whose button you want to edit, go to Buttons, Links, and Actions. 2. Click Edit next to the overridden button or tab link. 3. Select No override (use default) for Salesforce Classic Override. 4. Click Save 793 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Custom Button and Link Samples Use samples of custom Salesforce buttons and links to determine whether they can work for you. USER PERMISSIONS Custom Link Example: Link to Documents To create or change custom buttons or links: Use custom links to reference documents from a Salesforce record detail page. • Customize Application Custom Link Example: Link to Files in Chatter Use custom links to reference files from Chatter. EDITIONS Custom Link Example: Link to Reports Use custom links to run reports with filtered results from a Salesforce record detail page. For Available in: Salesforce example, let’s say you frequently run a mailing list report for the contacts related to an account. Classic (not available in all You can create a custom link for accounts that links directly to a report that is automatically orgs) filtered to the account you are viewing. In this case, your custom link must pass the account’s Custom buttons and links unique record ID to the report. are available in: All Editions Create a Custom Button for Performing Mass Deletes Visualforce pages and This example creates a JavaScript custom button for Salesforce Classic that can be added to s-controls are available in: activity-related lists and list views and allows users to delete selected records at the same time. Contact Manager, Group, Displaying Alerts Professional, Enterprise, Performance, Unlimited, This example creates a button that opens a popup dialog with a welcome message containing and Developer Editions the user's first name. Getting Record IDs This example creates a button that opens a popup window listing record IDs for user selected records. This is useful when testing to ensure you have the correct record IDs before processing them further. Passing Record IDs to an External System You can use Salesforce record IDs as unique identifiers for integrating with an external system. This example creates a button that calls a Visualforce page to determine the record IDs of selected records and passes them in a URL query parameter to an external Web page called “www.yourwebsitehere.com.” Launching Record Create Page with Default Field Values Construct custom buttons and links that pass default field values to a record create page. This feature applies to Lightning Experience in all editions. This feature doesn’t apply to Lightning Out, Experience Builder sites, or the Salesforce mobile app. Reopening Cases This example creates a button that can be added to cases related lists so users can reopen several cases on an opportunity at once. 794 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links International Maps This example creates a link that displays a country-specific Google map. SEE ALSO: Define Custom Buttons and Links Custom Link Example: Link to Documents Use custom links to reference documents from a Salesforce record detail page. EDITIONS 1. Create a folder on the Documents tab to which all users have access. 2. Upload the document to that folder. Available in: Salesforce Classic (not available in all 3. From the Documents tab, choose the folder and click Go. orgs) 4. Click View next to the document. Custom buttons and links 5. Copy the document’s URL from the browser. For example, are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions USER PERMISSIONS To create or change custom buttons or links: • Customize Application https://MyDomainName.my.salesforce.com/servlet/servlet.FileDownload?file=015300000000xvU. 6. Use everything after the domain portion of the URL to create your custom link. Using the example in the previous step, your link would point to /servlet/servlet.FileDownload?file=015300000000xvU. SEE ALSO: Constructing Effective Custom URL Buttons and Links Custom Link Example: Link to Files in Chatter Custom Link Example: Link to Reports 795 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Custom Link Example: Link to Files in Chatter Use custom links to reference files from Chatter. EDITIONS 1. Upload a file to the Files tab. 2. When the upload is finished, from the Upload dialog box, click Share settings. Available in: Salesforce Classic (not available in all 3. Click Anyone with link. orgs) 4. Copy the document’s URL from the Share via Link dialog box. For example, Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions USER PERMISSIONS To create or change custom buttons or links: • Customize Application https://MyDomainName.my.salesforce.com/sfc/p/D0000000JsES/a/D000000001dd/aiq8UPJ5q5i6Fs4Sz.IQLKUERsWYdbAm320cjqWnkfk=. 5. Use everything after the domain portion of the URL to create your custom link. Using the example in the previous step, your link would point to /sfc/p/D0000000JsES/a/D000000001dd/aiq8UPJ5q5i6Fs4Sz.IQLKUERsWYdbAm320cjqWnkfk=. SEE ALSO: Constructing Effective Custom URL Buttons and Links Custom Link Example: Link to Documents Custom Link Example: Link to Reports 796 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Custom Link Example: Link to Reports Use custom links to run reports with filtered results from a Salesforce record detail page. For example, EDITIONS let’s say you frequently run a mailing list report for the contacts related to an account. You can create a custom link for accounts that links directly to a report that is automatically filtered to the Available in: Salesforce account you are viewing. In this case, your custom link must pass the account’s unique record ID Classic (not available in all to the report. orgs) 1. Copy the ID for the type of record by which you want to filter your report (in this example, an Custom buttons and links account). To do so, view the record and copy the 15-character ID from the last part of the URL. are available in: All Editions For example, https://MyDomainName.my.salesforce.com/001200030012j3J. Visualforce pages and s-controls are available in: 2. From the Reports tab, create the report you want by either customizing a standard report or Contact Manager, Group, creating a custom report. Professional, Enterprise, 3. Filter the report by the record ID you copied. For example, “Account ID equals 001200030012j3J”. Performance, Unlimited, and Developer Editions 4. Run the report to verify that it contains the data you expect. 5. Click Customize. USER PERMISSIONS 6. Click Save or Save As to save the report to a public folder accessible by the appropriate users. Save doesn’t create a custom report, whereas Save As does. To create or change custom 7. Run the report and copy the report’s URL from the browser. buttons or links: • Customize Application 8. Begin creating your custom link. Set the Content Source field to URL. In the large formula text area, paste the report URL you copied. Remember to omit the domain portion https://MyDomainName.my.salesforce.com. 9. Add the custom link to the appropriate page layouts. 10. Verify that the new custom link works correctly. Tip: When creating a report for use in a custom link, set date ranges and report options generically so that report results include data that can be useful for multiple users. For example, if you set a date range using the “Created Date” of a record, set the Start Date far enough in the past to not exclude any relevant records and leave the End Date blank. If you scope the report to just “My” records, the report might not include all records that a user can see. Try setting the report options to “All visible” records. SEE ALSO: Constructing Effective Custom URL Buttons and Links Custom Link Example: Link to Documents Custom Link Example: Link to Files in Chatter 797 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Create a Custom Button for Performing Mass Deletes This example creates a JavaScript custom button for Salesforce Classic that can be added to USER PERMISSIONS activity-related lists and list views and allows users to delete selected records at the same time. To create or change custom Note: JavaScript custom buttons are supported in all editions, in Salesforce Classic only. The buttons or links: mass delete function described here doesn’t work in editions where the API isn’t enabled. • Customize Application 1. Define a button for events with the following attributes. • Display Type List Button EDITIONS Note: Select Display Checkboxes (for Multi-Record Selection) so users can select Available in: Salesforce multiple records in the list before clicking the button. Classic (not available in all • Behavior Execute JavaScript orgs) • Content Source OnClick JavaScript Custom buttons and links • Use the following sample code. are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions {!REQUIRESCRIPT("/soap/ajax/9.0/connection.js")} var records = {!GETRECORDIDS( $ObjectType.Event )}; var taskRecords = {!GETRECORDIDS( $ObjectType.Task)}; records = records.concat(taskRecords); if (records[0] == null) { alert("Please select at least one record.") } else { var errors = []; var result = sforce.connection.deleteIds(records); if (result && result.length){ var numFailed = 0; var numSucceeded = 0; for (var i = 0; i < result.length; i++){ var res = result[i]; if (res && res.success == 'true'){ numSucceeded++; } else { var es = res.getArray("errors"); if (es.length > 0) { errors.push(es[0].message); } numFailed++; } } 798 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links if (numFailed > 0){ alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n")); } else { alert("Number of records deleted: " + numSucceeded); } } window.location.reload(); } 2. Add the button to your activity list views. 3. Add the button to any page layout that contains an activity-related list. The button deletes any selected task or event in the list. You can install custom buttons from the Mass Delete app at http://sites.force.com/appexchange. SEE ALSO: Custom Button and Link Samples Displaying Alerts This example creates a button that opens a popup dialog with a welcome message containing the USER PERMISSIONS user's first name. 1. Define a button with the following attributes. To create or change custom buttons or links: • Display Type Detail Page Button • Customize Application • Behavior Execute JavaScript • Content Source OnClick JavaScript EDITIONS • Use the following sample code. Available in: Salesforce Classic (not available in all orgs) Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions alert ("Hello {!$User.FirstName}"); 2. Add the button to the appropriate page layout. SEE ALSO: Custom Button and Link Samples 799 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Getting Record IDs This example creates a button that opens a popup window listing record IDs for user selected USER PERMISSIONS records. This is useful when testing to ensure you have the correct record IDs before processing them further. To create or change custom 1. Define a button with the following attributes. buttons or links: • Customize Application • Display Type List Button Note: Select Display Checkboxes (for Multi-Record Selection) so users can select EDITIONS multiple records in the list before clicking the button. Available in: Salesforce • Behavior Execute JavaScript Classic (not available in all • Content Source OnClick JavaScript orgs) • Use the following sample code. Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions idArray = {!GETRECORDIDS($ObjectType.Contact)}; alert("The Ids you have selected are: "+idArray); Note: This example is for contacts. Change the object type for a different type of record. 2. Add the button to the appropriate related list on a page layout or list view layout. SEE ALSO: Custom Button and Link Samples 800 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Passing Record IDs to an External System You can use Salesforce record IDs as unique identifiers for integrating with an external system. This USER PERMISSIONS example creates a button that calls a Visualforce page to determine the record IDs of selected records and passes them in a URL query parameter to an external Web page called To create or change custom “www.yourwebsitehere.com.” buttons or links: • Customize Application 1. Create a Visualforce page that uses the GETRECORDIDS function to retrieve a list of selected records: EDITIONS Available in: Salesforce Classic (not available in all orgs) Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions idArray = {!GETRECORDIDS($ObjectType.Account)}; window.location.href="http://www.yourwebsitehere.com?array="+idArray; Note: Replace www.yourwebsitehere.com with your own URL. 2. Define a button for accounts with the following attributes. • Display Type List Button Note: Select Display Checkboxes (for Multi-Record Selection) so users can select multiple records in the list before clicking the button. • Behavior Display in existing window with sidebar • Content Source Visualforce Page • Select the Visualforce page you created in the first step. 3. Add the button to the appropriate page layout or list view layout. SEE ALSO: Custom Button and Link Samples 801 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Launching Record Create Page with Default Field Values Construct custom buttons and links that pass default field values to a record create page. This feature applies to Lightning Experience in all editions. This feature doesn’t apply to Lightning Out, Experience Builder sites, or the Salesforce mobile app. To construct a custom button or link, encode any field that is read from a record and contains special characters, like commas. Use this sample formula: /lightning/o/Account/new?defaultFieldValues= Name={!URLENCODE(Account.Name)}, OwnerId={!Account.OwnerId}, AccountNumber={!URLENCODE(Account.AccountNumber)}, NumberOfEmployees=35000, CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)} Important: The URLENCODE function works only when creating custom buttons and links. You can’t use it for custom fields. The TEXT function is supported for custom number fields, but it returns only the numbers without any separators, like commas. Note: Passing the RecordTypeId to defaultFieldValues isn’t yet supported. The recordTypeId influences routing behavior, layout assignment, and page assignment, so you can see unexpected results if you try to use it. Reopening Cases This example creates a button that can be added to cases related lists so users can reopen several USER PERMISSIONS cases on an opportunity at once. 1. Define a button for cases with the following attributes. To create or change custom buttons or links: • Display Type List Button • Customize Application Note: Select Display Checkboxes (for Multi-Record Selection) so users can select multiple records in the list before clicking the button. EDITIONS • Behavior Execute JavaScript Available in: Salesforce • Content Source OnClick JavaScript Classic (not available in all • Use the following sample code. orgs) Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions {!REQUIRESCRIPT ("/soap/ajax/13.0/connection.js")} var records = {!GETRECORDIDS($ObjectType.Sample)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one row") } else { for (var n=0; n 802 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links Note: This example references the AJAX Toolkit, which is available if API access is enabled. See https://developer.salesforce.com/page/Integration. 2. Add the button to your opportunity page layouts by editing the Cases related list. Tip: Use this button on any page layout that contains the cases related list, such as account or contact page layouts. Note: Notice the check for records[0] == null, which displays a message to users when they don’t select at least one record in the list. SEE ALSO: Custom Button and Link Samples International Maps This example creates a link that displays a country-specific Google map. USER PERMISSIONS 1. Define a link for accounts with the following attributes. To create or change custom • Display Type Detail Page Link buttons or links: • Behavior Display in new window • Customize Application • Content Source URL • Use the following sample code. EDITIONS Available in: Salesforce Classic (not available in all orgs) Custom buttons and links are available in: All Editions Visualforce pages and s-controls are available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions {! IF(Sample.BillingCountry = "US", "http://maps.google.com/maps?q="&Sample.BillingStreet& "+"&Sample.BillingCity&"+"&Sample.BillingState&"+"&Sample.BillingCountry, (IF(Sample.BillingCountry = "UK", "http://maps.google.co.uk/maps?q="&Sample.BillingStreet &"+"&Sample.BillingCity&"+"&Sample.BillingCountry, "http://maps.google.com"))) } 803 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links 2. Add the link to your account page layout. SEE ALSO: Custom Button and Link Samples Custom Button and Link Considerations Keep these considerations in mind when working with custom buttons and links. EDITIONS Implementation Tips Available in: Salesforce Classic (not available in all • Custom buttons display at the top and bottom of the detail page to the right of all standard orgs) buttons. • Custom buttons aren't distinguished from standard buttons in any graphical way. However, Custom buttons and links you can recognize them by their location on the right of all standard buttons. are available in: All Editions • If the button bar gets too wide on the detail page layout, the browser displays a horizontal Visualforce pages and scroll bar. If the button bar gets too wide on the list view, search result, tagging result, or related s-controls are available in: Contact Manager, Group, list layouts, the buttons wrap. Professional, Enterprise, • Custom buttons are available for activities under the individual setup links for tasks and events. Performance, Unlimited, To add a custom button to an activity list view or search layout, first create a custom list button and Developer Editions in tasks or events. Next, add it to your activity list view or search result layouts. You can override a button that applies to both tasks and events. • Person Account records use the custom buttons and links you have made for accounts. USER PERMISSIONS • If your organization uses the Console tab, list buttons are available in Mass Action. List To create or change custom buttons don’t display in the mini page layouts. Pages that display due to custom buttons and buttons or links: links display in the console without the header or sidebar. • Customize Application • If you get an error message when overriding a button that appears in a list, try calling the s-control using the URLFOR function. • When creating custom buttons, be aware of any validation rules your organization has for records on that object. For example, some custom list buttons that change case status conflict with a case validation rule. In this scenario, Salesforce displays the error message for the validation rule when users click the custom button. • To replace a standard button with a custom button, first define the custom button, then customize the page layout to hide the standard button and display the custom one in its place. • Visualforce pages used as custom links on the home page can’t specify a controller. • Visualforce pages used as custom buttons or links on detail pages must specify a standard controller of the same object. • Visualforce pages used as custom list buttons must use a standard list controller of the same object. • A Web tab or custom link could display a blank page if the embedded site: – Has been set to deny the loading of its content in a frame. – Has been set to allow the loading of its content in a frame only if the same site is delivering the content. – Contains a mix of secure and unsecure content, and the user’s browser has been configured to block mixed active content. To resolve this issue, try these workarounds. – Set your custom link to either open in a new window or display in the existing window without the sidebar or header. – Move the URL from a Web tab into a custom link instead, and set the URL to either open in a new window or display in the existing window without the sidebar or header. 804 Extend Salesforce with Clicks, Not Code Provide Actions, Buttons, and Links – If the site you’re embedding has an HTTP prefix and mixed active content, try changing the prefix to HTTPS. If the embedded site has a valid security certificate and it hasn’t blocked itself from being displayed in frames, using HTTPS as the prefix allows the site to display. Best Practices • Use formula functions in custom buttons with caution. Because functions run on the server before your HTML or JavaScript is passed to the browser, they can only evaluate information that exists at that time. Don't use functions like IF to evaluate conditions that only exist when the code reaches the browser, such as the value of a JavaScript variable that your code returns. • To prevent a user from performing a particular action, such as creating or editing, change the user's permissions rather than hiding the standard button. Hiding a standard button removes it from a page layout, but the link is still available and users can navigate to the new or edit page manually. • Use global variables to access special merge fields for components like custom buttons, links, and s-controls. For example, the $Request global variable allows you to access query parameters inside a snippet, s-control, or custom button. • When you create a custom list button, select Display Checkboxes (for Multi-Record Selection) only if your list button requires users to select individual records in a list. If your list button doesn’t require users to select individual records, don’t select this option. Don’t select Display Checkboxes (for Multi-Record Selection) if your list button links to a URL that doesn’t support POST operations, such as a URL that links to a Lightning component. • In Lightning Experience, when you select Display Checkboxes (for Multi-Record Selection), the related list type must be set to Enhanced List. You can set the related list type for a related list on a record page in the Lightning App Builder. • If you create multiple custom list buttons on a list and select Display Checkboxes (for Multi-Record Selection) for at least one of the list buttons, checkboxes appear next to records in the list. But those checkboxes aren’t activated for custom list buttons without Display Checkboxes (for Multi-Record Selection) selected. Limitations • A custom link's label can't exceed 1,024 characters. • A link URL can be up to 2,048 bytes. When data is substituted for the tokens in the URL, the link can exceed 3,000 bytes. Some browsers enforce limits on the maximum URL length. • Custom buttons that call JavaScript aren’t supported in Lightning Experience. • Custom buttons with a content source of OnClick JavaScript aren’t supported in the Salesforce app. • Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. • On record detail pages for external objects that are associated with high-data-volume external data sources, custom buttons, and links that call JavaScript aren’t supported. • Custom buttons aren’t available for Web-to-Lead, Web-to-Case, the Case Teams related list, or the user object. • Custom buttons on search results pages aren’t supported in Lightning Experience. • When you redirect to an external website with merge fields, use the Text Field data type field. If you use the URL data type field, the link breaks because symbols in the link are converted to hexadecimal code. Considerations for the Salesforce Mobile App • Custom buttons that are added to the Button section of a page layout and that define the content source as URL or Visualforce are supported in the Salesforce mobile app. Remember that Visualforce pages must be enabled for use in the Salesforce mobile app. Custom links, custom buttons that are added to list views, and custom buttons that define the content source as OnClick JavaScript aren’t available in the Salesforce mobile app. 805 Extend Salesforce with Clicks, Not Code External Services • Using URL custom buttons to pass parameters to standard pages in Salesforce Classic—such as prepopulating fields when creating a record—doesn’t work in the Salesforce mobile app. • Custom images used for action icons must be less than 1 MB in size. SEE ALSO: Define Custom Buttons and Links Custom Button and Link Samples Viewing References to Salesforce Components You can view a list of all the areas in Salesforce that reference a component. For example, view the EDITIONS custom links, custom buttons, or page layouts that reference another component, such as a Visualforce page or static resource. To do this, click Where is this used? from the detail page of Available in: Salesforce the component. Salesforce lists the type of component that references the component and the Classic label for that component. Click any item in the list to view it directly. Custom buttons and links are available in: All Editions SEE ALSO: Visualforce pages and Define Custom Buttons and Links custom components available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions USER PERMISSIONS To create or change custom buttons or links: • Customize Application To create, edit, and delete Visualforce pages and custom components: • Customize Application To clone, edit, or delete static resources: • Customize Application External Services Connect your Salesforce org to an external API using zero lines of code. Use declarative tools and OpenAPI specifications to describe the external API functionality, and External Services creates invocable actions within Salesforce. Use the invocable actions to create a flow that interacts with the external API source. What Can I Do with External Services? To illustrate how External Services work, let’s say you want to connect Salesforce to an external credit service that determines if credit is extended to a Salesforce account. You also want to know the payment terms. 806 Extend Salesforce with Clicks, Not Code External Services Current and Legacy Versions The current version of External Services became generally available in Spring ’20 release and has replaced the legacy version. Compared to the legacy version, this version provides significant improvements and adds a broader feature set, including support for larger and more complex schemas, and offers better error messaging and error recovery. External Services Registration To register and use External Services, provide an API spec that describes the services and methods for tools such as Flow Builder or Einstein Bots to consume. The API spec’s schema generates the External Service flow actions with corresponding input and output parameters. Import MuleSoft APIs Import your MuleSoft Anypoint Platform APIs in a few clicks with External Services for MuleSoft. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. Create a Flow with External Services Design and test the automation that sends a user’s information from Salesforce to the external employee banking system. Create the variables for user phone numbers, and combine different phone numbers into one piece of data. Then use the external service action to create the user. Add Actions to an Einstein Bot Integrating your Einstein bot with a registered external service is now as easy as adding an action to a dialog. You can add an external service action to your bot from Einstein’s Bot Builder. Edit, Delete, Save As, and View an External Service Find services that you already registered, view actions for a previously defined service, edit, clone, and delete a service. You can’t edit or delete an external service that is in use by a flow. Recreate an External Service Recreate your external service, and update the related flows. External Services and Packaging You can install or create packages containing an external service. Read these tips before you begin. Testing External Service Actions in Flow Test the example flow MyAtmFlow with a flow external service action MyAtmExternalService by implementing the HttpCalloutMock interface that provides a test response without performing the callout to the external service endpoint. What Can I Do with External Services? To illustrate how External Services work, let’s say you want to connect Salesforce to an external EDITIONS credit service that determines if credit is extended to a Salesforce account. You also want to know the payment terms. Available in: Lightning Example: First, you create a Named Credential by supplying a URL and authentication Experience settings for the credit service. Salesforce uses these items to make callouts to the external Available in: Enterprise, service. With the External Services wizard, you then select whether you will get your API spec Performance, Unlimited, from Mulesoft Anypoint Platform, or from an API spec provided elsewhere. To register an API and Developer Editions spec: 1. Enter a URL (or endpoint) to the location of the hosted OpenAPI specification (”API spec”) for the external service, or provide (paste in) the complete schema from the API spec. For Mulesoft, provide your credentials and select the ASPI spec. 2. Select the operations from the schema you want to make available in Salesforce as invocable actions, and complete the registration. 807 Extend Salesforce with Clicks, Not Code External Services The External Services wizard walks you through it so that you don’t directly touch the API. You can also skip writing Apex code to make the callout. Once you have registered your new external service, use a Salesforce point-and-click automation tool, such as Flow Builder or Einstein Bots. Create a flow using the External Service type for flow actions automatically generated from your External Services registration. When the flow runs, the output contains the credit decision and, if applicable, payment terms. Example: Another use case involves saving time when you add new users to an org. For instance, you want new users to automatically become collaborators for all external org-related applications. Create a flow using inputs such as user ID, which you can define in your API spec’s schema. Then you add triggers in your flow. When a user is created, the triggers engage and add the new user as a collaborator to your other applications. Current and Legacy Versions The current version of External Services became generally available in Spring ’20 release and has EDITIONS replaced the legacy version. Compared to the legacy version, this version provides significant improvements and adds a broader feature set, including support for larger and more complex Available in: Lightning schemas, and offers better error messaging and error recovery. Experience External Services (Current version) Available in: Enterprise, Here are some of the key enhancements and additions for OpenAPI support: Performance, Unlimited, • More complex OpenAPI 2.0 schema. and Developer Editions – Nested parameters - rendered as Dynamic Apex-defined data type in Flow Builder – Header parameters in HTTP request. • Named arrays, anonymous arrays, or inline arrays, supported as collection type in Flow Builder • Access to the latest product enhancements. • Normal packaging support. • Shows up as External Service type for flow actions. • External Services operations show up as External Service action type in Flow builder. Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement. SEE ALSO: Register an External Service Edit, Delete, Save As, and View an External Service External Services Considerations 808 Extend Salesforce with Clicks, Not Code External Services External Services Registration To register and use External Services, provide an API spec that describes the services and methods EDITIONS for tools such as Flow Builder or Einstein Bots to consume. The API spec’s schema generates the External Service flow actions with corresponding input and output parameters. Available in: Lightning When you create your API spec, keep the following in mind. Experience • An API spec can include up to 4,000,000 characters (4.0MB). Available in: Enterprise, • You can use the GET, PATCH, PUT, POST, and DELETE methods in a schema. Performance, Unlimited, and Developer Editions • A property must include a value. • Each parameter must have a name. • Request headers are supported. • Response headers aren’t supported. • Form parameters are supported. • Security settings defined in the API spec are ignored and defer to security settings in the Named Credential. Supported data types: • boolean • date • datetime • double • float • integer • long • string • any type (as Apex Object) • object: top level named and nested anonymous objects • anonymous and top level named lists (can nest both named and anonymous arrays) • additionalProperties as maps • allOf as an object composition Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement. Register an External Service Registering an external service takes only a few steps and no code. External Services Considerations Here are the semantic, service, and usage constraints to keep in mind when integrating your services into External Services. Examples: External Services Schema These API spec examples highlight various scenarios with JSON schemas supported by External Services and can help you avoid common mistakes with syntax and code placement. The API spec examples also cover schema elements like HTTP header as input parameters. 809 Extend Salesforce with Clicks, Not Code External Services MIME Type Mapping in External Service Registrations You can register OpenAPI specifications with non-permitted consumes or produces MIME types directives by mapping the MIME types to permitted MIME types. SEE ALSO: Register an External Service External Services Named Credentials Register an External Service Registering an external service takes only a few steps and no code. EDITIONS Before you begin, ensure that you have the OpenAPI version 2.0 endpoint information for the service that you’re registering. Then set up a named credential. A named credential specifies the URL of a Available in: Lightning callout endpoint (the service you want to access) and its authentication parameters. For example, Experience https://my_endpoint.example.com. Available in: Enterprise, Note: If you use OpenAPI 2.0, your endpoint is relative to the base URL. So if your named Performance, Unlimited, credential URL is https://my_endpoint.example.com and the basePath is and Developer Editions /basepath, they combine as the final endpoint of https://my_endpoint.example.com/basepath. USER PERMISSIONS External Services supports all named credential authoring schemes. To manage connections: Note: OpenAPI 2.0 security schemes are ignored. • Customize Application 1. From Setup in Lightning Experience, enter External Services in the Quick Find box, and select External Services. 2. Click New External Service. 3. On the Select an API Source screen, select whether you are importing an API spec From Mulesoft Anypoint Platform, or From API Specification. 4. Enter a service name and an optional description. 5. Choose a named credential. 6. If your schema includes operations that are not supported, you can filter them out by toggling on Only include supported operations (default). To learn why operations can't be included, disable this toggle. If you aren’t sure, leave this toggle on. 7. Enter a schema URL path (or endpoint), or provide a complete schema. If you enter a schema URL path, it must begin with “/” and be a relative path. For example, /accountSchema.json. If you provide a schema, it must be complete, valid OpenAPI 2.0, and JSON-compliant. 8. Click Save & Next. 9. Select the operations you want to import into your external service registration. Note that you can select up to 625 operations per org, and up to 625 active objects per org. If you exceed either of these limits, divide the operations in your schema across separate registrations. For information about limits, see External Services Considerations on page 811. For information about “objects” in Open API schemas, see https://swagger.io/docs/specification/2-0/basic-structure/ 10. Click Next. 810 Extend Salesforce with Clicks, Not Code External Services 11. Click Done. SEE ALSO: External Services Define a Named Credential Choose an Authentication Protocol External Services Considerations Here are the semantic, service, and usage constraints to keep in mind when integrating your services into External Services. OpenAPI 2.0 Support • The following MIME types are permitted: – application/json — Structured data in JSON format – application/x-www-form-urlencoded -- URL encoded form – text/plain -- Unstructured data as plain text • Non-permitted MIME types can be mapped to permitted MIME types for request and response content serialization. To do this, see MIME Type Mapping in External Service Registrations. • Form data parameters are supported. • Supports all Java runtime supported character set encodings. UTF-8 is the default encoding. • Server and operation level consumes and produces directives. Supported Schema Format • OpenAPI 2.0, JSON schema format • UTF-8, with full character set for names and identifiers Unsupported Schema Formats • Interagent hyper-schema format • OpenAPI 2.0 schema, YAML format • OpenAPI 3.0 Unsupported OpenAPI 2.0 Schema Constructs • The combined schema keywords: oneOf, anyOf, not • Media types such as xml, png, and pdf OpenAPI 2.0 Schema Definitions • A schema can have up to 4,000,000 characters (4.0 MB). • You can use up to 25 External Services registrations per org. • You can have up to 625 active operations per org. The sum of active (selected) and inactive operations can’t exceed 5,000 per org. 811 Extend Salesforce with Clicks, Not Code External Services • You can have up to 625 active, unique, Apex-defined objects per org. Apex-defined objects are derived from the object schemas in the OAS. The sum of active and inactive objects can’t exceed 5,000 per org. • You can have up to 200,000 properties per org. • You can use the GET, PATCH, PUT, POST, and DELETE methods in a schema. • The following MIME types are permitted: – application/json — Structured data in JSON format. – text/plain -- Unstructured data as plain text. – application/x-www-form-urlencoded -- URL encoded form. • The following OpenAPI schema components are ignored: – security requirement objects and security definitions – tag objects – external documentation objects – For allOf, the schema object property discriminator is ignored. The discriminator property determines the schema referenced by its type name. The discriminator property must be set in your flow to the appropriate schema property name. Only properties from the base schema are accessible, not the composition properties from the schema designated by the discriminator schema type value. For more information, see the Swagger 2.0 Specification OpenAPI Specification. • The operation name is derived from the schema's path operationId. If missing, it's derived from the HTTP method and resource path. • Use case consistently for object name definitions, property names, parameter names, and field names in a schema. • The derived Apex class name for an OpenAPI schema input or output parameter object can be a maximum of 255 characters. Ensure that class names are the correct length by choosing a short service name, or edit the schema object name definition to create a shorter name if errors are encountered during registration. The operation or object developer name is derived from the registered API specification. The name must fit within a maximum of 80 characters. If the individual objects or operations in the nested data structure don't themselves exceed 80 characters, then nested data structures can go up to 255 characters. • The derived Apex class name and Apex object property names require valid Apex identifier characters. Ensure that the object name in the schema object definition section matches the naming convention and the object property names. • External Services can handle up to 1,333 characters for any optional description string used to describe operations and parameters in your JSON schema definition. If the description string exceeds this limit, External Services stores only the first 1,333 characters of the description. Truncating the operation or parameter description doesn’t affect the integrity of your schema definition. • consumes/produces directives: – Unsupported consumes/produces directives invalidate the API spec registration. – consumes/produces directives that are incompatible with a request body or response entity schema declaration cause errors during callout. – Missing consumes/produces directives are defaulted to: • application/json—if the request body or the response body schema is either an object or an array • text/plain—if the request or response schema body is a primitive type such as a string or an integer number – If no request body parameter is defined for methods POST, PUT, and PATCH, form data request parameters are sent in the request body as application/x-www-form-urlencoded. – The applicable media type in the produces list or a default (json or text/plain) is set as the HTTP Accept header. • Character set encodings: 812 Extend Salesforce with Clicks, Not Code External Services – The request body is encoded by the character set in the operation’s resolved consumes directive. For example, application/json; charset=ISO-8859-1 encodes the HTTP request in Latin-1 before sending it to the server – The response body is encoded by the character set in the operation’s resolved produces directive. For example, application/x-www-form-urlencoded; charset=SHIFT_JIS decodes the percent URL encoded form with the Shift JIS character set. – The default character set for encoding request bodies is UTF-8 – The default character set for decoding server response entities is defined by the server response’s Content-Type header or UTF-8 if it’s missing. – Reserved HTTP request header characters aren’t escaped and are encoded by the request body’s character set – The supported encoding set is as defined by the Java JDK. For example, for version 11, supported encoding is documented here (replace the “11” in this URL with your Java SE Platform version number): https://docs.oracle.com/en/java/javase/11/intl/supported-encodings.html - and it’s recommended to use the standard character set encoding name as described by the IANA Charset Registry. • Considerations for properties and additionalProperties – In OpenAPI 2.0, the named properties are accessible as Apex properties with matching property type. additionalProperties allow for free form map or dictionary properties with a common property value type that are accessible in Apex as a Map property. – properties and additionalProperties under an OpenAPI 2 schema directive show as formal object properties and as a dictionary property. If declared under a property or additionalProperties type, then the OpenAPI 2 parser ignores one or the other. The registration process doesn't throw an error – OpenAPI 2.0 named properties are properties in Apex with the same name and property type. – OpenAPI 2.0 additionalProperties are grouped in the Apex property with name properties and type Map External Service support for Apex reserved keywords Although not a best practice, External Services doesn’t prohibit schema entities with the same name as the Apex reserved keywords. If your schema name conflicts with an Apex reserved keyword, External Services creates a unique name by encoding it to be compatible with Apex identifier rules. 813 Extend Salesforce with Clicks, Not Code External Services For example, you have an account object with property name type. Because the property name type conflicts with the Apex reserved keyword type, External Services encodes the property name type as z0type to make it Apex compliant. During callout, the property name type is used according to the original OpenAPI schema. Special characters that aren’t valid Apex identifiers are UTF-8 encoded. For example, 5getOpen-bankingV2.2Atms is encoded as x35getOpenx2dbankingV2x2e2Atms for a valid Apex identifier. Flow • You can’t edit an external service used in a flow. • External service callouts aren’t allowed when there are pending, uncommitted transactions. Close your transaction, and resume Flow using the flow element Pause. Array definition in OpenAPI 2.0 External Services supports inline array definitions and referenceable named arrays. List types in External Services are identified by their object element type. Supported Inline Array Definition with Reference to Array Items Definition { "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "type": "array", "items": { "$ref": "#definitions/MyObject" } } ... "definitions": { "MyObject": { "type": "object", "properties": {...} } } } In Flow Builder, declare a variable for the myObjects parameter by marking the variable as a collection and picking its Apex element type ExternalService__RegistrationName_MyObject. Inline Array Definition with Inline Array Items Definition { "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "type": "array", "items": { "type": "object", "properties": {...} } } 814 Extend Salesforce with Clicks, Not Code External Services ... "definitions": { ... } } In Flow Builder, declare a collection variable for the myObjects parameter and Apex element type ExternalService__RegistrationName_OperationName_IN_myObjects. Referenceable Array Definition with Reference to Array Item Definitions { "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "$ref": "#definitions/MyObjectList" } ... "definitions": { "MyObjectList": { "type": "array", "items": { "$ref": "#definitions/MyObject" } } "MyObject": { "type": "object", "properties": {...} } } } In Flow Builder, declare a collection variable for the myObjects parameter and Apex element type ExternalService__RegistrationName_MyObject. Referenceable Array Definition with Inline Array Items Definition { "swagger": "2.0", ... "name": "myObjects", "in": "body", "schema": { "$ref": "#definitions/MyObjectList" } ... "definitions": { "MyObjectList": { "type": "array", "items": { "type": "object", "properties": {...} } } 815 Extend Salesforce with Clicks, Not Code External Services } } In Flow Builder, declare a collection variable for the myObjects parameter and Apex element type ExternalService__RegistrationName_MyObjectList. Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement. Examples: External Services Schema These API spec examples highlight various scenarios with JSON schemas supported by External EDITIONS Services and can help you avoid common mistakes with syntax and code placement. The API spec examples also cover schema elements like HTTP header as input parameters. Available in: Lightning External Services API Spec Example 1 Experience Here’s an example of a an API spec that contains a supported JSON schema for OpenAPI 2.0. The Available in: Enterprise, parameters (in bold) contain the definition for the accountId input. The responses (also in bold) Performance, Unlimited, contain the definition for the output, which is creditRating. Parameters and responses and Developer Editions translate to inputs and outputs, respectively, for your flow actions. { "swagger":"2.0", "info":{ "description":"A service for checking credit for an account.", "version":"1.0.0", "title":"Credit Decision", "termsOfService":"http://swagger.io/terms/", "contact":{ "email":"[email protected]" }, "license":{ "name":"Apache 2.0", "url":"http://www.apache.org/licenses/LICENSE-2.0.html" } }, "host":" "description":"", "consumes":[ "application/json", "application/xml" ], "produces":[ "application/xml", "application/json" ], "parameters":[{ "in":"body", 816 Extend Salesforce with Clicks, Not Code External Services "name":"body", "description":"Specifies input parameters to calculate payment term", "required":true, "schema":{ "$ref":"#/definitions/accountId" } }], "responses":{ "200":{ "description":"success", "schema":{ "$ref":"#/definitions/creditRating" } }, "405":{ "description":"Invalid input" } } } } }, "definitions":{ "accountId":{ "type":"object", "properties":{ "accountIdString":{ "type":"string" } }, "xml":{ "name":"accountId" } }, "creditRating":{ "type":"object", "properties":{ "creditRatingString":{ "type":"string" } }, "xml":{ "name":"creditRating" } } } } External Services API Spec Example 2 Basic Setup • For the named credential that your org uses to access the banking system, assign the Bank label and the https://api.example.com URL. The named credential URL corresponds to the declared host of the JSON schema and one of its schemes or URL protocols. The URL can point to a different endpoint as long as it hosts the same external service. The base path is added to the named credential URL on callout. 817 Extend Salesforce with Clicks, Not Code External Services • Register the employee banking system’s external service. Use the Bank name and the Bank named credential, and then copy one of the following schemas provided. • The banking system's external service shows two ways to define parameters with object types: a named object type under a “definitions” block or an anonymously declared object type inline. Note: The defined or derived parameter object type name, or a property with an object type, must be fewer than 255 characters to be used in Flow Builder. Here’s a schema with the named object type defined under the “definitions” block. The phone object type's name is ExternalService__Bank_Phone in Flow Builder. { "swagger": "2.0", "info": { "title": "bankService", "description": "API description in Markdown.", "version": "1.0.0" }, "host": "api.example.com", "basePath": "/v1", "schemes": [ "https" ], "definitions": { "User": { "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones":{ "type":"array", "items":{ "type": "object", "$ref": "#/definitions/Phone" } } } }, "Phone":{ "properties":{ "typeofphone":{ "type":"string" }, "phone":{ "type":"string" } } } }, "paths": { "/users/{userId}": { 818 Extend Salesforce with Clicks, Not Code External Services "get": { "summary": "Returns a user by ID.", "parameters": [{ "in": "path", "name": "userId", "required": true, "type": "integer" }], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/User" } } } } }, "/users": { "post": { "summary": "Creates a new user.", "parameters": [{ "in": "body", "name": "user", "schema": { "$ref": "#/definitions/User" } }], "responses": { "200": { "description": "OK" } } } } } } External Services API Spec Example 3 Here’s an API spec with a JSON schema with anonymous object types defined inline. The derived phone object type's name is ExternalService__Bank_getUsers_OUT_200_phones. Note: For anonymous object types, Salesforce automatically derives object type names based on the external service, parent operation, operation parameter, parent object, and object property names. The derived name must be fewer than 255 characters. Object types with names longer than 40 characters and object types that reference through their properties’ object types with names longer than 40 characters can't be used in Flow Builder. { "swagger": "2.0", "info": { "title": "bankService", "description": "API description in Markdown.", "version": "1.0.0" }, 819 Extend Salesforce with Clicks, Not Code External Services "host": "api.example.com", "basePath": "/v1", "schemes": [ "https" ], "paths": { "/users/{userId}": { "get": { "summary": "Returns a user by ID.", "parameters": [{ "in": "path", "name": "userId", "required": true, "type": "integer" }], "responses": { "200": { "description": "OK", "schema": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones": { "type":"array", "items": { "type": "object", "properties": { "typeofphone": { "type":"string" }, "phone": { "type":"string" } } } } } } } } } }, "/users": { "post": { "summary": "Creates a new user.", "parameters": [{ "in": "body", "name": "user", "schema": { 820 Extend Salesforce with Clicks, Not Code External Services "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones": { "type":"array", "items": { "type": "object", "properties": { "typeofphone": { "type":"string" }, "phone": { "type":"string" } } } } } } }], "responses": { "200": { "description": "OK" } } } } } } External Services API Spec Example 4 Here's an API spec registered with external service name BankingAutomaticTellerMachine. However, the derived object names: • ExternalService__BankingAutomaticTellerMachine_VeryImportantCustomer_phone • ExternalService__BankingAutomaticTellerMachine_getBalanceAccountTypeChecking_OUT_200 Must be no longer than 255 characters. To use Flow Builder, you must shorten the external service schema name and the schema (shown in Example 5). Tip: If the derived object name is longer than 255 characters, try one of the following methods to resolve the issue. • Shorten the external service name. • If the object is declared inline under an operation parameter, shorten the operation name by adding an operationId to the schema. • If the object is declared inline under a parent object property, shorten the parent object name in the schema. • Declare the nested object as a top-level object under schema “definitions”. { "swagger": "2.0", 821 Extend Salesforce with Clicks, Not Code External Services ... "paths": { "/balance/account/{accountId}/type/checking": { "get": { "parameters": [{ "in": "path", "name": "accountId", "required": true, "type": "integer" }], "responses": { "200": { "schema": { "type": "object", "properties": { "balance": { "type": "integer" }, "owner": { "$ref": "#/definitions/VeryImportantCustomer" } } } } } } } }, "definitions": { "VeryImportantCustomer": { "type": "object", "properties": { "name": { "type": "string" }, "phone": { "type": "object", "properties": { "number": { "type": "string" } } } } } } } External Services API Spec Example 5 Here's an example of an API spec with a schema that results in shortened names. It's registered with the shortened name BankAtm. Shorten the external service schema name to BankAtm, the schema object name to VIP and add operationId as getBalance: • ExternalService__BankAtm_VIP_phone 822 Extend Salesforce with Clicks, Not Code External Services • ExternalService__BankAtm_getBalance_200 { "swagger": "2.0", ... "paths": { "/balance/account/{accountId}/type/checking": { "get": { "operationId": "getBalance", "parameters": [{ "in": "path", "name": "accountId", "required": true, "type": "integer" }], "responses": { "200": { "schema": { "type": "object", "properties": { "balance": { "type": "integer" }, "owner": { "$ref": "#/definitions/VIP" } } } } } } } }, "definitions": { "VIP": { "type": "object", "properties": { "name": { "type": "string" }, "phone": { "type": "object", "properties": { "number": { "type": "string" } } } } } } } External Services API Spec Example 6 823 Extend Salesforce with Clicks, Not Code External Services Here's an example with an inline array definition. { "swagger": "2.0", "host": "Employees.org", "basePath": "/", ... "paths": { "/employees/{employeeId}": { "get": { "operationId": "getEmployee", "parameters": [{ "in": "path", "name": "employeeId", "required": true, "type": "string" }], "responses": { "200": { "schema": { "type": "object", "properties": { "employee": {"$ref": "#/definitions/Employee"}, "manager": {"$ref": "#/definitions/Employee"}, "team": { "type": "array", "items": {"$ref": "#/definitions/Employee"} } } } } } } } }, "definitions": { "Employee" : { "type": "object", "properties": { "employeeId": {"type": "string"}, "firstName": {"type": "string"}, "middleName": {"type": "string"}, "lastName": {"type": "string"}, "dateOfHire": {"type": "date"} } } } } External Services API Spec Example 7 Here’s how a header parameter is declared in an OpenAPI schema. In Flow, the name “apiKey” shows up as a string parameter. Now when you set any string value in a flow to apiKey, it functions as an HTTP parameter when making a callout request. { "swagger": "2.0", 824 Extend Salesforce with Clicks, Not Code External Services "info": { "description": "A service for checking credit for an account.", "version": "1.0.0", "title": "Credit Decision", "termsOfService": "http://swagger.io/terms/", "contact": { "email": "[email protected]" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, "host": " 825 Extend Salesforce with Clicks, Not Code External Services }, "definitions": { "accountId": { "type": "object", "properties": { "accountIdString": { "type": "string" } }, "xml": { "name": "accountId" } }, "creditRating": { "type": "object", "properties": { "creditRatingString": { "type": "string" } }, "xml": { "name": "creditRating" } } } } External Services API Spec Example 8 Request and response form data is declared alongside the matching consumes and produces directives. { "swagger": "2.0", "info": { "description": "Apply here for your next mortgage", "version": "1.0.0", "title": "My Mortgage Buddy", "contact": { "email": "[email protected]" }, }, "host": "MyMortgageBuddy.org", "basePath": "/mortgages", "paths": { "/apply": { "post": { "operationId": "applyMortgage", "consumes": [ "application/x-www-form-urlencoded; charset=utf-8" ], "produces": [ "application/x-www-form-urlencoded; charset=utf-8" ], "parameters": [{ "description": "Desired mortgage terms", 826 Extend Salesforce with Clicks, Not Code External Services "name": "terms", "in": "formData", "type": "array", "items": { "type": "integer" }, "collectionFormat": "multi", "required": true },{ "description": "Full Name", "name": "fullName", "in": "formData", "type": "string", "required": true },{ "description": "Loan amount", "name": "loanAmount", "in": "formData", "type": "number", "required": true }], "responses": { "200": { "description": "200", "schema": { "type": "object", "properties": { "formApplicationId": { "type": "string" }, "loanOfficerFullName": { "type": "string" } } } } } } } } External Services API Spec Example 9 This JSON schema definition highlights the constructs allOf for schema object composition and additionalProperties for dictionary values. The sample schema is registered as external service MyBank with named credential MyBank. The registration is invoked by a sample flow that accesses the dictionary properties with an Apex invocable action. A flow Apex unit test ties it all together. The schema defines a banking service that gets customer details for a customer ID. • The Customer schema object has dictionary properties of type schema object CreditRating. In Apex, the class ExternalService.MyBank_Customer has property properties of type Map 827 Extend Salesforce with Clicks, Not Code External Services • Phones and Emails compose their own properties together with the common allOf properties from the schema object Contact. { "swagger": "2.0", "info": { "title": "myBank", "description": "Sample Banking Service with allOf and additionalProperties schema constructs", "version": "1.0.0" }, "host": "api.mybank.com", "basePath": "/v1", "schemes": [ "https" ], "definitions": { "Customer": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "phones": { "type":"array", "items": { "$ref": "#/definitions/Phone" } }, "emails": { "type": "array", "items": { "$ref": "#/definitions/Email" } } }, "additionalProperties": { "$ref": "#/definitions/CreditRating" }, "required": [ "id", "name" ] }, "Contact": { "type": "object", "properties": { "primary": { "type": "boolean" 828 Extend Salesforce with Clicks, Not Code External Services }, "timeOfDay": { "type": "string" } }, "required": [ "primary" ] }, "Phone": { "allOf": [ { "$ref": "#/definitions/Contact" }, { "type": "object", "properties": { "typeOfPhone": { "type":"string" }, "phoneNumber":{ "type":"string" } } } ] }, "Email": { "allOf": [ { "$ref": "#/definitions/Contact" }, { "type": "object", "properties": { "email": { "type":"string" } } } ] }, "CreditRating": { "type": "object", "properties": { "rating": { "type": "string" }, "score": { "type": "number", "format": "double" } } 829 Extend Salesforce with Clicks, Not Code External Services } }, "paths": { "/customers/{customerId}": { "get": { "summary": "Get the customer by ID.", "parameters": [{ "in": "path", "name": "customerId", "required": true, "type": "integer" }], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/Customer" } } } } } } } Here is the Apex invokable action that gets the customer credit ratings as a list demonstrating how to work with map data types from flow: public class MyBankGetCreditRatings { @InvocableMethod( label='Get Credit Ratings' description='A list of credit ratings for a customer' category='MyBank' ) public static List List Map 830 Extend Salesforce with Clicks, Not Code External Services outCreditRatingsList.add(outCreditRatings); } return outCreditRatingsList; } public class Customer { @InvocableVariable( label='Customer' description='Banking customer' required=true ) public ExternalService.MyBank_Customer customer; } public class CustomerCreditRatings { @InvocableVariable( label='Customer ID' description='Bank customer ID' required=true ) public Integer customerId; @InvocableVariable( label='Credit Ratings' description='Credit ratings for a customer' required=true ) public List The flow starts by calling the external MyBank service action getCustomerById to get the customer details given a customer ID. The Apex invokable flow action getCreditRatings gets the list of credit ratings from the customer details. Phone and email contact details are formatted as a list of customer contacts by looping through the phones and emails properties and assigning the formatted value to the contacts list. 831 Extend Salesforce with Clicks, Not Code External Services The HTTP callout mock asserts an expected request and responds with a sample customer as application/json: public class MyBankGetCustomerCalloutMock implements HttpCalloutMock { public HTTPResponse respond(HTTPRequest request) { // Assert expected request test data: customer ID in the request path System.assertEquals('GET', request.getMethod()); System.assertEquals('callout:MyBank/v1/customers/42', request.getEndpoint()); // Send response test data: customer details with sample ratings // as additional properties and sample contacts HttpResponse response = new HttpResponse(); response.setHeader('Content-Type', 'application/json'); response.setBody('{' + '"id": 42, "name": "Foo Bar", "phones": [' + ' {"primary": true, "timeOfDay": "Daytime", ' + ' "typeOfPhone": "Mobile", "phoneNumber": "555-5555"},' + ' {"primary": false, "timeOfDay": "Evening", ' + ' "typeOfPhone": "Landline", "phoneNumber": "222-5555"}' + '], "emails": [' + ' {"primary": true, "timeOfDay": "AllDay", "email": "[email protected]"}' + '],' + '"rating1": {"rating": "Rating 1", "score": 0.95}, ' + '"rating2": {"rating": "Rating 2", "score": 0.78}' + '}'); response.setStatusCode(200); return response; } } Tip: You can also use JSON to serialize a sample response matching the external service response type if the HTTP response mime type is application/json and the JSON properties are compliant with Apex identifier characters: ExternalService.MyBank_Customer customer = new ExternalService.MyBank_Customer(); customer.id = 42; ... customer.properties = new Map The Apex unit test sets up the HTTP callout mock and asserts the expected credit ratings and customer contacts: @IsTest public class MyBankFlowTest { @IsTest static public void testGetCustomer() { // Set HTTP callout mock to match flow's external service action invocation Test.setMock(HttpCalloutMock.class, new MyBankGetCustomerCalloutMock()); // Set flow input variables and create the flow interview Map 832 Extend Salesforce with Clicks, Not Code External Services Flow.Interview myBankFlow = Flow.Interview.createInterview('MyBank', inputVariables); // Start flow interview with set input variables myBankFlow.start(); // Assert customer's expected credit ratings List // Assert customer's contacts: List For another example of a flow Apex unit test, see Testing External Service Actions in Flow on page 850. MIME Type Mapping in External Service Registrations You can register OpenAPI specifications with non-permitted consumes or produces MIME types directives by mapping the MIME types to permitted MIME types. OpenAPI consumes MIME types: • The Content-Type header is the specified consumes MIME type. • The request body is serialized with the mapped permitted media type. OpenAPI produces MIME types: • The request Accept header is the specified produces MIME type. • The response Content-Type header, if present, is mapped to the permitted MIME type to deserialize the response body. Non-permitted MIME types must be mapped to permitted MIME types as mappings in the field serviceBinding of the ExternalServiceRegistration metadata file. MIME Type Mapping Example Acme bank specifies an OpenAPI 2.0 service for their credit rating service. It defines its own MIME type for handling the JSON compatible payload: application/x-acme-json: { "swagger":"2.0", "info":{ 833 Extend Salesforce with Clicks, Not Code External Services "description":"A service for checking credit for an account.", "version":"1.0.0", "title":"Credit Decision" }, "host":" 834 Extend Salesforce with Clicks, Not Code External Services } } } } To map the BankService MIME type to the permitted MIME type application/json, open a command-line terminal. Create a directory in which to retrieve the external service’s metadata. > mkdir BankService > cd BankService Create the manifest package.xml for the external service metadata for your BankService to retrieve from your organization: > touch package.xml Edit the package.xml: Retrieve the metadata for the external service with the Salesforce CLI command after successful authentication to your organization: > sfdx force:mdapi:retrieve -r . -k package.xml Unzip the package zip with the metadata and navigate to the directory with the external service: > unzip unpackaged.zip > cd unpackaged/externalServiceRegistrations Edit service bindings in the external service registration metadata file BankService.externalServiceRegistration: Note that the 835 Extend Salesforce with Clicks, Not Code External Services The service binding specifies in JSON format the non-permitted MIME types defined by this external service registration: {"compatibleMediaTypes":{ "application/x-acme-json":"application/x-acme-json" }} Map the non-permitted MIME type to the permitted MIME type for the external service payload serialization: {"compatibleMediaTypes":{ "application/x-acme-json":"application/json" }} The updated metadata for the bank rating external service sample registration respects the MIME type mapping to the permitted MIME type when deployed in a package: Note that the > cd ../.. > sfdx force:mdapi:deploy -d unpackaged For more information see Salesforce DX Developer Guide. Import MuleSoft APIs Import your MuleSoft Anypoint Platform APIs in a few clicks with External Services for MuleSoft. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. Configure a Connected App and Named Credentials To use External Services for MuleSoft, complete these setup steps. Register a MuleSoft-Hosted External Service Registering an external service for MuleSoft Anypoint Platform takes only a few steps and no code. 836 Extend Salesforce with Clicks, Not Code External Services Configure a Connected App and Named Credentials To use External Services for MuleSoft, complete these setup steps. Create a Connected App in MuleSoft Anypoint Platform Set up a connected app in MuleSoft Anypoint Platform that allows Salesforce to call MuleSoft APIs. Create an Authentication Provider Use the ID and the secret from your MuleSoft Anypoint Platform connected app to create an authentication provider. Update Your MuleSoft Anypoint Platform Connected App Use the Salesforce authentication provider callback URL to update your MuleSoft Anypoint Platform connected app. Create a Named Credential Create a named credential to access your MuleSoft Anypoint Platform connected app from Salesforce. Create a Connected App in MuleSoft Anypoint Platform Set up a connected app in MuleSoft Anypoint Platform that allows Salesforce to call MuleSoft APIs. To use the External Services for MuleSoft wizard, you need a valid MuleSoft license or demo account. The MuleSoft user account must have full permissions for the API Manager and Exchange in your MuleSoft Anypoint Platform org. Complete these steps in MuleSoft Anypoint Platform. 1. Log in to MuleSoft Anypoint Platform. 2. Under Management Center, click Access Management. 3. In the Access Management menu, select Connected Apps. 4. Click Create app. 5. Enter a name for your app. 6. Ensure that App acts on behalf of a user is selected for Type. 7. Under Grant types, select Authorization Code, and then select Refresh Token. 8. In Website URL, enter https://www.salesforce.com. 9. In Redirect URIs, enter https://www.salesforce.com, and click Add. Note: This redirect URI is a temporary value that is updated after you create an authentication provider in your Salesforce org. 10. For Who can use this application? select Members of this organization only. 11. Under Scopes, click Add Scopes. 12. In Add scopes, enable Background Access and Read-Only Access, and click Add scopes. 13. Save your changes. 14. On the Connected Apps page, click Copy Id, and paste the id into a text file. 15. Click Copy Secret, and paste it into the same text file. Create an authentication provider. 837 Extend Salesforce with Clicks, Not Code External Services Create an Authentication Provider Use the ID and the secret from your MuleSoft Anypoint Platform connected app to create an EDITIONS authentication provider. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. Available in: Lightning Experience This setup requires the ID and secret that can be copied when you created your connected app in MuleSoft Anypoint Platform. Available in: Enterprise, Complete these steps. Performance, Unlimited, and Developer Editions 1. From Setup, in the Quick Find box, enter Auth. Providers, and then select Auth. Providers. 2. Click New. 3. For Provider Type, select Open ID Connect. 4. Specify a name like MuleSoft Anypoint Platform. 5. For Consumer Key, enter the ID that you copied when you created your connected app in MuleSoft Anypoint Platform. 6. For Consumer Secret, enter the secret that you copied when you created your connected app in MuleSoft Anypoint Platform. 7. For Authorize Endpoint URL, enter https://anypoint.mulesoft.com/accounts/api/v2/oauth2/authorize. 8. For Token Endpoint URL, enter https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token. 9. Save your changes. 10. On the Auth. Provider Detail page, under Salesforce Configuration, copy the Callback URL. Update the connected app in MuleSoft Anypoint Platform. Update Your MuleSoft Anypoint Platform Connected App Use the Salesforce authentication provider callback URL to update your MuleSoft Anypoint Platform connected app. To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. This setup requires the callback URL that can be copied when you created your authentication provider in Salesforce. Complete these steps in MuleSoft Anypoint Platform. 1. In Access Management, on the Connected Apps page, click the name of the connected app you created in MuleSoft Anypoint Platform. 2. On the Update App page, in Redirect URIs, enter the callback URL that you copied when you created an authentication provider in Salesforce, and click Add. 3. Delete the Redirect URI for https://www.salesforce.com. 4. Save your changes. Create a named credential. 838 Extend Salesforce with Clicks, Not Code External Services Create a Named Credential Create a named credential to access your MuleSoft Anypoint Platform connected app from Salesforce. EDITIONS To use the External Services for MuleSoft wizard, you need a valid MuleSoft license or demo account. 1. From Setup, in the Quick Find box, enter Named Credentials, and then select Named Available in: Lightning Experience Credentials. 2. Click New Named Credential. Available in: Enterprise, Performance, Unlimited, 3. Enter a label for your named credential. The label can contain no spaces or special characters. and Developer Editions 4. (Optional) Enter a name for your named credentials, or use the name that the system generated based on the label you entered. 5. For URL, enter https://anypoint.mulesoft.com. 6. Select an Identity Type. a. To require that each Salesforce user log into MuleSoft Anypoint Platform from within their personal settings to get a token for their own use, select Per User. b. To allow one named credential to be shared by all users in your org, select Named Principal. 7. For Authentication Protocol, select OAuth 2.0. 8. Select an Authentications Provider. For Authentication Provider, click the magnifying glass and select the name of the auth provider that you created. 9. For Scope, enter read:full offline_access. 10. Ensure that Start Authentication Flow on Save is enabled. 11. Save your changes. Note: If you receive the “No_Oauth_State: State was not sent back” error when saving the named credential, ensure that the selected scopes for your MuleSoft Anypoint Platform connected app are Read-Only Access and Background Access. You can also receive the error if the read:full offline_access scope you specified has a period at the end of it. 12. (Optional) If you’re not already logged into MuleSoft Anypoint platform, log in now. 13. Grant read-only access and background access to your Salesforce user. 14. On the Named Credential Setup page, Authentication Status is now set to Authenticated. Import MuleSoft Anypoint Platform APIs. Register a MuleSoft-Hosted External Service Registering an external service for MuleSoft Anypoint Platform takes only a few steps and no code. EDITIONS To use External Services for MuleSoft, you need a valid MuleSoft license or demo account. 1. From Setup, in the Quick Find box, enter External Services, and then select External Available in: Lightning Experience Services. 2. Select New External Service, and click Next. Available in: Enterprise, Performance, Unlimited, 3. In the Select an API Source window, select From MuleSoft Anypoint Platform, and click and Developer Editions Next. Note: If you’re in an operationally isolated environment (OIE), the MuleSoft Anypoint Platform tile can’t be selected. 839 Extend Salesforce with Clicks, Not Code External Services 4. In the Select a MuleSoft Anypoint Platform Account window, select the named credential with the most access to MuleSoft. Important: External Services for MuleSoft use this credential to log in to MuleSoft Anypoint Platform and list MuleSoft APIs available for import. In a later step, you can specify a different named credential with more targeted access to MuleSoft to run the external service in the next step. 5. In the Configure Your MuleSoft Anypoint Platform Service window, set up the details for your external service. a. Select a MuleSoft API. b. Enter a name for your external service. The name must start with a letter, can’t contain spaces or special characters, and be no longer than 80 characters. c. (Optional) Enter a description of your external service. If you don’t enter a description, the system-generated description is used. d. Select a named credential to use to run the external service. e. Ensure that Only include supported operations is enabled. Important: External Services for MuleSoft use this credential to run a MuleSoft API operation when the external service is called from a flow. You can select a named credential with more targeted access than the one you chose in the previous step. f. Click Save & Next. Note: Clicking Save & Next creates an external service record in Salesforce. After this step, you can’t change the MuleSoft API name or version associated with the external service. You can only change the external service name, description, named credential, and included MuleSoft API operations. 6. In the Select Operations window, select up to 625 operations to include in your external service. Note: For limits, including the maximum number of operations allowed in your org, see External Services Considerations. 7. Click Next. 8. Review your changes, and click Done. Use your external service in a flow. Create a Flow with External Services Design and test the automation that sends a user’s information from Salesforce to the external employee banking system. Create the variables for user phone numbers, and combine different phone numbers into one piece of data. Then use the external service action to create the user. 1. Define a named credential For the named credential that your org uses to access the banking system, assign the Bank label and the https://api.example.com URL. The named credential URL corresponds to the declared host of the API spec and one of its transfer protocol schemes or URL protocols. The URL can point to a different endpoint as long as it hosts the same external service. The base path is added to the named credential URL on callout. 2. Register the employee banking system’s external service, using the steps described in Register an External Service on page 810 as a guide. Use the BankService name and the Bank named credential, and then copy the schema from one of the API spec examples. 3. Create a flow. 840 Extend Salesforce with Clicks, Not Code External Services This example uses static values for simplicity. In contrast, a production flow with user data includes elements to get user records, store values to variables, and communicate these values to the external service. 4. To handle the multiple phone numbers nested below the BankService_Phone value, add the two variable resources. a. Click Manager, and then click New Resource. b. For the resource type, select Variable. c. For the API name, enter WorkPhone. d. For the data type, select Apex-Defined. e. For the Apex class, select ExternalService__BankService_Phone. f. Click Done. g. Repeat these steps using the API name CellPhone. 5. Add the variable resource that acts as the array for the phone number values. a. Click New Resource. b. For the resource type, select Variable. c. For the API name, enter Phones. d. For the data type, select Apex-Defined, and select the Allow multiple values (collection) option. e. For the Apex class, select ExternalService__BankService_Phone. 841 Extend Salesforce with Clicks, Not Code External Services f. Click Done. 6. Add the variable resource that stores the user’s name. a. Click New Resource. b. For the resource type, select Variable. c. For the API name, enter User. d. For the data type, select Apex-Defined. e. For the Apex class, select ExternalService__BankService_User. f. Click Done. 7. Assign values to the work phone variable. a. From the Toolbox, click Elements. b. Drag an Assignment element to the canvas. c. For Label, enter Assign Work Phone, and let the API name autopopulate. d. Click Search variables, select WorkPhone, then select phone. The variable {!WorkPhone.phone} appears. e. For Value, enter 1234567890. f. Click Add Assignment. 842 Extend Salesforce with Clicks, Not Code External Services g. Click Search variables, select WorkPhone, then select typeofphone. The variable {!WorkPhone.typeofphone} appears. h. For Value, enter Work. i. Click Done. j. Connect the Start element to this assignment element. 8. Assign values to the cell phone variable. a. Drag an Assignment element to the canvas. b. For Label, enter Assign Cell Phone, and let the API name autopopulate. c. Click Search variables, select CellPhone, then select phone. The variable {!CellPhone.phone} appears. d. For Value, enter 0987654321 e. Click Add Assignment. f. Click Search variables, select CellPhone, then select typeofphone. The variable {!CellPhone.typeofphone} appears. g. For Value enter Cell. h. Click Done. i. Connect the last element to this one. 843 Extend Salesforce with Clicks, Not Code External Services 9. Assign multiple phone values to the single phone array variable. a. Drag an Assignment element to the canvas. b. For Label, enter Assign Phones, and let the API name autopopulate. c. Click Search variables then select Phones. The variable {!Phones} appears. d. Change the Operator to Add. e. For Value, select Workphone. f. Click Add Assignment. g. Click Search variables then select Phones again. h. Change the Operator to Add. i. For Value select Cellphone. j. Click Done. k. Connect the last element to this one. 10. Assign the user values. a. Drag an Assignment element to the canvas. 844 Extend Salesforce with Clicks, Not Code External Services b. For Label, enter Assign User, and let the API name autopopulate. c. Click Search variables, select User, then id. The variable {!User.id} appears. d. For Value, enter 1234. e. Click Add Assignment. f. Click Search variables, select User, then name. The variable {!User.name} appears. g. For Value, enter Maria. h. Click Add Assignment. i. Click Search variables, select User, then phones. The variable {!User.phones} appears. j. For Value, select Phones. k. Click Done. l. Connect the last element to this one. 11. To create users on the external bank system, add the action generated by your external service schema. 845 Extend Salesforce with Clicks, Not Code External Services a. Drag an Action element to the canvas. b. Filter the actions by type, and select External Service. c. Select postUser. d. For Label, enter Create a new user, and let the API name autopopulate. e. Next to >_user, click the toggle to include input values. f. From the lookup, select User. g. Click Done. h. Connect the last element to this one. Your canvas includes these elements. 12. Save and debug the flow. A successful debug includes the assignment and External Service callout. 846 Extend Salesforce with Clicks, Not Code External Services SEE ALSO: External Services Build a Flow Add Actions to an Einstein Bot Integrating your Einstein bot with a registered external service is now as easy as adding an action to a dialog. You can add an external service action to your bot from Einstein’s Bot Builder. Sometimes the data that your Einstein bot needs to personalize customer requests is stored outside of Salesforce. For example, a banking customer wants to update their account password and billing address in a single bot conversation. Or a retail customer starts a return process for a purchase and expects the bot to return a unique tracking number. Now you can automate these multi-platform requests directly from the Bot Builder, without writing a single line of code. SEE ALSO: Add an External Service Action 847 Extend Salesforce with Clicks, Not Code External Services Edit, Delete, Save As, and View an External Service Find services that you already registered, view actions for a previously defined service, edit, clone, EDITIONS and delete a service. You can’t edit or delete an external service that is in use by a flow. Available in: Lightning Locate Registered External Services Experience To find your registered services, go to Setup, in the Quick Find box enter External Services, Available in: Enterprise, and then select External Services. Performance, Unlimited, and Developer Editions 1. Actions that you can select for your external service registration: View Actions, Edit, Save As, and Delete. 2. Service recreated with Save As and has the provided prefix of CopyOf in front of the name. Remember to change the name to something more descriptive of the service. View Actions To view actions available for a service that you defined with your schema, click the arrow in the service’s Actions column, and select View Actions. Edit To edit an external service, click the arrow in the service’s Actions column, and select Edit. You can modify these service settings: • Named Credential • Description • Service Schema (URL or JSON) • Operations Save As Save As allows you to recreate your external service registration. Use this action to clone an existing service without changing anything except the name of the new service. 1. To save settings to a new external service, click the arrow in the service’s Actions column, and select Save As. 2. On the Save External Service As page, enter a unique External Service Name Note: By default, External Services automatically adds the prefix CopyOf in front of the existing external service name. Modify the default name so that it’s unique and descriptive of the external service. 3. Optionally change: • Named Credential • Description • Service Schema Relative URL or Complete JSON • Operations 4. Click Next, then click Done from the External Service Actions page. 848 Extend Salesforce with Clicks, Not Code External Services Delete To delete an external service, click the arrow in the service’s Actions column, and select Delete. Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement. Recreate an External Service Recreate your external service, and update the related flows. EDITIONS 1. From Setup in Lightning Experience, enter External Services in the Quick Find box, and select External Services. Available in: Lightning Experience 2. Under Actions, next to the name of the external service that you want to recreate, click Save As. Available in: Enterprise, Performance, Unlimited, 3. Note: External Services fills in most of the necessary information, including a modified and Developer Editions external service’s name, named credential used, description, and schema URL or JSON. Modify the external service name so that it’s different from the original registration. If you don’t USER PERMISSIONS provide a name, External Services automatically adds the prefix CopyOf in front of the existing external service name. To manage connections: 4. Verify or change the named credential used, description, schema URL, or JSON. • Customize Application 5. Click Save & Next. 6. If needed, modify the selected operations. 7. Click Next. 8. Click Done. 9. Update the flows that use the actions from the original external service. To locate actions for External Services registrations, filter the actions by type, and select External Service. To find actions that aren’t from External Services registrations, filter by type, and select Apex Action. 10. Return to External Services in Setup. 11. Under Actions, for the original external service that you recreated, click Delete. SEE ALSO: Register an External Service External Services and Packaging You can install or create packages containing an external service. Read these tips before you begin. EDITIONS Consuming an External Services Package Any flow within the package or newly added flows outside the package can reference external Available in: Lightning Experience service actions. Creating an External Services Package Available in: Enterprise, Performance, Unlimited, To ensure that subscriber orgs that install a package can use the External Service actions from the and Developer Editions External Services registration: Add named credential components to the external services registration 849 Extend Salesforce with Clicks, Not Code External Services package. Alternatively, a subscriber can create a named credential in the subscriber org using the same name as the one specified in the external services registration that references it. Note: Legacy External Services has been retired in Summer ’21. If you still have legacy registrations, they are visible in the list. You can delete them. You can’t do anything else with your legacy External Services registrations, including editing them, recreating them, or using legacy registrations in a flow. For more information, see Knowledge Article Legacy External Services Retirement. SEE ALSO: External Services Components Available in Managed Packages Testing External Service Actions in Flow Test the example flow MyAtmFlow with a flow external service action MyAtmExternalService by implementing the HttpCalloutMock interface that provides a test response without performing the callout to the external service endpoint. MyAtmExternalService is registered with a Named Credential MyAtmNamedCredential, has operation getBalance with String accountId as path parameter and Integer pin as header parameter. Its output is a JSON data structure with the account ID, account holder, balance and account type. The HTTP callout mock implementation reacts to an expected test request by responding with the appropriate HTTP response output: global class MyAtmHttpCalloutMock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest request) { // Assert expected request test data System.assertEquals('GET', request.getMethod()); System.assertEquals('callout:MyAtmNamedCredential/A123-456', request.getEndpoint()); System.assertEquals('1234', request.getHeader('pin')); // Send response test data HttpResponse response = new HttpResponse(); response.setHeader('Content-Type', 'application/json'); response.setBody('{"availableBal": 0, "name": "Account Holder", ' + '"type": "Checking", "accountId": "A123-456"}'); response.setStatusCode(200); return response; } } The flow test class sets up the HTTP callout mock for the external service action it’s calling. It creates a flow interview with input parameter values to test, runs the flow interview and then asserts the actual flow output parameters with expected test values: @IsTest public class MyAtmFlowTest { @IsTest static public void testMyAtmFlow() { // Set HTTP callout mock to match flow's external service action invocation Test.setMock(HttpCalloutMock.class, new MyAtmHttpCalloutMock()); // Set flow input variables and create the flow interview Map 850 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect // Start flow interview with set input variables myAtmFlow.start(); // Assert flow output variables System.assertEquals('expected', (String)myAtmFlow.getVariableValue('myFlowOutput')); } } Access External Data With Salesforce Connect Salesforce Connect lets your users view, search, and modify data that’s stored outside your Salesforce org. Instead of copying the data into standard or custom objects, use external objects to access the data in real time via web service callouts. Salesforce Connect Salesforce Connect provides seamless integration of data across system boundaries by letting your users view, search, and modify data that’s stored outside your Salesforce org. For example, perhaps you have data that’s stored on premises in an enterprise resource planning (ERP) system. Instead of copying the data into your org, you can use external objects to access the data in real time via web service callouts. External Data Sources With Salesforce Connect Salesforce Connect uses external data sources to access data that's stored outside your Salesforce org. You must configure an external data source and synchronize it to map its tables with external objects in Salesforce. Salesforce Platform Features Supported by Salesforce Connect Salesforce Connect provides seamless integration with the Salesforce Platform and enables users to view, search, and modify external object data. Access Data in Another Salesforce Org with the Cross-Org Adapter for Salesforce Connect Connect your users to data that's stored in another Salesforce org. Access External Data with the OData 2.0 or 4.0 Adapter for Salesforce Connect Connect your users to data that's exposed via the Open Data Protocol. Access External Data with a Custom Adapter for Salesforce Connect Connect your users to any data anywhere by developing your own custom adapter with the Apex Connector Framework. 851 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Salesforce Connect Salesforce Connect provides seamless integration of data across system boundaries by letting your EDITIONS users view, search, and modify data that’s stored outside your Salesforce org. For example, perhaps you have data that’s stored on premises in an enterprise resource planning (ERP) system. Instead Available in: both Salesforce of copying the data into your org, you can use external objects to access the data in real time via Classic (not available in all web service callouts. orgs) and Lightning Traditionally, we’ve recommended importing or copying data into your Salesforce org to let your Experience (not for users access that data. For example, extract, transform, and load (ETL) tools can integrate third-party high-data-volume external systems with Salesforce. However, doing so copies data into your org that you don’t need or that objects) quickly becomes stale. Available in: Developer In contrast, Salesforce Connect maps Salesforce external objects to data tables in external systems. Edition Instead of copying the data into your org, Salesforce Connect accesses the data on demand and in Available for an extra cost real time. The data is never stale, and we access only what you need. We recommend that you use in: Enterprise, Performance, Salesforce Connect when: and Unlimited Editions • You have a large amount of data that you don’t want to copy into your Salesforce org. • You need small amounts of data at any one time. • You want real-time access to the latest data. Even though the data is stored outside your org, Salesforce Connect provides seamless integration with the Lightning Platform. External objects are available to Salesforce tools, such as global search, lookup relationships, record feeds, and the Salesforce mobile app. External objects are also available to Apex, SOSL, SOQL queries, Salesforce APIs, and deployment via the Metadata API, change sets, and packages. For example, you store product order information in a back-office ERP system. You want to view those orders as a related list on each customer record in your Salesforce org. Salesforce Connect enables you to set up a lookup relationship between the customer object (parent) and the external object (child) for orders. Then you can set up the page layouts for the parent object to include a related list that displays child records. Going a step further, you can update the orders directly from the related list on the customer record. By default, external object records are read only. But you can define the external data source to enable writable external objects. For information about using Apex DML write operations on external object records, see the Apex Developer Guide. Note: If transmitting potentially sensitive information, including sensitive or regulated data such as personal health data or financial data, Salesforce recommends that customers encrypt their external data sources at rest. Transmissions through the Salesforce Connect service are already encrypted using mTLS. Example: This screenshot shows how Salesforce Connect can provide a seamless view of data across system boundaries. A record detail page for the Business_Partner external object includes two related lists of child objects. The external lookup relationships and page layouts enable users to view related data from inside and from outside the Salesforce org on a single page. • Account standard object (1) • Sales_Order external object (2) 852 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Salesforce Connect Adapters Salesforce Connect uses a protocol-specific adapter to connect to an external system and access its data. When you define an external data source in your organization, you specify the adapter in the Type field. Salesforce Connect Adapters Included per Add-On License Using Salesforce Connect to access external data in an org requires one or more Salesforce Connect add-on licenses. General Limits for Salesforce Connect Understand the limits that are applicable to all Salesforce Connect adapters. SEE ALSO: External Data Sources With Salesforce Connect External Object Relationships Salesforce Platform Features Supported by Salesforce Connect Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Set Up Salesforce Connect to Access External Data with a Custom Adapter 853 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Salesforce Connect Adapters Salesforce Connect uses a protocol-specific adapter to connect to an external system and access EDITIONS its data. When you define an external data source in your organization, you specify the adapter in the Type field. Available in: both Salesforce These adapters are available for Salesforce Connect. Classic (not available in all orgs) and Lightning Salesforce Description When to Use Experience (not for Connect high-data-volume external Adapter objects) Cross-org Uses the Lightning Platform REST API to To seamlessly connect data between Available in: Developer access data that’s stored in other your Salesforce orgs. For example, Edition Salesforce orgs. provide your service representatives a Available for an extra cost unified view of customer transactions by in: Enterprise, Performance, integrating data from different Salesforce and Unlimited Editions orgs. OData 2.0 Uses Open Data Protocol to access data To integrate external data sources into OData 4.0 that’s stored outside Salesforce. The your org that support the ODATA external data must be exposed via OData protocol and publish an OData provider. producers. For example, give your account executives a unified data view by pulling data from legacy systems such as SAP, Microsoft, and Oracle in real time. Custom You use the Apex Connector Framework To develop your own adapter with the adapter to develop your own custom adapter Apex Connector Framework when the created via when the other available adapters aren’t other available adapters aren’t suitable Apex suitable for your needs. for your needs. For example, when you A custom adapter can obtain data from want to retrieve data via callouts from a anywhere. For example, some data can REST API. be retrieved from anywhere in the Internet via callouts, while other data can be manipulated or even generated programmatically. SEE ALSO: Salesforce Connect OData 2.0 or 4.0 Adapter for Salesforce Connect Cross-Org Adapter for Salesforce Connect Custom Adapter for Salesforce Connect Salesforce Connect Adapters Included per Add-On License 854 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Salesforce Connect Adapters Included per Add-On License Using Salesforce Connect to access external data in an org requires one or more Salesforce Connect EDITIONS add-on licenses. Each Salesforce Connect add-on license includes a set number of connections per adapter type. A Available in: both Salesforce Salesforce Connect add-on license is associated with a single Salesforce org. Classic (not available in all orgs) and Lightning Salesforce Connect Adapter Number of Connections per License Experience (not for high-data-volume external Cross-org 5 objects) OData 2.0, OData 4.0, or a custom adapter 1 Available in: Developer Edition Available for an extra cost The number of Salesforce Connect add-on licenses you need depends on where the data is stored in: Enterprise, Performance, and which type of connections are required. These are some common data integration scenarios and Unlimited Editions and the number of licenses required. • Your primary Salesforce org accesses data stored in six other Salesforce orgs. You need two Salesforce Connect add-on licenses. Both Salesforce Connect add-on licenses are assigned to the primary org. • Your primary Salesforce org accesses data stored in one secondary Salesforce org. The secondary org accesses the primary org data. You need two Salesforce Connect add-on licenses, one for each org. • Your primary Salesforce org accesses data stored in five other Salesforce orgs and one external data source. You need one Salesforce Connect add-on license, which is assigned to the primary org. SEE ALSO: Salesforce Connect Salesforce Connect Adapters OData 2.0 or 4.0 Adapter for Salesforce Connect Cross-Org Adapter for Salesforce Connect Custom Adapter for Salesforce Connect General Limits for Salesforce Connect Understand the limits that are applicable to all Salesforce Connect adapters. EDITIONS The assigned user license determines the maximum number of custom objects that each user can access. You can also grant object permissions up to that same number of external objects. External Available in: both Salesforce objects don’t count toward the amount for custom objects. Classic (not available in all orgs) and Lightning Maximum external objects per org1 200 Experience (not for high-data-volume external Note: If the default value for external objects in your org is 100, create objects) a support case to increase your org limit to 200. Available in: Developer Maximum joins per query across external objects and other types of objects 4 Edition Available for an extra cost Maximum length of the OAuth token that’s issued by the external system 4,000 characters in: Enterprise, Performance, Maximum new rows retrieved by SOSL and Salesforce searches per hour. 100,000 and Unlimited Editions 855 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect This limit doesn’t apply to high-data-volume external data sources. Maximum new rows retrieved or created per hour. 100,000 This limit doesn’t apply to: • High-data-volume external data sources • Rows that are retrieved only as search results and aren’t opened or edited • Other rows that have already been retrieved Maximum page size for server-driven paging 2,000 rows 1 The amount of 200 external objects applies regardless of how many Salesforce Connect add-ons you purchase for your org. External objects don’t count toward the amount for custom objects. Callout Limits for Salesforce Connect Adapters Salesforce Connect accesses the external data in real time via Web service callouts to external data sources. • Cross-org adapter: No callout limits. However, each callout counts toward the API usage limits of the provider org. See API Request Limits and Allocations. • OData 2.0 and OData 4.0 adapter – 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require higher limits, create a support case. – 1,000 OData callouts per hour for Developer Edition. • Custom adapter: See Callout Limits and Limitations and Execution Governors and Limits in the Apex Developer Guide. SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect External Data Sources With Salesforce Connect Salesforce Connect uses external data sources to access data that's stored outside your Salesforce EDITIONS org. You must configure an external data source and synchronize it to map its tables with external objects in Salesforce. Available in: both Salesforce Classic (not available in all Identity Type for External Data Sources orgs) and Lightning On the external data source configured for Salesforce Connect, the Identity Type field Experience (not for high-data-volume external specifies whether your organization uses one set or multiple sets of credentials to access the objects) external system. Each set of credentials corresponds to a login account on the external system. Sync an External Data Source for Salesforce Connect Available in: Developer Edition When you validate and sync an external data source, it creates or overwrites Salesforce external objects that map to the external system’s schema. Syncing doesn’t copy any data into your Available for an extra cost Salesforce org or write data from your org to the external system. in: Enterprise, Performance, and Unlimited Editions 856 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect External Objects in Salesforce Connect External objects behave similar to custom objects except that they map to data stored outside Salesforce in an external data source. Each external object maps to a data table, and the object fields map to accessible table columns. Record IDs for Salesforce Connect External Objects The first time a data row is retrieved from an external system, the external object record is assigned a Salesforce ID. Each record ID remains associated with the same external data row, unless the external object is deleted from the org. Writable External Objects in Salesforce Connect Select Writable External Objects when you define an external data source and use Salesforce Connect external objects to create, update, and delete data. External objects are read only by default. SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Work with External Data Sources Identity Type for External Data Sources On the external data source configured for Salesforce Connect, the Identity Type field EDITIONS specifies whether your organization uses one set or multiple sets of credentials to access the external system. Each set of credentials corresponds to a login account on the external system. Available in: both Salesforce If you select Named Principal, your organization uses only one login account on the external Classic (not available in all system. orgs) and Lightning Experience (not for If you select Per User, your organization uses multiple login accounts on the external system. Each high-data-volume external of your users can have a unique set of credentials, or you can group your users—for example, by objects) function or business unit—and have each group share a set of credentials. After you grant user access to the external data source through permission sets or profiles, users can set up and manage Available in: Developer their own authentication settings for the external system. Edition Available for an extra cost Note: For an external data source with Per User Identity Type, site members in Experience in: Enterprise, Performance, Cloud can’t set up their own credentials. However, as an admin you can set up and manage and Unlimited Editions each user’s authentication settings for external systems from Lightning Experience or Salesforce Classic. Identity Type is Named Principal Identity Type is Per User To access the external system’s... The system uses the credentials that are defined in the... Data External data source definition User’s personal authentication settings for (search or view external objects) the external system Metadata External data source definition External data source definition (sync to create external objects) 857 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for each external system. If you’re using OAuth 2.0, test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes. SEE ALSO: Define an External Data Source for Salesforce Connect—Cross-Org Adapter Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Define an External Data Source for Salesforce Connect—Custom Adapter Grant Access to Authentication Settings for External Data Sources Store Authentication Settings for External Systems Sync an External Data Source for Salesforce Connect When you validate and sync an external data source, it creates or overwrites Salesforce external EDITIONS objects that map to the external system’s schema. Syncing doesn’t copy any data into your Salesforce org or write data from your org to the external system. Available in: both Salesforce Syncing fails if it causes your org to exceed 200 external objects. Syncing also fails if it tries to create Classic (not available in all an external object with an API name that conflicts with an existing object in the org. In such cases, orgs) and Lightning determine whether the existing object is needed. Experience (not for high-data-volume external • If the object isn’t needed, delete that object, and sync again. objects) • If the object is needed, change the API name of the existing object to no longer conflict with the table that you're trying to sync. However, if the existing object is an external object that Available in: Developer Edition was previously synced, you can’t resync it. Manually update the external object and its fields as needed for schema changes on the external system. Available for an extra cost in: Enterprise, Performance, Tip: We recommend that you create your external data sources and external objects in a and Unlimited Editions Developer Edition org. Then use managed packages to deploy the external data sources and external objects to your other orgs. Doing so prevents your external object names from conflicting with other objects in your org by applying a namespace prefix. When an external object is created via syncing, its Deployment Status is set to In Development. When you’re ready to expose the external object to users, set the status to Deployed. If the external system’s schema changes, the modifications aren’t automatically synced to your Salesforce org. To reflect the changes in the external system, resync the objects. After resyncing, all users who have the same profile as the user who initiated the resync are granted field-level access to the external objects. When you resync an external object: • The Display URL Reference Field is set to None. • If a custom field has the Is Name Field attribute, the attribute is removed. The External ID standard field is used as the name field of the external object. • The Deployment Status doesn’t change. 858 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect To understand how syncing affects relationship fields on external objects, see Relationships on External Objects on page 173. SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Deployment Status for Custom Objects and External Objects Validate and Sync an External Data Source External Objects in Salesforce Connect External objects behave similar to custom objects except that they map to data stored outside EDITIONS Salesforce in an external data source. Each external object maps to a data table, and the object fields map to accessible table columns. Available in: both Salesforce As with custom objects, you must create custom tabs to display external object data in Salesforce. Classic (not available in all When you add a custom tab to an app in Salesforce Classic, it appears as a tab. When you add a orgs) and Lightning custom tab to an app in Lightning Experience, it appears as an item in the app’s navigation bar and Experience (not for in the App Launcher. See Create a Custom Object Tab. high-data-volume external objects) To know the field types that you can create for external objects, see Custom Field Types. Some special behavior for text and number fields on external objects. Available in: Developer Edition • Text fields: Ensure that the field length matches the length of the associated field on the external object to avoid any display or edit issues. Available for an extra cost in: Enterprise, Performance, • Number fields: Ensure that the specified length can contain all digits to the left of the decimal and Unlimited Editions point in external values. If the numeric value from an external system doesn’t fit within the length of the associated number field on the external object, the value is blank in your Salesforce org. If you notice blank numeric field values, adjust Length and Decimal Places for the number field on the external object to accommodate more digits to the left of the decimal point. If the digits to the right of the decimal point in the external values don’t fit within the specified decimal places, the value is truncated. When a custom field on an external object record is displayed, leading and trailing spaces are removed from the field value. Keep this behavior in mind when you filter by a field that contains leading or trailing spaces. For example, include the leading and trailing spaces in the following SOQL query to match the values that are stored in the external system. However, the spaces aren’t displayed in the query results. SELECT FirstName__c FROM Buyers__x WHERE FirstName__c = ' Test ' Note: Formulas and Roll-up Summary fields can’t reference fields on external objects. Features Not Supported • Set up Data with External Objects – Merge Fields – Schema Builder – Validation Rules – Custom fields • Field types not supported – Auto-Number (available only with the cross-org adapter for Salesforce Connect) 859 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect – Currency (available only with the cross-org adapter for Salesforce Connect) – Formula – Geolocation – Master-Detail Relationship – Picklist and Picklist (Multi-select) (available only with the cross-org adapter for Salesforce Connect) – Roll-up Summary – Text (Encrypted) – Text Area (Rich) • Lookup filter on relationship fields • Default field values • Record-level security to manage data access for external objects • Record types to customize external data • Productivity Tools – Activities, Events, and Tasks – Attachments – Notes SEE ALSO: External Object Relationships Considerations for Relationships External Data Sources With Salesforce Connect Manage Custom Objects Record IDs for Salesforce Connect External Objects The first time a data row is retrieved from an external system, the external object record is assigned EDITIONS a Salesforce ID. Each record ID remains associated with the same external data row, unless the external object is deleted from the org. Available in: both Salesforce Note: Classic (not available in all orgs) and Lightning • Salesforce IDs aren’t assigned to external object records that are associated with Experience high-data-volume external data sources. Available in: Developer • In a near future release, temporary Salesforce record IDs will be assigned to external object Edition records that are retrieved by SOSL and Salesforce searches, rather than permanent IDs. To prepare for this change, don’t create code or use third-party integrations that require Available for an extra cost these record IDs to remain associated with the same external data rows. For existing code in: Enterprise, Performance, and Unlimited Editions 860 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect and integrations, we recommend removing dependencies on external object record IDs to avoid issues when this change is rolled out. SEE ALSO: Record IDs and External IDs for External Objects in Salesforce Connect—Cross-Org Adapter Salesforce Connect External Data Sources With Salesforce Connect Writable External Objects in Salesforce Connect Select Writable External Objects when you define an external data source and use Salesforce EDITIONS Connect external objects to create, update, and delete data. External objects are read only by default. External systems execute write operations initiated from Salesforce and also handle write conflicts, Available in: both Salesforce if any. Classic (not available in all orgs) and Lightning • It can take some time for changes to external object records to take effect. If you don’t see Experience (not for recent changes when you view or query an external object record, try again later. high-data-volume external • It can’t be guaranteed that all write operations that are initiated from Salesforce are applied in objects) case of write conflicts. Available in: Developer If Salesforce attempts to save changes to an external object and a standard or custom object in the Edition same transaction, an error occurs. As a best practice, we recommend you use a separate transaction Available for an extra cost to access or modify data in an external system. in: Enterprise, Performance, Write operations on external object records initiated from different contexts can occur in varying and Unlimited Editions order. When you create, update, or delete external object records via the user interface, processes or flows, operations occur synchronously. When Apex is used to perform external records operations, operations occur asynchronously and an active background queue minimizes potential save conflicts. To monitor an asynchronous job progress, use BackgroundOperation. Note: When a custom field on an external object record is edited, leading and trailing spaces are removed from the field value. SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect External Data Sources With Salesforce Connect Apex Developer Guide: Writable External Objects 861 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Salesforce Connect provides seamless integration with the Salesforce Platform and enables users EDITIONS to view, search, and modify external object data. Available in: both Salesforce Reports Classic (not available in all Depending on network latency and the availability of the external system, reports that include orgs) and Lightning an external object can take a long time to run. Experience (not for high-data-volume external Record Feed objects) View the Chatter feed associated with external object records you follow to see updates about the record. Following records helps keep you up to date on important changes to the external Available in: Developer Edition objects. Available for an extra cost Quick Actions in: Enterprise, Performance, External objects support quick actions, except when the actions involve features or functionality and Unlimited Editions that are incompatible with external objects. Flows and Processes You can build flows and processes that include external objects and automate your organization’s repetitive business tasks. Salesforce App You can view and search external objects from the Salesforce mobile app, Salesforce on the go! Salesforce Console You can access external objects from the Salesforce console only in Salesforce Classic. Other consoles, such as the Salesforce console in Lightning Experience, aren’t supported. More Features Supported by Salesforce Connect External objects are available to Salesforce APIs, SOQL queries, SOSL and Salesforce searches, SOQL queries, packages, Metadata API, change sets, and Lightning Experience app. SEE ALSO: Salesforce Connect External Data Sources With Salesforce Connect Cross-Org Adapter for Salesforce Connect OData 2.0 or 4.0 Adapter for Salesforce Connect Custom Adapter for Salesforce Connect 862 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Reports Depending on network latency and the availability of the external system, reports that include an EDITIONS external object can take a long time to run. When you run a report that includes external objects, your org performs a request callout for each Available in: both Salesforce external object in the report. And if it’s a joined report, your org performs separate request callouts Classic (not available in all for each block. If the URL of a report callout approaches or exceeds 2 KB, the request is split into orgs) and Lightning multiple HTTP calls, with each URL being less than 2 KB Experience (not for high-data-volume external A report that includes an external object fetches up to 20,000 records for the primary object. If the objects) report is customized to include child objects, the total number of rows can be greater or less than 10,000, depending on how many child records are fetched. To obtain more relevant external object Available in: Developer rows, try customizing the report. Edition For custom reports that include external objects as the primary object Available for an extra cost in: Enterprise, Performance, • If the deployment status of the external object changes, custom report type’s Deployment and Unlimited Editions Status changes similarly from Deployed to In Development. See Deployment Status for Custom Objects and External Objects. • If the external object is deleted, custom report type and reports created from it are deleted. For large external data sets, report callouts typically access only a subset of the external data. If the report includes summary fields and formulas, those aggregate values likely reflect only a subset of your data. To improve the accuracy of the aggregate values and obtain more relevant data, try customizing the report. As is true for all callouts for external objects, report callouts are limited by the Salesforce Connect adapters in use. • Cross-org adapter: No callout limits. However, each callout counts toward the API usage limits of the provider org. See API Request Limits and Allocations. • OData 2.0 and OData 4.0 adapter – 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require higher limits, create a support case. – 1,000 OData callouts per hour for Developer Edition. • Custom adapter: See Callout Limits and Limitations and Execution Governors and Limits in the Apex Developer Guide. Features Not Supported • Converted currency fields • Cross filters • Buckets and bucket fields • Historical trend reporting SEE ALSO: Reports and Dashboards Limits, Limitations, and Allocations Troubleshoot Reports External Object Relationships Salesforce Platform Features Supported by Salesforce Connect 863 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Record Feed View the Chatter feed associated with external object records you follow to see updates about the EDITIONS record. Following records helps keep you up to date on important changes to the external objects. Available in: both Salesforce Features Not Supported Classic (not available in all orgs) and Lightning • Field history tracking. Experience (not for • External objects that map to high-data-volume external data sources. high-data-volume external objects) SEE ALSO: Available in: Developer Records and List Views Edition Salesforce Connect Available for an extra cost Salesforce Platform Features Supported by Salesforce Connect in: Enterprise, Performance, and Unlimited Editions Quick Actions External objects support quick actions, except when the actions involve features or functionality EDITIONS that are incompatible with external objects. With custom quick actions, you can make your users’ navigation and workflow as smooth as possible Available in: both Salesforce by giving them convenient access to information that’s most important. For example, you can let Classic (not available in all users quickly create or update records, send emails, and more in the context of the external object. orgs) and Lightning Experience (not for high-data-volume external Features Not Supported objects) • Log a Call action: Creating tasks isn’t available for external objects. Available in: Developer • Predefined Field Values for Quick Action Fields: Formulas can’t reference external object fields. Edition Available for an extra cost SEE ALSO: in: Enterprise, Performance, Action Types and Unlimited Editions Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect 864 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Flows and Processes You can build flows and processes that include external objects and automate your organization’s EDITIONS repetitive business tasks. If a flow or a process accesses standard or custom objects along with external objects, you must Available in: both Salesforce commit the changes to the standard or custom object before accessing the external objects. We Classic (not available in all recommend using a separate transaction to access data from the external system. orgs) and Lightning Experience (not for • In Flow Builder, add a screen, local action, or Pause element that pauses until a flow-based time high-data-volume external occurs. See Flow Elements. objects) • In Process Builder, add a scheduled action. See Add Actions to Your Process. Available in: Developer To understand how processes interact with external objects, see Compatibility Considerations for Edition Processes. Available for an extra cost To know the limits while building flows with external objects, see External Object Considerations in: Enterprise, Performance, for Flows. and Unlimited Editions Features Not Supported These are the automation tool features that aren’t available for external objects in Salesforce Connect. • Approval Processes • Workflow Rules SEE ALSO: Flow Builder Process Builder Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Salesforce App You can view and search external objects from the Salesforce mobile app, Salesforce on the go! EDITIONS As with custom objects, external objects must be assigned to tabs that users can access, and object permissions must be granted via profiles or permission sets. When you search for an external object, Available in: both Salesforce click More in the Recent section to view the search results. Classic (not available in all orgs) and Lightning When external objects are used with Salesforce for iOS and Salesforce mobile web on iOS devices, Experience (not for you must select Enable Search in the associated external data sources. Only then external objects high-data-volume external appear in these apps. This requirement doesn’t apply to custom adapters for Salesforce Connect. objects) Available in: Developer SEE ALSO: Edition Salesforce Mobile App Available for an extra cost Salesforce Connect in: Enterprise, Performance, Salesforce Platform Features Supported by Salesforce Connect and Unlimited Editions 865 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Salesforce Console You can access external objects from the Salesforce console only in Salesforce Classic. Other consoles, EDITIONS such as the Salesforce console in Lightning Experience, aren’t supported. External objects haven’t been fully adapted to a console and can cause unexpected behaviors. Available in: both Salesforce Unlike other objects that haven’t been fully adapted to a console, external objects aren’t marked Classic (not available in all with asterisks in the console setup area. orgs) and Lightning Experience (not for high-data-volume external SEE ALSO: objects) Salesforce Console in Salesforce Classic Available in: Developer Salesforce Classic Console Limitations Edition Salesforce Connect Available for an extra cost Salesforce Platform Features Supported by Salesforce Connect in: Enterprise, Performance, and Unlimited Editions More Features Supported by Salesforce Connect External objects are available to Salesforce APIs, SOQL queries, SOSL and Salesforce searches, SOQL EDITIONS queries, packages, Metadata API, change sets, and Lightning Experience app. • API Query Available in: both Salesforce Classic (not available in all – To know how Salesforce Connect accesses the external data in real time via Web service orgs) and Lightning callouts, see query(), queryAll(), and queryMore(). Experience (not for – To understand the limitations that apply to queryAll() and queryMore() calls high-data-volume external on external data, see External Objects in the SOAP API Developer Guide. objects) – To implement server-driven or client-driven paging for external object data that’s obtained Available in: Developer by a custom adapter, see Paging with the Apex Connector Framework. Edition • SOQL Available for an extra cost – To know about the specific limits SOQL applies to external objects, see External objects in in: Enterprise, Performance, SOQL Limits on Objects. and Unlimited Editions – To understand the limitations for external objects when you design SOQL relationship queries, see Understanding Relationship Query Limitations. • SOSL and Salesforce searches – To know about the specific limits SOSL applies to external objects in search results, see SOSL Limits on External Object Search Results. – To learn about how to add RETURNING clause to a SOSL query with external objects, see RETURNING FieldSpec. – To understand how search works with external objects, look for external objects in Searchable Fields by Object in Lightning Experience and Searchable Fields by Object in Salesforce Classic. – (Salesforce Classic only) Search results for external object display only the top 25 rows. • Packaging – To understand how packaging affects external data sources and external objects, see Special Behavior of Components in Packages. – To know what components are automatically included in the package when you add external data sources and external objects, see Components Automatically Added to Packages. 866 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect – To learn about the behavior of external data sources and external objects with permission sets or profile settings, see About Permission Sets and Profile Settings. • Deployment via the Metadata API: In Metadata API, external objects are represented as CustomObject. • Change Sets: External objects are included in the Custom Object component. See Components Available in Change Sets. • Lightning Experience app: When you access external objects from the Lightning Experience app, the associated external data sources must have the High Data Volume option deselected. This requirement doesn’t apply to the cross-org adapter for Salesforce Connect. SEE ALSO: Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Writable External Objects in Salesforce Connect Access Data in Another Salesforce Org with the Cross-Org Adapter for Salesforce Connect Connect your users to data that's stored in another Salesforce org. Cross-Org Adapter for Salesforce Connect Collaborate more effectively and improve processes by connecting the data across your Salesforce orgs. With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access records in other Salesforce orgs. Nevertheless, setup is quick and easy with point-and-click tools. Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Provide users with seamless access to data in your other Salesforce orgs so that they have a complete view of the business. Setting up the cross-org adapter for Salesforce Connect is quick and easy with point-and-click tools. Considerations for Salesforce Connect—Cross-Org Adapter Understand the special behaviors, limits, and recommendations for using the cross-org adapter for Salesforce Connect. Cross-Org Adapter for Salesforce Connect Collaborate more effectively and improve processes by connecting the data across your Salesforce EDITIONS orgs. With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access records in other Salesforce orgs. Nevertheless, setup is quick and easy with point-and-click tools. Available in: both Salesforce Your users and the Lightning Platform interact with other orgs’ data via external objects. The Classic (not available in all cross-org adapter for Salesforce Connect converts each of those interactions into a Lightning orgs) and Lightning Platform REST API call. Experience (not for high-data-volume external Suppose that you store your inventory of products in one Salesforce org. You want your regional objects) and local branch offices, who have their own orgs, to see the latest information about your stock. With the cross-org adapter for Salesforce Connect, those other organizations can easily access your Available in: Developer data while respecting access restrictions that you control. Edition The cross-org adapter makes a Lightning Platform REST API call each time that: Available for an extra cost in: Enterprise, Performance, • A user clicks an external object tab for a list view. and Unlimited Editions • A user views a record detail page of an external object. 867 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect • A user views a record detail page of a parent object that displays a related list of child external object records. • A user performs a Salesforce global search. • A user creates, edits, or deletes an external object record. • A user runs a report. • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. To set up Salesforce Connect with the cross-org adapter, you use only point-and-click tools. Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter The provider org stores the data that the subscriber org accesses. API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter If external objects and custom fields are created in the subscriber org via syncing, their API names are derived from the corresponding API names in the provider org. Record IDs and External IDs for External Objects in Salesforce Connect—Cross-Org Adapter External object record IDs are derived from the corresponding record IDs in the provider organization. External ID values in external object records match the record IDs in the provider organization. User Access to External Data in Salesforce Connect—Cross-Org Adapter A user’s access to external data is determined by settings on both subscriber and provider orgs. SEE ALSO: Salesforce Connect Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter The provider org stores the data that the subscriber org accesses. EDITIONS You define the external data source and external objects in the subscriber org. Manually create the external objects and their fields, or automatically create them by syncing the provider org’s metadata. Available in: both Salesforce When users view or search those external objects in the subscriber org, the data is obtained from Classic (not available in all the provider org and displayed in the subscriber org. When users create or edit external object orgs) and Lightning records in the subscriber org, the data is saved in the provider org. Experience (not for high-data-volume external • An org can serve as both a subscriber and a provider. objects) • A subscriber org can access data from multiple provider orgs. Available in: Developer • A provider org can let multiple subscriber orgs access its data. Edition Available for an extra cost SEE ALSO: in: Enterprise, Performance, Cross-Org Adapter for Salesforce Connect and Unlimited Editions 868 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter If external objects and custom fields are created in the subscriber org via syncing, their API names EDITIONS are derived from the corresponding API names in the provider org. Each external object’s API name ends with __x. Custom fields on external objects use the traditional Available in: both Salesforce __c suffix in the API name. Specifically for objects and custom fields that are synced with the Classic (not available in all cross-org adapter for Salesforce Connect: orgs) and Lightning Experience • For an API name with no suffix in the provider org, the API name is reused in the subscriber org, but with an applied __x suffix for an object or __c suffix for a field. Available in: Developer • For an API name with a suffix in the provider org, the API name is reused in the subscriber org. Edition But one of the underscores (_) from the original suffix is removed, and a new __x or __c Available for an extra cost suffix is applied. in: Enterprise, Performance, and Unlimited Editions Example: If you sync the provider org’s Account object, the subscriber org creates: • An external object with the API name Account__x • Custom fields including one with the API name Account__x.Name__c If you sync the provider org’s CustObj__c object, the subscriber org creates: • An external object with the API name CustObj_c__x • Custom fields including one with the API name CustObj_c__x.Name__c If the provider org’s object has a custom field, the subscriber org creates the custom field on the equivalent external object, for example: • Account__x.MyCustField_c__c • CustObj_c__x.MyOtherCustField_c__c If you sync the provider org’s Account__x external object, the subscriber org creates: • An external object with the API name Account_x__x • Custom fields including one with API name Account_x__x.Name_c__c SEE ALSO: Cross-Org Adapter for Salesforce Connect Record IDs and External IDs for External Objects in Salesforce Connect—Cross-Org Adapter External object record IDs are derived from the corresponding record IDs in the provider organization. EDITIONS External ID values in external object records match the record IDs in the provider organization. Each object in Salesforce has an object ID with a key prefix as the first three characters. When an Available in: both Salesforce external object is created, it’s assigned a unique key prefix. Classic and Lightning Experience Each external object record has a record ID that uses the same key prefix as the external object ID. The rest of the external object record ID matches the original record ID that’s in the provider Available in: Developer organization, excluding its original key prefix. Edition Each record ID that comes from the provider organization becomes a case-insensitive 18-character Available for an extra cost alphanumeric string in the subscriber organization. in: Enterprise, Performance, and Unlimited Editions The original record ID is available in the subscriber organization as the value of the External ID standard field on the external object record. 869 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Each external object has an External ID standard field. Its values uniquely identify each external object record in your org. When the external object is the parent in an external lookup relationship, the External ID standard field is used to identify the child records. Example: You sync the provider organization’s Account object, and the subscriber organization’s Account__x object is assigned the key prefix x00. An account in the provider organization with the ID 001B0000003SVC7IAO appears in the subscriber organization with the ID x00B0000003SVC7IAO and the external ID 001B0000003SVC7IAO. SEE ALSO: Cross-Org Adapter for Salesforce Connect User Access to External Data in Salesforce Connect—Cross-Org Adapter A user’s access to external data is determined by settings on both subscriber and provider orgs. EDITIONS The credentials that are used by the subscriber org to connect to the provider org are associated with a user in the provider org. We refer to this user as the connected user. Available in: both Salesforce Classic (not available in all A user in the subscriber org can access only data that the connected user can access within the orgs) and Lightning provider org. In other words, the subscriber org’s user access respects the connected user’s access Experience (not for restrictions, which are determined by these settings in the provider org. high-data-volume external • Object-level security—permission sets and profiles objects) • Field-level security—permission sets and profiles Available in: Developer • Record-level security—organization-wide sharing settings, role hierarchies, and sharing rules Edition In the subscriber org, grant users access to external objects via permission sets and profiles. Available for an extra cost in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Cross-Org Adapter for Salesforce Connect Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter USER PERMISSIONS EDITIONS To create and edit external data sources: Customize Application Available in: both Salesforce Classic and Lightning To create and edit external objects: Customize Application Experience To define or change object-level help: Customize Application Available in: Developer To create and edit custom fields: Customize Application Edition Available for an extra cost To edit permission sets and user profiles: Manage Profiles and Permission Sets in: Enterprise, Performance, To edit another user’s authentication settings Manage Users and Unlimited Editions for external systems: Provide users with seamless access to data in your other Salesforce orgs so that they have a complete view of the business. Setting up the cross-org adapter for Salesforce Connect is quick and easy with point-and-click tools. Setting up Salesforce Connect with the cross-org adapter involves these high-level steps. 870 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect 1. Define an external data source of type Salesforce Connect: Cross-Org. Create an external data source for each provider org. 2. Create the external objects. Perform this task only if you don’t sync to automatically create the external objects. In the subscriber org, create an external object for each object in the provider org that you want to access. 3. Create help content for the external objects. Help your users distinguish between external objects and the other objects in the subscriber org, which can have similar names and types of data. On the subscriber org, create Visualforce pages to describe the external objects. When your users click Help for this Page on an external object, they read your custom help content. 4. Add custom fields and relationships to the external objects. Create relationships between objects. If you didn’t sync to automatically create the external objects and their fields on the subscriber org, create a custom field for each of the provider org’s fields that you want to access. 5. Enable user access to external objects. Grant object permissions through permission sets or profiles. 6. Enable user access to the fields on the external objects. Grant field permissions through permission sets or profiles. 7. If the external data source uses per-user authentication: a. Let users authenticate to the external system. Grant users access to authentication settings for the external data source through permission sets or profiles. b. Set up each user’s authentication settings. You or your users can perform this task. Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for the provider org. If you’re using OAuth 2.0, the OAuth flow displays the Salesforce login page twice: first to log in to the provider org to obtain an access token, and then to log back in to the subscriber org. Test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes. SEE ALSO: Cross-Org Adapter for Salesforce Connect Considerations for Salesforce Connect—Cross-Org Adapter Developer Guide: Visualforce Developer Guide External Object Relationships Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter 871 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Define an External Data Source for Salesforce Connect—Cross-Org Adapter Give your users seamless access to data across your Salesforce orgs. EDITIONS 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. Available in: both Salesforce Classic and Lightning 2. Click New External Data Source, or click Edit to modify an existing external data source. Experience 3. Complete the fields. Available in: Developer Edition Field Description Available for an extra cost Label A user-friendly name for the external data source. The label is displayed in: Enterprise, Performance, in the Salesforce user interface, such as in list views. and Unlimited Editions If you set Identity Type to Per User, this label appears when your users view or edit their authentication settings for external systems. USER PERMISSIONS To create and edit external Name A unique identifier that’s used to refer to this external data source data sources: definition through the API. • Customize Application The name can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. Type Select Salesforce Connect: Cross-Org. Connect to Determines which URL is used to connect to the provider org. URL If you selected Connect to Custom URL, enter the login URL for the provider org. API Version Select an API version that the provider org supports. The API version determines which of the provider org’s objects, fields, and types you can access from the subscriber org. Connection Number of seconds to wait for a response from the provider org before Timeout timing out. By default, the value is set to the maximum of 120 seconds. Writable Lets the Lightning platform and users in this org create, update, and External delete records for external objects associated with the external data Objects source. The external object data is stored outside the org. By default, external objects are read only. Enable Search Determines whether global searches in the subscriber org also search the external objects’ data, which is stored in the provider org. When selected, you can control which external objects are searchable by selecting or deselecting Allow Search on each external object. Only text, text area, and long text area fields on external objects can be searched. If an external object has no searchable fields, searches on that object return no records. 872 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Field Description Identity Type Determines whether the subscriber org uses one set or multiple sets of credentials to access the provider org. See Identity Type for External Data Sources on page 857. 4. Select the authentication protocol. • If you select Password Authentication, enter the username and password for accessing the external system. • If you select OAuth 2.0, complete the following fields. Field Description Authentication Select a Salesforce authentication provider. See “Configure a Salesforce Authentication Provider” Provider in the Salesforce Help. Note: On a production org, an external data source can’t use an authentication provider that directs authorization or token requests to a sandbox org. Similarly, on a sandbox org, an external data source can’t use an authentication provider that directs authorization or token requests to a production org. Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter. Note: – The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider. – Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen. – We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system. Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status. 5. Click Save. 6. Click Validate and Sync, and confirm that the connection is successful. If you instead receive an error message, refer to the following documents. • “Status Codes and Error Responses” in the REST API Developer Guide • The “API Fault Element,” “ExceptionCode,” “Error,” and “StatusCode” sections of “Core Data Types Used in API Calls” in the SOAP API Developer Guide 873 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect 7. Optionally, select tables and click Sync to do the following for each selected table. • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type. Note: Before you sync, make sure that you understand the considerations that are described in these topics. • Sync an External Data Source for Salesforce Connect on page 858 • Sync Considerations for Salesforce Connect—Cross-Org Adapter on page 875 You can instead choose to manually create the external objects and custom fields that map to the external data. Doing so lets you customize the external object names, decide which table columns to create custom fields for, and customize the custom field names. However, this approach takes longer and requires manual maintenance. SEE ALSO: Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Store Authentication Settings for External Systems API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Developer Guide: REST API Developer Guide Considerations for Salesforce Connect—Cross-Org Adapter Understand the special behaviors, limits, and recommendations for using the cross-org adapter for EDITIONS Salesforce Connect. Also review the considerations that apply to all Salesforce Connect adapters. Available in: both Salesforce Classic (not available in all orgs) and Lightning Salesforce Compatibility Considerations for Salesforce Connect—Cross-Org Adapter Experience (not for Some Salesforce features and functionality have special behaviors or aren’t available for external high-data-volume external objects that are associated with an external data source of type Salesforce Connect: objects) Cross-Org. Available in: Developer Sync Considerations for Salesforce Connect—Cross-Org Adapter Edition When you validate and sync an external data source of type Salesforce Connect: Available for an extra cost Cross-Org, some special behaviors and limitations apply. in: Enterprise, Performance, Writable External Objects Considerations for Salesforce Connect—Cross-Org Adapter and Unlimited Editions Some behaviors and limitations affect writable external objects that are associated with the cross-org adapter for Salesforce Connect. API Usage Considerations for Salesforce Connect—Cross-Org Adapter With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access records in other Salesforce orgs. Depending on how the external object is accessed, each call counts toward the API usage limits of only the provider org or of both provider and subscriber orgs. Picklist Considerations for Salesforce Connect—Cross-Org Adapter Special behaviors and limitations apply to picklist and multi-select picklist fields on external objects. 874 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Currency Considerations for Salesforce Connect—Cross-Org Adapter Special behaviors and limitations apply to currency fields on external objects. SEE ALSO: Salesforce Platform Features Supported by Salesforce Connect Salesforce Compatibility Considerations for Salesforce Connect—Cross-Org Adapter Some Salesforce features and functionality have special behaviors or aren’t available for external EDITIONS objects that are associated with an external data source of type Salesforce Connect: Cross-Org. Available in: both Salesforce • The cross-org adapter for Salesforce Connect can access only queryable objects in the provider Classic and Lightning org. If you define an external object whose table name specifies an object that can’t be queried, Experience your users and the Lightning Platform can’t access that external object. Available in: Developer • You can’t use Salesforce Connect external objects to access big objects in another org. Edition • When you deploy an external data source that uses OAuth 2.0 from a sandbox org to a Available for an extra cost production org, you must update the authentication provider. On a production org, an external in: Enterprise, Performance, data source can’t use an authentication provider that directs authorization or token requests and Unlimited Editions to a sandbox org. Similarly, on a sandbox org, an external data source can’t use an authentication provider that directs authorization or token requests to a production org. Also review the considerations that apply to all Salesforce Connect adapters. Sync Considerations for Salesforce Connect—Cross-Org Adapter When you validate and sync an external data source of type Salesforce Connect: EDITIONS Cross-Org, some special behaviors and limitations apply. • Which objects and fields can be synced is determined by the object permissions and field Available in: both Salesforce permissions of the provider org’s user whose credentials are defined in the external data source Classic (not available in all definition. See User Access to External Data in Salesforce Connect—Cross-Org Adapter on page orgs) and Lightning 870. Experience (not for high-data-volume external • Only queryable objects can be synced. objects) • You can’t sync an object whose API name contains 38 or more characters. An external object’s name can’t exceed 40 characters, including the automatically appended __x suffix. See API Available in: Developer Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter on Edition page 869. Available for an extra cost • These field types aren’t synced. in: Enterprise, Performance, and Unlimited Editions – Encrypted text – Rich text area • Global picklist value sets aren’t synced. If a provider org’s picklist field uses a global picklist value set, syncing creates a local picklist field on the subscriber org. A local picklist field has its own set of values. • Inactive picklist values aren’t synced. If the subscriber org accesses an external object record that contains an inactive picklist value, the inactive value is added to the picklist field on the external object. • Syncing converts restricted picklists on the provider org into unrestricted picklists on the subscriber org’s external objects. 875 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect We recommend having only unrestricted picklists on external objects, even when they’re associated with restricted picklists on the provider org. Restricted picklists on the provider org block unapproved values from the subscriber org, eliminating the need to restrict picklists on external objects. • To enable users to change the currency when editing an external object record, add the Currency field to the page layouts. All other synced fields are automatically added to the default page layout. • Syncing always enables search on the external object when search is enabled on the external data source, and vice versa. • Hierarchical, lookup, and master-detail relationship fields are synced. However, they become text fields in the subscriber org, and their values appear as IDs, not as record names. For example, suppose that we sync the Account object. When we view the Acme Wireless account in the provider org, the value of the Account Owner (Account.OwnerId) field appears as John Smith. When we view the equivalent account in the subscriber org, the value for the (Account__x.OwnerId__c) field appears as 005B00000019eapIAA. • You can use external lookup relationships in the subscriber org to mirror lookup relationships in the provider org. For each lookup relationship that you want to bring into the subscriber org, sync the parent and child objects. Each lookup relationship field becomes a text field on the subscriber org. Change the field type of the sync-created text field to External Lookup Relationship. When specifying the parent of the external lookup relationship, select the external object that corresponds to the parent object in the provider org. • The names and labels of synced fields on the subscriber org are derived from the API names—not the labels—of the fields on the provider org. For example, the Account object in the provider org has the Account Owner (OwnerId) standard field. If we sync the Account object, the Account__x.OwnerId__c field in the subscriber org has the label “Owner ID” and the name “OwnerId.” Important: When you select the provider org objects to sync, determine whether check marks appear in the Synced column. If a Synced check mark appears, the subscriber org has an external object whose object name (for example, Account__x) associates it with the object in the provider org (for example, Account). If you select the object and click Sync: • The external object is overwritten. • Any custom field on the external object is overwritten if its API name (for example, Email_c__c) associates it with a field on the provider org (for example, Email__c). • Any other custom fields on the external object remain as they are, including: – Previously synced custom fields whose API names were changed by editing their Field Name values. – Manually added custom fields whose API names aren’t associated with fields on the provider org’s object. If no Synced check mark appears, and you sync the object, a new external object is created in the subscriber org. For example, the object name is changed on the provider org to no longer be associated with the object name of the external object on the subscriber org. Syncing that object creates a new external object on the subscriber org. We recommend that you change the object name of the existing external object to match the updated object name on the provider org before you sync. Also review the considerations that apply to all Salesforce Connect adapters. SEE ALSO: API Names for External Objects and Custom Fields in Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Sync an External Data Source for Salesforce Connect Cross-Org Adapter for Salesforce Connect 876 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Writable External Objects Considerations for Salesforce Connect—Cross-Org Adapter Some behaviors and limitations affect writable external objects that are associated with the cross-org EDITIONS adapter for Salesforce Connect. • Some fields remain read only on writable external objects, such as fields that are creatable but Available in: both Salesforce not editable and fields that have derived or calculated values. For example: Classic (not available in all orgs) and Lightning – Address fields such as Billing Address and Shipping Address, which are Experience (not for derived from writable fields, such as Street Address, State, and Zip) high-data-volume external – Auto-number fields objects) – Created by fields Available in: Developer – Formula fields Edition – Last Modified fields Available for an extra cost – Roll-up summaries in: Enterprise, Performance, and Unlimited Editions • Picklist values on external objects can get out of sync with picklist values on the provider org. If picklist values are changed on the provider org, resync or manually delete and recreate the associated picklist fields on the subscriber org. • Enable multiple currencies in the subscriber org, and make sure that the subscriber org has all the currencies that the provider orgs use. If a currency is later added to the provider org, add the currency to the subscriber org. If you can’t enable multiple currencies in the subscriber org, make sure that all provider orgs are single-currency and use the same currency as the subscriber org. • To enable users to change the currency when editing an external object record, add the Currency field to the page layouts. • If a user tries to change the currency in an external object record, the list of currency options isn’t limited to active currencies in the provider org. If the user selects a currency that’s inactive or unavailable in the provider org, the user gets an error and can’t save the record. • You can use external lookup relationships in the subscriber org to mirror lookup relationships in the provider org. For each lookup relationship that you want to bring into the subscriber org, sync the parent and child objects. Each lookup relationship field becomes a text field on the subscriber org. Change the field type of the sync-created text field to External Lookup Relationship. When specifying the parent of the external lookup relationship, select the external object that corresponds to the parent object in the provider org. Also review the considerations that apply to all Salesforce Connect adapters. SEE ALSO: Writable External Objects in Salesforce Connect Sync an External Data Source for Salesforce Connect Cross-Org Adapter for Salesforce Connect 877 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect API Usage Considerations for Salesforce Connect—Cross-Org Adapter With the cross-org adapter, Salesforce Connect uses Lightning Platform REST API calls to access EDITIONS records in other Salesforce orgs. Depending on how the external object is accessed, each call counts toward the API usage limits of only the provider org or of both provider and subscriber orgs. Available in: both Salesforce When a user accesses an external object in one of the following ways, the Lightning Platform REST Classic (not available in all API call counts toward the API usage limits of the provider org. orgs) and Lightning Experience (not for • Opening a list view of external object records high-data-volume external • Viewing an external object record detail page objects) • Viewing a parent object record that contains an external object related list Available in: Developer • Viewing a child object record that contains an external lookup field Edition • Executing a search that also searches external objects Available for an extra cost • Accessing an external object from a flow, Visualforce page, Apex class, or Apex trigger in: Enterprise, Performance, • Creating, editing, or deleting an external object record and Unlimited Editions • Running a report • Editing a report and causing the preview to load in report builder If a user or system accesses an external object through the SOAP API, Bulk API, or Lightning Platform REST API, that access counts toward the API usage limits of both the subscriber org and the provider org. SEE ALSO: Salesforce Limits Quick Reference Guide: API Request Limits and Allocations Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Picklist Considerations for Salesforce Connect—Cross-Org Adapter Special behaviors and limitations apply to picklist and multi-select picklist fields on external objects. EDITIONS • You can edit picklist values on external objects, but changes to fields on the provider org aren’t automatically reflected in the subscriber org. To reflect changes on the subscriber org, resync Available in: both Salesforce the external object or manually update the picklist values on the external object. Classic (not available in all orgs) and Lightning If you don’t resync or update the picklist values on the external object: Experience (not for – When an active picklist value is added to the provider org, the subscriber org doesn’t display high-data-volume external it as an available picklist value on external object records. objects) – When an active picklist value is deleted from or made inactive on a restricted picklist on Available in: Developer the provider org, the subscriber org can’t create or edit external object records with that Edition value. Available for an extra cost • Global picklist value sets aren’t synced. If a provider org’s picklist field uses a global picklist value in: Enterprise, Performance, set, syncing creates a local picklist field on the subscriber org. A local picklist field has its own and Unlimited Editions set of values. • Inactive picklist values aren’t synced. If the subscriber org accesses an external object record that contains an inactive picklist value, the inactive value is added to the picklist field on the external object. • Syncing converts restricted picklists on the provider org into unrestricted picklists on the subscriber org’s external objects. 878 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect • We recommend having only unrestricted picklists on external objects, even when they’re associated with restricted picklists on the provider org. Restricted picklists on the provider org block unapproved values from the subscriber org, eliminating the need to restrict picklists on external objects. SEE ALSO: Sync Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Considerations for Salesforce Connect—Cross-Org Adapter Picklist Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter Currency Considerations for Salesforce Connect—Cross-Org Adapter Special behaviors and limitations apply to currency fields on external objects. EDITIONS • Enable multiple currencies in the subscriber org, and make sure that the subscriber org has all the currencies that the provider orgs use. If a currency is later added to the provider org, add Available in: both Salesforce the currency to the subscriber org. Classic (not available in all orgs) and Lightning If you can’t enable multiple currencies in the subscriber org, make sure that all provider orgs Experience (not for are single-currency and use the same currency as the subscriber org. high-data-volume external • To enable users to change the currency when editing an external object record, add the objects) Currency field to the page layouts. Available in: Developer • If a user tries to change the currency in an external object record, the list of currency options Edition isn’t limited to active currencies in the provider org. If the user selects a currency that’s inactive Available for an extra cost or unavailable in the provider org, the user gets an error and can’t save the record. in: Enterprise, Performance, • The convertCurrency() function is ignored in SOQL queries of external objects. and Unlimited Editions SEE ALSO: Considerations for Enabling Multiple Currencies Considerations for Salesforce Connect—Cross-Org Adapter Subscriber and Provider Orgs in Salesforce Connect—Cross-Org Adapter Access External Data with the OData 2.0 or 4.0 Adapter for Salesforce Connect Connect your users to data that's exposed via the Open Data Protocol. OData 2.0 or 4.0 Adapter for Salesforce Connect Connect to your back office for a complete view of your business. With the OData 2.0 or 4.0 adapter, Salesforce Connect uses Open Data Protocol Version 2.0 or Version 4.0 to access data that’s stored outside Salesforce. Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Let users view and search data that’s stored outside your Salesforce org, such as data in an enterprise resource planning (ERP) system. Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the special behaviors, limits, and recommendations for using the OData 2.0 or 4.0 adapter for Salesforce Connect. Picklist Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter Special behaviors and limitations apply to picklist fields on external objects. 879 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Get to know the Salesforce implementation of the Open Data Protocol (OData) for accessing external systems with Salesforce Connect. Use External Change Data Capture to Track Data Changes on External Objects With External Change Data Capture, you can track changes to data that is stored outside your Salesforce org when using the Odata 4.0 adapter. You can then build automation in response to the changes to increase productivity or provide a better customer experience. OData 2.0 or 4.0 Adapter for Salesforce Connect Connect to your back office for a complete view of your business. With the OData 2.0 or 4.0 adapter, EDITIONS Salesforce Connect uses Open Data Protocol Version 2.0 or Version 4.0 to access data that’s stored outside Salesforce. Available in: both Salesforce Your users and the Lightning Platform interact with the external data via external objects. Salesforce Classic (not available in all Connect converts each of those interactions into an OData query that contains the relevant orgs) and Lightning parameters to filter the results. Salesforce performs an OData callout each time that: Experience (not for high-data-volume external • A user clicks an external object tab for a list view. objects) • A user views a record detail page of an external object. Available in: Developer • A user views a record detail page of a parent object that displays a related list of child external Edition object records. Available for an extra cost • A user performs a Salesforce global search. in: Enterprise, Performance, • A user creates, edits, or deletes an external object record. and Unlimited Editions • A user runs a report. • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. The OData 2.0 adapter for Salesforce Connect can access external data that’s exposed via services called OData producers. Learn more about OData producers at www.odata.org. To understand the limitations on Apex code accessing external objects via the OData adapters, see Apex Considerations for Salesforce Connect External Objects. External IDs and OData Entity Keys When you access external data with the OData 2.0 or 4.0 adapter for Salesforce Connect, the values of the External ID standard field on an external object are derived according to the entity key that’s defined in the OData service metadata document. Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters It's common for Salesforce Connect queries of external data to have a large result set that's broken into smaller batches or pages. You decide whether to have the paging behavior controlled by the external system (server-driven) or by the OData 2.0 or 4.0 adapter for Salesforce Connect (client-driven). 880 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect General Limits for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the limits for the OData adapters for Salesforce Connect. SEE ALSO: Salesforce Connect Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters External IDs and OData Entity Keys When you access external data with the OData 2.0 or 4.0 adapter for Salesforce Connect, the values EDITIONS of the External ID standard field on an external object are derived according to the entity key that’s defined in the OData service metadata document. Available in: both Salesforce Each external object has an External ID standard field. Its values uniquely identify each Classic (not available in all external object record in your org. When the external object is the parent in an external lookup orgs) and Lightning relationship, the External ID standard field is used to identify the child records. Experience (not for high-data-volume external Important: Don’t use sensitive data as the values of the External ID standard field or fields objects) designated as name fields, because Salesforce sometimes stores those values. Available in: Developer • External lookup relationship fields on child records store and display the External ID values Edition of the parent records. Available for an extra cost • For internal use only, Salesforce stores the External ID value of each row that’s retrieved in: Enterprise, Performance, from the external system. This behavior doesn’t apply to external objects that are associated and Unlimited Editions with high-data-volume external data sources. This list view for the Order_Detail external object displays External ID values. Each External ID value is derived according to the entity key that’s defined in the OData service metadata document of the remote data service (OData producer). The entity key is formed from a subset of the entity type’s properties. This excerpt from an OData service metadata document shows that the External ID values for the Order_Detail external object are derived from the OrderID and ProductID properties. 881 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect This record detail page displays the OrderID and ProductID fields. Their values are combined to create the value of the External ID standard field. If you enable writable external objects, determine whether the external system requires write operations to specify values for the entity keys. For example, many external systems generate values for entity keys when new external object records are created in Salesforce. If your external system requires write operations to specify values for entity keys, ensure that External ID standard field values and entity key values don’t contradict each other. For each write operation, include either the External ID standard field value or the custom field values that form the entity key, but never both. SEE ALSO: OData 2.0 or 4.0 Adapter for Salesforce Connect Writable External Objects in Salesforce Connect Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters It's common for Salesforce Connect queries of external data to have a large result set that's broken EDITIONS into smaller batches or pages. You decide whether to have the paging behavior controlled by the external system (server-driven) or by the OData 2.0 or 4.0 adapter for Salesforce Connect Available in: both Salesforce (client-driven). Classic (not available in all By default, the OData 2.0 and 4.0 adapters for Salesforce Connect use client-driven paging. orgs) and Lightning Specifically, the OData requests use the $top and $skip system query options to page through Experience (not for the result set. high-data-volume external objects) With server-driven paging, the external system determines the page sizes and batch boundaries. The external system’s paging settings can optimize the external system’s performance and improve Available in: Developer the load times for external objects in your org. Also, the external data set can change while your Edition users or the Lightning Platform are paging through the result set. Typically, server-driven paging Available for an extra cost adjusts batch boundaries to accommodate changing data sets more effectively than client-driven in: Enterprise, Performance, paging. and Unlimited Editions 882 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect The Server Driven Pagination field on the external data source specifies whether to use client-driven or server-driven paging. If you enable server-driven paging on an external data source, Salesforce ignores the requested page sizes, including the default queryMore() batch size of 500 rows. The pages returned by the external system determine the batches, but each page can’t exceed 2,000 rows. However, the limits for the OData adapters for Salesforce Connect still apply. SEE ALSO: Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter General Limits for Salesforce Connect—OData 2.0 and 4.0 Adapters OData Query String Options General Limits for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the limits for the OData adapters for Salesforce Connect. EDITIONS An org is limited to: • 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require Available in: both Salesforce Classic (not available in all higher limits, create a support case. orgs) and Lightning • 1,000 OData callouts per hour for Developer Edition. Experience (not for • 100k new external object record IDs per hour for long-term ID mapping high-data-volume external • 100k new external object record IDs per hour for short-term ID mapping objects) Available in: Developer Note: To view external object records in Lightning Experience, Salesforce Connect maps the Edition external IDs of the record to Salesforce IDs. Mappings classified as short-term refer to records retrieved via Search results only. Mappings classified as long-term refer to records retrieved Available for an extra cost by all other Lightning Experience components, such as List Views. Record IDs not viewed in in: Enterprise, Performance, 365 days are subject to deletion unless the mappings have customer data attached to them. and Unlimited Editions Maximum HTTP request size for OData 8 MB Maximum HTTP response size for OData 8 MB Maximum result set size for an OData query 16 MB Maximum result set size for an OData subquery 1,000 rows SEE ALSO: General Limits for Salesforce Connect OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData 2.0 or 4.0 Adapter for Salesforce Connect Record IDs for Salesforce Connect External Objects 883 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter USER PERMISSIONS EDITIONS To create and edit external data sources: Customize Application Available in: both Salesforce Classic (not available in all To create and edit external objects: Customize Application orgs) and Lightning To define or change object-level help: Customize Application Experience (not for high-data-volume external To create and edit custom fields: Customize Application objects) To edit permission sets and user profiles: Manage Profiles and Permission Sets Available in: Developer To edit another user’s authentication settings Manage Users Edition for external systems: Available for an extra cost in: Enterprise, Performance, and Unlimited Editions Let users view and search data that’s stored outside your Salesforce org, such as data in an enterprise resource planning (ERP) system. Setting up Salesforce Connect with anOData 2.0 or 4.0 adapter involves these high-level steps. 1. Define an external data source of type Salesforce Connect: OData 2.0 or Salesforce Connect: OData 4.0. If your external system hosts multiple services, create an external data source for each service endpoint. Each service endpoint points to an OData service root URL and can expose collections of entities. For example, you’d create a separate external data source for each of these service endpoints. • http://services.example.org/Warehouse.svc • https://services.example.org/Payroll.svc 2. Create the external objects. Perform this task only if you don’t sync to automatically create the external objects. Create an external object for each external data table that you want to access from your Salesforce org. 3. Create help content for the external objects. Create Visualforce pages that describe the external data. When your users click Help for this Page on an external object, they read your custom help content. Remember, your users can’t find information about the external data in Salesforce Help. 4. Add custom fields and relationships to the external objects. Create relationships between objects. If you didn’t sync to automatically create the external objects and their fields, create a custom field for each external table column that you want to access from your Salesforce org. 5. Verify access to external object data. Check that expected user and code interactions with the external objects work, including sorting and filtering search and query results. Tip: After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results. 6. Enable user access to external objects. Grant object permissions through permission sets or profiles. 7. Enable user access to the fields on the external objects. 884 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Grant field permissions through permission sets or profiles. 8. If the external data source uses per-user authentication: a. Let users authenticate to the external system. Grant users access to authentication settings for the external data source through permission sets or profiles. b. Set up each user’s authentication settings. You or your users can perform this task. Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for each external system. If you’re using OAuth 2.0, test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes. SEE ALSO: OData 2.0 or 4.0 Adapter for Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Developer Guide: Visualforce Developer Guide External Object Relationships Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter ® Connect your Salesforce org to data that’s stored in an external system, such as SAP NetWeaver EDITIONS Gateway, Microsoft Dynamics® NAV, or IBM WebSphere®. Note: Available in: both Salesforce Classic (not available in all • The external data must be exposed by a service that uses Open Data Protocol (OData) orgs) and Lightning Version 2.0 or 4.0. Such a service is called an OData producer. Experience (not for • The URL for reaching the OData producer must be accessible by Salesforce application high-data-volume external servers through the Internet. You can allow access by white-listing Salesforce server IP objects) addresses on your corporate network firewall or by setting up a reverse-proxy XML Available in: Developer Gateway. Edition • The extent to which you can customize data visibility depends on the external system. Available for an extra cost To determine the optimal settings for integration with Salesforce, consult the external in: Enterprise, Performance, system’s documentation. and Unlimited Editions 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. USER PERMISSIONS 2. Click New External Data Source, or click Edit to modify an existing external data source. To create and edit external 3. Complete the fields. data sources: • Customize Application 885 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Field Description Label A user-friendly name for the external data source. The label is displayed in the Salesforce user interface, such as in list views. If you set Identity Type to Per User, this label appears when your users view or edit their authentication settings for external systems. Name A unique identifier that’s used to refer to this external data source definition through the API. The name can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. Type Select Salesforce Connect: OData 2.0 or Salesforce Connect: OData 4.0. URL The OData service root URL. Make sure that you escape all special characters. Each service endpoint requires its own external data source definition, but you can have multiple entities under one service root URL. For more information about the service root URL and other URL conventions, go to www.odata.org. Examples: • http://services.example.org/Warehouse.svc • https://services.example.org/Payroll.svc If the endpoint is defined in a named credential, enter the named credential URL. A named credential URL contains the scheme callout:, the name of the named credential, and an optional path. For example: callout:My_Named_Credential/some_path. You can append a query string to a named credential URL. Use a question mark (?) as the separator between the named credential URL and the query string. For example: callout:My_Named_Credential/some_path?format=json. If you enter a named credential URL, skip the Authentication section for the external data source. To access the external system, Salesforce Connect uses the authentication settings that are defined in the named credential. Connection Timeout Number of seconds to wait for a response from the external system before timing out. By default, the value is set to the maximum of 120 seconds. Depending on the availability of and the connection to the external system, it can take a long time to retrieve external data. Use this field to limit how long to wait for external data to load into your org. Writable External Lets the Lightning platform and users in this org create, update, and delete records for external Objects objects associated with the external data source. The external object data is stored outside the org. By default, external objects are read only. High Data Volume Salesforce enforces rate limits for retrieving and viewing data from external systems. If your org hits rate limits when accessing external objects, consider selecting the High Data Volume option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. See High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 897. 886 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Field Description High-data-volume external data sources are still limited to 20,000 OData queries per hour for Enterprise, Performance, and Unlimited Editions. If you require higher limits, create a support case. See OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 896. Server Driven It's common for Salesforce Connect queries of external data to have a large result set that's broken Pagination into smaller batches or pages. Select this option to have the external system control the paging behavior. See Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 882. Request Row Counts Includes one of the following system query options in each OData query so that the response includes the total row count of the result set. • $inlinecount=allpages for the OData 2.0 adapter • $count=true for the OData 4.0 adapter Some external systems don’t support these system query options. If you receive errors or notice long load times when you try to access their data, deselect Request Row Counts on the external data source. If you do so, however, the external data source and its associated external objects can’t support the following functionality, which requires the total row count. • SOQL COUNT() aggregate function • Batch Apex with Database.QueryLocator Compress Requests When selected, Salesforce sends compressed HTTP requests to the external system. Make sure that the external system is set up to receive gzip-compressed data. Salesforce automatically accepts gzip-compressed responses. Enable Search Determines whether SOSL and Salesforce global searches also query the external objects that are associated with this external data source. When selected, you can control which external objects are searchable by selecting or deselecting Allow Search on each external object. Only text, text area, and long text area fields on external objects can be searched. If an external object has no searchable fields, searches on that object return no records. Select this option to allow the external data source’s associated external objects to appear in Salesforce for iOS and Salesforce mobile web when used on iOS devices. Custom Query Option Available only for the OData 2.0 adapter for Salesforce Connect. If the OData producer has for Salesforce implemented and exposed a free-text-search custom query option, enter the name of that query Search string parameter. Learn more about OData custom query options and other URI conventions at www.odata.org. This field has no effect when Enable Search is deselected or when the OData producer isn’t set up to correctly handle the custom query option. See OData 2.0 Query Options. Use Free-Text Search Available only for the OData 4.0 adapter for Salesforce Connect. Select this option to use the Expressions $search system query option instead of $filter in search requests that are sent to the 887 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Field Description external system. Make sure that the OData producer is set up to support the $search system query option. This field has no effect when Enable Search is deselected. See OData 4.0 Query Options. Format The format that the OData producer uses to represent resources, such as collections of data. Make sure that the OData producer is set up to support the selected format. Learn more about representation formats and operations at www.odata.org. If your external data source uses the OData 4.0 adapter and JSON format, make sure that the OData producer accepts headers that contain the odata.metadata=full format parameter. Other variations, including odata.metadata=minimal, aren’t supported. Special Select Socrata only if the URL specifies a Socrata open data endpoint. See Socrata™ Considerations Compatibility for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 898. CSRF Protection If the external system requires Cross-Site Request Forgery (CSRF) protection in requests to create, edit or delete its data, select this option. If you do so, your org obtains an anti-CSRF token and cookie from the external system and includes them in each create, edit, and delete request. See CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters on page 898. Available only when Writable External Objects is selected. Anti-CSRF Token Name HTTP header field that contains the anti-CSRF token. The external system determines the field name. Default: X-CSRF-Token Available only when CSRF Protection is selected. Certificate If you specify a certificate, your Salesforce org supplies it when establishing each two-way SSL connection with the external system. The certificate is used for digital signatures, which verify that requests are coming from your Salesforce org. Identity Type Determines whether you're using one set or multiple sets of credentials to access the external system. See Identity Type for External Data Sources on page 857. Select Anonymous only if the external system doesn’t require authentication. 4. Select the authentication protocol. • If you select Password Authentication, enter the username and password for accessing the external system. • If you select OAuth 2.0, complete the following fields. Field Description Authentication Choose the provider. See Authentication Providers. Provider 888 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Field Description Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter. Note: – The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider. – Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen. – We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system. Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status. 5. Click Save. 6. Click Validate and Sync, and confirm that the connection is successful. 7. Optionally, select tables and click Sync to do the following for each selected table. • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type. Note: Before you sync, make sure that you understand the considerations that are described in these topics. • Sync an External Data Source for Salesforce Connect on page 858 • Sync Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter on page 894 You can instead choose to manually create the external objects and custom fields that map to the external data. Doing so lets you customize the external object names, decide which table columns to create custom fields for, and customize the custom field names. However, this approach takes longer and requires manual maintenance. Optionally, you can associate custom HTTP headers to the external data source to retrieve or request additional data. SEE ALSO: Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Store Authentication Settings for External Systems OData Query String Options OData Type Mapping Named Credentials 889 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Define Custom HTTP Headers for OData Connectors Define and activate custom HTTP headers to pass more request information to the external data EDITIONS source for processing. Custom HTTP headers provide context information from Salesforce such as region, org details, or Available in: both Salesforce the role of the person viewing the external object. For each OData external data source, define up Classic (not available in all 10 HTTP headers to request or data. For example, to see who’s making a callout to the external data orgs) and Lightning source, use a formula that resolves to the name of the user. Experience When naming the custom HTTP header, don’t override the following existing standard header Available with Salesforce names. Connect, which is available in: Developer Edition and for • Content-Type an extra cost in: Enterprise, • Accept Performance, and • maxVersionHeader Unlimited Editions • versionHeader • X-HTTP-METHOD USER PERMISSIONS • Content-Length To create and edit external • X-CSRF-Token (when CSRF-enabled) data sources: • Prefer (when a trigger on the external object is enabled) • Customize Application • Cookie 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. 2. Click the name of an OData 2.0 or 4.0 data source. 3. In the External Custom HTTP Headers related list, click New to create a custom HTTP header or Edit to change an existing one. 4. Complete the fields. Field Description Header Field Name Enter a name that contains at least one alphanumeric character or underscore. It can also include: ! # $ % & ' * + - . ^ _ ` | ~ Header Field Value Create a formula for the Header Field Value using the formula editor. The values in the formula must evaluate to a string. If the formula resolves to null and an empty string, the header isn’t sent. Active To start using the header field right away, select the Active checkbox. Description A text description of the header field’s purpose. Parent The name of the entity that the custom HTTP header is related to. Note: A named credential as the parent entity for the custom HTTP header isn’t supported. 5. Click Save. Note: You can’t add or delete Custom HTTP headers that are included in a managed package. However, you can edit custom HTTP headers that are part of a managed package. The Header Name and Description fields are developer editable. The Active and Header Field Value fields are both subscriber and developer editable. 890 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Named Credential as Callouts for Salesforce Connect OData 2.0 or 4.0 Adapters This example shows how Salesforce Connect OData 2.0 or 4.0 adapters can make callouts using the authentication settings defined in a named credential. Define a named credential that specifies the endpoint URL and the JWT authentication settings. When you’re defining an external data source with an Odata 2.0 or Odata 4.0 adapter, specify the named credential you defined as the OData service root URL. In this example, the URL is callout:Test_named_credential. And skip the Authentication section for the external data source. To access the external system, Salesforce Connect uses the authentication settings defined in the named credential. SEE ALSO: Define a Named Credential Store Authentication Settings for External Systems Grant Access to Authentication Settings for Named Credentials 891 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the special behaviors, limits, and recommendations for using the OData 2.0 or 4.0 EDITIONS adapter for Salesforce Connect. Also review the considerations that apply to all Salesforce Connect adapters. Available in: both Salesforce Classic (not available in all orgs) and Lightning Lightning Experience Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Experience (not for Users can access external objects from the Lightning Experience app. But some requirements high-data-volume external and special behaviors apply when the external data is accessed via the OData 2.0 or 4.0 adapter objects) for Salesforce Connect. Available in: Developer Writable External Objects Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Edition Some special behaviors and limitations affect writable external objects that are associated with Available for an extra cost OData adapters for Salesforce Connect. in: Enterprise, Performance, Sync Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter and Unlimited Editions When you validate and sync an external data source of type Salesforce Connect: OData 2.0 or Salesforce Connect: OData 4.0, some special behaviors and limitations apply. OData Producer Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the limits and recommendations for the remote data service that exposes the external data to your Salesforce org. OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters An external object references data that’s stored outside Salesforce. Access to an external object involves a callout to its associated external system. Salesforce enforces rate limits for these callouts. High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters If your org hits rate limits when accessing external objects, consider selecting the High Data Volume option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. Socrata™ Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Socrata Open Data Protocol™ is commonly used for health data and for collaboration between governments and their citizens. Salesforce Connect can access data from endpoints that are backed by Socrata Open Data Portal. To accommodate Socrata-specific requirements, set the Special Compatibility field on the external data source to Socrata. CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the special behaviors, limitations, and recommendations for Cross-Site Request Forgery (CSRF) on OData external data sources. SEE ALSO: Salesforce Platform Features Supported by Salesforce Connect 892 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Lightning Experience Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Users can access external objects from the Lightning Experience app. But some requirements and EDITIONS special behaviors apply when the external data is accessed via the OData 2.0 or 4.0 adapter for Salesforce Connect. Available in: both Salesforce • If external object records don’t appear in your org, make sure that the OData producer doesn’t Classic and Lightning change the values specified in the OData query filters. When your org sends OData queries that Experience specify field values with the $filter equals (eq) operator, the OData producer must return Available in: Developer those same field values in the resulting data rows. Edition • If external object records don’t appear in relationship fields or related lists, check for case-sensitive Available for an extra cost values. For example, suppose that you set up an indirect lookup relationship. If the external in: Enterprise, Performance, system uses case-sensitive values in the specified External Column Name, make sure that the and Unlimited Editions parent object field is also case-sensitive. When you define the parent object’s custom field, select External ID, Unique, and Treat "ABC" and "abc" as different values (case sensitive). SEE ALSO: External Object Relationships OData Query String Options OData 2.0 or 4.0 Adapter for Salesforce Connect Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Writable External Objects Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Some special behaviors and limitations affect writable external objects that are associated with EDITIONS OData adapters for Salesforce Connect. • An external object custom field associated with an OData complex type on the external system Available in: both Salesforce is always read only, even if the external object is writable. Classic (not available in all • Writable external objects aren’t available for high-data-volume external data sources. orgs) and Lightning Experience (not for • If your external system requires write operations to specify values for entity keys, ensure that high-data-volume external External ID standard field values and entity key values don’t contradict each other. For objects) each write operation, include either the External ID standard field value or the custom field values that form the entity key, but never both. Available in: Developer Edition • When an external object record is edited, Salesforce Connect sends an HTTP request to the external system. Available for an extra cost in: Enterprise, Performance, – If the record is edited from the Salesforce user interface, the HTTP request includes all fields, and Unlimited Editions including the fields that weren’t changed. – If the record is edited from the API, only the specified fields are included in the HTTP request. • Make sure that the OData producer supports the HTTP methods that are used by your Salesforce Connect adapter. To Do This OData 4.0 Adapter Uses This HTTP Method OData 2.0 Adapter Uses This HTTP Method Create record POST POST Edit record POST with X-HTTP-METHOD header set to PATCH POST with X-HTTP-METHOD header set to MERGE Delete record DELETE DELETE 893 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect To Do This OData 4.0 Adapter Uses This HTTP Method OData 2.0 Adapter Uses This HTTP Method View record GET GET Also review the considerations that apply to all Salesforce Connect adapters. SEE ALSO: Writable External Objects in Salesforce Connect External IDs and OData Entity Keys OData 2.0 or 4.0 Adapter for Salesforce Connect Sync Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter When you validate and sync an external data source of type Salesforce Connect: OData EDITIONS 2.0 or Salesforce Connect: OData 4.0, some special behaviors and limitations apply. Available in: both Salesforce • Syncing always enables search on the external object when search is enabled on the external Classic (not available in all data source, and vice versa. orgs) and Lightning Experience (not for • For a list of supported OData types, see “OData Type Mapping” in Salesforce Help. high-data-volume external Important: When you select the tables to sync, determine whether check marks appear in objects) the Synced column. Available in: Developer If a Synced check mark appears, your org has an external object whose object name matches Edition the table name. If you select the table and click Sync: Available for an extra cost • The external object is overwritten. in: Enterprise, Performance, and Unlimited Editions • Any custom field on the external object is overwritten if its API name (for example, Email__c) associates it with a table column name (for example, Email). • Any other custom fields on the external object remain as they are, including: – Previously synced custom fields whose API names were changed by editing their Field Name values. – Manually added custom fields whose API names aren’t associated with table column names. If no Synced check mark appears, and you sync the table, a new external object is created in your org. The new external object’s object name matches the table name. For example, if the table name is changed on the external system to no longer match the object name of the external object, syncing that table creates a new external object in Salesforce. We recommend that you change the object name of the existing external object to match the new table name on the external system before you sync that table. 894 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Also review the considerations that apply to all Salesforce Connect adapters. SEE ALSO: Sync an External Data Source for Salesforce Connect Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter OData 2.0 or 4.0 Adapter for Salesforce Connect OData Type Mapping OData Producer Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the limits and recommendations for the remote data service that exposes the external EDITIONS data to your Salesforce org. • Validate your OData producer by using the Open Data Protocol Service Validation Tool at Available in: both Salesforce services.odata.org/validation. Doing so checks your implementation against Classic and Lightning the OData specification and identifies potential issues. Experience • To improve performance over low-bandwidth connections, set up your OData producer to Available in: Developer receive gzip-compressed data. Then, in the external data source definition in Salesforce, select Edition Compress Requests. You can also set up the OData producer to send gzip-compressed data Available for an extra cost to Salesforce, which automatically accepts gzip-compressed responses. in: Enterprise, Performance, • By default, Salesforce sends each OData request with one of the following system query options and Unlimited Editions so that the response includes the total row count of the result set. – $inlinecount=allpages for the OData 2.0 adapter – $count=true for the OData 4.0 adapter Some external systems don’t support these system query options. If you receive errors or notice long load times when you try to access their data, deselect Request Row Counts on the external data source. If you do so, however, the external data source and its associated external objects can’t support the following functionality, which requires the total row count. – SOQL COUNT() aggregate function – Batch Apex with Database.QueryLocator For details about OData URI conventions, go to www.odata.org. • Configure your OData producer to use a page size that’s large enough to avoid excessive round trips. Querying a large set of data with a small page size can take a long time because of network latency. Salesforce pages that display external data can take a long time to load. For example, if the query results include 100 records, and the page size holds only 5 records, it takes 20 round trips to retrieve the results. If the network latency is 100 ms per round trip, it takes 2 seconds (20 × 100 ms) to retrieve the results. In contrast, if the page size holds 20 records, it takes only five round trips to retrieve the 100 records. With the same network latency of 100 ms per round trip, it takes 0.5 seconds (5 × 100 ms) to retrieve the results. • For a list of supported OData types, see “OData Type Mapping” in Salesforce Help. • If your external data source uses the OData 4.0 adapter and JSON format, make sure that the OData producer accepts headers that contain the odata.metadata=full format parameter. Other variations, including odata.metadata=minimal, aren’t supported. 895 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect • If external object records don’t appear in your org, make sure that the OData producer doesn’t change the values specified in the OData query filters. When your org sends OData queries that specify field values with the $filter equals (eq) operator, the OData producer must return those same field values in the resulting data rows. SEE ALSO: OData 2.0 or 4.0 Adapter for Salesforce Connect OData Query String Options OData Type Mapping OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters An external object references data that’s stored outside Salesforce. Access to an external object EDITIONS involves a callout to its associated external system. Salesforce enforces rate limits for these callouts. An org is limited to: Available in: both Salesforce Classic (not available in all • 20,000 OData callouts per hour for Enterprise, Performance, and Unlimited editions. If you require orgs) and Lightning higher limits, create a support case. Experience (not for • 1,000 OData callouts per hour for Developer Edition. high-data-volume external • 100k new external object record IDs per hour for long-term ID mapping objects) • 100k new external object record IDs per hour for short-term ID mapping Available in: Developer Edition Note: To view external object records in Lightning Experience, Salesforce Connect maps the external IDs of the record to Salesforce IDs. Mappings classified as short-term refer to records Available for an extra cost retrieved via Search results only. Mappings classified as long-term refer to records retrieved in: Enterprise, Performance, by all other Lightning Experience components, such as List Views. Record IDs not viewed in and Unlimited Editions 365 days are subject to deletion unless the mappings have customer data attached to them. To obtain your org’s limits and current usage against those limits, use the Limits resource in the Lightning Platform REST API. Salesforce performs an OData callout each time that: • A user clicks an external object tab for a list view. • A user views a record detail page of an external object. • A user views a record detail page of a parent object that displays a related list of child external object records. • A user performs a Salesforce global search. • A user creates, edits, or deletes an external object record. • A user runs a report. • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. If your users or applications encounter rate limit errors for OData callouts, try one or more of the following. • Select High Data Volume in the external data source definition. Doing so bypasses most rate limits, but some special behaviors and limitations apply. • Run fewer SOQL and SOSL queries. • If you have Apex code that invokes the external system, modify that code to cache frequently accessed external data that seldom changes. 896 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect • Contact Salesforce to request a higher limit. SEE ALSO: REST API Developer Guide : List Organization Limits High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData 2.0 or 4.0 Adapter for Salesforce Connect Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters High Data Volume Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters If your org hits rate limits when accessing external objects, consider selecting the High Data Volume EDITIONS option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. Available in: both Salesforce • The following features aren’t available for external objects that are associated with Classic (not available in all high-data-volume external data sources. orgs) and Lightning Experience (not for – Access via Lightning Experience high-data-volume external – Access via the Salesforce mobile app objects) – Appearance in Recent Items lists Available in: Developer – Record feeds Edition – Reports and dashboards Available for an extra cost – Writable external objects in: Enterprise, Performance, and Unlimited Editions • Salesforce IDs aren’t assigned to external object records that are associated with high-data-volume external data sources. • On record detail pages for external objects that are associated with high-data-volume external data sources, custom buttons, and links that call JavaScript aren’t supported. • Salesforce Console in Salesforce Classic doesn’t support external objects that are associated with high-data-volume external data sources. • CSRF protection for writable external objects isn’t available for high-data-volume external data sources. SEE ALSO: REST API Developer Guide : List Organization Limits OData Callout Rate Limit Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter 897 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Socrata™ Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters ™ Socrata Open Data Protocol is commonly used for health data and for collaboration between EDITIONS governments and their citizens. Salesforce Connect can access data from endpoints that are backed by Socrata Open Data Portal. To accommodate Socrata-specific requirements, set the Special Available in: both Salesforce Compatibility field on the external data source to Socrata. Classic (not available in all Socrata doesn’t support the row identifier (_id) column in $select or $orderby clauses in orgs) and Lightning OData queries. When Socrata is selected in the Special Compatibility field: Experience (not for high-data-volume external • OData queries don’t include the _id column in $select clauses. objects) • If an _id column is synced from a Socrata endpoint, the resulting custom field on the external Available in: Developer object isn’t sortable. Edition • If you manually define an external object’s custom field with _id as the External Column Available for an extra cost Name, make sure that you select the Sorting Disabled attribute for that custom field. in: Enterprise, Performance, If you modify the Special Compatibility field on an external data source, we recommend and Unlimited Editions that you resync its external objects. Or instead, you can test whether queries or user access to the external objects result in errors, and resync only the problematic external objects. SEE ALSO: Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters CSRF Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters Understand the special behaviors, limitations, and recommendations for Cross-Site Request Forgery EDITIONS (CSRF) on OData external data sources. • CSRF protection isn’t available for high-data-volume external data sources. Available in: both Salesforce • Make sure that the URL of the external data source starts with https:// so that secure HTTP Classic (not available in all can prevent unauthorized access to the anti-CSRF token and cookie. orgs) and Lightning Experience (not for • In addition to enabling CSRF protection on the external data source, we recommend keeping high-data-volume external CSRF protection enabled in your org’s session security settings. These session settings are objects) enabled by default, and keeping them enabled protects your Salesforce data and your external data from CSRF attacks. Available in: Developer Edition – Enable CSRF protection on GET requests on non-setup pages Available for an extra cost Enable CSRF protection on POST requests on non-setup pages – in: Enterprise, Performance, and Unlimited Editions SEE ALSO: Define an External Data Source for Salesforce Connect—OData 2.0 or 4.0 Adapter Modify Session Security Settings 898 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Picklist Considerations for Salesforce Connect—OData 2.0 or 4.0 Adapter Special behaviors and limitations apply to picklist fields on external objects. EDITIONS • Global and local single-select picklists are supported. • You must manually update picklist values to stay in sync between your org and the external Available in: both Salesforce system. If values are not in sync, your users could see an error message when viewing the field. Classic (not available in all orgs) and Lightning – Add values to the picklist as you would a picklist on a custom object. Experience (not for – Remove a value from a picklist by deactivating the value rather than deleting it. high-data-volume external – Replace a value by deactivating it and then adding the new value. Update the external objects) system’s record values to the new value on the external system. Available in: Developer Edition • Convert existing external object text fields to picklists by deleting and recreating. Delete the text field and create a picklist pointing to the text field’s existing External Column Name. Available for an extra cost in: Enterprise, Performance, • If you select to delete, you might be prompted to replace the value with another value. No and Unlimited Editions replace occurs for external object record values. You must manually change the values on the external system. • We recommend having only unrestricted picklists on external objects, even when they’re associated with restricted picklists on the provider org. Restricted picklists on the provider org block unapproved values from the subscriber org, eliminating the need to restrict picklists on external objects. SEE ALSO: Picklist Considerations for Salesforce Connect—Cross-Org Adapter OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Get to know the Salesforce implementation of the Open Data Protocol (OData) for accessing external EDITIONS systems with Salesforce Connect. Available in: both Salesforce OData Type Mapping Classic (not available in all Salesforce Connect maps OData types to Salesforce metadata field types when syncing metadata orgs) and Lightning and converting values between Salesforce and external systems. Experience (not for high-data-volume external OData Query String Options objects) The OData adapters for Salesforce Connect use a subset of the OData 2.0 and 4.0 system functions and filter expression constructs to query external systems. Available in: Developer Edition Available for an extra cost SEE ALSO: in: Enterprise, Performance, OData 2.0 or 4.0 Adapter for Salesforce Connect and Unlimited Editions 899 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect OData Type Mapping Salesforce Connect maps OData types to Salesforce metadata field types when syncing metadata EDITIONS and converting values between Salesforce and external systems. Available in: both Salesforce OData 2.0 Type Mapping Classic (not available in all Understand how the OData 2.0 adapter for Salesforce Connect maps OData types to Salesforce orgs) and Lightning metadata field types. Experience (not for high-data-volume external OData 4.0 Type Mapping objects) Understand how the OData 4.0 adapter for Salesforce Connect maps OData types to Salesforce metadata field types. Available in: Developer Edition Available for an extra cost in: Enterprise, Performance, and Unlimited Editions OData 2.0 Type Mapping Understand how the OData 2.0 adapter for Salesforce Connect maps OData types to Salesforce EDITIONS metadata field types. Salesforce Connect supports only the following types when syncing metadata and converting Available in: both Salesforce values between Salesforce and an external system. Classic (not available in all orgs) and Lightning Experience (not for OData 2.0 Primitive Types high-data-volume external objects) OData 2.0 Type Salesforce Metadata Field Type Available in: Developer Binary TextArea Edition Boolean Checkbox Available for an extra cost in: Enterprise, Performance, Byte Number and Unlimited Editions DateTime DateTime DateTimeOffset DateTime Decimal Number Double Number Guid Text Int16 Number Int32 Number Int64 Number SByte Number Single Number 900 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect OData 2.0 Type Salesforce Metadata Field Type String Depends on the declared maximum length of the OData string column. OData Declared Maximum Salesforce Field Type Salesforce Field Length Length Attribute Not declared Text 128 characters 255 or fewer characters Text Same as declared More than 255 characters LongTextArea Same as declared Time Text Tip: A binary value from an external system is represented in Salesforce as a base64-encoded string. You can convert it to a value of type Blob by using the EncodingUtil.base64Decode(inputString) Apex method. OData 2.0 Complex Types Salesforce Connect supports OData complex types as follows. • External data of complex type is flattened into a string that contains field names and values. For example, an address is flattened into the following string. Street: 55 East 5th Street, City: New York, State: NY, Zip: 10003 • An external object custom field associated with an OData complex type on the external system is always read only, even if the external object is writable. SEE ALSO: Sync an External Data Source for Salesforce Connect Custom Field Types Custom Field Attributes OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Apex Developer Guide : EncodingUtil Class: base64Decode(inputString) 901 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect OData 4.0 Type Mapping Understand how the OData 4.0 adapter for Salesforce Connect maps OData types to Salesforce EDITIONS metadata field types. Salesforce Connect supports only the following types when syncing metadata and converting Available in: both Salesforce values between Salesforce and an external system. Classic (not available in all orgs) and Lightning Experience (not for OData 4.0 Primitive Types high-data-volume external objects) OData 4.0 Type Salesforce Metadata Field Type Available in: Developer Binary TextArea Edition Boolean Checkbox Available for an extra cost in: Enterprise, Performance, Byte Number and Unlimited Editions Date DateTime with time properties set to 0 DateTimeOffset DateTime Decimal Number Double Number Guid Text Int16 Number Int32 Number Int64 Number SByte Number Single Number String Depends on the declared maximum length of the OData string column. OData Declared Salesforce Field Salesforce Field Maximum Length Type Length Attribute Not declared Text 128 characters 255 or fewer Text Same as declared characters More than 255 LongTextArea Same as declared characters Tip: A binary value from an external system is represented in Salesforce as a base64-encoded string. You can convert it to a value of type Blob by using the EncodingUtil.base64Decode(inputString) Apex method. 902 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect OData 4.0 Complex Types Salesforce Connect supports OData complex types as follows. • External data of complex type is flattened into a string that contains field names and values. For example, an address is flattened into the following string. Street: 55 East 5th Street, City: New York, State: NY, Zip: 10003 • An external object custom field associated with an OData complex type on the external system is always read only, even if the external object is writable. SEE ALSO: Sync an External Data Source for Salesforce Connect Custom Field Types Custom Field Attributes OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Apex Developer Guide : EncodingUtil Class: base64Decode(inputString) OData Query String Options The OData adapters for Salesforce Connect use a subset of the OData 2.0 and 4.0 system functions EDITIONS and filter expression constructs to query external systems. When your users or the Lightning Platform interact with external objects, the OData 2.0 or 4.0 Available in: both Salesforce adapter for Salesforce Connect converts those actions into OData queries. Salesforce performs an Classic (not available in all OData callout each time that: orgs) and Lightning Experience (not for • A user clicks an external object tab for a list view. high-data-volume external • A user views a record detail page of an external object. objects) • A user views a record detail page of a parent object that displays a related list of child external Available in: Developer object records. Edition • A user performs a Salesforce global search. Available for an extra cost • A user creates, edits, or deletes an external object record. in: Enterprise, Performance, • A user runs a report. and Unlimited Editions • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. The following sections describe the Salesforce Connect implementation as a consumer of OData services. Salesforce automatically creates the OData queries so that you, as an administrator or developer, don’t have to. However, understanding how OData queries are generated—or even attempting manual OData queries—can help you troubleshoot issues with the external system’s OData producer. For details about each system query option, go to www.odata.org. Salesforce Connect supports only the following OData system query options. All other options in the OData 2.0 and 4.0 specifications are unused. • $count (OData 4.0 only) on page 904 • $filter on page 904 • $inlinecount (OData 2.0 only) on page 904 903 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect • $orderby on page 905 • $search (OData 4.0 only) on page 905 • $select on page 905 • $skip on page 906 • $top on page 906 A query search string to an external system is sent as a case-sensitive single phrase after removing all ASCII punctuation characters except hyphens (-). For example, if the search string is Sales & Marketing, the external system receives Sales Marketing. $count (OData 4.0 only) Specifies that the response must include the number of rows that the URI identifies after $filter system query options are applied, but before $top and $skip system query options are applied. When Request Row Counts is enabled on the external data source, Salesforce includes $count=true in all OData 4.0 queries of that external data source to determine the total number of items in each result set. The total items in the result set is the same as the LIMIT value in the query for values less than 202. If the LIMIT value is greater than 202, then 202 items are returned to indicate that more records exist in the next batch. If Request Row Counts is disabled, Salesforce includes $count=false in all OData 4.0 queries of the external data source, and 2000 items are returned in each result set. Examples User action in View or access an external object. Salesforce SOQL query Any SOQL query of an external object Resulting OData http://services.example.org/my.svc/Suppliers?$select=SupplierID& query $count=true&$top=26 $filter Filters the collection of resources that’s addressed by a request URL. The response contains the results that evaluate to true. Examples User action in Open a list view of cities from supplier records that are filtered so that the country is USA. Salesforce SOQL query SELECT City__c FROM Suppliers__x WHERE Country__c = 'USA' ORDER BY City__c ASC LIMIT 26 Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=City& query $select=City,SupplierID&$inlinecount=allpages&$filter=Country+eq+'USA'& $top=26 $inlinecount (OData 2.0 only) Specifies that the response must include a count of the number of rows that the URI identifies after $filter system query options are applied but before $top and $skip system query options are applied. 904 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect When Request Row Counts is enabled on the external data source, Salesforce uses $inlinecount in all OData 2.0 queries of that external data source to determine the total number of items in each result set. If Request Row Counts is disabled, $inlinecount is excluded from all OData 2.0 queries of the external data source. Examples User action in View or access an external object. Salesforce SOQL query Any SOQL query of an external object. Resulting OData http://services.example.org/my.svc/Suppliers?$select=SupplierID& query $inlinecount=allpages&$top=26 $orderby Sorts the result set in ascending or descending order. The fields in the ORDER BY clause of the SOQL query don't always match the properties used by the $orderby option in the resulting OData query. If you use the OFFSET clause in the SOQL query, the entity key property is added in the resulting OData query. Examples User action in Open a list view of supplier records that are ordered by company name. Salesforce SOQL query SELECT CompanyName__c,ContactName__c FROM Suppliers__x ORDER BY CompanyName__c ASC LIMIT 26 Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=CompanyName& query $select=CompanyName,ContactName,SupplierID&$inlinecount=allpages&$top=26 $search (OData 4.0 only) Requests entities that match the search query string as a free-text search expression. Enable this option by selecting Use Free-Text Search Expressions on the external data source. By default, Use Free-Text Search Expressions is not enabled. The search query string is used as the contains value in the $filter system query option. Examples User action in View or access an external object. Salesforce SOQL query Any SOQL query of an external object Resulting OData http://services.example.org/my.svc/Shippers? query $select=CompanyName,Phone,ShipperID&$count=true&$search=Acme&$top=25 $select Requests a limited set of properties for each entity. 905 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Examples User action in Open a list view of supplier records where the page layout displays the company name and contact name. Salesforce SOQL query SELECT CompanyName__c,ContactName__c FROM Suppliers__x ORDER BY CompanyName__c ASC LIMIT 26 Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=CompanyName& query $select=CompanyName,ContactName,SupplierID&$inlinecount=allpages&$top=26 $skip Specifies the number of items in the queried collection to skip in the result set. Examples User action in Click to view the second page of a list view of supplier records that are ordered by city. Salesforce SOQL query SELECT City__c,CompanyName__c FROM Suppliers__x ORDER BY City__c ASC OFFSET 25 Resulting OData http://services.example.org/my.svc/Suppliers?$orderby=City& query $select=City,CompanyName,SupplierID&$inlinecount=allpages&$top=25& $skip=25 $top Specifies the number of items in the queried collection to include in the result. The value in the LIMIT clause of a SOQL query doesn’t always match the requested $top value, because the latter is modified as needed for client-driven paging and queryMore() calls. Examples User action in Open a list view of the top 25 supplier records. Salesforce SOQL query SELECT SupplierID__c FROM Suppliers__x LIMIT 25 Resulting OData http://services.example.org/my.svc/Suppliers?$select=SupplierID& query $inlinecount=allpages&$top=25 OData 2.0 Query Options By default, the search query string is used as the substringof value in the $filter system query option. 906 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect OData 4.0 Query Options By default, the search query string is used as the contains value in the $filter system query option. SEE ALSO: OData Producer Considerations for Salesforce Connect—OData 2.0 and 4.0 Adapters OData Reference for Salesforce Connect—OData 2.0 and 4.0 Adapters Client-driven and Server-driven Paging for Salesforce Connect—OData 2.0 and 4.0 Adapters OData 2.0 Query Options By default, the search query string is used as the substringof value in the $filter system EDITIONS query option. In this example, the search query string is Acme. Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience (not for high-data-volume external objects) Available in: Developer Edition Available for an extra cost in: Enterprise, Performance, and Unlimited Editions http://services.example.org/my.svc/Shippers? $select=CompanyName,Phone,ShipperID&$inlinecount=allpages& $filter=substringof('Acme',CompanyName)+eq+true+ or+substringof('Acme',Phone)+eq+true&$top=25 OData 2.0 Custom Query Option We recommend that you set up the OData producer to support free text search expressions with the custom query option. You can then specify the name of the query string parameter in the Custom Query Option for Salesforce Search field on the external data source. In this example, the custom query parameter is doSearch and the search query string is Acme. http://services.example.org/my.svc/Shippers? $select=CompanyName,Phone,ShipperID& $inlinecount=allpages&doSearch=Acme&$top=25 Learn more about OData URI conventions at www.odata.org. 907 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect OData 4.0 Query Options By default, the search query string is used as the contains value in the $filter system query EDITIONS option. In the following example, the search query string is Acme. Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience (not for high-data-volume external objects) Available in: Developer Edition Available for an extra cost in: Enterprise, Performance, and Unlimited Editions http://services.example.org/v4.svc/Shippers? $select=CompanyName,Phone,ShipperID&$count=true& $filter=contains(CompanyName,'Acme') eq true or contains(Phone,'Acme') eq true$top=25& OData 4.0 Custom Query Option We recommend that you set up the OData producer to support free text search expressions with the $search system query option. You can then select Use Free-Text Search Expressions on the external data source. http://services.example.org/v4.svc/Shippers? $select=CompanyName,Phone,ShipperID&$count=true& $search=Acme&$top=25 Learn more about OData URI conventions at www.odata.org. Use External Change Data Capture to Track Data Changes on External Objects With External Change Data Capture, you can track changes to data that is stored outside your Salesforce org when using the Odata 4.0 adapter. You can then build automation in response to the changes to increase productivity or provide a better customer experience. The external data change tracking feature polls the external system at configurable intervals (5–30 minutes) for tracked changes. For each external object that has the feature enabled, a topic channel and an associate change event entity are created where change event notifications are published. You add a subscriber to each topic channel and then process the data changes through Streaming API. You can also add an Apex trigger that is called when change event notifications are published. External Change Data Capture Considerations Keep these considerations in mind when working with External Change Data Capture. Enable External Change Data Capture and Tracking Enable external change data capture for the data source and each external object that you want to monitor. 908 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Subscribe to Change Events You can use Apex triggers to subscribe to change events. Or you can use a Bayeux client to subscribe to Streaming API on the publication channel. Check the External Change Data Capture Status for an External Object You can quickly check the change-tracking status from an external object’s detail page. More detailed monitoring is also available. Change the Polling Interval for External Change Data Capture By default, the external change data capture feature polls the external system every 30 minutes for tracked changes. You can change the interval to poll the external system as frequently as every 5 minutes. Monitor and Troubleshoot External Change Data Capture Check these tips when troubleshooting change tracking on external objects. Example: How Codey Outfitters Uses External Change Data Capture The fictitious company, Codey Outfitters, distributes outdoor equipment from local small businesses to outdoor enthusiasts around the world. The company handles all logistics, such as complying with import laws for each state and country. External Change Data Capture Considerations Keep these considerations in mind when working with External Change Data Capture. • Each polling request counts toward your Salesforce org’s OData callout rate allocation. • OData doesn’t differentiate between created and updated change events. Both events are published with update change type. • When you enable change tracking, a $top=0 query for zero rows is sent to the external data source to tell it to track changes, and a delta link is returned. • If an error occurs, Salesforce stops sending polling requests. You can check for an error status by querying the BackgroundOperation object or viewing the latest error on the object’s setup page. • If you create an Apex trigger to respond to change events, these requirements and behaviors apply. – Create the Apex trigger with development tools, such as the Developer Console or Metadata API or Salesforce UI. You can’t create the trigger from the Salesforce UI. – Because the Apex trigger runs after an event occurs, only the after-insert trigger event is supported. – The trigger passes the associated change event, not the object that caused the change. – Changed records can be committed in the same transaction that started the trigger. However, keep in mind that this transaction is separate from the transaction that created the original event. Enable External Change Data Capture and Tracking Enable external change data capture for the data source and each external object that you want USER PERMISSIONS to monitor. 1. From Setup, enter External Data Sources in the Quick Find box, then select External To create or edit external Data Sources. objects: • Customize Application 2. Click Edit, and select Eligible for External Change Data Capture. 3. Click Save. 4. From the External Objects list , select the external object that you want to track. 5. Click Edit, and select Track Data Changes. 6. Click Save. 909 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect After you enable change tracking, a publication channel is created under the topic for the external object. For example, /data/Object Name__ChangeEvents appears as /data/Products__ChangeEvents, where Product is the object name. Subscribe to Change Events You can use Apex triggers to subscribe to change events. Or you can use a Bayeux client to subscribe to Streaming API on the publication channel. After subscribing, you can observe change event notifications when you perform a DML operation on an external object. You can also see change events on the tracked data stored on the external system. Check the External Change Data Capture Status for an External Object You can quickly check the change-tracking status from an external object’s detail page. More USER PERMISSIONS detailed monitoring is also available. 1. From Setup, enter External Objects in the Quick Find box, then select External Objects. To create or edit external objects: 2. Click the label of the external object. • Customize Application The External Change Data Capture Status field shows one of the following statuses. • Disabled—Either the data source or the external object doesn’t have external change data capture enabled. • Error—External change data capture encountered an error in the last poll for changes and stopped. After resolving the error, restart external change data capture. • Running—External change data capture is running and polls the external system in the configured time interval for changes. • Stopped—External change data capture is not scheduled to poll for changes. Change the Polling Interval for External Change Data Capture By default, the external change data capture feature polls the external system every 30 minutes for tracked changes. You can change the interval to poll the external system as frequently as every 5 minutes. 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. 2. Next to the name of the external data source, click Edit. 3. In the Polling Interval for External Change Data Capture field, enter the number of seconds between polling. 4. Click Save. Monitor and Troubleshoot External Change Data Capture Check these tips when troubleshooting change tracking on external objects. • To check the status of external data change tracking, query the BackgroundOperation object. • Each BackgroundOperation record is available for inspection for one day. You can include the ExpiresAt field in your SOQL query of the BackgroundOperation object to check when the record expires. • Set up and view debug logs. Example: How Codey Outfitters Uses External Change Data Capture The fictitious company, Codey Outfitters, distributes outdoor equipment from local small businesses to outdoor enthusiasts around the world. The company handles all logistics, such as complying with import laws for each state and country. 910 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Over the years, Codey Outfitters has acquired different IT systems to manage orders, shipments, inventory, and billing. It uses Salesforce CRM to manage its customer base and the suppliers whose items it sells. Codey Outfitters wants to provide customers with a one-stop shopping portal where they can see price changes on the gear. When the inventory is updated, Codey Outfitters wants the change notifications sent to its Salesforce org. Salesforce then performs business logic to determine whether the updates include price changes that are valuable to customers based on their order history. Customers can see or be notified about relevant deals on their Codey Outfitters portal. Let’s see how Codey Outfitters sets up and uses external change data capture to accomplish these goals. Set Up the External Data Source and the External Object Codey Outfitters has an OData 4.0 service for its inventory. The company connects its Salesforce org to the inventory by creating an external data source called Gear Inventory and creating an external object called Products. Monitor External Change Data Capture With external change data capture enabled, Codey Outfitters’ org polls the external system every 30 minutes. To monitor the tracking status, it queries the BackgroundOperation object. Codey Outfitters prefers to run SOQL queries in the Query Editor of the Developer Console, but you can use your preferred tool. Subscribe to Changes with Streaming API When Codey Outfitters runs its Bayeux client, the client subscribes to Streaming API on the products publication channel. React to Changes with Apex Triggers To automate your business with external change events, use Apex triggers. Set Up the External Data Source and the External Object Codey Outfitters has an OData 4.0 service for its inventory. The company connects its Salesforce org to the inventory by creating an external data source called Gear Inventory and creating an external object called Products. The Products external object provides the following data. • Name (product name) • UnitPrice (current price) • Stock (number of items in stock) • OrderLimit (limit for each order) To track changes, Codey Outfitters selects Eligible for External Change Data Capture for the Gear Inventory external data source. It then enables Track Data Changes on the Products external object. Monitor External Change Data Capture With external change data capture enabled, Codey Outfitters’ org polls the external system every 30 minutes. To monitor the tracking status, it queries the BackgroundOperation object. Codey Outfitters prefers to run SOQL queries in the Query Editor of the Developer Console, but you can use your preferred tool. Here’s the SOQL query that Codey Outfitters uses to monitor the tracking status. SELECT Id,Name,SubmittedAt,StartedAt,FinishedAt,ProcessAfter,Status FROM BackgroundOperation WHERE WorkerUri='v45.0/xds/data-changes' In the query results, the first row shows the initial callout to the external system. The initial request tells the OData producer to start tracking changes on the Products__x object. In the second row, the org schedules the next callout to request the tracked changes. Notice that the callout is scheduled to occur after 30 minutes have passed. 911 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect ID Name Submitted Started Finished Process After Status 08Pxx0000000019EAA Products__x 2017-10-06T01:11:04.000Z 2017-10-06T01:11:08.000Z 2017-10-06T01:11:08.000Z Complete 08Pxx000000000qEAA Products__x 2017-10-06T01:11:08.000Z 2017-10-06T01:41:08.000Z Waiting After waiting 30 minutes, querying the BackgroundOperation object shows that the second callout finishes, and the status is Complete. In the third row, a new change request is scheduled to run after 30 more minutes have passed. ID Name Submitted Started Finished Process After Status 08Pxx0000000019EAA Products__x 2017-10-06T01:11:04.000Z 2017-10-06T01:11:08.000Z 2017-10-06T01:11:08.000Z Complete 08Pxx000000000qEAA Products__x 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:08.000Z Complete 08Pxx000000002MEAQ Products__x 2017-10-06T01:41:09.000Z 2017-10-06T02:11:09.000Z Waiting Suppose that the Codey Outfitters inventory has a service outage, preventing the scheduled poll request from succeeding. Errors cause change tracking to stop, so querying the BackgroundOperation object shows the error status and no new rows. ID Name Submitted Started Finished Process After Status 08Pxx0000000019EAA Products__x 2017-10-06T01:11:04.000Z 2017-10-06T01:11:08.000Z 2017-10-06T01:11:08.000Z Complete 08Pxx000000000qEAA Products__x 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z 2017-10-06T01:41:09.000Z Complete 08Pxx000000002MEAQ Products__x 2017-10-06T01:41:09.000Z 2017-10-06T02:12:07.000Z 2017-10-06T02:12:07.000Z 2017-10-06T02:11:09.000Z Error When query results show no rows in Waiting status, external change data capture is disabled. When the query results show an error, you can get error details by including the Error field in your SOQL query of the BackgroundOperation object. Here’s how Codey Outfitters investigates the error. SELECT Error FROM BackgroundOperation WHERE Id=’08Pxx000000002MEAQ’ Because a service outage caused the problem, the error message says: The external system is unreachable. Try again later, or contact your admin, who can verify the external data source settings and the external system's availability. Attempted to reach this URL: https://codey-outfitters.example.com/inventory/Products Codey Outfitters fixes the service outage and restarts change tracking on the Products__x object. Subscribe to Changes with Streaming API When Codey Outfitters runs its Bayeux client, the client subscribes to Streaming API on the products publication channel. Codey Outfitters uses a Visualforce page to show its customers updates to prices and inventory and new and discontinued outdoor gear. This sample source code for the Visualforce page is on Github, and you can modify it to work with your OData 4.0 producer. The heart of the subscription mechanism is in the _subscribeChannels method in src/js/channel/ServerConnection.js. cometd.subscribe(channelName, function(event) { if (event && event.data && event.data.payload && 912 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect event.data.payload.ChangeEventHeader) { var header = event.data.payload.ChangeEventHeader; var entityName = header.entityName; var recordId = header.recordIds[0]; var timestamp = header.commitTimestamp; var changeType = header.changeType; switch (changeType) { case "UPDATE": // Update logic ... break; case "CREATE": // Create logic break; case "DELETE": // Delete logic break; } } } The channelName for Codey Outfitters’ products is /data/Products__ChangeEvent. Each change event notification that’s published on the channel is in the Bayeux format and represents an updated record in the product inventory. The data.payload contains the change event data and includes a header that describes the nature of the change event. This sample event notification describes a change to a Codey Outfitters product record. { schema=”lswW55LyUCYeU7raSrmZ5A”, payload={ ChangeEventHeader={ commitUser=”005xx000001SvAn”, sequenceNumber=15, entityName=”Products__x”, changeType=”UPDATE”, changeOrigin=”Products?$deltaToken=3779”, transactionKey=”f158f145-a...”, commitTimestamp=1507759119826, recordIds=[“x03xx0000000008”] }, Name__c=”Camping Stove”, ExternalId=7801, UnitPrice__c=10.0, Stock__c=1500.0, OrderLimit__c=12.0, ProductId__c=7801.0 }, event={replayId=15} } Each change event notification has this structure. Field Description schema Versioned schema reference that defines the change event. 913 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Field Description payload Details about the change event. • ChangeEventHeader—Describes the nature of the data change event. • Record fields and values—The OData producer can also include fields that have no changed values. To see the current values, query the external object using the record ID in the change event header. event The replay ID that refers to the position of the event notification in the event stream on a channel. Each change event header contains these fields. Field Description commitUser User who publishes the event. sequenceNumber Change event sequence number. Each change occurs in the order in which it’s received. entityName API name of the external object. changeType Specifies whether a record was updated, created, or deleted. changeOrigin Delta link that’s used to request the change. The OData producer calculates the delta token while executing the previous change request. transactionKey Unique identifier for the transaction. commitTimestamp Specifies when the change event notification is published in milliseconds since January 1, 1970. recordIds Salesforce ID of the external object record that’s updated, created, or deleted. To see the current values of the record’s fields, query the external object using this record ID. nulledFields List of fields set to null. React to Changes with Apex Triggers To automate your business with external change events, use Apex triggers. Codey Outfitters can customize Salesforce to send email or SMS notifications on items that are low on stock or have been updated to an attractive price. Gear and other items that are in high demand can be monitored for low stock and automatically ordered. Before customizing Salesforce, make sure that you’re tracking data changes on the external object that you want to track. To track items that are running low on stock, Codey Outfitters creates an Apex trigger named LowOnStock. Next, the company selects the trigger’s sObject and the change event that publishes changes for the external object Products__x: Products__ChangeEvent. 914 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Here’s an example of a simple rule that sends a notification when an item is low on stock. trigger LowOnStock on Products__ChangeEvent (after insert) { // Get the change event’s product ID for added and updated products Set The product notifications class queries the external Product objects for the given changed product IDs and LowOnStock threshold value. Looking up the current Product records on the external system for qualifying products is a callout and is scheduled as an Apex future. public class ProductNotifications { // Notify subscribers on product updates that are low on stock. // This method is run asynchronously as it is performing a callout to the external // system to get the latest product details @future (callout=true) public static void notifyOnLowOnStockProductUpdates(Set // Get the external Product objects for each Product ID public static List // Notify subscribers by sending an email or SMS public static void notifySubscribers(String message, List You can discover the metadata for change events through the sObject describe API. For example, the sObject describe for Products__ChangeEvent shows the following standard change event fields. 915 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Field Type Description Id String The change event’s Salesforce ID. This ID isn’t the Salesforce ID of the record that changed, but the event that carries the record’s changes. ReplayId String The position of the event notification in the event stream on a channel. ChangeEventHeader Complex Type The type of data change event. Each change event object defines fields that hold the updated value at the time the record was updated. The OData producer can also include fields that haven’t changed. To see the current values, query the external object using the record ID in the change event header. The following table shows sample Products__x fields. Event change objects are tailored to their tracked external object. For a change event, not all fields are necessarily present. Field Type Description Id String Product record’s Salesforce ID in your org ExternalId String Product record’s external ID DisplayUrl String URL representing the record in the external system CreatedOn__c DateTime When the record was created in the external system UpdatedOn__c DateTime When the record was last updated on the external system Name__c String Product name in Product__x OrderLimit__c Integer Number of items that can be ordered at a time Stock__c Integer Number of items in stock UnitPrice__c Decimal(8,2) Item’s unit price The following fields are change event header complex type fields. To access ChangeEventHeader fields from Apex, use its getter method. For example, to access the field ChangeType, use eventObject.ChangeEventHeader.getChangeType(). Field Type Description commitUser String User who published the event. sequenceNumber Integer Change event sequence number. Each change is listed in the order in which it’s received. entityName String API name of the external object. 916 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Field Type Description changeType ChangeType enum Specifies whether a record was updated, created, or deleted. The enum values for external change events are Create, Update, and Delete. changeOrigin String Delta link that’s used to request the changes made since the previous or initial change request. The OData producer calculates the delta token while executing the previous change request. transactionKey String Unique identifier for the transaction. commitTimestamp Long Specifies when the change event notification is published in milliseconds since January 1, 1970. recordIds Array of type String Salesforce ID of the external object record that is updated, created, or deleted. To see the current values of the record fields, query the external object using this record ID. This array always has exactly one Salesforce ID. nulledFields Array of type String List of field names set to null. Access External Data with a Custom Adapter for Salesforce Connect Connect your users to any data anywhere by developing your own custom adapter with the Apex Connector Framework. Custom Adapter for Salesforce Connect Connect to any data anywhere for a complete view of your business. Use the Apex Connector Framework to develop a custom adapter for Salesforce Connect. Set Up Salesforce Connect to Access External Data with a Custom Adapter Let users view, search, and modify any data anywhere from within their Salesforce org. Considerations for Salesforce Connect—Custom Adapter Understand the special behaviors, limits, and recommendations for using a custom adapter for Salesforce Connect. 917 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Custom Adapter for Salesforce Connect Connect to any data anywhere for a complete view of your business. Use the Apex Connector EDITIONS Framework to develop a custom adapter for Salesforce Connect. Your users and the Lightning Platform interact with the external data via external objects. For each Available in: both Salesforce of those interactions, Salesforce Connect invokes methods in the Apex classes that compose the Classic (not available in all custom adapter. Salesforce invokes the custom adapter’s Apex code each time that: orgs) and Lightning Experience (not for • A user clicks an external object tab for a list view. high-data-volume external • A user views a record detail page of an external object. objects) • A user views a record detail page of a parent object that displays a related list of child external Available in: Developer object records. Edition • A user performs a Salesforce global search. Available for an extra cost • A user creates, edits, or deletes an external object record. in: Enterprise, Performance, • A user runs a report. and Unlimited Editions • The preview loads in the report builder. • An external object is accessed via flows, processes, APIs, Apex, SOQL, or SOSL. • You validate or sync an external data source. Apex code can access external objects, but some limitations and requirements apply. • To understand the limitations on Apex code accessing external objects, see Apex Considerations for Salesforce Connect External Objects. • To know how to use a custom adapter for Salesforce Connect, see Get Started with the Apex Connector Framework. External IDs for External Objects in Salesforce Connect—Custom Adapter When you access external data with a custom adapter for Salesforce Connect, the values of the External ID standard field on an external object come from the DataSource.Column named ExternalId. SEE ALSO: Salesforce Connect Set Up Salesforce Connect to Access External Data with a Custom Adapter Considerations for Salesforce Connect—Custom Adapter 918 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect External IDs for External Objects in Salesforce Connect—Custom Adapter When you access external data with a custom adapter for Salesforce Connect, the values of the EDITIONS External ID standard field on an external object come from the DataSource.Column named ExternalId. Available in: both Salesforce Each external object has an External ID standard field. Its values uniquely identify each Classic (not available in all external object record in your org. When the external object is the parent in an external lookup orgs) and Lightning relationship, the External ID standard field is used to identify the child records. Experience (not for high-data-volume external Important: objects) • The custom adapter’s Apex code must declare the DataSource.Column named Available in: Developer ExternalId and provide its values. Edition • Don’t use sensitive data as the values of the External ID standard field or fields designated Available for an extra cost as name fields, because Salesforce sometimes stores those values. in: Enterprise, Performance, – External lookup relationship fields on child records store and display the External ID and Unlimited Editions values of the parent records. – For internal use only, Salesforce stores the External ID value of each row that’s retrieved from the external system. This behavior doesn’t apply to external objects that are associated with high-data-volume external data sources. Example: This excerpt from a sample DataSource.Connection class shows the DataSource.Column named ExternalId. override global List SEE ALSO: Custom Adapter for Salesforce Connect Apex Developer Guide 919 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Set Up Salesforce Connect to Access External Data with a Custom Adapter USER PERMISSIONS EDITIONS To create Apex classes: Author Apex Available in: both Salesforce Classic (not available in all To configure remote settings: Modify All Data orgs) and Lightning To create and edit external data sources: Customize Application Experience (not for high-data-volume external To create and edit external objects: Customize Application objects) To define or change object-level help: Customize Application Available in: Developer To create and edit custom fields: Customize Application Edition Available for an extra cost To edit permission sets and user profiles: Manage Profiles and Permission Sets in: Enterprise, Performance, To edit another user’s authentication settings Manage Users and Unlimited Editions for external systems: Let users view, search, and modify any data anywhere from within their Salesforce org. Setting up Salesforce Connect with a custom adapter involves these high-level steps. 1. Develop the custom adapter for Salesforce Connect. Using the Apex Connector Framework, create the DataSource.Connection and DataSource.Provider classes that comprise the custom adapter. 2. Define remote sites for Apex callouts. If the custom adapter involves any Apex callouts, define each callout endpoint as a remote site in your organization. However, you don’t need to define a remote site for a callout whose endpoint is specified as a named credential instead of a URL. 3. Define an external data source of type Salesforce Connect: Custom. If you created multiple custom adapters, make sure that the external data source’s Type field specifies the correct DataSource.Provider class. 4. Create the external objects. Perform this task only if you don’t sync to automatically create the external objects. Create an external object for each external data table that you want to access from your Salesforce org. 5. Create help content for the external objects. Create Visualforce pages that describe the external data. When your users click Help for this Page on an external object, they read your custom help content. Remember, your users can’t find information about the external data in Salesforce Help. 6. Add custom fields and relationships to the external objects. Create relationships between objects. If you didn’t sync to automatically create the external objects and their fields, create a custom field for each external table column that you want to access from your Salesforce org. 7. Verify access to external object data. Check that expected user and code interactions with the external objects work, including sorting and filtering search and query results. 920 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Tip: After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results. 8. Enable user access to external objects. Grant object permissions through permission sets or profiles. 9. Enable user access to the fields on the external objects. Grant field permissions through permission sets or profiles. 10. If the external data source uses per-user authentication: a. Let users authenticate to the external system. Grant users access to authentication settings for the external data source through permission sets or profiles. b. Set up each user’s authentication settings. You or your users can perform this task. Tip: Train your users on how to set up their authentication settings for external systems. Make sure that they know which credentials to enter for each external system. If you’re using OAuth 2.0, test the OAuth flow for potentially confusing prompts or redirects, and train your users as needed. OAuth flows vary, depending on your external system, authentication provider, and specified scopes. SEE ALSO: Custom Adapter for Salesforce Connect Salesforce Platform Features Supported by Salesforce Connect Developer Guide: Visualforce Developer's Guide External Object Relationships Define an External Data Source for Salesforce Connect—Custom Adapter Connect your Salesforce org to any data anywhere via a Salesforce Connect custom adapter that EDITIONS you create with the Apex Connector Framework. Before you begin, develop the custom adapter for Salesforce Connect. If the custom adapter uses Available in: both Salesforce Apex callouts, also define remote sites for the callout endpoints. See Set Up Salesforce Connect to Classic and Lightning Access External Data with a Custom Adapter on page 920. Experience 1. From Setup, enter External Data Sources in the Quick Find box, then select Available in: Developer External Data Sources. Edition 2. Click New External Data Source, or click Edit to modify an existing external data source. Available for an extra cost in: Enterprise, Performance, 3. Complete the fields. and Unlimited Editions Field Description Label A user-friendly name for the external data source. The label is displayed USER PERMISSIONS in the Salesforce user interface, such as in list views. To create and edit external If you set Identity Type to Per User, this label appears when data sources: your users view or edit their authentication settings for external • Customize Application systems. 921 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Field Description Name A unique identifier that’s used to refer to this external data source definition through the API. The name can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. Type Select Salesforce Connect: Custom— URL URL of the external system. Available only when the DataSource.Provider class declares the REQUIRE_ENDPOINT capability. If the class also declares the REQUIRE_HTTPS capability, the URL must begin with https://. If the endpoint is defined in a named credential, enter the named credential URL. A named credential URL contains the scheme callout:, the name of the named credential, and an optional path. For example: callout:My_Named_Credential/some_path. You can append a query string to a named credential URL. Use a question mark (?) as the separator between the named credential URL and the query string. For example: callout:My_Named_Credential/some_path?format=json. Writable External Lets the Lightning platform and users in this org create, update, and delete records for external Objects objects associated with the external data source. The external object data is stored outside the org. By default, external objects are read only. High Data Volume Salesforce enforces rate limits for retrieving and viewing data from external systems. If your org hits rate limits when accessing external objects, consider selecting the High Data Volume option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. See High Data Volume Considerations for Salesforce Connect—Custom Adapters on page 926. Certificate If you specify a certificate, your Salesforce org supplies it when establishing each two-way SSL connection with the external system. The certificate is used for digital signatures, which verify that requests are coming from your Salesforce org. Available only when the DataSource.Provider class declares the CERTIFICATE authentication capability. Identity Type Determines whether you're using one set or multiple sets of credentials to access the external system. See Identity Type for External Data Sources on page 857. Available only when the DataSource.Provider class declares the BASIC or OAUTH authentication capability. 4. Select the authentication protocol. • If you select Password Authentication, enter the username and password for accessing the external system. 922 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Password authentication is available only when the DataSource.Provider class declares the BASIC authentication capability. • If you select OAuth 2.0, complete the following fields. OAuth 2.0 is available only when the DataSource.Provider class declares the OAUTH authentication capability. Field Description Authentication Choose the provider. See Authentication Providers. Provider Scope Specifies the scope of permissions to request for the access token. Your authentication provider determines the allowed values. See Use the Scope Parameter. Note: – The value that you enter replaces the Default Scopes value that’s defined in the specified authentication provider. – Whether scopes are defined can affect whether each OAuth flow prompts the user with a consent screen. – We recommend that you request a refresh token or offline access. Otherwise, when the token expires, you lose access to the external system. Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status. 5. Click Save. 6. Click Validate and Sync, and confirm that the connection is successful. This step also invokes the sync() method on the DataSource.Connection class to obtain the list of tables that you can sync to create external objects and their fields. 7. Optionally, select tables and click Sync to do the following for each selected table. • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type. Note: Before you sync, make sure that you understand the considerations that are described in these topics. • Sync an External Data Source for Salesforce Connect on page 858 • Sync Considerations for Salesforce Connect—Custom Adapter on page 927 923 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect You can instead choose to manually create the external objects and custom fields that map to the external data. Doing so lets you customize the external object names, decide which table columns to create custom fields for, and customize the custom field names. However, this approach takes longer and requires manual maintenance. SEE ALSO: Set Up Salesforce Connect to Access External Data with a Custom Adapter Store Authentication Settings for External Systems Named Credentials Considerations for Salesforce Connect—Custom Adapter Understand the special behaviors, limits, and recommendations for using a custom adapter for EDITIONS Salesforce Connect. Also review the considerations that apply to all Salesforce Connect adapters. Available in: both Salesforce Classic (not available in all orgs) and Lightning Apex Connector Framework Considerations for Salesforce Connect—Custom Adapter Experience (not for Understand the limits and considerations for creating Salesforce Connect custom adapters with high-data-volume external the Apex Connector Framework. objects) High Data Volume Considerations for Salesforce Connect—Custom Adapters Available in: Developer If your org hits rate limits when accessing external objects, consider selecting the High Data Edition Volume option on the associated external data sources. Doing so bypasses most rate limits, Available for an extra cost but some special behaviors and limitations apply. in: Enterprise, Performance, Writable External Objects Considerations for Salesforce Connect—Custom Adapters and Unlimited Editions Some special behaviors and limitations affect writable external objects that are associated with custom adapters for Salesforce Connect. Sync Considerations for Salesforce Connect—Custom Adapter When you validate and sync an external data source of type Salesforce Connect: Custom, some special behaviors and limitations apply. SEE ALSO: Salesforce Platform Features Supported by Salesforce Connect 924 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect Apex Connector Framework Considerations for Salesforce Connect—Custom Adapter Understand the limits and considerations for creating Salesforce Connect custom adapters with EDITIONS the Apex Connector Framework. • If you change and save a DataSource.Connection class, resave the corresponding Available in: both Salesforce DataSource.Provider class. Otherwise, when you define the external data source, the Classic (not available in all custom adapter doesn’t appear as an option for the Type field. Also, the associated external orgs) and Lightning objects’ custom tabs no longer appear in the Salesforce UI. Experience (not for high-data-volume external • DML operations aren’t allowed in the Apex code that comprises the custom adapter. objects) • Make sure that you understand the limits of the external system’s APIs. For example, some external systems accept only requests for up to 40 rows. Available in: Developer Edition • Apex data type limitations: Available for an extra cost – Double—The value loses precision beyond 18 significant digits. For higher precision, use in: Enterprise, Performance, decimals instead of doubles. and Unlimited Editions – String—If the length is greater than 255 characters, the string is mapped to a long text area field in Salesforce. • Custom adapters for Salesforce Connect are subject to the same limitations as any other Apex code. For example: – All Apex governor limits apply. – Test methods don’t support web service callouts. Tests that perform web service callouts fail. For an example that shows how to avoid these failing tests by returning mock responses, see Google Drive™ Custom Adapter for Salesforce Connect. • In Apex tests, use dynamic SOQL to query external objects. Tests that perform static SOQL queries of external objects fail. SEE ALSO: Custom Adapter for Salesforce Connect External Objects in Salesforce Connect Apex Developer Guide: Primitive Data Types Apex Developer Guide: Execution Governors and Limits Apex Developer Guide: Callout Limits and Limitations Apex Developer Guide: Google Drive™ Custom Adapter for Salesforce Connect Apex Developer Guide: Dymamic SOQL 925 Extend Salesforce with Clicks, Not Code Access External Data With Salesforce Connect High Data Volume Considerations for Salesforce Connect—Custom Adapters If your org hits rate limits when accessing external objects, consider selecting the High Data Volume EDITIONS option on the associated external data sources. Doing so bypasses most rate limits, but some special behaviors and limitations apply. Available in: both Salesforce • The following features aren’t available for external objects that are associated with Classic (not available in all high-data-volume external data sources. orgs) and Lightning Experience (not for – Access via Lightning Experience high-data-volume external – Access via the Salesforce mobile app objects) – Appearance in Recent Items lists Available in: Developer – Record feeds Edition – Reports and dashboards Available for an extra cost – Writable external objects in: Enterprise, Performance, and Unlimited Editions • Salesforce IDs aren’t assigned to external object records that are associated with high-data-volume external data sources. • On record detail pages for external objects that are associated with high-data-volume external data sources, custom buttons, and links that call JavaScript aren’t supported. • Salesforce Console in Salesforce Classic doesn’t support external objects that are associated with high-data-volume external data sources. SEE ALSO: Custom Adapter for Salesforce Connect Considerations for Salesforce Connect—Custom Adapter Writable External Objects Considerations for Salesforce Connect—Custom Adapters Some special behaviors and limitations affect writable external objects that are associated with EDITIONS custom adapters for Salesforce Connect. • Writable external objects aren’t available for high-data-volume external data sources. Available in: both Salesforce • Queued changes to the external data execute over time, so external object records that are Classic (not available in all read successively can contain different data. orgs) and Lightning Experience (not for Also review the considerations that apply to all Salesforce Connect adapters. high-data-volume external objects) SEE ALSO: Available in: Developer Writable External Objects in Salesforce Connect Edition Custom Adapter for Salesforce Connect Available for an extra cost Apex Developer Guide : Writable External Objects in: Enterprise, Performance, and Unlimited Editions 926 Extend Salesforce with Clicks, Not Code Work with External Data Sources Sync Considerations for Salesforce Connect—Custom Adapter When you validate and sync an external data source of type Salesforce Connect: Custom, EDITIONS some special behaviors and limitations apply. • Syncing always enables search on the external object when search is enabled on the external Available in: both Salesforce data source, and vice versa. For an external data source of type Salesforce Connect: Custom, Classic (not available in all search is enabled when the custom adapter’s DataSource.Provider class declares the orgs) and Lightning DataSource.Capability.SEARCH capability. Experience (not for high-data-volume external Important: When you select the tables to sync, determine whether check marks appear in objects) the Synced column. Available in: Developer If a Synced check mark appears, your org has an external object whose object name matches Edition the table name. If you select the table and click Sync: Available for an extra cost • The external object is overwritten. in: Enterprise, Performance, • Any custom field on the external object is overwritten if its API name (for example, and Unlimited Editions Email__c) associates it with a table column name (for example, Email). • Any other custom fields on the external object remain as they are, including: – Previously synced custom fields whose API names were changed by editing their Field Name values. – Manually added custom fields whose API names aren’t associated with table column names. • Syncing always enables search on the external object when search is enabled on the external data source, and vice versa. For an external data source of type Salesforce Connect: Custom, search is enabled when the custom adapter’s DataSource.Provider class declares the DataSource.Capability.SEARCH capability. If no Synced check mark appears, and you sync the table, a new external object is created in your org. The new external object’s object name matches the table name. For example, suppose you change the table name in the custom adapter’s DataSource.Connection class to no longer match the object name of the external object. Syncing that table creates a new external object in Salesforce. We recommend that you change the object name of the existing external object to match the new table name in the DataSource.Connection class before you sync that table. Also review the considerations that apply to all Salesforce Connect adapters. SEE ALSO: Sync an External Data Source for Salesforce Connect Define an External Data Source for Salesforce Connect—Custom Adapter Custom Adapter for Salesforce Connect Work with External Data Sources An external data source specifies how to access an external system. Salesforce Connect uses external data sources to access data that's stored outside your Salesforce organization. Files Connect uses external data sources to access third-party content systems. External data sources have associated external objects, which your users and the Lightning platform use to interact with the external data and content. 927 Extend Salesforce with Clicks, Not Code Work with External Data Sources Define External Data Sources Create external data sources to connect to content and data that is stored outside your Salesforce org. Validate and Sync an External Data Source After you configure an external data source, synchronize it to map its tables with external objects in your Salesforce org. The content and data of external objects appear in federated search, together with your Salesforce content and data. Define External Objects Tables in external systems map to external objects in Salesforce, combining all your data and content for users in your org. Validate External Object Connections After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results. Validator is available for external objects from Apex and Odata data sources. Grant Access to Authentication Settings for External Data Sources For external data sources that use per-user authentication, grant users access through permission sets and profiles. Doing so lets users set up and manage their own authentication settings for accessing the external system. Store Authentication Settings for External Systems You or your administrator can set up and manage your authentication settings for external systems. With valid authentication settings, you can access external systems from within your Salesforce org. External Object Relationships External objects support standard lookup relationships, which use the 18-character Salesforce record IDs to associate related records with each other. However, data that’s stored outside your Salesforce org often doesn’t contain those record IDs. Therefore, two special types of lookup relationships are available for external objects: external lookups and indirect lookups. 928 Extend Salesforce with Clicks, Not Code Work with External Data Sources Define External Data Sources Create external data sources to connect to content and data that is stored outside your Salesforce EDITIONS org. 1. From Setup, enter External Data Sources in the Quick Find box, then select External Available in: both Salesforce Data Sources. Classic (not available in all orgs) and Lightning 2. Click New External Data Source. To modify an existing external data source, click Edit. Experience 3. Complete the steps for your type of external data source. Salesforce Connect is • Files Connect: Google Drive available in: Developer • Files Connect: SharePoint 2010 or 2013 Edition and for an extra cost • Files Connect: SharePoint Online or OneDrive for Business in: Enterprise, Performance, and Unlimited Editions • Files Connect: Box Files Connect for • Simple URL: Data from Another Web Domain cloud-based external data • Salesforce Connect: OData 2.0 sources is available in: • Salesforce Connect: OData 4.0 Professional, Enterprise, Performance, Unlimited, • Salesforce Connect: Cross-Org and Developer Editions • Salesforce Connect: Custom Federated Search is • Federated Search available in: Enterprise, Professional, Unlimited, and Developer Editions SEE ALSO: Salesforce Connect USER PERMISSIONS To create and edit an external data source: • Customize Application 929 Extend Salesforce with Clicks, Not Code Work with External Data Sources Validate and Sync an External Data Source After you configure an external data source, synchronize it to map its tables with external objects EDITIONS in your Salesforce org. The content and data of external objects appear in federated search, together with your Salesforce content and data. Available in: both Salesforce When you sync a large number of tables, you can select to execute the sync operation asynchronously Classic (not available in all as a background job and avoid connection timeout. You can view the list of sync operations orgs) and Lightning performed as background jobs in the corresponding External Data Source page. Experience Note: Salesforce Connect is available in: Developer • Syncing creates or overwrites Salesforce external objects that map to the external system’s Edition and for an extra cost schema. Syncing doesn’t copy any data into your Salesforce org or write data from your in: Enterprise, Performance, org to the external system. and Unlimited Editions • Syncing is a one-time process. If the external system’s schema changes, the modifications Files Connect for aren’t automatically synced to your Salesforce org. To reflect the changes in the external cloud-based external data system, resync the objects. After resyncing, full field-level security to the external objects sources is available in: is granted to all users who have the same profile as the user who initiated the resync. Professional, Enterprise, • Each org can have up to 200 external objects. External objects don’t count toward the Performance, Unlimited, amount for custom objects. Syncing fails if it causes your org to exceed 200 external and Developer Editions objects. Federated Search is • For Salesforce Connect external data sources, make sure that you read and understand available in: Enterprise, the sync considerations. See Sync an External Data Source for Salesforce Connect on page Professional, Unlimited, 858. and Developer Editions 1. From Setup, enter External Data Sources in the Quick Find box, then select External Data Sources. USER PERMISSIONS 2. Click the name of the external data source. To create an external object 3. Click Validate and Sync, and confirm that the connection is successful. from an external data source: 4. Select tables and click Sync to do the following for each selected table. • Customize Application • Automatically create a Salesforce external object. • Automatically create a custom field for each table column that’s compatible with a Salesforce metadata field type. Example: The resulting external data source detail page will include a list of related external objects like this. 930 Extend Salesforce with Clicks, Not Code Work with External Data Sources SEE ALSO: Salesforce Connect Define External Objects Tables in external systems map to external objects in Salesforce, combining all your data and content EDITIONS for users in your org. External objects are similar to custom objects, except that they map to data that’s stored outside Available in: both Salesforce your Salesforce org. Each external object relies on an external data source definition to connect Classic (not available in all with the external system’s data. Each external object definition maps to a data table on the external orgs) and Lightning system. Each of the external object’s fields maps to a table column on the external system. External Experience objects enable your users and the Lightning Platform to search and interact with the external data. Salesforce Connect is Note: available in: Developer Edition and for an extra cost • Each org can have up to 200 external objects. External objects don’t count toward the in: Enterprise, Performance, amount for custom objects. and Unlimited Editions • If the external system allows it, we recommend that you sync the external data source to Files Connect for automatically create related external objects. You can instead choose to manually define cloud-based external data external objects to customize the external object names and manually create the custom sources is available in: fields. Professional, Enterprise, Performance, Unlimited, To create or modify an external object: and Developer Editions 1. From Setup, enter External Objects in the Quick Find box, then select External Objects. Federated Search is 2. Click New External Object, or click Edit to modify an existing external object. available in: Enterprise, Professional, Unlimited, 3. Enter the following: and Developer Editions Field Description Label A user-friendly name for the external object. The label is displayed in USER PERMISSIONS the Salesforce user interface, such as in list views. To create or edit external We recommend that you make object labels unique across all objects: standard, custom, and external objects in the org. • Customize Application Plural Label The plural name of the external object. If you create a tab for this object, this name is used for the tab. Starts with If it’s appropriate for your org’s default language, select to precede vowel sound your label with “an” instead of “a” for any automated messages. Object Name A unique identifier used to refer to this external object definition when using the API. Object names must be unique across all standard, custom, and external objects in the org. The Object Name field can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. 931 Extend Salesforce with Clicks, Not Code Work with External Data Sources Field Description Description An optional description of the external object. A meaningful description helps you distinguish among your external objects when you view them in a list. Context-Sensitive Defines what appears when users click Help for this Page from the external object record home Help Setting (overview) and detail pages, as well as list views and related lists. We recommend that you select Open a window using a Visualforce page to display custom help that you create for your users. See Object-Level Help in Salesforce Classic on page 94. If you instead keep the default value, your users only see Salesforce Help, which doesn’t provide any information about your external data. This setting doesn’t affect the Help & Training link at the top of each page, which always opens Salesforce Help. Content Name Select the Visualforce page that best describes the data that’s provided by this external object. This field is available only when you select Open a window using a Visualforce page. External Data Source The external data source definition that contains the connection details you want to use for this external object. Table Name Table in the external system that the external object maps to. For SharePoint, the table name must match the related scope name. Display URL Available only for Salesforce Connect. The external object’s Display URL standard field values Reference Field are automatically generated from the external system. For example, with the OData 2.0 adapter for Salesforce Connect, the value is based on the link href that’s defined on the OData producer. You can override the default values with the values of a custom field on the same external object. Select the field name, and make sure that the custom field’s values are valid URLs. Allow Reports Available only for Salesforce Connect. Deployment Status Indicates whether the external object is visible to other users. Launch New Custom If selected, the custom tab wizard starts after you save the external object. Tab Wizard after saving this external object Allow Search If search is also enabled on the external data source, selecting this option lets users find the external object’s records via SOSL and Salesforce global searches. By default, search is disabled for new external objects. However, you can validate and sync an external data source to automatically create external objects. Syncing always enables search on the external object when search is enabled on the external data source, and vice versa. 4. Click Save. 932 Extend Salesforce with Clicks, Not Code Work with External Data Sources 5. On the external object detail page, view and modify the external object’s custom fields and relationships, page layouts, field sets, search layouts, and buttons and links. • To create field mappings or add fields to an external object, click New on the Custom Fields & Relationships related list. • To assign different page layouts by user profile, click Page Layout Assignments. Tip: After you configure an external data source, run the validator tool on each external object to test and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results. SEE ALSO: Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Set Up Salesforce Connect to Access External Data with a Custom Adapter Deployment Status for Custom Objects and External Objects Validate External Object Connections After you configure an external data source, run the validator tool on each external object to test EDITIONS and troubleshoot its connections. The tool tests for ID uniqueness and the ability to sort and filter results. Validator is available for external objects from Apex and Odata data sources. Available in: both Salesforce 1. From Setup, enter External Data Source in the Quick Find box, then select External Classic (not available in all Data Source. orgs) and Lightning Experience 2. Select the external data source that contains the external object you want to validate. 3. Next to the external object’s name, click Validate. Salesforce Connect is available in: Developer 4. Select each query type you want validator to run. Edition and for an extra cost 5. Click Run Queries. in: Enterprise, Performance, and Unlimited Editions The validator results are displayed. Queries that ran successfully are listed in the Passed Queries table. The Failed Queries table lists the unsuccessful queries with information to help with Files Connect for troubleshooting. Queries that weren’t run because a prerequisite query was unsuccessful are in the cloud-based external data sources is available in: Skipped Queries table. Professional, Enterprise, Performance, Unlimited, SEE ALSO: and Developer Editions Define External Objects Federated Search is available in: Enterprise, Professional, Unlimited, and Developer Editions USER PERMISSIONS To create or edit external objects: • Customize Application 933 Extend Salesforce with Clicks, Not Code Work with External Data Sources Grant Access to Authentication Settings for External Data Sources For external data sources that use per-user authentication, grant users access through permission EDITIONS sets and profiles. Doing so lets users set up and manage their own authentication settings for accessing the external system. Available in: both Salesforce 1. From Setup, enter Permission Sets in the Quick Find box, then select Permission Sets Classic (not available in all or Profiles. orgs) and Lightning Experience 2. Click the name of the permission set or profile that you want to modify. 3. Do one of the following. Salesforce Connect is available in: Developer • For a permission set, or for a profile in the enhanced profile user interface, click External Edition and for an extra cost Data Source Access in the Apps section. Then click Edit. in: Enterprise, Performance, • For a profile in the original profile user interface, click Edit in the Enabled External Data and Unlimited Editions Source Access section. Files Connect for cloud-based external data 4. Add the data sources that you want to enable. sources is available in: 5. Click Save. Professional, Enterprise, Performance, Unlimited, and Developer Editions SEE ALSO: Federated Search is Store Authentication Settings for External Systems available in: Enterprise, Set Up Salesforce Connect to Access Data in Another Org with the Cross-Org Adapter Professional, Unlimited, Set Up Salesforce Connect to Access External Data with the OData 2.0 or 4.0 Adapter and Developer Editions Set Up Salesforce Connect to Access External Data with a Custom Adapter USER PERMISSIONS To edit permission sets and user profiles: • Manage Profiles and Permission Sets 934 Extend Salesforce with Clicks, Not Code Work with External Data Sources Store Authentication Settings for External Systems You or your administrator can set up and manage your authentication settings for external systems. EDITIONS With valid authentication settings, you can access external systems from within your Salesforce org. Note: All credentials stored within the NamedCredential, ExternalDataSource, and Available in: both Salesforce ExternalDataUserAuth entities are encrypted under a framework that is consistent with other Classic and Lightning encryption frameworks on the platform. Salesforce encrypts your credentials by auto-creating Experience org-specific keys. Credentials encrypted using the previous encryption scheme were migrated Named credentials are to the new framework. available in: All Editions. Your administrator defines external systems in external data sources and named credentials. External Salesforce Connect is data sources specify how to access data or content that’s stored outside your Salesforce org. Named available in: Developer credentials specify callout endpoints, which receive Web service callouts from your org. Edition and for an extra cost in: Enterprise, Performance, Before you begin, your administrator: and Unlimited Editions. • Sets up the external data source or named credential to use per-user authentication. Files Connect for • Grants you access to the external data source or named credential. cloud-based external data • Verifies that your org can connect to the external system. sources is available in: Professional, Enterprise, • Tells you the authentication settings to enter. Performance, Unlimited, • Sets up the community, if applicable, by using the Salesforce Tabs + Visualforce template. and Developer Editions If the community is built with the Customer Service template, only your administrator can set up and manage your authentication settings for external systems. You can’t complete these steps on your own. USER PERMISSIONS If you don’t see the expected settings or options, contact your administrator. To store authentication settings for an external data 1. Access your authentication settings for external systems in one of the following ways. source: From within a community: • The data source enabled under External • If you have a community license, click My Settings > Authentication Settings for External Data Source Access Systems. To store authentication • Otherwise, from your personal settings, enter Authentication, then select settings for a named Authentication Settings for External Systems credential: From Salesforce, go to your personal settings and enter Authentication in the Quick • The named credential enabled under Named Find box, then select Authentication Settings for External Systems. Credential Access 2. Click New or Edit. To edit another user’s authentication settings for 3. Complete the fields. external systems: • Manage Users Field Description External If you’re not sure which option to select, ask your administrator. System • External Data Source: Provides access to external objects, whose Definition data is stored outside your Salesforce organization. • Named Credential: Enables your actions to trigger authenticated callouts to the endpoint that’s specified in the named credential. A named credential can handle the authentication for an external data source. In this scenario, your administrator instructs you to select Named Credential in this field to access external objects. 935 Extend Salesforce with Clicks, Not Code Work with External Data Sources Field Description External Data Source Which field appears depends on what’s selected for External System Definition. or If you’re not sure which option to select, ask your administrator. Your administrator can change Named Credential the option labels to make them more relevant or easier to distinguish from each other. User Available only to administrators. Select the user whose authentication settings you’re entering. 4. Select the authentication protocol that’s required by the external system. If you’re not sure which option to select, ask your administrator. • If you select Password Authentication, enter your username and password for the external system. • If you select OAuth 2.0, complete the following fields. Field Description Authentication If you’re not sure which option to select, ask your administrator. Your administrator can change Provider the option labels to make them more relevant or easier to distinguish from each other. Scope If you’re not sure what to enter, ask your administrator. Specifies the scope of permissions to request for the access token. Start To authenticate to the external system and obtain an OAuth token, select this checkbox. This Authentication Flow authentication process is called an OAuth flow. on Save When you click Save, the external system prompts you to log in. After successful login, the external system grants you an OAuth token for accessing its data from this org. Redo the OAuth flow when you need a new token—for example, if the token expires—or if you edit the Scope or Authentication Provider fields. When the token expires, the external system returns a 401 HTTP error status. 5. Click Save. SEE ALSO: Define External Data Sources Grant Access to Authentication Settings for External Data Sources Define a Named Credential Grant Access to Authentication Settings for Named Credentials Add Tabs to Your Salesforce Tabs + Visualforce Site Personalize Your Salesforce Experience 936 Extend Salesforce with Clicks, Not Code Work with External Data Sources External Object Relationships External objects support standard lookup relationships, which use the 18-character Salesforce record EDITIONS IDs to associate related records with each other. However, data that’s stored outside your Salesforce org often doesn’t contain those record IDs. Therefore, two special types of lookup relationships are Available in: both Salesforce available for external objects: external lookups and indirect lookups. Classic (not available in all External lookups and indirect lookups compare a specific field’s values on the parent object to the orgs) and Lightning relationship field’s values on the child object. When values match, the records are related to each Experience other. Salesforce Connect is To create an external object relationship, create a custom field on the child object with one of the available in: Developer following field types. If the child is an external object, you can instead change the field type of an Edition and for an extra cost existing custom field to one of the following. in: Enterprise, Performance, and Unlimited Editions • Lookup Relationship Files Connect for • External Lookup Relationship cloud-based external data • Indirect Lookup Relationship sources is available in: This table summarizes the types of relationships that are available to external objects. Professional, Enterprise, Performance, Unlimited, Note: Federated Search supports only external lookup relationships, and the Federated and Developer Editions Search external object is always the parent. Federated Search is available in: Enterprise, Relationship Allowed Child Allowed Parent Parent Field for Matching Professional, Unlimited, Objects Objects Records and Developer Editions Lookup Standard Standard The 18-character Salesforce Custom Custom record ID External External lookup Standard External The External ID standard field Custom External Indirect lookup External Standard You select a custom field with Custom the External ID and Unique attributes Lookup Relationship Fields on External Objects Use a lookup relationship when the external data includes a column that identifies related Salesforce records by their 18-character IDs. External Lookup Relationship Fields on External Objects Use an external lookup relationship when the parent is an external object. 937 Extend Salesforce with Clicks, Not Code Work with External Data Sources Indirect Lookup Relationship Fields on External Objects Use an indirect lookup relationship when the external data doesn’t include Salesforce record IDs. SEE ALSO: Create Custom Fields Change the Custom Field Type Relationships on External Objects Include a Files Connect Data Source in Global Search Object Relationships Overview Lookup Relationship Fields on External Objects Use a lookup relationship when the external data includes a column that identifies related Salesforce EDITIONS records by their 18-character IDs. A lookup relationship field links a child standard, custom, or external object to a parent standard Available in: both Salesforce or custom object. A user who’s editing a child record can click the field’s lookup icon to select a Classic (not available in all specific parent record, and a user who’s viewing a parent record can view a related list of child orgs) and Lightning records. Experience When you create a lookup relationship field on an external object, enter the External Column Name Salesforce Connect is that contains the 18-character Salesforce IDs for identifying the parent records. available in: Developer Edition and for an extra cost Example: in: Enterprise, Performance, • Account record (parent standard object) displays a related list of external SAP sales orders and Unlimited Editions (child external object). Files Connect for • Account record (parent standard object) displays a related list of support cases (child cloud-based external data standard object). sources is available in: Professional, Enterprise, Performance, Unlimited, SEE ALSO: and Developer Editions External Object Relationships Federated Search is Create Custom Fields available in: Enterprise, Professional, Unlimited, Relationships on External Objects and Developer Editions Include a Files Connect Data Source in Global Search 938 Extend Salesforce with Clicks, Not Code Work with External Data Sources External Lookup Relationship Fields on External Objects Use an external lookup relationship when the parent is an external object. EDITIONS An external lookup relationship links a child standard, custom, or external object to a parent external object. Available in: both Salesforce Classic (not available in all The values of the standard External ID field on the parent external object are matched against the orgs) and Lightning values of the external lookup relationship field. For a child external object, the values of the external Experience lookup relationship field come from the specified External Column Name. When you sync two external system tables with a lookup relationship field, an external lookup Salesforce Connect is available in: Developer relationship for the mapped external objects is automatically created. This auto mapping happens Edition and for an extra cost only if in: Enterprise, Performance, • The parent and child objects are synced from the same data source. and Unlimited Editions • The parent object is already synced or the parent and child objects are in the same sync Files Connect for operation. cloud-based external data Creating an external lookup relationship on the external object for a lookup relationship on a table sources is available in: is supported by Cross Org, OData 4.0, and Custom Apex adapters. For the OData2.0 adapter, it’s Professional, Enterprise, supported only in the default Olingo library and not supported in OData4J. Performance, Unlimited, and Developer Editions Example: Federated Search is • External product catalog item (parent external object) displays a related list of support available in: Enterprise, cases (child standard object). Professional, Unlimited, and Developer Editions • External customer (parent external object) displays a related list of external orders (child external object). Example: For the cross-org adapter for Salesforce Connect, suppose that you store contacts and accounts in the provider org. From the subscriber org, you want to view each account’s related contacts. To do so, create an external lookup field on the subscriber org’s Contact external object. Link that external lookup field to the subscriber org’s Account external object. Then set up the page layouts for the Account external object to include a related list that displays the related Contact external object records. Example: In this screenshot, a record detail page for the Business_Partner external object includes two related lists of child objects. This example shows how external lookup relationships and page layouts enable users to view related data from within and from outside their Salesforce org on a single page. • Account standard object (1) • Sales_Order external object (2) 939 Extend Salesforce with Clicks, Not Code Work with External Data Sources SEE ALSO: External Object Relationships Create Custom Fields Change the Custom Field Type Relationships on External Objects Include a Files Connect Data Source in Global Search 940 Extend Salesforce with Clicks, Not Code Sync Data Between Salesforce and Heroku Indirect Lookup Relationship Fields on External Objects Use an indirect lookup relationship when the external data doesn’t include Salesforce record IDs. EDITIONS An indirect lookup relationship links a child external object to a parent standard or custom object. When you create an indirect lookup relationship field on an external object, you specify the parent Available in: both Salesforce object field and the child object field to match against each other. Classic (not available in all orgs) and Lightning Specifically, you select a custom unique, external ID field on the parent object to match against the Experience child’s indirect lookup relationship field, whose values are determined by the specified External Column Name. Salesforce Connect is available in: Developer If the external system uses case-sensitive values in the specified External Column Name, make sure Edition and for an extra cost that the parent object field is also case-sensitive. When you define the parent object’s custom field, in: Enterprise, Performance, select External ID, Unique, and Treat "ABC" and "abc" as different values (case sensitive). and Unlimited Editions Note: Only objects that have a custom field with the External ID and Unique Files Connect for attributes are available as parent objects in indirect lookup relationships. If you don't see the cloud-based external data desired object when you create an indirect lookup relationship field, add a custom unique, sources is available in: external ID field to that object. Professional, Enterprise, Performance, Unlimited, Example: and Developer Editions • Account record (parent standard object) displays a related list of SAP sales orders (child Federated Search is external object) with matching customer IDs that aren’t Salesforce IDs. available in: Enterprise, • Contact record (parent standard object) displays a related list of social media posts (child Professional, Unlimited, external object) with matching social media handles. and Developer Editions SEE ALSO: External Object Relationships Create Custom Fields Change the Custom Field Type Relationships on External Objects Include a Files Connect Data Source in Global Search Sync Data Between Salesforce and Heroku Heroku Connect lets you sync data between Salesforce and Heroku Postgres. EDITIONS Using Heroku Connect with Heroku Postgres, you can build Heroku apps that interact with your Salesforce data using your favorite language, like Ruby, Node.js, Python, PHP, Java, Scala or Clojure Available in: Salesforce or web framework like Rails, Django, or Play. For more information, refer to the Heroku Connect Classic website and the Heroku Connect documentation on the Heroku Dev Center website. Available for: Developer, Enterprise, Performance, Organization Sync and Unlimited Editions This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable. 941 Extend Salesforce with Clicks, Not Code Build Your Own Salesforce App Managing Organization Sync This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable. Actions in the Organization Sync Record Queue This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable. Managing Organization Sync This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable. Actions in the Organization Sync Record Queue This feature is now retired. In previous releases, Organization Sync let you set up a secondary, synced Salesforce org. Users could access a subset of Salesforce data in that org when the primary org was unavailable. Build Your Own Salesforce App An app is a collection of items that work together to serve a particular function. Salesforce apps EDITIONS come in two flavors: Classic and Lightning. Classic apps are created and managed in Salesforce Classic. Lightning apps are created and managed in Lightning Experience. You can customize both Available in: Salesforce types of app to match the way your users work. Classic (not available in all Classic apps are a collection of standard and custom tabs, including: orgs), Lightning Experience, and the Salesforce mobile • Most standard objects, including Home, the main Chatter feed, Groups, and People app • Your org’s custom objects Available in: Contact • Visualforce tabs Manager, Group, • Lightning component tabs Professional, Enterprise, • Canvas apps via Visualforce tabs Performance, Unlimited, and Developer Editions • Web tabs Lightning apps are a collection of items that include everything from the Classic apps list, plus Lightning page tabs, and utilities like Sales Dialer. In Lightning apps, you can customize the app’s USER PERMISSIONS logo and enhance its branding by customizing the color of the navigation bar. To view apps: You can also upgrade Classic apps to Lightning apps in Lightning Experience, but the two versions • View Setup and of the app must then be managed separately in their own environments. Configuration Salesforce provides standard apps such as Sales and Service. To manage apps: • Customize Application You can also build your own on-demand apps by grouping items into new custom apps. A custom app consists of a label, a description, and an ordered list of items, which often includes tabs. You can also add custom logos and branding to your custom apps. In Salesforce Classic, custom apps are listed in the Lightning Platform app menu, which is a dropdown list displayed at the top of every page. 942 Extend Salesforce with Clicks, Not Code Build Your Own Salesforce App In Lightning Experience and the Salesforce mobile app, you can find your available custom apps in the App Launcher ( ). In Lightning Experience, to see all your available Salesforce apps and items, click View All. When you choose an app, your screen changes to reflect the contents of that app. For example, if you switch from an app that contains Opportunities to another app that doesn’t, the Opportunities item disappears. In addition, the app might display a different default landing tab when selected. Apps are associated with profiles. Profiles control which tabs you can see or hide, as well as which apps are available to you. 943 Extend Salesforce with Clicks, Not Code App Tools App Tools What is a Subtab App? An app is a group of tabs that work as a unit to provide application functionality. Similarly, a subtab app is a collection of tabs that appears on the Chatter profile page. A subtab app can include both default and custom tabs. Lightning Platform Home Page The Lightning Platform Home page contains options for building and managing applications. Configuring System Overview Messages SEE ALSO: Create Custom Apps for Salesforce Classic Set the Default Sort Order for Apps Salesforce App Considerations App Tools The platform includes innovative point-and-click app-building tools that give you the power to EDITIONS customize Salesforce to meet the needs of your business. You can also build your own apps to share and store information that is important to you. You don’t need any programming knowledge to Available in: Salesforce use these tools. You can find them in Salesforce Classic Setup by selecting Create, and in Lightning Classic (not available in all Experience Setup by entering App in the Quick Find box to get started. orgs) and Lightning The platform also includes app building tools that require some programming knowledge. You can Experience find tools that require advanced programming knowledge in Salesforce Classic Setup by selecting Available in: Contact Develop, and in Lightning Experience Setup by entering Custom Code in the Quick Find Manager, Group, box. Professional, Enterprise, Performance, Unlimited, Create Apps in Salesforce Classic with App Quick Start Developer, and Database.com Editions App quick start is a fast way to create a basic Classic app in just one step. App Quick Start: Next Steps for Building and Managing Apps in Salesforce Classic After you've created a basic working app with app quick start in Salesforce Classic, build out the app with more objects and fields, define its access settings, and add users to share your app with them. Create Custom Apps for Salesforce Classic Create custom apps to give your Salesforce Classic users access to everything they need all in one place. Lightning Apps With apps in Lightning Experience, members of your org can work more efficiently by easily switching between apps. Users can open apps you’ve created from the App Launcher. What’s most important to sales reps? Accounts, events, and organizations. How about sales managers? Reports and dashboards make the top of the list. Lightning apps take things to another level past Classic apps by letting you brand your apps with a custom color, logo, and utility bar. Tips for Creating Apps in Lightning Experience It’s time for the fun part: deciding how to set up Lightning apps for your users. Here are some tips for planning Lightning apps for your org. 944 Extend Salesforce with Clicks, Not Code App Tools Create Lightning Apps As in Salesforce Classic, you can create apps in Lightning Experience, but with even more bells and whistles. You can brand and customize Lightning apps to help your users work more efficiently. For example, you can create a Lightning app for your finance department that includes all important items (including tabs) that users need to complete common tasks. You can customize the navigation bar color, brand it with a logo, and make the app available in the App Launcher for the user profiles associated with the finance department. Customize Lightning Apps with the Lightning App Builder When you edit a Lightning app from the App Manager in Setup, you’re brought into the Lightning App Builder to manage the app’s settings. Update app branding, navigation, and other options, and manage the Lightning pages assigned to that app all in one place. Add a Utility Bar to Lightning Apps The utility bar is a specialized type of Lightning page that gives your users quick access to common productivity tools, like Notes and Recent Items. It appears as a fixed footer that users can access to open utilities in docked panels. Some utilities support pop-out, which lets them open in a new browser window. Lightning App Navigation Bar Items Most of the items that appear in the App Launcher can appear in a Lightning app navigation bar. To add items to an app’s navigation bar, you can use the Lightning app creation wizard, which lets you choose from a list of available items. Upgrade Classic Apps to Lightning Apps You can upgrade a Classic app to a Lightning app in Lightning Experience, enhancing it for your Lightning Experience users with a customized color, logo, utility bar, and more items like Lightning pages supported in the navigation bar. Salesforce App Considerations Keep these considerations in mind when working with apps in either Lightning Experience or Salesforce Classic. Create Apps in Salesforce Classic with App Quick Start App quick start is a fast way to create a basic Classic app in just one step. EDITIONS 1. From Setup, enter Apps in the Quick Find box, then select Apps, and click Quick Start. Alternatively, from the Lightning Platform Home page, click Add App under Getting Started, Available in: Salesforce or App Quick Start under Quick Links. Classic (not available in all orgs), Lightning Experience, 2. Enter the information needed for your app. and the Salesforce mobile app Field Name Description Available in: Contact App Label The app's name that appears in the Lightning Manager, Group, Platform app menu. The label can have a Professional, Enterprise, maximum of 40 characters, including spaces. Performance, Unlimited, Plural Label The plural name of the object. This name and Developer Editions appears on the tab. USER PERMISSIONS Singular Label A name used to refer to the object in any user interface pages. To create apps: Gender If it's appropriate for your org’s default • Customize Application language, specify the gender of the label. This AND field appears if the org-wide default language Manage Profiles and expects gender. Permission Sets 945 Extend Salesforce with Clicks, Not Code App Tools Field Name Description Starts with a vowel sound If it's appropriate for your org’s default language, enable this option if your label should be preceded by “an” instead of “a”. 3. Click Create. 4. On the You’re All Set! page, click here to add new fields to your app. 5. To see your app as it will appear to users, click Go To My App. The app quick start: • Generates an app label and API name (a unique name that's used to refer to the object when using the Lightning Platform API). • Generates an object label and API name. • Generates a tab label, and associates the tab with the object. • Enables feed tracking for the object. Feed tracking lets people follow records of that object type and see Chatter feed updates. • Enables access to the app and tab in your user profile. Any users who have the “Modify All Data” permission can also access the object. • Generates a permission set that grants access to the new custom object. • Assigns the permission set to the user who creates the app. Note: If you’re in a custom app, only the tabs included in the app appear and include the Create button. After you've created an app, you can extend it with more components, specify access settings, and add users to your org. SEE ALSO: App Quick Start: Next Steps for Building and Managing Apps in Salesforce Classic Salesforce App Considerations 946 Extend Salesforce with Clicks, Not Code App Tools App Quick Start: Next Steps for Building and Managing Apps in Salesforce Classic After you've created a basic working app with app quick start in Salesforce Classic, build out the EDITIONS app with more objects and fields, define its access settings, and add users to share your app with them. Available in: Salesforce 1. Build out your app with the basic components used in apps. Classic (not available in all orgs), Lightning Experience, • Create objects, which are custom database tables that allow you to store information specific and the Salesforce mobile to your app. app • Create tabs that are associated with the objects you've created. Available in: Contact • For each object, create fields to store the information that's important to your organization. Manager, Group, • Create validation rules, which verify that the data users enter meets the standards you Professional, Enterprise, specify before they save a record. Performance, Unlimited, For quick shortcuts to these tools, use the Lightning Platform quick access menu, which is and Developer Editions available from object list view pages and record detail pages. USER PERMISSIONS 2. Create user profiles or permission sets. These are collections of settings and permissions that determine what users can do in an app. To create objects, tabs, 3. Specify the types of access that users will have to the app. fields, and validation rules: • Customize Application a. Make your app visible using profiles or permission sets. To create users: b. Make your object tabs visible. • Manage Internal Users c. Set the object permissions for the objects you created. To create profiles and permission sets: 4. Add users to your organization. When adding users, be sure to assign them the appropriate • Manage Profiles and profiles or permission sets you created so they can access your app. Permission Sets SEE ALSO: Create Apps in Salesforce Classic with App Quick Start Salesforce App Considerations 947 Extend Salesforce with Clicks, Not Code App Tools Create Custom Apps for Salesforce Classic Create custom apps to give your Salesforce Classic users access to everything they need all in one EDITIONS place. If you're new to custom apps, we recommend using Lightning Platform quick start to create an Available in: Salesforce app. With this tool, you can generate a basic working app in just one step. Classic (not available in all orgs), Lightning Experience, If you’ve already created the objects, tabs, and fields you need for your app, follow these steps. With and the Salesforce mobile this option, you create an app label and logo, add items to the app, and assign the app to profiles. app 1. From Setup, enter Apps in the Quick Find box, then select Apps. Available in: Contact 2. Click New. Manager, Group, 3. If the Salesforce console is available, select whether you want to define a custom app or a Professional, Enterprise, Salesforce console. Performance, Unlimited, and Developer Editions 4. Give the app a name and description. An app name can have a maximum of 40 characters, including spaces. USER PERMISSIONS 5. Optionally, brand your app by giving it a custom logo. 6. Select which items to include in the app. To view apps: • View Setup and 7. Optionally, set the default landing tab for your new app using the Default Landing Tab Configuration drop-down menu below the list of selected tabs. This determines the first tab a user sees when logging into this app. To manage apps: • Customize Application 8. Choose which profiles the app will be visible to. 9. Check the Default box to set the app as that profile’s default app, meaning that new users with the profile see this app the first time they log in. Profiles with limits are excluded from this list. 10. Click Save. SEE ALSO: Build Your Own Salesforce App Salesforce App Considerations Lightning Apps With apps in Lightning Experience, members of your org can work more efficiently by easily switching EDITIONS between apps. Users can open apps you’ve created from the App Launcher. What’s most important to sales reps? Accounts, events, and organizations. How about sales managers? Reports and Available in: Lightning dashboards make the top of the list. Lightning apps take things to another level past Classic apps Experience by letting you brand your apps with a custom color, logo, and utility bar. Available in: Contact Lightning apps contain everything you expect from a custom app, such as custom and standard Manager, Group, objects, and custom tabs. But Lightning apps can also include Lightning page tabs and utilities like Professional, Enterprise, Lightning Voice. The navigation model of Lightning apps is optimized for efficiency, with actions Performance, Unlimited, on certain items like Opportunities in the navigation bar. You can even append navigation items and Developer Editions to a Lightning app that you found on AppExchange and installed from a managed package. Custom apps from Salesforce Classic automatically work in Lightning Experience and can be upgraded to Lightning apps. Classic apps appear in the list of apps in Setup alongside your Lightning apps, and are available from the App Launcher as long as their Show in Lightning Experience attribute is enabled. 948 Extend Salesforce with Clicks, Not Code App Tools However, the reverse isn’t true for Lightning apps. Lightning apps aren’t available in Salesforce Classic. You can assign multiple user profiles to multiple apps. Also, you can assign as many user profiles to one app as you need to. For instance, you have several groups involved with inside sales. Assign all the groups to your inside sales app, and they all have access to it. To switch between apps, users can use the App Launcher. This makes it easy for users to switch contexts and still have access to the items, objects, and pages they need most. You can view all the apps in your org from the App Manager. In Lightning Experience Setup, enter App in the Quick Find box, then select App Manager. SEE ALSO: Create Lightning Apps Upgrade Classic Apps to Lightning Apps Salesforce App Considerations Tips for Creating Apps in Lightning Experience It’s time for the fun part: deciding how to set up Lightning apps for your users. Here are some tips EDITIONS for planning Lightning apps for your org. The best time to create Lightning apps is when you’re rolling out Lightning Experience. So make Available in: Lightning creating Lightning apps a part of your rollout strategy. Check out the Trailhead module “Lightning Experience Experience Rollout” for many great ideas to help you make a smooth transition. Available in: Enterprise, Talk to your users. Ask them what their priorities are. Customizing tabs in apps gives you a unique Professional, Performance, opportunity to engage with your users. Each group of users has its own priorities. Find out which Unlimited, and Developer objects and items represent their highest priorities. Editions • Ask users to post feedback to a Chatter group. • Publish polls. • Schedule lunch sessions. Everyone likes a free lunch, and nearly everybody is happy to express their opinion. Create a master list of objects that everyone in your org wants. Then trim down the list for each group—sales reps, sales managers, execs, and so on. The menus for every user group share some common objects, like Home, Tasks, and Feed. Keep the high-priority items for each group at the top. Put low-priority items at the bottom, or remove them altogether. Users can always go to the App Launcher to get the items they use less often. 949 Extend Salesforce with Clicks, Not Code App Tools Create Lightning Apps As in Salesforce Classic, you can create apps in Lightning Experience, but with even more bells and EDITIONS whistles. You can brand and customize Lightning apps to help your users work more efficiently. For example, you can create a Lightning app for your finance department that includes all important Available in: Lightning items (including tabs) that users need to complete common tasks. You can customize the navigation Experience bar color, brand it with a logo, and make the app available in the App Launcher for the user profiles associated with the finance department. Available in: Contact Manager, Group, App 1. From the Home tab in Setup, enter in the Quick Find box, then select App Manager. Professional, Enterprise, 2. Click New Lightning App, and walk through the New Lightning App wizard. Performance, Unlimited, Here are some things you can do in the wizard: and Developer Editions • Give your app a name, set its primary color, and give it a logo. USER PERMISSIONS The app description displays alongside the icon in the App Launcher. Make sure that the description is meaningful to your users. To view apps: • View Setup and • Choose whether to override a custom theme’s brand image and navigation bar color with Configuration the brand image and color from the app. To manage apps: • Choose which type of navigation to use—standard or console. • Customize Application • Choose which form factors your app is available for. • Add a utility bar for common processes and tools, like Recent Items, Notes, Dialer, and Open CTI. • Customize which items appear in the app’s navigation bar. Note: If you add more than 50 default navigation items to an app, your users can’t personalize the app’s navigation bar. When organizing the navigation bar, the item at the top of the list becomes your app’s landing page on both desktop and mobile. The order of items in the navigation bar also determines the default objects shown in the Top Results page on the search results page. After the user interacts with the app for 15 days, Top Results reflects the user's most frequently used objects. If the user doesn’t have access or permissions to the app, Top Results includes the Account, Contact, Opportunity, Case, Lead, People (User), and Group objects until the user’s most frequently used objects are determined. • Assign the app to user profiles. SEE ALSO: Lightning Apps Create and Edit a Custom Lightning Console App Add a Utility Bar to Lightning Apps Salesforce App Considerations 950 Extend Salesforce with Clicks, Not Code App Tools Customize Lightning Apps with the Lightning App Builder When you edit a Lightning app from the App Manager in Setup, you’re brought into the Lightning EDITIONS App Builder to manage the app’s settings. Update app branding, navigation, and other options, and manage the Lightning pages assigned to that app all in one place. Lightning App Builder is 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager available in: both Salesforce Classic and Lightning 2. Click on a Lightning app’s row, and select Edit. Experience Here are some things you can do from the App Settings tab. Lightning apps are available • Change your app’s name, primary color, and logo. in: Lightning Experience • Override the org theme with your app’s brand image and nav bar color. Available in: Group, • Add a utility bar for common processes and tools, like Recent Items, Notes, Dialer, and Open Professional, Enterprise, CTI. Performance, Unlimited, • Manage which default items appear in the app’s navigation bar. and Developer Editions • Manage user profile assignments. On the Navigation Items tab, you can control which objects and other items—like Visualforce USER PERMISSIONS pages or Lightning components—are included in your app. To create a custom object by To manage apps, and to importing data from a spreadsheet, click Create at the top of the Available Items section. create and save Lightning 3. Click the Pages tab in the Lightning App Builder header to see all the active Lightning pages pages in the Lightning App Builder: assigned to the app, create pages, and open existing pages, even ones not associated with the • Customize Application app. To view apps, and to view Tip: If you create pages for your app, when finished, don’t forget to click Activation to Lightning pages in the make them active for your users and assign them to the app. Lightning App Builder: • View Setup and Configuration SEE ALSO: Lightning Apps Create Lightning Apps Lightning App Builder 951 Extend Salesforce with Clicks, Not Code App Tools Add a Utility Bar to Lightning Apps The utility bar is a specialized type of Lightning page that gives your users quick access to common EDITIONS productivity tools, like Notes and Recent Items. It appears as a fixed footer that users can access to open utilities in docked panels. Some utilities support pop-out, which lets them open in a new Available in: Lightning browser window. Experience Utilities harness the power of Lightning components. When you set up a utility bar, you select which Available in: Contact Lightning components to use as utilities. However, not all Lightning components can be utilities. Manager, Group, To be added to a utility bar, a Lightning component must implement the Professional, Enterprise, flexipage:availableForAllPageTypes interface. This interface also makes the Performance, Unlimited, component usable on all types of Lightning pages. To add a Lightning web component to the and Developer Editions utility bar, see Lightning Web Components Developer Guide: Configure a Component for the Utility Bar. To create a background utility item, implement the lightning:backgroundUtilityItem USER PERMISSIONS interface. Background utility items are added the same way as normal utility items, but don’t appear in the utility bar. The icon appears next to background utility items on the utility item list. If you To view apps: have only background utility items in your utility bar, the utility bar doesn’t appear in your app. You • View Setup and need at least one non-background utility item in your utility bar for it to appear. Configuration You can add or edit a utility bar at any time. To manage apps: • Customize Application 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager. 2. To edit or add a utility bar to an existing app, click Edit in the dropdown menu next to your app. To create a Lightning app with a utility bar, click New Lightning App. 3. Click the Utility Items tab and add the utilities you want. Specify component and utility properties, like the height and width of the utility panel, and what label and icon to display in the utility bar. Some utilities have properties that can’t be changed. Tip: A Lightning page region can contain up to 100 components. We recommend adding no more than 10 utilities, and that you keep the utility labels short and sweet. You want your users to quickly find the tools and processes they need most. Example: Here’s a utility bar with the Recent Items and Notes utilities. When creating a utility bar for your app, keep these things in mind: 952 Extend Salesforce with Clicks, Not Code App Tools • Utility bars created using the Lightning App Wizard or in the Lightning App Builder can be assigned to only one Lightning app. However, utility bars created using the API can be assigned to multiple Lightning apps. • The utility bar doesn’t support Visualforce pages or components. • The utility bar doesn’t fully support the Chatter Publisher and Feed components. • The History utility works in Lightning console apps only. • The Omni-Channel utility works in the Lightning Service Console app only. • The default utility bar alignment matches the user’s language setting alignment. For example, English is read left to right. If you select Default and a user’s language is set to English, the utility bar appears at the bottom of the left side of the screen. If you select Mirrored, the utility bar appears at the bottom of the right side of the screen. Using Pop-Out Utilities Utilities that support pop-out can be “popped out” of the utility bar and into their own separate child windows. To pop a utility out, click the icon. From there, you can pop the utility back into the utility bar with the icon, or close the utility. Pop-out utilities are the Lightning equivalent to multi-monitor components in Classic. SEE ALSO: Customize Your Lightning Console App with Utilities Create Lightning Apps Salesforce Console Developer Guide: Using Background Utility Items Salesforce Console Developer Guide: Using Pop-Out Utilities Using Pop-Out Utilities Utilities that support pop-out can be “popped out” of the utility bar and into their own separate child windows. To pop a utility out, click the icon. From there, you can pop the utility back into the utility bar with the icon, or close the utility. Pop-out utilities are the Lightning equivalent to multi-monitor components in Classic. Note: Popping-out docked utility bar items isn't supported in Lightning Experience on iPad Safari. Standard Utilities Pop-out is supported for these standard utilities. Standard utilities are utilities that are included with Salesforce. • Open CTI Softphone • History • Rich Text • Report Chart • Visualforce • Flow • List View • Recent Items • Chatter Feed • Chatter Publisher • Notes 953 Extend Salesforce with Clicks, Not Code App Tools Custom Utilities Pop-out is available for custom utilities. To enable pop-out for custom utilities, activate the Utility Bar: Enable Pop-Out for Custom Utilities critical update. The critical update enables pop-out for all utilities in the “Custom” and “Custom – Managed” categories. Test your custom utilities in a sandbox environment before you enable the update. Disabling Pop-Out If you don’t want your custom utility to be popped out, you can disable pop-out in two ways. Disabling Pop-Out within the Component Use the lightning:utilityItem interface in your component and set the supportsPopOut attribute to false to disable pop-out. Disabling pop-out within the component itself is a useful and simple way to ensure that the component can never be popped out. Disabling Pop-Out with the Lightning Console JavaScript API Use the disableUtilityPopOut() method and set the disabled argument to true to disable utility pop-out. If you’re migrating from a Classic console app and using a Visualforce page for your utility, we automatically respect if setCustomConsoleComponentPopoutable is set to false. Disabling pop-out with the Lightning Console JavaScript API allows you to enable and disable pop-out in real time. Lightning App Navigation Bar Items Most of the items that appear in the App Launcher can appear in a Lightning app navigation bar. EDITIONS To add items to an app’s navigation bar, you can use the Lightning app creation wizard, which lets you choose from a list of available items. Available in: Lightning The list of available items contains only those items in your org that are eligible for Lightning app Experience navigation bars, which includes: Available in: Enterprise, • Most standard objects, including Home, the main Chatter feed, Groups, and People Professional, Performance, • Your org’s custom objects and apps Unlimited, and Developer Editions • Visualforce tabs • Lightning component tabs USER PERMISSIONS • Lightning page tabs • Canvas apps via Visualforce tabs To view navigation menus: • Web tabs • View Setup and Configuration If the Lightning app was installed from a managed package, you can append navigation items To create navigation menus: below the original set of navigation items included in the Lightning app, which are locked. • Customize Application Note: You can’t add Connected apps like Gmail™ and Microsoft® Office 365™ to the navigation bar. Users can continue to access them from the App Launcher. 954 Extend Salesforce with Clicks, Not Code App Tools Upgrade Classic Apps to Lightning Apps You can upgrade a Classic app to a Lightning app in Lightning Experience, enhancing it for your EDITIONS Lightning Experience users with a customized color, logo, utility bar, and more items like Lightning pages supported in the navigation bar. Available in: Lightning Note: You can’t upgrade a Salesforce Classic console app to Lightning Experience. You can Experience choose to display or hide the app in the Lightning Experience App Launcher, but you can’t Available in: Contact edit the app from the App Manager page in Lightning Experience Setup. To get started in Manager, Group, Lightning Experience, customize these Salesforce-provided Lightning console apps: Service Professional, Enterprise, Console and Sales Console. You can also recreate your Salesforce Classic console app in Performance, Unlimited, Lightning Experience, but using the Salesforce out-of-the-box app is faster and easier. and Developer Editions 1. From the Home tab in Setup, enter App in the Quick Find box, then select App Manager. 2. Find the Classic app that you want to upgrade in the apps list. USER PERMISSIONS Note: A checkmark in the Visible in Lightning Experience column means that the app To view apps: is accessible in Lightning Experience via the App Launcher and is fully functional. Even • View Setup and though a Classic app works in Lightning Experience, it doesn’t take advantage of all the Configuration benefits of being a Lightning app. That’s why we recommend that you upgrade it. To manage apps: • Customize Application 3. Click , and select Upgrade. 4. Review the app properties and update them if necessary. If you have custom Lightning Home pages assigned to profiles in your org, and the app you’re upgrading is visible in Lightning Experience, you see a checkbox that lets you apply those Home page profile assignments to the upgraded app. Selecting the checkbox ensures that users see the custom Home page assigned to their profile when they're working in the upgraded app, and that you can modify those Home page assignments if you need to. 5. Click Upgrade. Your Classic app is copied and upgraded for Lightning Experience. You now have two versions of the app: a Classic version, and a Lightning version. After you upgrade it, the Classic app is no longer accessible in Lightning Experience via the App Launcher. You still see the Classic app in the apps list, but with the Visible in Lightning column deselected. The two versions of your app now must be managed separately. Future changes you make to the Classic app won’t be reflected in the Lightning version of the app, and vice versa. Note: You can toggle the availability of your Classic apps in Lightning Experience by selecting or deselecting Show in Lightning Experience on the Classic app’s detail page. SEE ALSO: Lightning Apps Salesforce App Considerations 955 Extend Salesforce with Clicks, Not Code App Tools Salesforce App Considerations Keep these considerations in mind when working with apps in either Lightning Experience or EDITIONS Salesforce Classic. Available in: Salesforce General Classic (not available in all orgs), Lightning Experience, • You can delete custom apps, but not standard apps. Deleting a custom app removes it from and the Salesforce mobile the apps menu and the App Launcher, but doesn’t delete any associated objects. If you created app objects for an app, consider deleting them as well. Available in: Contact • Salesforce Classic console apps are custom apps. Manager, Group, • You can’t change an app’s type—such as standard to connected or vice versa—after you create Professional, Enterprise, it. Performance, Unlimited, • For Salesforce Platform and Salesforce Platform One license users, the Platform standard app and Developer Editions is the only app listed in the Lightning Platform app menu and the Lightning Experience App Launcher. For details about specifying a unique label for the Platform standard app in Salesforce Classic, see Create Custom Apps for Salesforce Classic on page 948. • To assign apps to user profiles in Professional Edition, you must have user profiles enabled for your org. Classic Apps Consider these requirements when choosing a custom app logo for a Classic app from the document library: • The image must be in GIF or JPEG format and less than 20 KB. • If the image is larger than 300 pixels wide by 55 pixels high, then it is scaled to fit. • For the best on-screen display, we recommend that you use an image with a transparent background. • The Externally Available checkbox must be selected on the document’s properties so that users can view the image. Lightning Apps • The number of Lightning Apps you can create in an org varies by edition. Edition Lightning Apps Limit Professional Edition 10 Enterprise Edition 25 Unlimited Edition Unlimited • A Lightning app’s description displays in the App Launcher, so we recommend that you keep the description concise. • Users can’t remove the items you include in the navigation bar, and they can’t personalize the navigation bar when it contains more than 50 items. For example, if you include 32 items in an app’s navigation bar, users can add 18 more personal items. • Consider these requirements when choosing a custom app image for apps in Lightning Experience: – App images represent your app in both Lightning Experience and the Salesforce app. – Choose a JPG, PNG, BMP, or GIF image that's smaller than 5 MB. – For best results, upload an image that's 128 by 128 pixels. Images larger than the maximum display of 128 by 128 pixels are automatically resized. 956 Extend Salesforce with Clicks, Not Code What is a Subtab App? • Even if you haven’t selected the option to override themes in the App Manager, your app’s brand image and color always override the Lightning Lite and Lightning Blue themes. • If you restrict an app to one type of device, only users viewing the app on that device can access it. For example, if you assign your app to the Phone form factor, your desktop users don’t see the app in the App Launcher. Only your Salesforce mobile app users can see it. • Not all objects that appear in the App Launcher can appear in an app, but it’s easy to figure out which ones can. When you start the wizard from the Lightning Experience App Manager, you see all available items for a navigation bar. • Navigation items in a Lightning app installed from a managed package are locked. You can’t remove or reorder them. However, you can append other navigation items so that they’re accessible in the Lightning app. • You can create records and access recent records and lists for certain items directly from the navigation bar. Items with next to their name support this feature, with a few exceptions. Tasks and Notes allow you to create a record but you can't access recent records or lists. Reports and Dashboards allow you to see recent records but you can't see recent lists or create a record. • Some tabs, such as web tabs and Visualforce tabs, aren't highlighted when you select them on the navigation bar. For example, when you select Contacts, the tab is highlighted (1). However, when you select a web tab, the page displays but the tab isn’t highlighted (2). What is a Subtab App? An app is a group of tabs that work as a unit to provide application functionality. Similarly, a subtab EDITIONS app is a collection of tabs that appears on the Chatter profile page. A subtab app can include both default and custom tabs. Available in: both Salesforce Users can see different sets of tabs on the profile page depending on their context. Subtab apps Classic (not available in all are the various sets of tabs available on specific pages, such as users’ profile pages. orgs) and Lightning Experience These default subtab apps determine which tabs display, depending on the user’s context. Available in: Contact Subtab App Displayed to the user when viewing... Manager, Group, Professional, Enterprise, Profile (Others) Another user inside their internal organization Performance, Unlimited, Profile (Self) Their own profile inside their internal and Developer Editions organization Profile in Communities (Others) Another user while inside a community. It’s shown only if Communities is enabled. Profile in Communities (Self) Their own profile inside a community. It’s shown only if Communities is enabled. 957 Extend Salesforce with Clicks, Not Code What is a Subtab App? Note: End users can’t customize the display of subtab apps. Administrators can hide tabs within subtab apps using the Tab Hidden option in Tab Settings. Users can see tabs set to Default Off and Default On. Managing Subtab Apps You can view and customize the subtab apps on users’ profile pages. Controlling Subtab App Visibility Once you have configured subtab apps, you can specify which users can see specific tabs on the profile page. Managing Subtab Apps You can view and customize the subtab apps on users’ profile pages. EDITIONS From Setup, enter Apps in the Quick Find box, then select Apps to display your organization’s subtab apps. Available in: Salesforce Classic (not available in all You can do the following: orgs), Lightning Experience, • To view details for a subtab app, click the name in the Subtab Apps section. This displays its and the Salesforce mobile properties, such as which tabs are part of the app, including any tabs that are not yet deployed. app Click custom tabs in the Included Tabs list to view details. Available in: Contact • To change the properties of a subtab app, click Edit to choose the tabs to include in the subtab Manager, Group, app, change their display order, and set the Default Landing Tab. Professional, Enterprise, Performance, Unlimited, Note: Administrators can change permission sets or profile settings to limit users’ access and Developer Editions to each tab. This allows administrators to make specific tabs available to some users, but not to others. USER PERMISSIONS SEE ALSO: To view apps: What is a Subtab App? • View Setup and Configuration Controlling Subtab App Visibility To manage apps: • Customize Application 958 Extend Salesforce with Clicks, Not Code Lightning Platform Home Page Controlling Subtab App Visibility Once you have configured subtab apps, you can specify which users can see specific tabs on the EDITIONS profile page. To control the visibility of tabs within a subtab app: Available in: Salesforce Classic (not available in all 1. From Setup, enter Profiles in the Quick Find box, then select Profiles. orgs), Lightning Experience, 2. Do one of the following: and the Salesforce mobile • Original profile user interface—Click Edit next to the profile you want to modify and scroll app to the Tab Settings section. Available in: Contact • Enhanced profile user interface—Click the profile you want to modify and click Object Manager, Group, Settings. Click the object you want to modify and click Edit. Professional, Enterprise, Performance, Unlimited, Note: Some profiles, including Chatter External and Chatter Free users, don’t have the and Developer Editions permissions needed to view subtab apps. 3. Change the tab settings. USER PERMISSIONS End users can’t customize the display of subtab apps. Administrators can hide tabs within subtab To view apps: apps using the Tab Hidden option in Tab Settings. Users can see tabs set to Default • View Setup and Off and Default On. Configuration 4. (Original profile user interface only) To reset users’ tab customizations to the tab visibility settings To manage apps: that you specify, select Overwrite users’ personal tab customizations. • Customize Application 5. Click Save. SEE ALSO: What is a Subtab App? Managing Subtab Apps Lightning Platform Home Page The Lightning Platform Home page contains options for building and managing applications. EDITIONS You access the Lightning Platform Home page from Setup. In Lightning Experience: Available in: both Salesforce Classic (not available in all • The left sidebar, which you can browse or search, provides access to all setup actions, tasks, orgs) and Lightning and tools. Experience • The Quick Find lets you quickly navigate to any node using a keyword. Quick Find is the best Available in: all editions way to find what you’re looking for if you know its name. except Database.com • The Create menu gives you quick access to common Setup creation functions—including users, custom objects, custom tabs, apps, email templates, and processes—without having to drill down through the Setup tree to get the page. You can get to the Create menu from any page USER PERMISSIONS in Setup. To access the Lightning • A carousel of quick-access tiles gives you instant access to important setup tools and information, Platform Home page: as well as the release notes. There’s a link to download SalesforceA—which lets you do Salesforce • Customize Application administration from a mobile app—and a link to the System Status screen so you can view your org’s performance and usage data. 959 Extend Salesforce with Clicks, Not Code Lightning Platform Home Page • The Most Recently Used list shows your most recently used records or customization features in Setup. You can quickly link back to what you were working on by clicking its name. • The Object Manager provides a one-stop shop for managing all objects in your organization, both standard and custom. In Salesforce Classic: • The left sidebar, which you can browse or search, provides access to all setup actions, tasks, and tools. • The Getting Started box contains a tool for generating a basic app in a single step and links to information about extending and managing apps. This box doesn’t appear if you’ve previously dismissed it. • The Recent Items list shows recent metadata items that you’ve viewed, edited, or created and their related objects. • The System Overview messages box displays messages to remind you when your organization reaches its usage limits. The System Overview messages box is not enabled by default. • The Quick Links box provides links for managing tools, users, apps, security, and data. • The Community box showcases available resources. If you’ve previously dismissed this box, it reappears with each new release. • The right pane includes external links that are useful for developers and administrators. Recent Items List (Beta) The Recent Items list shows recent metadata items that you’ve viewed, edited, or created and their related objects. Recent Items List (Beta) The Recent Items list shows recent metadata items that you’ve viewed, edited, or created and their EDITIONS related objects. Note: The Recent Items list is in beta. It is production quality but has known limitations. Available in: Salesforce Classic (not available in all The Recent Items list includes: orgs) and Lightning Experience • Apex classes • Apex triggers Available in: all editions except Database.com • Approval processes • Apps • Custom report types • Email templates • Fields • Objects • Page layouts • Permission sets • Profiles • Record types • Static resources • Tabs • Users • Validation rules • Visualforce pages • Visualforce components 960 Extend Salesforce with Clicks, Not Code Configuring System Overview Messages • Workflow email alerts • Workflow field updates • Workflow outbound messages • Workflow rules • Workflow tasks Note: The Recent Items list in Setup is independent of the Recent Items section in the sidebar column of many Salesforce pages. The list in Setup shows items that administrators use, while the Recent Items section in the sidebar displays records with which end users have worked. Configuring System Overview Messages Note: The system overview page shows only the items enabled for your organization. For EDITIONS example, your system overview page shows workflow rules only if workflow is enabled for your organization. Available in: both Salesforce Add system overview usage messages to the Salesforce Home page to remind you when your Classic (not available in all organization approaches its limits. You can expand, collapse, and dismiss the system overview orgs) and Lightning Experience messages that appear on the Home page. By default, the system overview home page messages are enabled. Available in: All Editions To configure the system overview messages on the Home page: except Personal and Database.com 1. From Setup, enter System Overview in the Quick Find box, then select System Overview. USER PERMISSIONS 2. Click Configure Messages. 3. Select or deselect the types of system overview messages to show or hide on the Home page. To configure system messages: 4. Click OK. • Customize Application Important: System overview messages only appear on the Salesforce Home page when your organization approaches its limits. When you enable or dismiss system overview messages, it only impacts your individual view of the messages. Lightning App Builder The Lightning App Builder is a point-and-click tool that makes it easy to create custom pages for EDITIONS the Salesforce mobile app and Lightning Experience, giving your users what they need all in one place. The Lightning App Builder is also a one-stop shop for configuring Lightning apps. Available in: both Salesforce You can access the Lightning App Builder from Setup by entering Lightning App Builder Classic and Lightning in the Quick Find box and then selecting Lightning App Builder. Experience With the Lightning App Builder, you can build: Available in: Group • Single-page apps that drill down into standard pages Essentials, Professional, • Dashboard-style apps, such as apps to track top sales prospects or key leads for the quarter Enterprise, Performance, Unlimited, and Developer • “Point” apps to solve a particular task, such as an expense app for users to enter expenses and Editions monitor expenses they’ve submitted • Custom record pages for your objects, tailored to the needs of your users 961 Extend Salesforce with Clicks, Not Code Create a Custom App Page: The Big Picture • Custom Home pages containing the components and features that your users use most But that’s not all. When you edit a Lightning app from the App Manager in Setup, you’re brought into the Lightning App Builder to manage the app’s settings. You can update the app’s branding, navigation, app options, and manage the Lightning pages assigned to that app all inside the Lightning App Builder. The Lightning App Builder supports the same browsers as Lightning Experience and isn’t supported on mobile browsers. The minimum recommended resolution for the Lightning App Builder is 1280x1024. SEE ALSO: Create an App Home Page with the Lightning App Builder Create and Configure Lightning Experience Record Pages Supported Browsers and Devices for Lightning Experience Lightning Aura Components Developer Guide Lightning Web Components Developer Guide Create a Custom App Page: The Big Picture With just a few steps, you can create an app page that lets your Lightning Experience and Salesforce mobile app users access the most important objects and items in your custom app. Custom app pages are built using Lightning pages. 1. Before creating your page, determine which components you want to include and the global actions your users need. 2. Create the Lightning page. 3. Add actions to your page. 4. Activate your Lightning page in the Lightning App Builder. 962 Extend Salesforce with Clicks, Not Code Lightning Pages Activation lets you create a custom tab for your app page, set its visibility, and add it to the Salesforce “Mobile Only” app navigation and Lightning app navigation bar all in one place. Lightning Pages A Lightning page is a custom layout that lets you design pages for use in the Salesforce mobile app or Lightning Experience. Lightning pages occupy a middle ground between page layouts and Visualforce pages. Like a page layout, Lightning pages allow you to add custom items to a page. However, these items, instead of being fields or Visualforce components, are Lightning components, which allow much more flexibility. The structure of a Lightning page adapts for the device it’s viewed on. The template you choose when creating the page controls how it displays on a given device. The Lightning page’s template divides the page into regions. Lightning pages are built using Lightning components—compact, configurable, and reusable elements that you can drop into regions of the page in the Lightning App Builder. You can use a Lightning page to create an app page that you can add to the navigation bar of a Lightning app, which makes it appear when that app is viewed in both Lightning Experience and the Salesforce mobile apps. An app page gives your users quick access to the objects and items that are most important in that app. You can also use a Lightning page to create a customized Home page for Lightning Experience, or a custom record page for Lightning Experience and the Salesforce mobile app. And if you have integrated Salesforce with Microsoft® Outlook® or Gmail™, you can create a custom Email Application pane. If you have a console app, you can create a Lightning page with pinned regions to let your users view and work with records while navigating between subtabs. Lightning pages support these components: Standard Components Standard components are Lightning components built by Salesforce. 963 Extend Salesforce with Clicks, Not Code Lightning Pages Custom Components Custom components are Lightning components that you or someone else have created. With some configuration, custom Lightning components can work in the Lightning App Builder. Third-Party Components on AppExchange The AppExchange provides a marketplace for Lightning components. You can find packages containing components already configured and ready to use in the Lightning App Builder. Example: This Lightning app page in the Salesforce mobile app has a list view component, a recent items component, and one global action. Lightning Page Types You can create different types of Lightning pages with the Lightning App Builder. After you set a Lightning page’s type, you can’t change it. App Page App pages are supported both in the Salesforce mobile app and Lightning Experience. Use an app page to create a home page for a third-party app that you can add directly into the Salesforce mobile app and Lightning Experience navigation menus. Your users then have an app home page where they can quickly access the most important objects and items. Add global actions to an app page to enhance its functionality. Global actions allow a user to do things from your app page, such as add call details, create and update records, send email, and create a task. When a user visits a Lightning page in the Salesforce mobile app, the page’s actions appear in its action bar. In Lightning Experience, actions appear in the highlights panel at the top of the page. Important: Create actions in the full Salesforce site before adding them to your app page. App pages support only global actions. Standard Chatter actions, such as Post, File, Link, and Poll, aren’t supported. When a user visits an app page in the Salesforce mobile app or Lightning Experience, only the actions that you specify for the page are displayed. If you haven’t specified any actions, no actions appear. 964 Extend Salesforce with Clicks, Not Code Lightning Pages Home Page Create Home pages with features relevant to specific types of users, and assign the customized pages to different apps or app-and-user-profile combinations. Custom Home pages are supported in Lightning Experience only. Record Page With a record page, you can create a customized version of an object’s record page, tailoring it to your users’ needs. Custom record pages are supported in Lightning Experience and the Salesforce mobile app. Note: Actions you see on Lightning Experience record pages and the Home page are taken from object and global page layouts. You can’t add, edit, or remove actions on these pages using the Lightning App Builder. Email Application Pane Create custom email application panes to let users work with Salesforce content that’s most relevant to them in Microsoft® Outlook® and Gmail™. Custom email application panes are supported in Salesforce Classic and Lightning Experience. SEE ALSO: Create an App Home Page with the Lightning App Builder Create and Configure Lightning Experience Record Pages Lightning Page Templates Lightning page templates are Lightning components that have been configured to serve as templates EDITIONS for custom Lightning pages. Page templates can support different form factors, such as desktop or phone. When you create a Lightning page in the Lightning App Builder, you can select a page Lightning App Builder template that matches the device you’re designing the page for. available in: both Salesforce Home page templates are desktop-only. Standard app page templates support both desktop and Classic and Lightning phone. Standard record page templates support both desktop and phone, except the console Experience pinned region templates, which are desktop only. If a form factor isn’t on the options list when you Lightning Home and utility try to assign a Lightning page, then the page template doesn’t support it. bar pages available in: When working on a page in the Lightning App Builder, you can use the form factor switcher to Lightning Experience preview what the page looks like on different devices that the template supports. Lightning app and record Custom Lightning page template components are supported for record pages, app pages, and pages available in: both the Home pages. You can create custom page templates only in Aura. For more information, see “Create Salesforce mobile app and a Custom Lightning Page Template Component” in the Lightning Aura Components Developer Lightning Experience Guide. Email application pane When switching your Lightning record pages to a different template, keep these considerations in pages available in: both mind. Salesforce Classic and Lightning Experience • You can’t switch to a template that supports a smaller scope of devices than the original template. For example, if you have a page using a template that supports both desktop and Available in: Group phone, you can’t switch the page to use a template that supports only phone or only desktop. Essentials, Professional, When you choose to switch, the list of available templates reflects this rule and shows only the Enterprise, Performance, templates that you can switch to. Unlimited, and Developer • If you switch to a page template that doesn’t support the form factor of a component on your Editions page, that component is dropped from the page at run time. 965 Extend Salesforce with Clicks, Not Code Lightning Pages • You can’t switch from a non-pinned region template to a pinned region template. Standard Lightning Page Components Standard components are Lightning components built by Salesforce. Several standard components EDITIONS are available when creating Lightning pages. Note: The components listed here are supported across all page types, except when otherwise Lightning App Builder indicated. This list doesn’t show all available standard components. Other standard component available in: both Salesforce types are available and vary based on the type of page you create and with which object the Classic and Lightning Experience page is associated. Some standard components have required properties that you must configure for the component Lightning Home and utility to work on the page. When you add a component to a Lightning page in the Lightning App Builder, bar pages available in: its required properties are marked with an asterisk. Lightning Experience A Lightning page region can contain up to 100 components. Lightning app and record pages available in: both the If you have a page to be used in the Salesforce mobile app, use only Lightning components that Salesforce mobile app and the mobile app supports. See Data Available in the Salesforce Mobile App. Lightning Experience Email application pane Accordion pages available in: both Use the Accordion component to organize your components into collapsible sections. You can put Salesforce Classic and multiple components in each section and customize the section name. You can have up to 25 Lightning Experience sections, but we recommend no more than 10. Available in: Group The Accordion component is supported for record and Home pages. Essentials, Professional, Enterprise, Performance, Note: Programmatic versions of the accordion components don’t provide the same Unlimited, and Developer functionality as their App Builder counterparts. For example, lightning-accordion Editions and lightning:accordion components don’t currently support lazy loading. Actions & Recommendations Component Give your users a to-do list in the Actions & Recommendations component. Show a variety of steps, including screen flows, field service mobile flows, quick actions, and recommendations from your Next Best Action strategies. When a user opens a flow, in a console app it starts in a subtab. In a navigation app, it starts in a window. You can add this component to supported object pages in Lightning Experience. For more information, see Lightning Flow for Service and the Actions & Recommendations Component. Activities Display the timeline of the activities of the record. This component appears only if Default Activities View is set to Activity Timeline. The component can contain Create a Record quick actions that point to the Event and Task objects. It contains Log A Call and Send Email actions for each of your org’s accounts, contacts, contracts, leads, opportunities, and activity-enabled custom object records. Note: On the Case object, the component only shows the timeline of the activities. Actions appear in a Chatter Publisher component. For more information, see Activities View and Actions in Lightning Experience. 966 Extend Salesforce with Clicks, Not Code Lightning Pages After Conversation Work (Beta) Display a countdown after a customer conversation ends. During the After Conversation Work (ACW) countdown period, support agents can complete closing tasks like sending follow-up emails, updating a case, or finalizing their notes. Agents can exit the countdown early by closing the call record or let it run its course. When the time runs out, the agent is considered available to help the next customer whether or not they’ve closed the call record. After Conversation Work is available only for Voice Call channels. To learn more, see Configure After Conversation Work (Beta). App Launcher Component The App Launcher displays a user’s available Salesforce apps and the connected apps the administrator has configured. Users navigate between apps using the App Launcher. This component is supported in API version 35.0 and later. Contact Salesforce to enable the App Launcher component for the Lightning App Builder in your organization. C360 Global Profiles The C360 Global Profile component shows the matched Customer 360 profile data related to the person account record in the page layout. This component retrieves data from Customer 360 Data Manager for your single customer view. Some of the data in this component isn't stored locally in your Service Cloud org if the data originated in another data source connected to Customer 360 Data Manager. Your admin user can determine which data is copied into your Service Cloud and which data is queried on demand via this component and Customer 360 Data Federation Services. This component displays data in Customer 360 Data Manager that’s matched back to the person account record. The component shows these fields. • Name — First and Last or Family name of a person. • Email — Email addresses of a person • Phone Note: Removing Data Mappings from the Cloud Information Model in Customer 360 Data Manager can remove data visible in this component. C360 Order History The C360 Order History component shows the ecommerce order history for the person account that was matched to B2C Commerce orders through Customer 360 Data Manager. This component displays ecommerce order data from B2C Commerce retrieved by the Customer 360 Data Federation Service. Otherwise, an admin must copy and store order data locally in your Service Cloud org. These fields are displayed in this component. • Order No. — The customer’s order number, generated by B2C Commerce. The values in this field are hyperlinks, which open a separate UI for the Order Details. • Checkout Date — The date on which the customer placed the order on the website. • Order Status — The status of the customer’s order, such as Not Shipped, Shipped, or Returned. • Total Amount — The total amount, in the site’s currency, paid by the customer for the order. • WebsiteID — The B2C Commerce site ID as defined in Business Manager. 967 Extend Salesforce with Clicks, Not Code Lightning Pages Note: Removing Data Mappings from Commerce Cloud in Customer 360 Data Manager can remove data visible in this component. Call Recording Player Use this component to listen to audio recordings of calls. The Call Recording Player component is available only for the Voice Call object. This component is available in the Lightning App Builder in orgs where Service Cloud Voice is turned on. To view and use this component, users need the Contact Center Agent permission set. Because the Call Recording Player doesn't have an alternative text-based transcript, we recommend adding the Conversation Body component underneath the Call Recording Player to support accessibility. Chatter Component As of API version 38.0, the Feed component has been renamed Chatter in the Lightning App Builder. Use it to place a publisher and feed combo on a record page. Chatter Feed Component Use the Chatter Feed component to place a feed anywhere on a record page. The feed gives you a way to view posts, comments, and questions. Its attribute, Feed Type, takes one of these values. • Bookmarked—Shows a feed of all items the current user has bookmarked. • What I Follow—Shows a feed of all items the current user has followed. • To Me—Shows a feed of all items where the current user is mentioned. No coding is required to join a feed to a publisher. The connection is made automatically with the publisher and any feed on the page. The Chatter Feed component is available in API version 38.0 and later. Chatter Publisher Component Use the Chatter Publisher component to place a feed publisher anywhere on a record page. The publisher gives you a way to post, poll, or ask a question in a feed. Its attribute, Type, has the default value Global. Use the value Record when you want to associate the publisher with an object's feed. Then posts that are created with the publisher are associated with the record rather than the global Chatter feed. Use the Chatter Publisher component with the Chatter Feed component to get a full feed experience. No coding is required to join a publisher to a feed. The connection is made automatically with the publisher and any feed on the page. The Chatter Publisher component is available in API version 38.0 and later. Conversation Body Use this component to let agents view call transcripts in Service Cloud Voice. The Conversation Body component is available only for the Voice Call object. Transcripts are generated in real time during the call and the complete transcript is stored on the call record. As the call progresses, the transcript is generated and displayed in the component. Configure transcription data streams in Amazon Web Services to generate call transcripts. To view and use this component, users need the Contact Center Agent permission set. Customer Experience Score (Pilot) The Customer Experience Score component lets users view the score participants gave a particular record and the average score for all records of that object. You can add this component to custom objects and these standard objects: Account, Case, Contact, and User. To use this component, you must enable Salesforce Surveys in your org. This component is supported in API version 47.0 and later. For more information, see Customer Experience Score. 968 Extend Salesforce with Clicks, Not Code Lightning Pages Note: We provide Customer Experience Score component to selected customers through a pilot program that requires agreement to specific terms and conditions. To be nominated to participate in the program, contact Salesforce. Pilot programs are subject to change, and we can’t guarantee acceptance. Customer Experience Score component isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only based on generally available products and features. Dynamic Actions Bar Component (Pilot) With this component you can add action buttons anywhere on your Lightning record and app pages. Add, delete, and change the order of actions in the Dynamic Actions Bar. You can also control the visibility of the component and of individual actions in the component, based on record field, permission, or user. Note: We provide the Dynamic Actions Bar component to selected customers through a pilot program that requires agreement to specific terms and conditions. To be nominated to participate in the program, contact Salesforce. Pilot programs are subject to change, and we can’t guarantee acceptance. Dynamic Actions Bar component isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only based on generally available products and features. To set the visibility of individual actions in the Dynamic Actions Bar component at runtime: 1. In the Dynamic Actions Bar properties pane, click an action name to open the Action dialog. 2. Under Set Action Visibility in the Action dialog, click Add Filter. 3. Select Record Field to control action visibility for a record field, or Advanced to control action visibility for a record, permission, or user. 4. Click the Field name field and select a field from the dropdown list (for Record Field), or select a field type and then select a field (for Advanced). 5. Select an operator and enter a value, then click Done. Considerations • This component is supported only for Lightning Experience desktop on record and app pages. • The Dynamic Actions Bar supports all standard and custom global actions. • This component is supported as a source for Dynamic Interactions on app pages only. See Dynamic Interactions in the Lightning App Builder on page 1005. • Email quick action and FeedItem.MobileSmartActions actions aren’t supported for the Dynamic Actions Bar. • If no actions are supported for the current object, a message appears in the Lightning App Builder properties pane. Einstein Field Recommendations Component The Einstein Field Recommendations component recommends values for picklist, checkbox, and lookup fields on cases. It’s used in Einstein Case Classification and Einstein Case Wrap-Up, and is available only if you enabled one or both of those features. Einstein’s field value recommendations are based on data from recently closed cases. The component has two types: Case Classification and Case Wrap-Up. To learn more about using this component with Einstein Case Classification, see Display Recommendations in the Service Console. Available in API version 49.0 and later. 969 Extend Salesforce with Clicks, Not Code Lightning Pages Einstein Next Best Action Component The Einstein Next Best Action component displays suggested recommendations and actions on a record page. Use strategies to apply your org’s business rules to display context-specific suggestions to users. For more information, see Einstein Next Best Action Component. Einstein Predictions Component The Einstein Predictions component displays predictions and recommendations on a Lightning record page for a standard or custom object. For more information, see Add Einstein Predictions to a Lightning Page. Einstein Replies Component The Einstein Replies component recommends stock replies that support agents can insert into chat and messaging sessions. It’s used in Einstein Reply Recommendations, and is available only if that feature is enabled. The replies that Einstein recommends are based on past closed chats. To learn more, see Einstein Reply Recommendations. If Einstein Reply Recommendations is enabled, this component appears automatically on the Chat and Messaging console tabs for any users with the View and Act on Einstein Reply Recommendations user permission. Available in API version 49.0 and later. Highlights Panel Component The Highlights Panel component displays key record fields along with page-level actions. The fields that appear in the highlights panel come from the compact layout assigned to the object. The actions in the highlights panel come from the Salesforce Mobile and Lightning Experience Actions section of the page layout. Record highlights show up to the first 7 fields on desktop and up to the first 10 fields in the Salesforce mobile app. To streamline your highlights panel by not showing the second row of information and reducing the size of the first row, select the Show as collapsed (desktop only) checkbox. To show fewer action buttons, reduce the number using the Number of Visible Action Buttons (desktop only) attribute. To display the highlights horizontally or vertically (desktop only), drag the Highlights Panel component into a region with the horizontal or vertical dimensions you want. The highlights panel adjusts to fit the region’s space. For example, if you drag it into a narrow column, the highlights display vertically. If you drag it to a full-page width column, the highlights display horizontally. Event Insights Component The Event Insights component shows Salesforce IoT data about your customers’ connected devices on Lightning record pages alongside your CRM data. Salesforce IoT must be enabled, and you need an active orchestration to set up the Event Insights component. You can put up to five IoT orchestration variables in your Event Insights component. In the Lightning App Builder, you specify the parent record, the orchestration to pull the variables from, and the variables to show. You set the component visibility by filtering on record type. Each device (instance) can have up to 1 MB of data. Event message and device allocations follow your normal Salesforce IoT allocations. This component is supported in API version 44.0 and later. List View Component The List View component points to a list view and displays the first few records from that view. It supports all public and shared list views that are associated with standard and custom objects, except: 970 Extend Salesforce with Clicks, Not Code Lightning Pages • Activity • ContentVersion (Files) • User • UserProfile By default, a List View component displays the first three records in the list, but you can set it to show a maximum of 30. You can’t give a List View component a custom name. The component’s name is derived from the name of the list view filter you select when you configure the component. In the Lightning App Builder, the Object dropdown list for this component displays only those objects that have list views associated with them. Adding too many List View components can cause page performance issues. Use them sparingly. Order Product Summaries by Recipient Component Use the Order Product Summaries by Recipient component to display order product details on an Order Summary record page. This component is available in Salesforce Order Management. The Order Product Summaries by Recipient component displays information about the order delivery group summaries associated with the order summary, including the order product summaries associated with them. The displayed order product summary fields are defined by the Order Product Summaries related list on the OrderDeliveryGroup object page layout. To modify the columns in this component on the order summary details page, edit the related list on the Order Delivery Group page layout, not the Order Summary page layout. You can create a custom filter to control which order delivery group summary records are displayed. Order Summary Totals Use the Order Summary Totals component to display order financial totals on an Order Summary record page. This component is available in Salesforce Order Management. You can customize the panel title and which values to display. Phone Use this component to give agents easy access to the Service Cloud Voice softphone call controls so they can mute, hold, and end call. This component is displayed when an agent accepts a call and is hidden when the call ends. The Phone component is available for the Account, Case, Contact, and Voice Call objects, and for custom objects. To view and use this component, users need the Contact Center Agent permission set. Quip Document Component Use the Quip Document component to embed Quip documents directly in records. Set up any Quip document as a template so that your users can quickly create documents on Salesforce records. When you set up the Quip Document component in Lightning App Builder, you can choose different modes. • Allow different documents on each record. Let users attach different documents to different records, or create and embed new documents from scratch. Admins can programmatically attach preselected documents to different records. • Use the same document for every record. Choose an existing document to embed in each record associated with a given object. • Use a template to create new documents for each record. Specify a template from which users can create and embed documents on a per-record basis. You can use any Quip document as a template. You can set up the template to add record data to documents. 971 Extend Salesforce with Clicks, Not Code Lightning Pages • Use different templates for different records. Specify different templates for different records on the same object. This option requires you to programmatically pre-populate the component field with the URLs of different templates rather than manually choosing a single template URL. Rebate Types Panel Component The Rebate Types Panel component allows you to select and apply eligible rebate types and incentives to a mapped object. This component is supported in API version 52.0 and later. Note: To view and use this component, users need the Rebate Management license. Rebate Types Tab Component The Rebate Types component is used in combination with the Rebate Types Panel component to view and modify the benefit tiers associated with the applied rebate types and incentives. This component is supported in API version 52.0 and later. Note: To view and use this component, users need the Rebate Management license. Recent Items Component The Recent Items component displays a list of the most recently used items. The default is three, but you can set it to show a maximum of 30. In the Lightning App Builder, you can specify which objects’ records appear in the recent items list. The Recent Items component supports these objects, based on the specified properties: • All custom objects. • All standard objects for which both of these conditions are true: – A compact layout is defined for the object. – The object is tracked in the most recently used objects list. Note: The object isn’t supported for this component when it meets both of these criteria but isn’t in the list of available objects when you configure the component. Although they appear in the available objects list, the Task, Report, KnowledgeArticle, and Article objects aren’t supported for this component. If an object is tracked in the most recently used objects list, one or both of the LastViewedDate or LastReferencedDate fields are present. Record Detail Component The Record Detail component displays fields and sections from the page layout associated with the object. When users view the Lightning record page, they see different fields and sections based on their profile and page layout assignments. You can’t add, remove, or move the fields and sections when you’re viewing the component in the Lightning App Builder. You can only make field and section changes on the page layout. Related List - Single Component Use the Related List – Single component to include a single related list for a record in your Lightning page. To include all related lists for a record, use the Related Lists component. You can configure this component to display a related list for the record associated with your page, or you can display information for the parent record. Using a parent record is optional. 972 Extend Salesforce with Clicks, Not Code Lightning Pages This component is supported in API version 39.0 and later. You can use it in record pages only. Tip: Make sure that the page layout for your users includes the related list you want to use. If using a parent record, update the parent record’s page layout. Related List Quick Links Component The Related List Quick Links component displays a set of links. Users can hover over the links to see all the related list columns without opening the View All page. Header actions, mass actions, row actions, and text wrapping are all available on the hover pane. The component displays two rows of related list links in large or medium page regions, and six rows in small regions. Users can view the remaining related list links by clicking Show All, which expands the component. When a user hovers over a related list quick link, it displays the first 10 items in the related list. The content of this component is based on the set of related lists on the object's page layout plus the user’s preferences. Users can customize the order of the quick links. They can also exclude the ones they don't want in their personal settings. To exclude, they can enter Customize My Pages in the Quick Find box, selecting Customize My Pages, then clicking the object. The Open Activities and Activity History related lists aren't supported for this component. You can use this component in record pages only. Related Record Component Use the Related Record component to display the details of a related record, including the details of a parent record, in your Lightning page. This component provides your users with built-in record creation, inline edit, and the ability to unlink a record and link a new one. This functionality is possible because the component uses actions. This component is supported in API version 39.0 and later. You can use it only in record pages. Keep these considerations in mind when using the Related Record component. • To use the component, an object must have an associated quick action to update the records. Some lookup fields have default actions. If no actions are available for your lookup, follow the links in the Lightning App Builder property editor to create the actions. • To change the displayed fields for the Related Record component, configure different lookup fields, and customize the associated action in Setup. If you don’t see the action or can’t modify it, create one. Also, ensure that the lookup field to the related object is included on the page layout of the main object. Otherwise the component can’t be refreshed. • To let users look up two levels of record relationships, specify the first-level lookup and then the second-level lookup. You must specify a first-level lookup before you can add a second-level lookup. • To let users look up polymorphic fields, select a polymorphic lookup field type on the first-level lookup or on the second-level lookup. • To use the Parent Case, Asset, and Case Source lookup fields on cases, change the field-level security to visible instead of hidden. Otherwise, your users see an error. • Users without Read access to the value of a lookup field see an error. • Person account records that display in contact Related Record components are read-only. • Cases are linked to default accounts that can’t be removed (unlinked) from the component unless the contact is also removed at the same time. • The Related Record component typically uses quick action metadata to determine which fields to show. However, if the user viewing the component has read-only access to the related record, a compact layout is used to render the fields instead. As a result, a read-only user sees a smaller set of fields. 973 Extend Salesforce with Clicks, Not Code Lightning Pages Report Chart Component Use the Report Chart component to include a chart from a report in your Lightning page. If you leave the component’s Label field blank, the component’s label is derived from the report’s label. The chart refreshes if its report data is more than one day old. In the component properties, you can choose to display a refresh button to enable users to refresh the chart. Saving the report’s definitions also updates the chart data in the component. Setting a filter on the report chart data is supported only for record pages. If you set a filter option, the Report Chart component displays only that filtered data to users. This component is supported in API version 32.0 and later. It doesn’t work with reports in the My Personal Custom Reports folder. Report Chart components that refer to reports in the Unfiled Public Reports folder aren’t deployable when you include them in a package. Rich Text Component Use the Rich Text component to add text and simple HTML markup to your Lightning page. Note: JavaScript, CSS, iframes, and other advanced markup aren’t supported. To use advanced HTML elements in a component, we recommend using a Visualforce page component or a custom Lightning component. The Rich Text component uses Quill as its text editor. Keep these considerations in mind when using the text editor. • Quill wraps each line of text with tags. The tags can increase the number of characters in the rich text API value when you save the text. If you get a max length warning, break up the text into two Rich Text components. • In Quill, the default color for text is gray in the editor, but the text renders black in the output. • Selecting text using keyboard shortcuts, such as with Cmd+A, and then typing something new resets the formatting of the existing text. You can include up to 4,000 characters in the Rich Text component. This component is supported in API version 32.0 and later. Salesforce Surveys Component The Salesforce Surveys component adds an active survey to your Lightning page, so you can collect data from your users while they work on Salesforce records. This component is supported in API version 42.0 and later. Note: To create surveys and add them to Lightning pages, you must enable Salesforce Surveys in your org. Send Email Later - Pending List The Send Email Later - Pending List component shows the list of scheduled emails. From this list, your users can see pending emails, cancel an email, edit its scheduled time, or edit its content. Tableau CRM Dashboard Component The Tableau CRM Dashboard component surfaces an entire dashboard right where people work. The dashboard is fully functional and interactive. Users can refresh them, apply filters, and click chart segments to drill into filtered reports. Dashboards need space to display charts and tables. If an embedded dashboard is squished into too small a space, then a collapsed version displays instead of the full dashboard. Users can click View Dashboard to open a collapsed dashboard. Available in API version 41.0 and later. The Dashboard component isn’t available on record pages. Private dashboards aren’t available. 974 Extend Salesforce with Clicks, Not Code Lightning Pages Tabs Component Use the Tabs component to add tabs to a region of your Lightning page. Choose from a set of standard tabs or create custom tabs to enhance record and Home pages for your Lightning Experience users. The Tabs component is supported only for Lightning Experience record and Home pages. You can place up to 100 tabs in a Tabs component. This component is supported in API version 36.0 and later. Twitter Component Social Accounts and Contacts must be enabled for your organization before you can add the Twitter component to a Lightning page. Visualforce Page Component Use the Visualforce Page component to include a Visualforce page in your Lightning page. If you leave the component’s Label field blank, the label is taken from the Visualforce page that you assign to it. If you leave the Height field blank, the Visualforce page’s height defaults to 300 pixels when it displays in the Salesforce mobile app. This component is supported in API version 32.0 and later. To appear in the Salesforce mobile app or Lightning Experience, the Visualforce page must have the Available for Salesforce mobile apps and Lightning pages option selected. This option is available for pages that are set to API version 27.0 and later. Wave Dashboard Component Use the Wave Dashboard component to include Tableau CRM dashboards in your Lightning page. Contact Salesforce to enable the Wave Dashboard component for the Lightning App Builder. Select the dashboard to display from the dropdown list. If you leave the Height field blank, the dashboard’s height defaults to 300 pixels when it displays in your Lightning page. You can control the visibility of the dashboard’s title and specify whether the dashboard appears when an error occurs. With the Open Links in New Windows attribute, you can specify where links from the dashboard to other assets are opened. With the Filter attribute, you can use JSON to filter dataset fields at run time. For more information, see Embed Tableau CRM Dashboards in Lightning Pages. SEE ALSO: Custom Lightning Page Components 975 Extend Salesforce with Clicks, Not Code Lightning Pages Custom Lightning Page Components The Lightning App Builder supports custom Lightning components. EDITIONS Custom components in your org that are configured for use in the Lightning App Builder appear in the Lightning Components pane. Lightning App Builder available in: both Salesforce Classic and Lightning Experience Lightning Home and utility bar pages available in: Lightning Experience Lightning app and record pages available in: both the Salesforce mobile app and Lightning Experience Email application pane pages available in: both Salesforce Classic and Lightning Experience Available in: Group Essentials, Professional, Enterprise, Performance, Unlimited, and Developer Editions If you have a page to be used in the Salesforce mobile app, use only Lightning components that the mobile app supports. See Data Available in the Salesforce Mobile App. Your custom Lightning components don’t automatically work on Lightning pages or in the Lightning App Builder. To make a custom component usable in both: 1. Configure the component and its component bundle so that they’re compatible with the Lightning App Builder and Lightning pages. For Aura components, see the Lightning Aura Components Developer Guide. For Lightning web components, see the Lightning Web Components Developer Guide. . 2. Deploy My Domain in your org. When you deploy My Domain, references and links to Lightning resources are in the format https://MyDomainName.lightning.force.com. You can configure custom components to support different devices. For instance, you have a record page whose template supports both phone and desktop, and you activate the page for both. Then you add a phone-only component to the page. When the page is viewed on a phone, users see the component. When the page is viewed on a desktop, the phone-only component doesn’t appear. 976 Extend Salesforce with Clicks, Not Code Lightning Pages Note: Pull to refresh doesn’t work for custom Lightning web components in the Salesforce mobile app. SEE ALSO: Standard Lightning Page Components My Domain Dynamic Lightning Pages Control when a component appears on a Lightning page by adding filter conditions and logic to EDITIONS its properties in the Lightning App Builder. For example, you can construct a filter that causes a rich text component on an opportunity page to display when the opportunity’s amount is greater than Lightning App Builder or equal to $1 million. available in: Salesforce Component visibility properties appear when you select a component on a record, app, or Home Classic and Lightning page in the Lightning App Builder. This behavior applies to standard components, custom Experience components, and components from AppExchange. No need to do anything to your custom Lightning pages available in: components. It’s all handled by the Lightning App Builder. Lightning Experience and the On record pages, you can choose record fields or advanced fields, such as fields from related objects Salesforce mobile app or from a global object like User. Field values in component visibility filters can’t span more than five fields. For example, Available in: Group Record.Account.Owner.Manager.Manager.Manager.LastName has six spans, Essentials, Professional, and therefore isn’t supported. Enterprise, Performance, Unlimited, and Developer Editions App and Home pages aren’t associated with an object, so the filters you can use are limited to other contexts, such as User, User Permission, or Device. But that doesn’t mean that they’re less powerful. If you don’t define a filter, the component displays on the Lightning page as usual. When you define one or more filters and set the filter logic for a component, the component is hidden until the filter logic criteria are met. In the Lightning App Builder, components that have at least one filter assigned are indicated with an icon ( ). 977 Extend Salesforce with Clicks, Not Code Lightning Pages Visibility Rules on Dynamic Forms Fields and Field Sections You can make your Lightning record pages even more dynamic by setting visibility filters on Field and Field Section components. For example, you can have a field or set of fields hidden until a person with a certain profile, permission, or viewing on a certain device visits the page. Be careful when setting up visibility rules on multiple components in the same region. If your rules cause all the components in a region to be invisible at run time, the region will be empty. Visibility rules on fields are respected in the edit, clone, inline edit, and new record screens. Component visibility rules on field sections behave differently than they do on fields. Visibility rules on fields are assessed dynamically. Changes a user makes while editing a record can make fields appear and disappear as visibility rules are evaluated. Visibility rules on field sections aren't dynamic and don't react to what a user does while editing. Field section visibility rules are evaluated only after the record is saved. Component Visibility Based on Form Factor With a filter using the Device context, you can set a component to display exclusively when its page is viewed in a specific experience, such as a phone or a desktop. Custom Lightning components can also be set to support different form factors. For Lightning web components, see “Configure Your Component for Different Form Factors.” For Aura components, see “Aura Component Bundle Design Resources.” Supported Objects, Fields, Field Types, and Operators Two objects aren’t supported for component visibility filters: ProcessInstanceStep and ProcessInstanceWorkItem. On record pages, component visibility filters rely on the data captured in fields associated with the page’s object. Not all fields, field types, and operators are supported. These field types are supported: • String type fields: Autonumber, Currency, Email, Number, Percent, Phone, Text, Text Area, URL • ID • Checkbox (boolean) • Geolocation • Picklist • Formula fields which resolve to one of the above types • Roll-up summary fields which resolve to one of the above types These operators are supported: 978 Extend Salesforce with Clicks, Not Code Lightning Pages • CONTAINS • = and == (Equal) • <> or != (Not Equal) • > (Greater Than) • >= (Greater Than or Equal) • < (Less Than) • <= (Less Than or Equal) SEE ALSO: Formula Operators and Functions Standard Lightning Page Components Build Localized Component Labels and Attribute Values on Lightning Pages with Custom Labels When you specify labels or attributes in the Lightning App Builder such as for components or custom EDITIONS tabs, you can use the {!$Label.customLabelName} expression to help define the label or attribute’s value. Lightning App Builder On a Lightning page, custom Tabs component labels and other component attribute values aren’t available in: both Salesforce localized when they’re entered as plain text in the Lightning App Builder. For example, if you have Classic and Lightning an org whose default language is English, and you have a Tabs component with three custom tabs Experience that you entered as Cars, Trucks, and Planes, the non-English users in your org see those tab label Lightning Home pages values as Cars, Trucks, and Planes when they view the page. The tab label values aren’t translated available in: Lightning into your users’ languages. Experience But configuring custom label values in the Lightning App Builder using the Lightning app and record {!$Label. } customLabelName expression lets users see labels in their chosen language pages available in: both the if you created a translation for that label in their language. Salesforce mobile app and The {!$Label.customLabelName} expression works with any custom labels that you Lightning Experience create in Setup using the custom label feature. The text that you define in the Value field for your custom label displays as the label value when the component renders on a Lightning page. And, Available in: Group if you create a translated value for the label, users using that language in your org see the translated Essentials, Professional, Enterprise, Performance, value. Unlimited, and Developer Expressions are supported only in String type fields in component labels and attributes on app, Editions Home, and record pages. You can’t use an expression in page-level properties. 1. Create a translated custom label in Setup. USER PERMISSIONS For more information, see Translate Custom Labels. To create and save Lightning 2. Navigate to the Lightning App Builder. From Setup, in the Quick Find box, enter App pages in the Lightning App Builder, then select Lightning App Builder. Builder: 3. Open an app, record, or Home Lightning page. • Customize Application 4. Select the component whose label or property you want to replace with your translated custom To view Lightning pages in label. the Lightning App Builder: • View Setup and 5. Enter {!$Label.customLabelName} in the label or attribute field, replacing Configuration “customLabelName” with the name of your custom label. 979 Extend Salesforce with Clicks, Not Code Lightning Pages Label and property fields that support using this expression have an info bubble that says so. 6. Save your changes. Users in your org whose language is set to the language of your translated label see the label or attribute in its translated value. Example: Your org’s default language is English, but you want the custom Planes tab on your Lightning page to show a translated custom label for your German users. Here’s how to do it. 1. Create a custom label in Setup with the name Planes_Label, and enter the Value as Planes. That’s what your English users see. 2. From the Translations related list on the custom label detail page, create a translation for the label with the language set to German and the Translation Text value as Flugzeuge. 3. Save the translation. 4. In the Lightning App Builder, open your page and click the Tabs component on the canvas. 5. In the properties pane, click the Planes tab, and in the Custom Label field, replace the Planes plain text with {!$Label.Planes_Label}. 6. Click Done and save your page. When viewing the page, your English users see the tab as Planes, and your German users see the tab as Flugzeuge. Note: When a field in a component contains an expression, Salesforce can’t validate the value it resolves to. If the expression resolves to a value that’s invalid for the field, sometimes the component doesn’t work as expected. We recommend that you test the page in the translated languages before you make the page with the expression available to users. 980 Extend Salesforce with Clicks, Not Code Create an App Home Page with the Lightning App Builder Create an App Home Page with the Lightning App Builder Create a home page for an app that you can add directly into Lightning apps and the Salesforce EDITIONS mobile apps. Your users can then easily access the objects and items that are most important in that app. Lightning App Builder 1. From Setup, enter App Builder in the Quick Find box, then select Lightning App Builder. available in: both Salesforce Classic and Lightning 2. Click New. Experience 3. Select App Page and then click Next. Lightning app pages 4. Give your app page a label, and then click Next. available in: both the The label can be up to 80 characters. Salesforce mobile app and Lightning Experience 5. Select a page template and click Finish. 6. Drag the components that you want onto the page. Available in: Group, Essentials Professional, Drag components up and down to rearrange them. You can also click a component’s top or Enterprise, Performance, bottom border to create an insertion point ( ) for the next component. Unlimited, and Developer 7. Click each component on the page to configure its properties. Editions 8. Click in the empty area of the canvas or on the Page link in the breadcrumb to configure the page properties. USER PERMISSIONS The Description field is limited to 255 characters. The Developer Name field is limited to 80 characters, but if you have a namespaced org, we recommend using fewer than 65 characters. To create and save Lightning pages in the Lightning App When you create a Lightning page, the developer name is derived from the first 40 characters Builder: of the label that you give the page. • Customize Application 9. Optionally add global actions to your page. To view Lightning pages in the Lightning App Builder: a. In the page properties, click Select. • View Setup and b. Add, remove, or reorder the actions for your page. Configuration Actions you select appear on the page’s action bar and in the highlights panel at the top of the page in Lightning Experience. An app page is the only type of Lightning page that you can add actions to in this way. Other Lightning pages derive their actions from the object and global page layouts. c. Click OK. 10. Click Save when you’re done editing your page. To give your users access to the app page, you must activate it. SEE ALSO: Activate Your Lightning App Page Lightning App Builder 981 Extend Salesforce with Clicks, Not Code Create a Mobile App Page with the Lightning App Builder Create a Mobile App Page with the Lightning App Builder Create a mobile home page for the Salesforce mobile app. Your users can see this page right when EDITIONS they log in. Note: These steps are similar to Create an App Home Page with the Lightning App Builder. Lightning App Builder That’s because when you create an app page or record page, it can be made available on available in: both Salesforce both Lightning Experience and the Salesforce mobile app. The following steps focus on Classic and Lightning Experience creating an app page for the mobile app only. 1. From Setup, enter App Builder in the Quick Find box, then select Lightning App Builder. Lightning app pages available in: both the 2. Click New. Salesforce mobile app and 3. Select App Page and then click Next. Lightning Experience 4. Give your app page a label, and then click Next. Available in: Group, The label can be up to 80 characters. Essentials Professional, Enterprise, Performance, 5. Select the first template (Header and Left Sidebar) and click Finish. Unlimited, and Developer If this is a mobile-only page, it doesn't matter which template you pick. If you plan to share this Editions page between mobile and desktop users, choose the template most appropriate for desktop use. On mobile devices, the page responsively collapses into a single column. USER PERMISSIONS 6. Make sure you’re viewing the template preview using the Phone form factor. The regions on the template are displayed in a one column layout. To create and save Lightning pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration 982 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder 7. Drag the components that you want onto the page. Drag components up and down to rearrange them. You can also click a component’s top or bottom border to create an insertion point ( ) for the next component. To increase mobile adoption, we recommend making available the top features that your users use most frequently. For example, the Recent Items can take them back into the records that they were working with. Also, the List View standard components can be set to their open tasks to improve productivity in the mobile app. Remember that screen space and bandwidth are precious on mobile, so try to limit each page to 4 or 5 components at most. If you overload the page with features, it can be slow and harder to use. See Preview Mobile App Pages in Lightning App Builder on page 983. 8. Click each component on the page to configure its properties. 9. Click in the empty area of the canvas or on the Page link in the breadcrumb to configure the page properties. The Description field is limited to 255 characters. The Developer Name field is limited to 80 characters, but if you have a namespaced org, we recommend using fewer than 65 characters. When you create a Lightning page, the developer name is derived from the first 40 characters of the label that you give the page. 10. Optionally add global actions to your page. Global actions help your users perform tasks easily from the app page, like log a call, create a new case or event etc. a. In the page properties, click Select. b. Add, remove, or reorder the actions for your page. Actions you select appear on the page’s action bar and in the highlights panel at the top of the page in Lightning Experience. An app page is the only type of Lightning page that you can add actions to in this way. Other Lightning pages derive their actions from the object and global page layouts. c. Click OK. 11. Click Save when you’re done editing your page. To give your users access to the mobile app page, you must activate it. You can limit the page to mobile users during the page activation process. After activation, you can add this to any Lightning App in the App Manager for your users to personalize. If your Lightning App is available on both desktop and mobile, you can use the same page across both. Or create a Lightning App specifically for your mobile users, and add it to the navigation there. Preview Mobile App Pages in Lightning App Builder For a consistent experience across devices, use the Lightning App builder to preview your record EDITIONS and app pages. The Salesforce mobile web experience is no longer available after Summer ’20. To customize and Available in: Lightning preview your apps and pages for Lightning Experience or the mobile app, use the App Builder. You Experience can also specify certain components as mobile- or desktop-only. Available in: Group If you need more than a preview, run the Lightning apps and components in the Salesforce mobile Essentials, Professional, app. Testing in the mobile app helps validate that users have the best experience on mobile. Enterprise, Performance, When you build a mobile app page, the steps include: Unlimited, and Developer Editions • Build a new app page with the App Builder on page 982 • Activate the page and add the page to your mobile navigation • Create a Lightning app in the App Manager for your users to personalize 983 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder Watch a Demo (9 minutes) The following sections discuss best practices on building a mobile app page using the App Builder. Display Mobile-Friendly Components When you create a Lightning app page or record page via the App Builder, the template you choose controls how it displays across devices. Here are several ideas on including standard components on page 966 for mobile users. The list can vary depending on your user’s role. • The Report Chart component displays helpful data, such as your top deals, based on a filter. • The List View component can display your events, such as today’s agenda. • The Task List component can display your open tasks, overdue tasks, or another list based on a filter. • The Recent Items component lets you get back to the records you are working with recently. • The Launchpad component lets you add a grid of navigation items, such as your contacts or a custom Visualforce page, which users can access with one tap. If standard components don’t meet your requirements, create custom components on page 976. Customize Actions for the Mobile Page If you’re creating an app page, you can also customize the actions available for the page. On the Page link, click Select under the Actions label. 984 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder Here are several popular actions for mobile users that make them more productive. Again, the list can vary depending on your user’s role. • Log a call • New case • New event • New task For more information, see Salesforce Mobile App Action Bar. Activate the Page for Mobile Users When you activate the page, you have the option to add the page to both Lightning Experience and mobile app. You can add the page to any mobile-enabled Lightning app. Adding your app page to Lightning Experience makes it available to users viewing the app on desktop and in the Salesforce mobile app. Enable Users to Personalize Tabs for the Mobile App If you haven't already, enable your Lightning apps for mobile in the App Manager so your users can access the same navigation on all devices. Or create a Lightning app if you want separate navigation items on mobile. To customize your mobile experience, personalize the app on desktop with your favorite tabs, and then use them on the mobile app. This guideline is optional but highly recommended to optimize your users’ mobile experience. For this use case, choose the Desktop and phone form factors. 985 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder Add navigation items, including the app page you created and several basic tabs like Chatter and Groups. Keep the app lightweight since users can personalize their own tabs using this app. Add the profiles who need mobile access to this app. For example, the mobile app is ideal for your sales and marketing users who need access to the mobile app on the go. Both profiles can then use the mobile app to personalize the tabs they need for their role. If you have multiple Lightning apps available to different users profiles, the profiles also get access to the mobile app. Personalize Tabs for the Mobile App In Lightning Experience on desktop, users access the Lightning app you created. Go to a list view and open it in a new tab. This adds the list view to the mobile navigation and enable users to be productive in the mobile app. 986 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder After adding tabs, users can edit the mobile navigation items, edit item names, and reorder the items. 987 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder When users log in to the mobile app, the App Launcher lets them switch to the customized Lightning app. For more information, see Customize the Salesforce Mobile App. The actions you added are displayed on the home page screen with the components you added to the template in the App Builder. 988 Extend Salesforce with Clicks, Not Code Preview Mobile App Pages in Lightning App Builder 989 Extend Salesforce with Clicks, Not Code Activate Lightning Experience Home Pages Activate Lightning Experience Home Pages Is your custom home page ready for your users? Use the Activation function inside the Lightning EDITIONS App Builder to get the page out to them. You have three activation options. You can make your custom home page the default home page for all users, assign it to specific Lightning apps, or assign Lightning App Builder it to app-and-profile combinations. Assigning the page to a Lightning app or app-and-profile available in: both Salesforce combination gives your users access to a home page customized for the context they’re working Classic and Lightning in. Experience 1. Create a home page or open an existing one in the Lightning App Builder. Lightning Home and utility 2. If you opened a home page that is ready for your users and doesn’t need editing, click Activation. bar pages available in: Lightning Experience 3. If you created a page or opened a page that needs adjustment, make the necessary changes, click Save, and then click Activate. Lightning app and record You have a few options for activating a home page. pages available in: both the • Make the page the org default. Salesforce mobile app and Lightning Experience • Make the page the default home page for specific Lightning apps. Email application pane • Assign the page to a combination of Lightning apps and profiles. pages available in: both 4. On the activation screen, click the tab for the option you’ve chosen, and follow the steps to Salesforce Classic and activate the page. Lightning Experience Tip: You can also assign home pages from Setup. Enter Home in the Quick Find box, Available in: Group and then select Home. Essentials, Professional, Enterprise, Performance, • Classic apps can be viewed in Lightning Experience, but you can’t display different Unlimited, and Developer home pages assigned for specific apps and profiles. Upgrade Classic apps to Lightning Editions apps from the App Manager to make home page assignments. • If you no longer want a page to be an app or org default, redo the activation process for the page, and select the option to remove it as the default. USER PERMISSIONS • If you activate a page and then return to make changes, you don’t have to activate To create and save Lightning it again. Clicking Save after you make your edits pushes the changes to your users. pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration 990 Extend Salesforce with Clicks, Not Code Activate Your Lightning App Page Activate Your Lightning App Page To make your custom app page available to users, you must activate it. You can also rename the EDITIONS Lightning page tab, adjust its visibility, and set its position in the navigation list. The Lightning App Builder’s activation feature makes this process easy. Lightning App Builder 1. To open your app page, from Setup, enter Lightning App Builder in the Quick Find available in: both Salesforce box, select Lightning App Builder, and then click Edit next to the page. Classic and Lightning Experience 2. In the Lightning App Builder, click Activation. 3. Update the activation properties, if desired. Lightning Home and utility bar pages available in: You can: Lightning Experience • Change the page’s custom tab label. By default, the label that you give the Lightning page Lightning app and record is used as the label for its custom tab. pages available in: both the • Change the custom tab’s icon. The icon that you choose here is used as the icon for the Salesforce mobile app and page in the mobile app and in Lightning Experience. Lightning Experience • Adjust the app page custom tab’s visibility. Email application pane Note: If you select System Administrators only, the tab is set to Default On pages available in: both for System Administrators. For all other users, it’s set to Default Off and doesn’t Salesforce Classic and Lightning Experience show up in the navigation of the apps it has been assigned to, but users can see the tab in the App Launcher in Lightning Experience and on the All Tabs page in Salesforce Available in: Group Classic. Essentials, Professional, If you select Active for all users, the tab is set to Default On for all users. It Enterprise, Performance, appears in the visible tabs for its associated app, in the App Launcher in Lightning Unlimited, and Developer Experience, and on the All Tabs page in Salesforce Classic. Editions 4. Add the page to one or more Lightning apps. USER PERMISSIONS Adding your app page to Lightning Experience makes it available to users viewing the app on desktop and in the Salesforce mobile app. To create and save Lightning pages in the Lightning App 5. Set the page’s position in the Salesforce “Mobile Only” app navigation. Builder: The first item that you put in the mobile navigation list becomes your users’ landing page. • Customize Application To view Lightning pages in 6. Click Activate. the Lightning App Builder: Your Lightning page is now ready for your mobile and Lightning Experience users! • View Setup and Configuration To enable your users to personalize the app with their favorite tabs, create a new Lightning App in the App Manager. They can then use the tabs in the Salesforce mobile app. Tip: You can give your app page a custom icon image by editing the style of the page’s custom tab in Setup. SEE ALSO: Create Lightning Page Tabs Tab Settings 991 Extend Salesforce with Clicks, Not Code Create Lightning Page Tabs Create Lightning Page Tabs Before you can include a Lightning app page in the Salesforce mobile apps or in a Lightning app, EDITIONS you must create a custom tab for it. When you first activate an app page in the Lightning App Builder, a tab is created for the page as Available in: both Salesforce part of the activation process. You can also create a tab for the page manually in Setup before you Classic (not available in all activate it. orgs) and Lightning Experience You can create a custom tab only for an App Page type of Lightning page. 1. From Setup, enter Tabs in the Quick Find box, then select Tabs. Available in: All editions 2. Click New in the Lightning Page Tabs related list. USER PERMISSIONS 3. Choose a Lightning page for the tab. 4. Enter a label. To create and edit custom tabs: This text is used as the display name for the Lightning page. • Customize Application 5. Select a tab style to set a color scheme and icon for the Lightning page tab. 6. Enter a description of the tab, if desired, and click Next. 7. Choose the user profiles the new custom tab is available for. Note: In Salesforce Classic, the Default On and Default Off options for Lightning page tabs don’t work the same way as for other custom tabs. The Lightning page menu item appears for the selected profiles in Salesforce for Android and Salesforce for iOS whether you choose Default On or Default Off. Select the Tab Hidden option to hide the Lightning page for the selected profiles. 8. Click Save. Tip: When creating a custom icon for your Lightning page tab, follow these image guidelines. The icon should: • Be less than 10k in size • Be 120 x 120 pixels • Be a PNG with a transparent background • Have a resolution of 72 dpi • Not include a color background • Not include outer shadows on the inner icon graphic 992 Extend Salesforce with Clicks, Not Code Create and Configure Lightning Experience Record Pages Create and Configure Lightning Experience Record Pages Use the Lightning App Builder to add, remove, or reorder components on a record page to give EDITIONS users a customized view for each object’s records. 1. Create a record page for Lightning Experience in one of these ways. Lightning App Builder available in: both Salesforce a. From the Setup menu on a record page, select Edit Page. Classic and Lightning Experience Lightning Home and utility bar pages available in: Lightning Experience Lightning app and record pages available in: both the Salesforce mobile app and Lightning Experience Email application pane pages available in: both Salesforce Classic and Lightning Experience Available in: Group Essentials, Professional, When you select Edit Page for the first time, Salesforce makes a copy of the standard page. Enterprise, Performance, This copy is what you edit in the Lightning App Builder. If a customized page exists and is Unlimited, and Developer active, selecting Edit Page opens that page to edit. Editions b. Create a page from the Lightning App Builder list page in Setup. To find it, enter App Builder in the Quick Find box, then select Lightning App Builder. USER PERMISSIONS To create an empty page, select a page template. To create a page prepopulated with standard components, clone the system default page. To create and save Lightning pages in the Lightning App c. Clone an existing custom Lightning page from its detail page or from the Lightning page Builder: list in Setup. • Customize Application d. Click New Page from the Pages list inside the Lightning App Builder. To view Lightning pages in the Lightning App Builder: 2. In the Lightning App Builder, add, edit, or remove components to change the page’s layout. • View Setup and Reorder components by dragging them around the canvas. Configuration 3. In the page properties, give your customized page a unique, descriptive label. To get to the page properties, click Page from the breadcrumb at the top of the properties pane. 4. Save your page. 993 Extend Salesforce with Clicks, Not Code Add and Customize Tabs on Lightning Pages Using the Lightning App Builder Hang on, you’re not done yet! To make your customized record page available to your Lightning Experience and mobile users, you must activate it. You can activate the page from the Save dialog when you save it for the first time or later using the Activation button. SEE ALSO: Add and Customize Tabs on Lightning Pages Using the Lightning App Builder Lightning App Builder Considerations Lightning App Builder Limits and Limitations Add and Customize Tabs on Lightning Pages Using the Lightning App Builder With the Lightning App Builder, you can create, update, delete, and change the order of tabs and EDITIONS tab sets on record and Home pages in Lightning Experience. Configure the tabs that your users see, name them whatever you like, and add components to each tab. Lightning App Builder 1. Open a Home or record page for Lightning Experience in one of these ways. available in: both Salesforce Classic and Lightning a. From the Setup menu, select Edit Page. Experience Lightning Home and utility bar pages available in: Lightning Experience Lightning app and record pages available in: both the Salesforce mobile app and Lightning Experience Email application pane pages available in: both Salesforce Classic and Lightning Experience Available in: Group Essentials, Professional, Enterprise, Performance, When you select Edit Page for the first time, Salesforce makes a copy of the standard page. Unlimited, and Developer This copy is what you edit in the Lightning App Builder. If a customized page exists and is Editions active, selecting Edit Page opens that page to edit. b. Open a page from the Lightning App Builder list page in Setup. To find it, enter App USER PERMISSIONS Builder in the Quick Find box, then select Lightning App Builder. To create and save Lightning 2. Add a Tabs component to the page. pages in the Lightning App A default set of tabs is added. Builder: 3. To add a tab, click Add Tab in the Tabs component properties. • Customize Application 4. Customize a tab by clicking it in the properties pane. You can select a different standard label To view Lightning pages in or click Custom and enter the tab name you want. the Lightning App Builder: • View Setup and Configuration 994 Extend Salesforce with Clicks, Not Code Add and Customize Tabs on Lightning Pages Using the Lightning App Builder Note: Custom tab labels in the Tabs component—including those installed from packages—aren’t translated. For example, if you create a custom Goals tab in English, then view the page as a user whose language is set to French, the tab still displays as Goals. However, you can use the {!$Label.customLabelName} expression in a component label or attribute to represent a custom label that you create in Setup using the custom label feature. For more information, see “Build Localized Component Labels and Attribute Values on Lightning Pages with Custom Labels on page 979.” 5. To add your first component to a tab, select the tab on the canvas and then drop the component directly below it. 6. Reorder tabs in the Tabs properties pane by dragging and dropping them into position. You can’t drag and drop individual tabs on the canvas. SEE ALSO: Create and Configure Lightning Experience Record Pages Lightning App Builder Considerations Personalize the Navigation Bar in Lightning Experience 995 Extend Salesforce with Clicks, Not Code Activate Lightning Experience Record Pages Activate Lightning Experience Record Pages Is your custom record page ready for your users? Use the Activation function inside the Lightning EDITIONS App Builder to get the page out to them. You can make your custom record page the default record page for all users, assign it to specific Lightning apps, or assign it to record types and profiles. Lightning App Builder Assigning the page to a Lightning app, record type, or profile gives your users access to a record available in: both Salesforce page customized for the context they’re working in. Classic and Lightning 1. Create a record page or open an existing one in the Lightning App Builder. Experience 2. If you opened a record page that is ready for your users and doesn’t need editing, click Lightning Home and utility Activation. bar pages available in: Lightning Experience 3. If you created a page or opened a page that needs adjustment, make the necessary changes, click Save, and then click Activate. Lightning app and record You have a few options for activating a record page. pages available in: both the • Make the page the org default for the object. Salesforce mobile app and Lightning Experience • Make the page the default object record page for specific Lightning apps. Email application pane • Assign the page to a combination of Lightning apps, record types, and profiles. pages available in: both • Assign the page to a form factor, such as a desktop or phone. Salesforce Classic and Lightning Experience 4. On the activation screen, click the tab for the option you’ve chosen, and follow the steps to activate the page. Available in: Group Essentials, Professional, SEE ALSO: Enterprise, Performance, Create and Configure Lightning Experience Record Pages Unlimited, and Developer Editions Lightning App Builder Considerations USER PERMISSIONS To create and save Lightning pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration Break Up Your Record Details with Dynamic Forms The more fields that you have on your page layout, the more that the Record Detail component EDITIONS becomes a monolithic block of fields that you can’t customize. With Dynamic Forms, you can migrate the fields and sections from your page layout as individual components into the Lightning App Available in: Lightning Builder. Then, you can configure them just like the rest of the components on the page, and give Experience the users of that page only the fields and sections that they need. Dynamic Forms benefits you three ways. Available in: Group, Professional, Enterprise, • An instant upgrade from page layouts: Place fields and sections wherever you want. Performance, Unlimited, • Dynamic layouts: Use visibility rules to show and hide fields and sections. and Developer Editions 996 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms • Simpler layout management: – Manage the fields and sections on your pages in the Lightning App Builder without touching the page layout editor. – Reduce the number of page layouts you need with component visibility rules. – Take advantage of a single assignment model for the Lightning page instead of the dual model of assigning a Lightning page and a page layout. You can start using Dynamic Forms in two ways. • Create a custom object record page, then drag Field and Field Section components onto it. • Open an existing record page and migrate its record details using the migration wizard. Dynamic Forms doesn’t only affect how your users see fields on a record page. It also affects what they see when they click to edit, create, or clone a record. On Dynamic Forms-based pages, the fields that users see when creating, editing, or cloning come from the fields on the page, not from the page layout. Note: Dynamic Forms is supported on record pages for custom objects only. Migrate a Record Page to Dynamic Forms With Dynamic Forms, you can migrate the fields and sections from your existing record pages as individual components in the Lightning App Builder. Then you can configure them just like the rest of the components on the page, and give the users of that page only the fields and sections that they need. Dynamic Forms is supported only for custom objects. Required and Read-Only Fields in Dynamic Forms Universally required fields retain their status when you’re working with them on a Dynamic Forms-based Lightning page. However, you can make other fields required or read-only just for the page you’re working on. Dynamic Forms and Mobile The Dynamic Forms Field Section component and the Field components that go inside it are desktop-only. But your mobile users are still covered. The Record Detail - Mobile component gives your mobile users a way to see the record details on a Dynamic Forms-enabled page. 997 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms Dynamic Forms Tips and Considerations Keep these tips and considerations in mind when working with Dynamic Forms. Dynamic Forms Limitations Keep these limitations in mind when working with Dynamic Forms. Dynamic Forms Known Issues Keep these known issues in mind when working with Dynamic Forms. Migrate a Record Page to Dynamic Forms With Dynamic Forms, you can migrate the fields and sections from your existing record pages as EDITIONS individual components in the Lightning App Builder. Then you can configure them just like the rest of the components on the page, and give the users of that page only the fields and sections that Available in: Lightning they need. Dynamic Forms is supported only for custom objects. Experience 1. Open an existing custom object record page for Lightning Experience in one of these ways. Available in: Group, a. From the Setup menu on a record page, select Edit Page. Professional, Enterprise, Performance, Unlimited, and Developer Editions USER PERMISSIONS To create and save Lightning pages in the Lightning App Builder: • Customize Application To view Lightning pages in the Lightning App Builder: • View Setup and Configuration When you select Edit Page for the first time, Salesforce makes a copy of the standard page. This copy is what you edit in the Lightning App Builder. If a customized page exists and is active, selecting Edit Page opens that page to edit. b. From the Object Manager in Setup, open a custom object, then select Lightning Record Pages. c. Open a custom object record page from the Lightning App Builder list page in Setup. To find it, enter App Builder in the Quick Find box, then select Lightning App Builder. 2. Click the Record Detail component. 3. In the component detail pane, click Upgrade Now to start the Dynamic Forms migration wizard. 998 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms 4. Walk through the wizard, and select which page layout has the fields that you want to migrate to the page. Why choose a page layout when the Fields tab has all the fields you need? Well, the upgrade wizard takes the fields and sections from the page layout you choose and automatically adds them to your page. Just a few clicks and you’re done. No need to drag all those fields manually. As long as a field is inside a Field Section component, you can put it anywhere on the page, even inside tabs. Note: By default, fields and field sections are migrated into an Accordion component to prevent page performance issues. If you disable this option, migrated fields and sections are added to the page in place of the Record Detail component. If the Record Detail was in a region that's visible on page load, and you have a lot of fields, disabling this option can significantly impair page performance. As part of the migration process, the Record Detail component is removed from the page, replaced with fields and sections that you can configure and place anywhere you like. 999 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms If your record page supports the phone form factor, a “Record Detail - Mobile” component is added to your page as part of the migration. This new component is unique to Dynamic Forms. It displays the standard record detail fields and sections to your users when they view the page on a mobile device. SEE ALSO: Dynamic Forms and Mobile Break Up Your Record Details with Dynamic Forms Required and Read-Only Fields in Dynamic Forms Universally required fields retain their status when you’re working with them on a Dynamic EDITIONS Forms-based Lightning page. However, you can make other fields required or read-only just for the page you’re working on. Available in: Lightning A field set to Required in the field definition in the Object Manager is a universally required field. Experience Its Required value isn’t editable in the field’s properties in the Lightning App Builder property panel. Also, the read-only status of some standard fields—such as Created By, Last Modified By, Owner, Available in: Group, and Record Type—can’t be changed in the Lightning App Builder property panel. Professional, Enterprise, Performance, Unlimited, Fields marked as Required or Read-Only on a page layout retain that state when migrated into a and Developer Editions Dynamic Forms-based page. You can find all universally required fields for your page in the Universally Required Fields section of the Fields palette. Fields that you make required at the page layout level or in the Lightning App Builder property panel don’t appear in the Universally Required Fields section of the palette. If you set a field on a Lightning page to Required or Read-Only in the Lightning App Builder property panel, the behavior applies only to the field on that page, not all instances of the field. 1000 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms Be sure to include required fields on your Lightning pages. They aren’t added automatically. If there are required fields missing from the page, and the missing required fields don't have values, users can’t save a record after editing, creating, or cloning it. Don’t hide universally required fields with visibility filters. SEE ALSO: Break Up Your Record Details with Dynamic Forms Require Field Input to Ensure Data Quality Considerations for Universally Required Fields Dynamic Forms and Mobile The Dynamic Forms Field Section component and the Field components that go inside it are EDITIONS desktop-only. But your mobile users are still covered. The Record Detail - Mobile component gives your mobile users a way to see the record details on a Dynamic Forms-enabled page. Available in: Lightning When you migrate a record page that supports both desktop and phone to Dynamic Forms, a Experience Record Detail - Mobile component is added to the page for you. Available in: Group, But when you create a fresh page using a template that supports both desktop and phone, after Professional, Enterprise, adding the fields and field sections, you must add the Record Detail - Mobile component to the Performance, Unlimited, page yourself. and Developer Editions The Record Detail - Mobile component wraps fields from the Record Detail component into a mobile-only container. So, on pages that support both desktop and phone, your desktop users see the Field Section components, and your mobile users see the Record Detail - Mobile component. Example: Here’s what a page that you create in desktop mode in the Lightning App Builder looks like when viewed on a phone. The Field Section components just below the Highlights Panel on desktop are dropped on mobile, and the Record Detail - Mobile component takes over to deliver the sections and fields. 1001 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms The Record Detail - Mobile component displays with an “Unsupported form factor” message when viewed on a page in the Lightning App Builder in Desktop preview mode. SEE ALSO: Migrate a Record Page to Dynamic Forms Break Up Your Record Details with Dynamic Forms Dynamic Forms Tips and Considerations Keep these tips and considerations in mind when working with Dynamic Forms. EDITIONS General Considerations Available in: Lightning Experience • When you switch page templates on a page that uses Dynamic Forms, the list of available templates contains only the templates that are supported for your Dynamic Forms-enabled Available in: Group, page. Professional, Enterprise, • The Owner and Record Type fields get special handling in Dynamic Forms. They’re set to Performance, Unlimited, Read-Only, and that state isn’t editable in the properties pane. and Developer Editions • You can add more than one instance of the same field to a Lightning page, but all instances of that field on the page show the same data. • Programmatic versions of the accordion components don’t provide the same functionality as their App Builder counterparts. For example, lightning-accordion and lightning:accordion components don’t currently support lazy loading. • Expanding or collapsing a field section while designing a page has no effect on whether a section is expanded or collapsed for users during runtime. • When you clone a record based on a Dynamic Forms-enabled page that has visibility rules, all the fields referenced in the visibility rules are added to the cloned record, regardless of whether those fields are on the page. • When you save a new record with an empty custom object name, the API populates the custom object name field with the record ID. So make sure that the Name field is on the page and is marked as required. Visibility Rules and Dynamic Forms • If a field is hidden on a page due to a visibility rule, and a user edits the value of the field, its new or changed value isn’t saved. • Dependent picklist fields don’t respect visibility rules. Even if they have visibility rules assigned to them, dependent picklist fields still appear in the View All Dependencies list. • Component visibility rules on field sections behave differently than they do on fields. Visibility rules on fields are assessed dynamically. Changes a user makes while editing a record can make fields appear and disappear as visibility rules are evaluated. Visibility rules on field sections aren't dynamic and don't react to what a user does while editing. Field section visibility rules are evaluated only after the record is saved. Tips • We recommend not having both a Record Detail component and field sections on the same page. If you do, users can have issues with the page, including: – Multiple, overlapping save and cancel bars when both are on the page and both in inline edit. – Visibility rules on Field and Field Section components not working properly. 1002 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms – When users create, edit, or clone a record, the fields they see come from the Field Sections on the page, not from the Record Detail. – Field sections are top-down-left-right tab order only, while Record Detail is left-right-top-down tab order, which can cause confusion. As a result, fields inside a Field Section sometimes don’t line up horizontally, while Record Detail fields do. • Don’t place Field Section components on mobile-only Lightning pages. Field Section components are desktop-only and don’t appear when the page is viewed on a phone. • You can use one Lightning page for both desktop and phone. Add the Record Detail - Mobile component to the same page with your Field Section components. Your desktop users see the Field Section components, and your mobile users see the Record Detail - Mobile component. SEE ALSO: Dynamic Forms Limitations Dynamic Forms Known Issues Break Up Your Record Details with Dynamic Forms Dynamic Forms Limitations Keep these limitations in mind when working with Dynamic Forms. EDITIONS Limitations Available in: Lightning Experience • Dynamic Forms is supported on record pages for custom objects only. • Dynamic Forms doesn’t work in Internet Explorer 11. Users with IE 11 who try to view a page Available in: Group, that uses Dynamic Forms see a page with an error. Professional, Enterprise, • Dynamic Forms doesn’t work on pages based on pinned region templates and custom templates. Performance, Unlimited, and Developer Editions • Blank spaces aren’t supported. • You can add up to 100 fields per column in a Field Section component. • Only fields and sections containing fields are included when migrating a page to Dynamic Forms. Other elements on the page layout, such as custom links and blank spaces, aren't included. • If the page layout you choose to migrate has more fields and sections than we can handle, we migrate up to the first 100 sections in each region and the first 100 fields in each column. The rest of the fields are dropped, even if they’re required fields. You can manually add the dropped items later. If you change your mind after you make the switch, you can click the undo button ( ) to roll back the changes. • If you convert a section from two columns to one, the new single column can only hold 100 fields. If you had more than 100 fields total between the two columns, when you switch to a single column, the first 100 fields are moved into the single column, and the rest of the fields are dropped. If you change your mind after switching to single column, you can revert the change by immediately clicking the undo button ( ). 1003 Extend Salesforce with Clicks, Not Code Break Up Your Record Details with Dynamic Forms • Users can expand or collapse field sections only while in view or inline edit mode, not in the full edit, create, or clone windows. SEE ALSO: Knowledge Article: Extended Support for Accessing Lightning Experience Using Microsoft Internet Explorer 11 Dynamic Forms Tips and Considerations Dynamic Forms Known Issues Break Up Your Record Details with Dynamic Forms Dynamic Forms Known Issues Keep these known issues in mind when working with Dynamic Forms. EDITIONS • Density settings for field sections aren’t respected in Lightning App Builder preview. Lightning App Builder preview always shows the Comfy setting for field sections. Proper density settings Available in: Lightning are applied during runtime. Experience • If you click View All Dependencies from the Path component, the dependencies that you see Available in: Group, come from the record details on the page layout, not from the Dynamic Forms fields on the Professional, Enterprise, page. Performance, Unlimited, • If you create a record from a lookup, the fields on the window that appears come from the and Developer Editions record details, not from the Dynamic Forms fields on the page. • The CurrencyISOCode field doesn’t display as required (with the asterisk) at runtime, although it still behaves as required. • When you hover over fields in the palette, the data types shown are inaccurate. • On a Dynamic Forms-based page, multiple instances of the same lookup field that look up to an object that’s not supported in the UI API result in a page error. See the User Interface API Developer Guide for the list of supported objects. • Fields in two-column Field Section components don’t horizontally align correctly. • For a non-UI API supported object that has a Forms-enabled object as a related list, if you click New from the related list, the parent lookup field doesn't appear in the New dialog. But you can save the new record. • A record’s printable view is based on the fields from its default page layout, not the fields on the Dynamic Forms-based page. • Dynamic Forms field components aren’t supported inside the Macro Builder. When a Dynamic Forms-enabled record page is opened inside of the Macro Builder, the field components don’t appear. Visibility Rule Known Issues with Dynamic Forms • Visibility rules based on parent object fields don’t work correctly. • When you clone a record based on a Dynamic Forms-enabled page that has visibility rules, all the fields referenced in the visibility rules are added to the cloned record, regardless of whether those fields are on the page. The field value used in the rule evaluation and the field’s saved value on the cloned record can vary, depending on the cloning user’s access to the field used in the visibility rule. – If the user has read and write access to the field used in the visibility rule, and the field has a value, the source record's original value is used in the rule evaluation and saved to the cloned record. – If the user has read and write access to the field used in the visibility rule, and the field has no value, the source record's blank value is used in the rule evaluation, but the cloned record saves with the field’s default value. – If the user has only read access to the field used in the visibility rule, the source record's original value is used in the rule evaluation, but the cloned record saves with the field’s default value. 1004 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder – If the user doesn’t have read or write access to the field used in the visibility rule, the source value is treated as blank, and the cloned record saves with the field’s default value. SEE ALSO: Dynamic Forms Tips and Considerations Dynamic Forms Limitations Break Up Your Record Details with Dynamic Forms Dynamic Interactions in the Lightning App Builder Dynamic Interactions is part of our continuing drive to make Lightning pages more dynamic and EDITIONS interactive. With Dynamic Interactions, an event occurring in one component on a Lightning page, such as the user clicking an item in a list view, can update other components on the page. Dynamic Available in: Lightning Interactions lets admins create applications with components that communicate and transform Experience based on user interactions, all in the Lightning App Builder UI. It unlocks capabilities that previously were reserved only for developers. Available in: Group, To get the most out of Dynamic Interactions, admins and developers work together. Professional, Enterprise, Performance, Unlimited, Developers write custom components that power the Dynamic Interactions. The developer defines and Developer Editions the events that the component supports and then exposes the events in the Lightning App Builder UI. Then, in the Lightning App Builder, an admin configures the event by setting up the interactions between the components. Dynamic Interactions has four major building blocks. • Event—Anything that can trigger an interaction, such as a mouse click, a button press, or a change in a field’s value. • Interaction—An activity that happens between the source and the target. • Source—The item triggering the event. Currently, only custom Lightning web components and the Dynamic Actions Bar component (Pilot) on page 969 are supported as sources. • Target—The item that’s the target of the interaction. Any component on a Lightning page can be a target. An event occurring in one component (the source) can trigger changes in one or more other components on the page (the targets). A single source can have multiple targets. Note: Dynamic Interactions is supported only on app pages, and interactions are limited to activity between components. Example: Kai (they/them) and Rina (she/her) are an admin and developer team. Kai wants to give their on-the-go users an easy way to check the location of various accounts so that they can plan efficient site visits using a simple app page. Kai enlists Rina’s help to make this happen. As a developer, Rina knows that she can wire up events between components using code. But she wants to give Kai the power to configure the event interactions in the way that they need to without having to come back to her every time a change is necessary. Rina creates a custom source component for Kai, plus two other components to act as event targets. After installing the new components in their org, Kai has an app page with three custom components: Account List, Account Detail, and Account Location (a map). 1005 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder The source component is the Account List on the left. It has an Item Selected event enabled, which Rina exposed to the Lightning App Builder UI using new Dynamic Interactions code. After Kai finishes configuring the event interactions, when a user clicks a list item in the Account List component, the event fires. The Account Detail component updates to show that account’s details. At the same time, the Account Location component pinpoints that account’s location on a map. Every new click or tap on an account in the list results in updating the content in the other two components. SEE ALSO: Lightning Web Components Dev Guide: Configure a Component for Dynamic Interactions in the Lightning App Builder Lightning Web Components Dev Guide: XML Configuration File Elements 1006 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder Configure Interactions in the Lightning App Builder After you have a custom source component with exposed events in your org, you can assign event EDITIONS targets and configure the event interactions in the Lightning App Builder. 1. From Setup, in the Quick Find box, enter App Builder, then select Lightning App Builder. Available in: Lightning Experience 2. Edit an existing app page, or click New to create one. 3. In the Lightning App Builder, add a custom source component to your page. Available in: Group, If you don’t have target components on your page, add those too. Professional, Enterprise, Performance, Unlimited, 4. Click the source component on the canvas. and Developer Editions 5. In the properties pane, click the Interactions tab. 6. Under the desired event, click Add Interaction. USER PERMISSIONS The properties pane changes to show you the interaction details. To create and save Lightning 7. Select an interaction. pages in the Lightning App Currently, the only interaction available is Update Properties. Builder: • Customize Application 8. Select the target component for the interaction. To view Lightning pages in Components are listed with their region location to help you select the correct component the Lightning App Builder: when you work on pages with components spread across multiple regions. • View Setup and Configuration 9. Configure the target component properties. When you select a target component, its properties appear in the Interaction Details pane. There you define the value that you want each target property to have when the interaction happens. If you leave a target property blank, its value remains unchanged when the event triggers. To use an expression to define a target property value dynamically, click . Checkbox properties have a No change option. If you’ve changed the value of a checkbox property, use this option to reset it back to its original value, and to indicate that you want its value to remain unchanged when the event triggers. 10. Save the page. SEE ALSO: Dynamic Interactions in the Lightning App Builder Dynamic Interactions Considerations 1007 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder Expressions in Dynamic Interactions Target Properties An expression is a small chunk of code that can be evaluated to a value. It can be as literal and EDITIONS simple as 1+1 or a more complex combination of variables, operators, and functions. One expression is supported for Dynamic Interactions in the Lightning App Builder: Available in: Lightning {!Event.eventPropertyName}. You can use this expression when setting target Experience component property values in the Lightning App Builder UI and in Metadata API. The value of the eventPropertyName part of the expression varies based on which properties the developer Available in: Group, makes available for the event in the source component. Professional, Enterprise, Performance, Unlimited, Note: If you see the button on a target property, you can set its value with an expression. and Developer Editions With an expression, you can pass a value, such as a record ID or an API name, to the target item. Then when the event fires, the target item can use that value. Using an expression to define a property value makes the event interaction dynamic. We can illustrate this with an example of an app page with custom Account List and Account Location components. Here, an admin is configuring an interaction between the Account List source component and the Account Location target component. The goal for the interaction in this example is that when a user clicks an account in the list, the Account Location component updates to show the selected account’s location as a point on a map. But the Account Location component needs to know the record ID of the selected account to do that. Passing the record ID into the Account Location component tells the component which record to look at to pull the address information. In this case, the developer made the recId property available as part of the event, so the target value can be set to the active list item’s record ID using the {!Event.recId} expression. 1008 Extend Salesforce with Clicks, Not Code Dynamic Interactions in the Lightning App Builder Why not enter a 15- or 18-digit record ID into the field? If you do, any item clicked in the Account List always resolves to that one record ID, which isn’t dynamic and is incorrect. If the developer makes more than one target property available, you can set the property to be passed in by starting to type the expression in the field. After the period, you can use autocomplete to select which property to use in the expression. But don’t forget to add the ending bracket } after you make your selection. Note: Expression autocomplete doesn’t work when: • Using expressions in the rich text editor • Typing an expression in a text field without first clicking the expression button ( ) SEE ALSO: Configure Interactions in the Lightning App Builder Dynamic Interactions Limits and Limitations Dynamic Interactions in the Lightning App Builder Dynamic Interactions Considerations Keep these considerations in mind when working with Dynamic Interactions. EDITIONS • Informational components within target components are ignored when the target component’s properties are shown in the Event property editor. Available in: Lightning • If you switch page templates for a page that contains Dynamic Interactions, the available Experience template list shows only templates that support Dynamic Interactions. Available in: Group, • Aura components re-render when an interaction targeting them is triggered. Professional, Enterprise, • Autocomplete doesn’t work when entering an expression in the rich text editor. Performance, Unlimited, and Developer Editions 1009 Extend Salesforce with Clicks, Not Code Guidance for App Builder • After a component’s event metadata is used on a Lightning page or released as part of a managed package, certain breaking changes aren’t allowed, such as removing the event, renaming a property, or changing a property type. Dynamic Interactions Limits and Limitations Keep these considerations in mind when working with Dynamic Interactions in the Lightning App EDITIONS Builder. • Dynamic Interactions is supported only on app pages. Available in: Lightning • Only LWC custom components can be source components, but any component present on Experience the page (Aura or LWC) can be a target. Available in: Group, • Dynamic Interactions isn’t supported on pages based on custom page templates. Professional, Enterprise, • Only String and Rich Text type properties can use expressions to define their values. Performance, Unlimited, • The “required” property restriction isn’t respected when defining a new value for a target and Developer Editions property in Dynamic Interactions, regardless of its type or whether it’s defined with an expression. • Event is the only context supported for expressions in interactions. • You can use expressions only for properties of type String, Integer, and Boolean. • You can’t set a target property value as an array or list of values, such as a multi-select picklist. • You can set a target property value of a String attribute to empty or a Boolean attribute to false using Metadata API but not in the Lightning App Builder UI. • Dynamic Interactions doesn’t work in the Mobile Only app in the Salesforce mobile app or in the legacy tablet mobile experience. • When a dependent property is autopopulated with a value based on a selection you made or a value you entered in another property, the autopopulated value isn’t saved unless you “touch” the dependent property field by clicking into it or tabbing to it. Guidance for App Builder Get suggestions for improving your Lightning pages just when you need them. Guidance for App EDITIONS Builder gives you feedback for enhancing your Lightning pages right in the design phase, via tips in a docked prompt. Available in: Lightning Tips are available for categories such as performance, usability, and structural issues. Some issues Experience that the tips cover are also captured in the Salesforce Optimizer report. For example, if two components on a page are identical, you see a tip that tells you so. After you fix the issue, the tip Available in: Group disappears. Essentials, Professional, Enterprise, Performance, Unlimited, and Developer Editions 1010 Extend Salesforce with Clicks, Not Code Guidance for App Builder If there are tips available for your page, you see an indicator icon on the Help menu. To hide the tips docked prompt while you design your page, go to the Help menu and select Mute Tips. You can reopen the tips prompt by selecting View Tips. SEE ALSO: Lightning App Builder Considerations Salesforce Help: Improve Your Implementation with Salesforce Optimizer 1011 Extend Salesforce with Clicks, Not Code Lightning Page Performance Lightning Page Performance Several factors can negatively affect your Lightning page’s performance at runtime. For example, EDITIONS your users can run into page performance issues if they aren’t using the latest version of a Salesforce recommended browser to view the page. Some factors you can control, and others you can’t. Here Lightning App Builder are some ways you can improve performance while configuring your page in the Lightning App available in: both Salesforce Builder. Classic and Lightning Consider the number, type, and placement of components on the page. These design-related issues Experience can cause a page to load slowly: Lightning Home and utility • Too many components visible on page load bar pages available in: • Too many heavy-impact related lists visible, especially those lists with multiple-object Lightning Experience relationships Lightning app and record • Too many fields in your Record Detail component pages available in: both the Salesforce mobile app and • Having the News or Twitter component visible Lightning Experience If your page falls into one or more of these categories, we recommend that you move some components into a non-default tab or Accordion component section, unless you’re designing the Email application pane page for blind or low-vision users. For the heavy-impact related lists, we recommend that you move pages available in: both the related lists lower on their respective page layouts so that they aren’t part of the initial page Salesforce Classic and Lightning Experience load. If your Record Detail component has many fields, we recommend that you reduce the fields on Available in: Group your page layout to fewer than 60. Alternatively, move the Record Detail component into a Essentials, Professional, non-default tab or Accordion section so that it’s not part of the initial page load. Enterprise, Performance, Unlimited, and Developer For pages that are viewed on a phone, we recommend a maximum of eight visible components Editions per page. If a page has more than eight, put some in a tab or Accordion section or hide them for mobile with a visibility filter. You can see how your pages are performing in the Lightning Usage App from the App Launcher. It shows you the most used pages in your org and their page load time by browser or by page. Performance Analysis for App Builder automatically runs when you build a page. If your page performance is poor or moderate, recommendations to improve performance appear. You can manually check a Lightning record page’s runtime performance at any time by clicking Analyze from the Lightning App Builder toolbar. It assesses page performance based on all visible standard and custom components on the page. Components in nondefault tabs and Accordion sections aren’t analyzed. The User Metrics card provides 90 days of your org’s user data such as browser speeds, network latency, and number of cores. Use this information to help you decide which Performance Analysis for App Builder recommendations to take. Note: Salesforce measures performance in Experienced Page Time (EPT). The page load time mentioned here and in the Performance Analysis for App Builder tool is EPT. Considerations • If a page has more than 5 related lists or more than 25 fields in the record detail, users can encounter performance issues when viewing the page in the Salesforce mobile app. • In the Performance Analysis for App Builder tool: – Components that are restricted to the desktop form factor via a visibility rule aren’t included in the phone form factor performance assessment. – Analysis of page performance on a phone is available only on pages whose template supports the phone form factor. 1012 Extend Salesforce with Clicks, Not Code Lightning App Builder Considerations – Components aren't the only factors influencing page load time, so the numbers in the component impact chart don't add up to 100% of the predicted page load time. – Analysis of pages for the desktop form factor is measured in seconds. For the phone form factor, the page is scored based on the components that are visible when the page loads on a phone. – User metrics are org-specific or page-specific data. Previously activated pages display metrics from visits to that page. New pages display metrics from visits to all org pages. Metrics displayed in a sandbox can differ from metrics in production. SEE ALSO: Supported Browsers and Devices Technical Requirements and Performance Best Practices Measure Performance for Your Salesforce Org Get Lightning Experience Adoption Insights with the Lightning Usage App Lightning App Builder Considerations Keep these considerations in mind when working with Lightning pages and Lightning apps in the EDITIONS Lightning App Builder. Lightning App Builder General available in: both Salesforce Classic and Lightning • The Lightning App Builder supports the same browsers as Lightning Experience and isn’t Experience supported on mobile browsers. The minimum recommended resolution for the Lightning App Lightning Home and utility Builder is 1280x1024. bar pages available in: • To reduce user confusion, give each tab and Accordion section a unique label. Lightning Experience • The Lightning App Builder palette displays only the components that are available for the Lightning app and record devices supported by the page template. For example, you’re working on a page whose template pages available in: both the supports only desktop, the component palette contains components that support desktop, Salesforce mobile app and whether they support desktop only or both desktop and phone. Lightning Experience • When you open a record page in the Lightning App Builder, you see only the components that are available for the object tied to that page. For person account pages, some of the components Email application pane pages available in: both you see apply only to business accounts. Salesforce Classic and • When viewing a page in the Lightning App Builder, the form factor switcher displays only the Lightning Experience devices that the page template supports. • If the Lightning App Builder canvas view is switched to a form factor that a component on the Available in: Group page doesn’t support, that component displays as a placeholder with a warning. Essentials, Professional, Enterprise, Performance, • When a component is viewed on a device that the component doesn’t support, it’s dropped Unlimited, and Developer from the page. Editions • If you’re curious about a component, click it to see more information in the properties pane. • You can create and edit a record page even if you don’t have permission to access the object that the page is associated with. You can add, remove, delete, and reconfigure components on the page, but you don’t see any of the content for the components that are based on that object. • In Salesforce Classic, Lightning page tabs don’t display on the All Tabs page when you click . Lightning page tabs also don’t appear in the Available Tabs list when you customize the tabs for your apps. 1013 Extend Salesforce with Clicks, Not Code Lightning App Builder Considerations • When editing navigation items in a Lightning app, consider how many items you include. Users can’t remove the items you include in the navigation bar, and they can’t personalize the navigation bar when it contains more than 50 items. For example, if you include 32 items in an app’s navigation bar, users can add 18 more personal items. Users can personalize the navigation to add or move items, but users can't remove or rename the items that you add. • Put the activity timeline component at the bottom of a layout, with no other components beneath it. • On Lightning Experience record pages, a Record Detail component that contains more than four external lookup fields breaks the page at runtime. Page Templates • The Three Regions template and the pinned region templates are designed with Lightning console apps in mind. They feature a main region and two sidebars with fixed proportional widths. The main region is 50%, and the side region widths are each 25%. Three-region templates require more screen width to display correctly. Three-region templates can display incorrectly on certain devices or monitors with low resolutions. • When switching page templates, if a region in the template that you’re switching to has more than 25 components mapped to it, all components after the 25th are dropped from the page. You can proceed with the template swap, but you must then manually add the dropped components from the palette and reconfigure their properties. • The console pinned region templates let users view and work with records while navigating subtabs in console apps. These templates also work in apps with standard navigation. However, we recommend that you use a non-pinned region template in standard apps because those apps don’t benefit from a pinned region. When working with pinned region templates, keep the following in mind. – The templates are available only for record pages. – Pinned regions don’t support theming. For example, if you use custom theming to brand your app with the color green, the pinned region doesn’t apply the green color. Page Activation and Assignment • If a device isn’t on the options list when you try to assign a Lightning page as the org default, the page template doesn’t support it. • You can see which record pages are activated for which Lightning app and which form factor in the Lightning Record Pages related list in the Object Manager. • If you no longer want a page to be an app or org default, redo the activation process for the page, and select the option to remove it as the default. • If you activate a page and then return to make changes, you don’t have to activate it again. Clicking Save after you make your edits pushes the changes to your users. • If you no longer want a page assigned to a particular form factor, redo the activation process, and select the option to remove it. • If you activate a page for only one form factor, you can add support for another form factor later as long as the page’s template supports it. • Changes that you make to Lightning record page assignments aren’t immediately reflected in the Salesforce mobile app. To see a newly assigned record page, close and restart the Salesforce mobile app. • If there are no custom app-level page assignments set for the Service Console or Lightning Sales Console apps, users viewing those apps in the Salesforce mobile app see the org default record page assigned to the object instead of the system app default record page. • If you assign a custom record page as the org-wide default for an object, it becomes the default page for that object across all your Lightning apps. It also appears as the default record page for that object in Classic apps when you open them in Lightning Experience. • Accounts and person accounts have different standard default pages to begin with. However, when you create a Lightning page for accounts and assign it as the default for an org or an app, that page becomes the org or app default for business accounts and 1014 Extend Salesforce with Clicks, Not Code Considerations and Limitations for Flows in Lightning Pages person accounts. To display a custom record page for person accounts, create a custom account record page, then assign it to the person account record type. Component Visibility Rules • If a visibility filter assigns a component to “Device equals desktop,” the component appears on a page when viewed in Lightning Experience on a desktop and when viewed in a browser on an iPad. • The Salesforce mobile app on an iPad uses the phone form factor. Salesforce viewed in a browser on an iPad uses the desktop form factor. These form factors affect components on record pages differently. – If the visibility filter is “Device not equal to desktop” or “Device equals phone,” the component appears on record pages in the Salesforce mobile app on a phone and an iPad. It doesn’t appear on pages viewed in a browser on an iPad. – If the visibility filter is “Device not equal to phone,” the component appears on record pages in Lightning Experience on a desktop and on pages viewed in a browser on an iPad. It doesn’t appear in the Salesforce mobile app on a phone or an iPad. Pages and Packages • If you package a Lightning page that references protected labels, then if a subscriber org clones that page, the protected labels cause the components that use them on the cloned page to be invalid. • A Lightning page installed from a managed package appears in the Lightning pages list with a Clone option rather than Edit or Delete. The Edit and Delete buttons are also replaced with Clone on the installed page’s detail page. SEE ALSO: Create and Configure Lightning Experience Record Pages Lightning App Builder Limits and Limitations Supported Browsers and Devices Considerations and Limitations for Flows in Lightning Pages Here are some things to keep in mind when you add a flow component to a Lightning page. EDITIONS Lightning pages always use Lightning runtime, so also review Limitations of Lightning Runtime for Flows. Available in: both Salesforce Classic and Lightning Running Flows from a Lightning Page Experience When a user opens a Lightning page that has a flow component, the flow runs when the page loads. Make sure that the flow doesn’t perform any actions – such as create or delete records Available in: Essentials, – before the first screen. Professional, Enterprise, Performance, Unlimited, Input Variable Limitations and Developer Editions • These variables aren’t supported. – Collection variables – Record variables – Record collection variables • The component supports only manually entered values for input variables. • Text input variables accept a maximum length of 4,000 characters. 1015 Extend Salesforce with Clicks, Not Code Lightning App Builder Limits and Limitations Deployment Considerations Change sets and the Metadata API deploy all flows as inactive, which users can’t run. If you deploy a Lightning page (known as FlexiPage in the API) that contains a flow component, make sure to activate the flow. Lightning App Builder Limits and Limitations Keep these limits and limitations in mind when working with Lightning pages and Lightning apps EDITIONS in the Lightning App Builder. • In Salesforce Classic, the Default On and Default Off options for Lightning page tabs don’t work Lightning App Builder the same way as for other custom tabs. The Lightning page menu item appears for the selected available in: both Salesforce profiles in Salesforce for Android, Salesforce for iOS, and Salesforce mobile web whether you Classic and Lightning choose Default On or Default Off. Select the Tab Hidden option to hide the Lightning page Experience for the selected profiles. Lightning Home and utility • You can place up to 100 tabs in a Tabs component. bar pages available in: • A Lightning page region can contain up to 100 components. Lightning Experience • Lightning component global actions aren’t supported for app pages. Lightning app and record • Page overrides by profile aren’t supported in packaging. They are supported in change sets, pages available in: both the but have to be added manually. Salesforce mobile app and Lightning Experience • Dropdown menus in the Lightning App Builder can display up to 200 items. Enter a few characters, and all available matches are displayed as you type. Email application pane • Although you can add the Potential Duplicates component to person account pages, the pages available in: both Salesforce Classic and component doesn’t display duplicate person accounts. Lightning Experience • Custom tab labels in the Tabs component—including those installed from packages—aren’t translated. For example, if you create a custom Goals tab in English, then view the page as a Available in: Group user whose language is set to French, the tab still displays as Goals. However, you can use the Essentials, Professional, {!$Label.customLabelName} expression in a component label or attribute to represent Enterprise, Performance, a custom label that you create in Setup using the custom label feature. For more information, Unlimited, and Developer see “Build Localized Component Labels and Attribute Values on Lightning Pages with Custom Editions Labels on page 979.” Component Visibility Rules • A component can have up to 10 filters. • Visibility filters aren’t supported for individual tabs inside the Tabs component. • Some person account fields, including Email and Mobile, can’t be used in filters. SEE ALSO: Lightning App Builder Considerations Resources for the Point & Click Administrator In addition to online help, Salesforce creates guides and tip sheets to help you learn about our features and successfully administer Salesforce. 1016 Extend Salesforce with Clicks, Not Code Resources for the Point & Click Administrator Platform and Apps Guides and Tip Sheets For End Users For Admins Implementing State and Country/Territory Picklists Useful Workflow Rules Useful Approval Processes Salesforce Sites Implementation Guide Formulas Guides and Tip Sheets For End Users For Admins Useful Formula Fields Tips for Reducing Formula Size Using Date and Date/Time in Formulas Useful Validation Rules 1017 INDEX C N clickjack protection Notification Builder 461 Site.com 528 Custom fields P references 242 Prompts 57, 63, 68, 70, 72–73, 75, 77 Custom Help 93 S I Site.com In-App Guidance 57 clickjacking 528 1018
{!$Request.titleText}