Salesforce URL Hacking for Lightning

Salesforce URL Hacking for Lightning

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.

Amit Chaudhary

Amit Chaudhary

Amit Chaudhary is Salesforce Application & System Architect and working on Salesforce Platform since 2010. He is Salesforce MVP since 2017 and have 17 Salesforce Certificates. He is a active blogger and founder of Apex Hours.

Share this article

4 Comments

  • Can populate value on edit mode?

  • Very helpful article!
    Regarding prepopulating the Record Type, it can be done but the parameter needs to be passed as an independent parent parameter, outside of default field values.
    Example:

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

  • Hi,
    Its really great pleasure to learn from this platform. As I just wonder to know ,Like i f we do have “Clone ” option on record detail page.. why do we need salesforce URL Hack ? can you please let me know as I am learner here , so i may sound novice.

    Thank you

Leave a reply

Subscribe for Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 3,546 other subscribers

Our Supporter

RECENT POSTS

Apex Hours

Apex Hours is one stop platform to learn Salesforce skills and technology

Join our Newsletter and get tips and tricks how to explore the salesforce for free!