Are you still missing the Salesforce Classic URL Hacking in Lightning Experience? You may remember that lightning Experience initially don't support URL Hacking in Salesforce and that was replaced with Custom Actions. Don't worry Spring 20 Release highlight the URL Hacks are Back. Let see how to Navigate to a Record's Create Page with Default Field Values.

What is a Salesforce URL Hack?

URL Hack is create a custom button that creates a new record with some presets default values using static or dynamic fields based on the record you're currently on. Instead of asking users to click the standard "Create New" button and fill all information from scratch on screen, you could use a custom button to create a new record and pass some default value on page to save your users some keyboard time!

URL Hacks are Back

In Spring '20 release notes Salesforce provide the new tricks for us to Navigate to a Record's Create Page with Default Field Values, Now you don't need to check and decode the URLs to find the secret sauce. The old URL Hacks also used the field Ids rather than API names. With this trick we can use Field API names.

URL Hacking Example

Create custom buttons and links that pass default field values to a new record. To construct a custom button or link that launches a new record with prepopulated field values, use this sample formula.

/lightning/o/Account/new?defaultFieldValues=     Name={!URLENCODE(Account.Name)},     OwnerId={!Account.OwnerId},     AccountNumber={!Account.AccountNumber},     NumberOfEmployees=35000,     CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)}

Let see how we can create opportunity record with some per-populated values while create from Account object.

Step 1: Create the Custom Button and Add URL

Step 2: Add on page layout

Step 3: Testing

Restrictions

Yes we have some restrictions that apply to the new URL Hacks

  1. Not available in Community
  2. Not available for Salesforce Mobile Aoo.
  3. They also wont work with Lightning Out
  4. Passing the RecordTypeId to defaultFieldValues isn't yet supported
  5. The URLENCODE function works only when creating custom buttons and links. You can't use it for custom fields

Summary

Simply construct a custom button or a link that launches a new record and use the sample formula to prep-populate your field values using Salesforce URL Hacking for Lightning. Stay tuned and Subscribe the blog for more Tips and trick.