Alternative: Quick Actions
Use Case: Validate field values
We have customers who want their users to create or update records, but they want to make sure that some fields are filled in or populated with certain criteria.
For example, let’s say you want to give users an action for closing a task without requiring them to go to a full edit page. But you also want to make sure that the task has a due date before it can be closed.
You can create a new action for the Task object like this:
- In the object management settings for activities, go to Task Buttons, Links, and Actions.
- Click New Action.
- For Action Type, select Update a Record.
- For Label, type in Close Task.
- Click Save.
Select the fields that you want to appear on the “Close Task” quick action. You can easily make a field “Required” or “Read-Only” through its field properties.
After you’ve set the fields on the action layout, you can add predefined field values for any of the fields on the task record. In this example, I’ve marked the Due Date field as required. I also added a predefined value for the Status field to be changed to Completed.
Now that the action definition is finished, add this action to the Task page layout for users. Once that’s done, users of Lightning Experience and Salesforce1 can see it on the task record page and use it. Here’s an example of a Close Task action on the Tasks page.
Clicking Close Task brings up the action, which the user can quickly act upon and save.
The same action is also available in Salesforce1.
Use Case: Pre-populate fields with values
A more advanced use case is when you want to let users create a record, but you also want one or more of the fields to be populated automatically based on values in a dependent field.
For example, your inside sales teams’ typical quarterly quota is one fourth of their customers’ revenues from last year, upped by 10%. But that simple formula doesn’t always hold true, so you want to prefill the opportunity amount with that value, but let the user modify it. The benefit of the action is that users can do this efficiently without having to navigate to the full opportunity record page.
To create this sample action, follow the same steps as before for creating the opportunity quick action:
- In the object management settings for accounts, go to Buttons, Links, and Actions.
- Click New Action.
- For Action Type, select Create a Record.
- For Target Object, select Opportunity.
- Pick the appropriate Record Type.
- For Label, enter New Oppty.
- Click Save.
Once you’ve picked the fields for the action layout, you can add predefined field values for the Amount field. In this example, I’ve added a predefined value for the Amount field, using this formula:
Account.Last_Year_Revenue_Generated__c * 1.10 / 4
You would then add this action to the Account page layout, and when users invoke it, they see a value pre-populated in the field that they can accept or override.
The cool thing about this action is that you can pull data from the opportunity’s account to use when creating the new opportunity. We also support record traversal, so if you have hierarchical accounts, you can also pull the revenues from the parent account like this:
But don’t worry about remembering the formula formats, quick actions are declarative and use our formula builder.
Use Case: Redirect to a Visualforce page based on input values
Salesforce customers create Visualforce pages to enhance their business processes. Users can navigate to these Visualforce pages in a variety of ways, such as with custom buttons, action overrides, and tabs.
One benefit of Visualforce pages is that by using the standard controller, you can create customized record pages and add pre-validation, pre-populated fields, formulas, and much more.
For object-specific Visualforce quick actions, you must include the standardController for the object in your Visualforce page to gain access to the record data and have the Visualforce page appear in the quick action picklist.
Alternative: Custom URL Buttons
Here’s a list of different URL buttons and their redirect behavior in Lightning Experience.
Alternative: Apex Triggers
Many of you are probably familiar with Apex triggers; they’ve been supported on our platform for years. Apex triggers can be set up to execute before or after a user clicks Save on a record.
When your use cases call for pre-save validation, calculation, and population of fields, you should also consider triggers. They’re especially useful for 3rd-party integration scenarios because the rules are enforced through the Salesforce API across Salesforce Classic, Lightning Experience, and Salesforce1.
Alternative: Custom Visualforce Buttons
Another great feature in Winter ’17 for Lightning Experience is support for using Visualforce buttons on list views. With this feature, you can use existing Visualforce actions in Lightning and work with multiple records in lists. Here’s an example of how.
1. Create your Visualforce page.
Here is sample code for editing the Stage and Close dates for multiple opportunities:
2. Create a custom button that references your Visualforce page.
3. Add the action to your list view.
Mass actions aren’t supported on the most recent records list. They are only available on list views.
Here’s how that action shows up in Lightning Experience.
- Understanding How Actions Work in Lightning Experience
- Writing Your First Apex Class and Trigger
- Implementing Object-Specific Actions with Visualforce Page
Want to find out more? Join us at one of these Dreamforce ’16 sessions!
Breakout Session on Thursday: Five Cool Ways to use Actions in Lightning Experience