Spring ’20 URL Hack Explained

Spring ’20 brings us a revised version of a classic admin’s old favorite: the URL hack, the ability to pass field values via the URL. Let’s try it now with a custom button.

Read the release notes: Navigate to a Record’s Create Page with Default Field Values.

Use Case

The Ugly Dog Adoption Agency wants to click a button on the Animal record (parent) to create a new Treatment Plan record (child), and have a few fields automatically filled in. In this video, I start on the dog Grover’s record and click the button to create a new Treatment Plan. The lookup fields Animal and Vet Assigned are pre-populated.

Instructions

  1. From set-up, go to Object Manager for the object on which you’ll click the button (Animal, in this case).
  2. Click “Buttons, Links and Actions.”
  3. Click “New Button or Link.”
  4. Fill out label, name, description, Display Type of “Detail Page Button”, choose desired behavior, and leave Content Source as “URL.” Be very careful when writing out your formula. Spacing is important! custom button1
  5. HOW TO PASS THE RECORD ID OF STARTING OBJECT. The first value I want to populate is Animal on the Treatment Plan with the Record ID of the Animal I’m starting from. animal url hack
  6. HOW TO PASS THE VALUE OF A LOOKUP FIELD
    Vet_Assigned__c={!Animal__c.Primary_VetId__c}

For my second field assignment, I populate the field Vet Assigned on the Treatment Plan with the value of Primary Vet on the Animal record. (These are both lookups to a Contact).

On the left, I type in the API Name of Vet Assigned. On the right, I use the drop down lists for “Select Field Type” and “Insert Field.” When I look for the merge field for Primary Vet, my choices are Primary Vet and Primary Vet ID. Choose the one with ID. Save the button.

Add to the Page Layout

  1. Start at the Object manager for the starting object (Animal), and select Page Layouts. Select the appropriate layout.
  2. Find your new button under “Mobile and Lightning Actions” (don’t be lured by that tempting choice of “Buttons”!) Drag it down to the “Salesforce Mobile and Lightning Experience Buttons” section. Save.

More Examples

Huge thanks to Aaron Crear for showing me this example. His button creates a new Opportunity from an Account.

/lightning/o/Opportunity/new?defaultFieldValues=Market__c={!Account.Market_PL__c},Region__c={!Account.Region_pl__c},Client_Leader__c={!Account.OwnerId},AccountId={!Account.Id}

Here’s one that surprised me. From the Contact record, you populate the Account ID with {!Account.Id}, rather than Contact.Account.Id field. This button takes the Rainier Valley Food Bank from the contact record to creating a new custom Food Bank Visit record and pre-populates the client and the household(Account in Nonprofit Success Pack).

/lightning/o/Food_Bank__c/new?defaultFieldValues=Food_Bank_Client__c={!Contact.Id},Household__c={!Account.Id}

See more examples in this discussion on the Trailblazer community.

Published by

JessieRymph

Jessie joined Salesforce.org in 2018 to give introductory webinars to nonprofit customers. She now is a Senior Solution Developer supporting nonprofits and education customers at Salesforce. All opinions expressed on this blog are her own or those of the contributors. She's spent 17 years more or less in CRMs and databases, but didn't meet Salesforce until 2011. Jessie co-led the Seattle Salesforce Nonprofit User Group in 2015-2016. She wrote a sh*tty first draft of a novel and hopes to turn it into a screenplay!

12 thoughts on “Spring ’20 URL Hack Explained”

  1. Is there a version of this Lightning URL hack for Related List buttons? When I click “New Quote” on an Opportunity’s related Quotes list, I want to pre-populate Account, Opportunity, Sales Rep, etc.

  2. The recordId of the starting object doesn’t work for me unfortunately. I suspect the same will be true about the look ups. Could it be something with the new release?

    1. Hi! I’m sorry, but I don’t know. I see you asked on SalesforceBen. Did you get an answer?

      1. Hi Jessie, thanks for your interest
        Actually I didn’t. Anyhow, I kept researching, and it seems Salesforce does not allow this possibility.
        So URL hacking is only for prepopulating NEW records with specific values, not possible to update with specific values and save in one link…
        Have a nice weekend!

  3. Hey Jessie, do you know if we can add the retURL functionality in lightning? I’m trying to create a button that will return a user to the parent record after a child record is created. (i.e. after a contact is created from an account, return to the account record rather than opening up the newly created contact record).

    Any help is truly appreciated!
    -Jovanny

  4. Does this only work for standard objects? I can’t seem to get this to work on a lookup to a custom object. I’ve try every combincation and still no success. I can get it to auto populate if the record Id is hardcode.

    /lightning/o/Quote/new?defaultFieldValues=
    Project__c=Opportunity.Project__c.Id

Leave a Reply