Pages

Monday, March 12, 2018

Salesforce: Action in Lightning to replace URL Hacks in Classic

In Classic, many of us implemented URL hack, the purpose is to populate a value, example: populate a value from Account field into Opportunity when creating new Opportunity, but also allows the user to change it manually.

But, when switch to Lightning, URL hack will not work. In Lightning, you can implement Action to replace URL hack. Here is the step.

Use Case: to pre-populate Payment Term and Area (both are custom fields) in Opportunity when create Opportunity from Account, both fields are available in Account and Opportunity, although the field type may different.
Account:
- Area = Lookup
- Payment Term = Picklist

Opportunity:
- Area = Lookup
- Payment Term = Number

1. Create New Action in Account
Because we are creating Opportunity from Account, the Action must be create from Account.
- Navigate to Setup | Object Manager | Account | Buttons, Links, and Actions
- Click New Action button
- Enter as screenshot below (in my Opportunity, I have record type, therefore need to populate).



2. Edit Action Layout
From action created, click Edit Layout, remove default fields added, add both Area and Payment Term, and click Save button.



3. Add Predefined Field Values
Still in Action created, look for Predefined Field Values section and click New button. Select the Opportunity field name, since we have 2 fields to pre-populate, repeat this step twice.
You need to enter formula text, see screenshot below.



4. Add the Action to Account page layout
Still, in Account object manager, click Page Layouts menu, then click the Page Layout name.
Click Mobile & Lightning Actions section, then drag New Opportunity to Salesforce Mobile and Lightning Experience Actions.



5. New Opportunity
Now you should see New Opportunity button when open Account record page.



Click the button and system will popup New Opportunity action window with fields added in action layout. Both fields value should have been populated, and the user also allows to change it too.



One of the drawback when the user creates new opportunities not from the action button, e.g., from New button in Opportunity Related List, the values will be not pre-populated.


Reference: Trailhead: Create Object-Specific Quick Actions



1 comment:

  1. Super useful walk-through! This let me replace a URL Hack button in about 5 minutes (and the Lightning version is actually better). Thanks!

    ReplyDelete

Page-level ad