After completing this unit, you'll be able to:
Every org has a unique set of business needs. If your users frequently need to access other pages in or outside your org, you can add custom buttons and links directly to object and record detail pages.
Custom buttons and links help you integrate Salesforce data with external URLs, applications, your company’s intranet, or other back-end office systems.
When your users have all the information they need on hand, they can be even more productive with Salesforce.
Custom links can link to an external URL, such as www.google.com, a Visualforce page, or your company’s intranet. Custom buttons can connect users to external applications, such as web pages, and 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 can include Salesforce fields as tokens within the URL. For example, you can include an account name in a URL that searches Yahoo: http://search.yahoo.com/bin/search?p={!Account_Name}.
If you want the button or link to launch a custom page or other code, consider a Visualforce page. If you don’t know how to use Visualforce pages yet, don’t worry. We don’t address them here, but you can learn about them in a different module.
In Lightning Experience, custom buttons and links live on your page layouts and appear in different areas of a Lightning page.
There are three primary types of custom buttons and links that you can create.
We’ll explore all three of these options.
If you're still in the Salesforce Classic interface from the last unit, locate a link near the top of your Salesforce page labeled Switch to Lightning Experience. Go ahead and activate that link.
We'll start off back in the Lightning Experience interface, then switch to Classic as we begin working with Page Layout Editor a little later on.
You’ve read what they can do, now find out how to create one. For each type, you must define the action that occurs when a user clicks it. First, the custom list button.
A custom list button is a button that you can add to a related list. When you create a list button for an object, you can add that button to that object’s related list when the related list appears on other objects. Because Energy Audits are tied to accounts with a lookup relationship field, an Energy Audits related list automatically appears on account records.
For example, earlier in the module you entered audit information for “GenePoint 5-year review.” When you view the GenePoint account record, then select the Related tab and scroll to the end of the record page, you see an Energy Audits related list heading displaying that audit.
Maria wants to add a custom button to that Energy Audits related list to let users navigate directly to the Ursa Major Solar energy audit guidelines PDF. She’s already uploaded the PDF as a file, but she needs its URL in order to have the custom button point to it. Here’s how that works.
Here, Maria can see the guidelines PDF she uploaded.
This generates a public URL for the file that you can share with others, or in this case, add as a URL to a custom button or link. In this example, the URL is https://ursamajorsolar.salesforce.com/sfc/p/R00000008nD1/a/R000000007LK/8Z8auAJBSeSCzqQ8Kv9ofolIWi_jP13oR3LUUYuXc3A
You might be thinking to yourself: “OK, whoa! What’s all that formula-looking stuff in the function combo boxes? What do I do with that?” That’s a version of Salesforce’s formula editor, and you use it to define the properties of the button or link. For example, if your content source is URL as in this case, this section is where you put the URL you want the button or link to point to. And, you can add merge fields and operators to enhance the behavior of the button or link by including data from Salesforce.
For more information on merge fields and operators, check out the Salesforce Help.
The button won’t appear on the Energy Audits related list until Maria adds it. That’s next.
Screen reader users, we'll need to hop back into Salesforce Classic now.
Navigate all the way down the end of the layout to the table for the Energy Audits related list. You can find this section easily by locating a checkbox labeled "Overwrite users' custom related lists." The section begins after this checkbox.
Maria, our Ursa Major Solar admin, wants to add a custom link that lets her users do a quick Google search on the accounts they’re viewing.
Let’s get started.
We should be in the Lightning Experience interface.
Now it’s time to add the URL we want this link to point to.
You can use Quick Save to save and continue editing. Saving validates the URL you defined if you set the content source to URL. Before you can use your custom buttons and links, you must add them to an object’s page layout. You can then see and use the button or link on a record detail page. Let’s do that next.
For screen reader users, we'll switch back to Salesforce Classic now. Activate the View Profile button and press ENTER on the link for Switch to Salesforce Classic under the Options heading.
However, the Custom Links section on our page canvas is currently empty. As mentioned in a previous unit, there is an accessibility blocker in the page layout editor when it comes to dropping elements into empty sections.
You have the theory of how to add a custom link to the page, so let's go ahead and activate the Save button to close the Page Layout Editor. This work is not tested in a challenge, so you can feel free to save and close. The challenge uses a custom button rather than a link.
Maria wants to add a custom button to account pages that shows the account’s location on Google Maps. Let's stick to the Salesforce Classic interface for this part.
http://maps.google.com/maps?q={!Account_BillingStreet}%20{!Account_BillingCity}%20{!Account_BillingState}%20{!Account_BillingPostalCode}
This URL uses merge fields ({!Account_BillingStreet}) and passes the field information from the account record that the button is clicked from into the URL. So instead of {account_billing_street}, the link will instead have the actual account billing street from the account record's address.
Now add it to the Account page layout.
OK! Now let’s test it. Go ahead and activate the link for Switch to Lightning Experience at the top of the page.
In the highlights panel at the top of the record page, not only do you see the fields from the object’s compact layout, but you also see an actions menu. The actions menu is a combination of the standard buttons, custom buttons, and actions from the page layout. (We’ll go over actions in the next unit.)
The browser opens a new window or tab that shows you the account’s address in Google Maps. Is Map Location not showing up in the actions menu even though you added the custom button to the page layout? This happens sometimes if you override the default settings of the "Salesforce Mobile and Lightning Experience Actions" section of a page layout. To fix it, add any missing buttons to the page layout as actions by dragging them from the "Mobile & Lightning Actions" category in the palette into the "Salesforce Mobile and Lightning Experience Actions" section.
Custom detail page buttons and links can do the same things. Consider where and how you want them to appear on your page, and that can help you decide which type to choose.
Click to return to the unit on Trailhead to access your challenge and proceed to the next step.