The Salesforce Admin's Toolbox is written by Megan Burch, a Salesforce Business Analyst at Sonoma Partners.
Salesforce is a powerful platform and it’s incredible to see what administrators can do without custom code or development. But what many Salesforce admins don’t realize is that they can solve many complex scenarios with a just a little bit of code and configuration, without the assistance of a developer.
The Salesforce Admin’s Toolbox is a series designed to showcase a variety of technical tasks that admins can do to elevate their Salesforce solution. I’m here to empower the admin and show you how to accomplish things you once believed could only be done by a developer.
Visual workflows allow admins to construct complex scenarios with forms and business processes. What becomes a little tricky, is providing users an easy way to access the flow within Salesforce. Users access these flows directly from a URL, through a custom web tab, or a custom button. Personally, I like using custom buttons to access the flow because the user can run it directly from the record they’re viewing. This approach may appear a bit intimidating because in addition to creating the custom button, you first have to embed the flow in a Visualforce page. But as you will see, this is really not as hard as it sounds if you follow these steps.
1. Create a new Visualforce Page
This can be done by navigating to Setup > Develop > Pages then clicking “New”
2. Embed your flow
Every new Visualforce page starts out looking like this
Remove the existing code.
For line 1, type the following:
<apex:page standardController="Contact" tabStyle="Contact" >›
The <apex:page /> tag is the command to create the page.
Note you’ll set the style of the page based on the object where you want the button to appear. In this case we’re going to put it on the Contact page. If you’re using this on another object, just substitute the name in line 1, if you’re using a custom object, append __c at the end for the standardController and tabStyle values.
The second line of your page will call the flow using a component. The component for calling a flow is simply <flow:interview /> with a name filled out.
On the second line, use the following:
Note: The name must be the unique name you created in Salesforce, so underscores will be used between words. If you’re not sure what the unique name of your flow is, navigate back to the flow you created and locate the unique name on the top right.
The last line will just be the closing page tag, so overall you’re page will look like this:
<apex:page standardController="Contact" tabStyle="Contact" >
We have just created a custom VisualForce page! Next we need to create the custom button that will access our new page.
3. Create a Custom Button
To create a custom button navigate to the “Button, Links, and Actions” option from the object you want to create the button. For your example, we will use the Contact object.
The first thing you’ll want to set is the display type.
A “Detail Page Link” button will show up next to the custom links on the detail page.
A “List Button” will show up on any related lists or list view you choose to put it on.
For this example, I chose a “Detail Page Button”. This means the custom button will show up at the top of the record along with the standard Salesforce buttons.
Next, choose your behavior. This just gives you an option of how you want the flow to open. As you can guess, the Display in new window option opens the page in a new window.
Display in existing window with sidebar will run the flow in the same window you were in, showing the Salesforce sidebar.
Display in existing window without sidebar will run the flow in the same window you were in, without showing the Salesforce sidebar.
Display in existing window without sidebar or header will run the flow in the same window you were in, without showing the Salesforce sidebar or standard header.
Again for this example, I chose Display in new window. I chose this behavior so the user could run the flow without losing visibility of the contact record they were on previously.Finally, you’ll want to select your content source, which in this case is Visualforce page.
In the Content drop down, you’ll see a list of all the Visualforce pages in your organization. Pick the page you just created and save.
4. Adding a Custom Button to a Page Layout
To add your custom button, navigate to the edit page layout screen. Select the “Buttons” option from the sidebar, and drag your button onto the page.
Users will now be able to launch the custom flow without leaving the record, which is a huge win over the custom URL solution.