Button, Button, Who’s Got The Button?
“Button, button, who’s got the button?” is a children’s game in which one child hides a button in one of his or her hands, and another child tries to guess which hand it’s in. (Yes, before iPhones, children did indeed play games like this!) Believe it or not, there’s an equivalent game in Lightning Experience.
Mass Action Buttons (and Any Other List View Buttons)
In your Salesforce org, you may have created buttons that appear on a list view, allowing users to check a checkbox next to one or more records, and then performing some sort of action on all of the selected records. Alas, those buttons are not even visible in Lightning Experience. There are several reasons:
- Lightning Experience doesn’t display checkboxes next to records.
- As of Winter 16, Lightning Experience doesn’t support customization of list views. None of your custom buttons, whether mass action or not, will appear in Lightning Experience list views.
- In Salesforce Classic, mass action buttons almost always use JavaScript, and Lightning Experience doesn’t support JavaScript in custom buttons.
What can you do about this? Sadly, not much. At the moment, your only choice is to develop a custom UI (either in Visualforce or with Lightning Components) that emulates the Salesforce Classic functionality, displaying its own list view selector with a checkbox next to each record, and as well as a button that allows the user to perform the mass action. You’ll also need to come up with some way to launch your custom UI, since Lightning Experience doesn’t yet support adding custom buttons to list views.
Will Salesforce ever support mass action buttons, or any JavaScript buttons, in Lightning Experience? They won’t say. I’d like to think that the fact that the Salesforce documentation still describes how to create mass action buttons (for example, http://sforce.co/1OalMJN) is a hint that they will support this in the future. However, at the moment, their only response to questions about the availability of these buttons is, “Users can always switch back to Salesforce Classic to use those buttons.” On the bright side, there does appear to be a plan in the works to allow admins to customize list views in Lightning Experience, although Salesforce isn’t saying when that might be available.
Custom Buttons with URL Hacks
Yes, the word “hack” implies something that doesn’t quite play by the rules, but even so, people have been using Salesforce URL hacks for years now. A few examples:
- A custom button on the Contact page launches the standard Send Email page, with URL parameters that initialize the page with a specific email template, subject, and/or body.
- A custom button on the Account page that launches the standard New Opportunity page, with specific fields like Opportunity Name and Close Date pre-populated.
Alas, URL hacks are no longer supported. First of all, there’s no way to get these buttons on a standard Lightning Experience page layout: neither JavaScript nor URL buttons will appear there. Second, navigating to familiar URLs (like /001 for the Accounts tab or EmailAuthor.jsp for the Send Email page) flat out don’t work in Lightning Experience, and will, at best, kick you out to Salesforce Classic.
What can you do about this? Again, alas, not much. In some limited cases, you may be able to replace your custom button with an object-specific Quick Action or a Global Action, but the action types are limited: Create a Record, Log a Call, Update a Record, Visualforce Page, etc. The more likely scenario is that you’ll have to develop a custom UI (either Visualforce or Lightning Component based) that emulates the functionality that used to be supported with URL hacks.
JavaScript Buttons on Detail Pages
For years, Salesforce developers have been calling Apex code from custom JavaScript buttons. In fact, the Apex Language Reference still describes how to call Apex code from a custom JavaScript button. However, in Lightning Experience, JavaScript buttons aren’t even visible.
What can you do about this? Again, your best option is to replace your JavaScript button with a Visualforce button, and develop a Visualforce page that performs the desired action. For example, imagine that, in Salesforce Classic, your Case page has a custom JavaScript button that calls Apex code to close the Case, send an email to the customer, and then refresh the Case page. You can replace that with a Visualforce page that does the same thing. Your users may notice a delay, since, when they click the button, the UI will redirect to your Visualforce page before performing the actions, then redirect back to the refreshed Case page when done. The good news, though, is that you can probably re-use most, if not all, of your original Apex code.
Why, oh why, are my buttons disappearing?
Why are these types of buttons, especially JavaScript buttons, not available in Lightning Experience? Salesforce cites security concerns. Salesforce is a very security-conscious platform, and over the years, we’ve all benefited from that. As we search for ways to implement functionality in Lightning Experience that was common in Salesforce Classic, we can at least take some comfort from the fact that Salesforce continues to be so security-conscious.
Will Salesforce ever support JavaScript buttons in Lightning Experience? They’re not saying. The most they’ve said is that they’re considering options for how to support JavaScript. Stay tuned – we’ll let you know when we hear more.