Create Custom Buttons
How to Create a Custom Button in Salesforce to Improve User Experience
Overview
This guide provides step-by-step instructions on creating a custom button in Salesforce to enhance the user experience. The use case demonstrated in this guide is creating an easily accessible button that allows sales users to input descriptions into opportunity records more efficiently.
Prerequisites
A Salesforce account with the necessary permissions.
A screen flow with three elements:
Record ID variable (text type, available for input)
Get Records element to store opportunity data
Screen element to allow users to input a new description
Update Records element to update the opportunity with the new description
Step-by-Step Guide
1. Create a Screen Flow
Create a new screen flow in Salesforce.
Add the following elements to the flow:
Record ID Variable: Create a text variable named "recordId" (ensure the exact spelling matches). This variable will be used as a placeholder for the opportunity ID and must be available for input.
Get Records Element: Use this element to store all opportunity data. Set the object to "Opportunity," the ID field to "recordId" (the variable created in the previous step), and select "Get only the first record." You can choose to store all fields or just specific fields like the description.
Screen Element: This element allows users to input the new description. Use a text component, hide the header, and make the text field required. Set the default value to {!opportunity.Description} (replace "opportunity" with the API name of your opportunity object) to display the existing description as a placeholder.
Update Records Element: Use this element to update the opportunity. Select the opportunity object, filter by ID using "recordId," and update the description field with the value from the screen component (e.g., {!Place_Update_Description}).
2. Create a Custom Action
In the Opportunity object manager, click on "Buttons, Links, and Actions."
Click on "New Action."
Choose the "Opportunity Update Description" screen flow created in the previous step.
Enter a label (e.g., "Update Description") and click "Save."
3. Add the Custom Button to the Opportunity Page
Go back to the Opportunity page layout.
Click on "New Action" next to the existing buttons.
Select the "Update Description" action created in the previous step and click "Done."
Position the button as desired and click "Save."
4. Test the Custom Button
Refresh the Opportunity page.
The custom button should now be visible.
Click on the button to open the screen flow.
The existing description should be displayed as a placeholder.
Edit the description and click "Save."
The description of the opportunity should be updated accordingly.
Additional Notes
This guide demonstrates a basic example of creating a custom button for the Lightning Experience. For the Salesforce Classic interface, a different approach may be required.
The use cases for custom buttons are extensive, including creating new records, updating multiple fields, utilizing custom fields, and more.
Custom buttons can greatly enhance the user experience by providing quick and easy access to frequently performed actions.
Last updated