With Lightning Experience, we can't use url hacks anymore. I'm fine with that, as this was not a supported solution. However, behind this technical hack was a business need: pre-populate field on record creation, often with different values depending on where you're coming from.

I tried to play with sforce.one to pass some parameters and as I expected I was not able to pass any parameter.

My question is: Is there a way to pre-populate fields on record creation (or have you heard of it on the roadmap), or should we just forget about this business need for now with Lightning Experience ?

Obviously, as we're starting to do impacts analysis on existing orgs for clients wishing to switch to Lightning Experience, this would be a big step back.

  • Dont think any prepopulation is possible unless you build your own components for that Commented Nov 10, 2015 at 23:15
  • 1
    You could use quick actions instead of buttons.
    – Jenny B
    Commented Nov 12, 2015 at 22:16
  • I know, but that's not really what I want. Sometime the info I need to pre-populate is not as easy to get as what can be done with Quick Actions. Also, this means maintaining different layouts. Commented Nov 13, 2015 at 10:50
  • How exactly do you want it then? Buttons mean maintaining different layouts as well. Commented Feb 29, 2016 at 13:07
  • 2
    I would like it to be like today with url hacks: opening the creation page of an object, but with fields prepopulated. I only have to maintain my object layout, not my object layout + my Quick Action layout. Also, with url hacks, it was possible to use apex in the middle to have complex logic to determine which value should be used. Commented Feb 29, 2016 at 13:13

3 Answers 3


The Spring '20 release brought the URL hack for prepopulating field values to Lightning. You can now achieve this with custom buttons and links (not Javascript buttons) much like we used to in Classic.

Spring '20 release note: Navigate to a Record's Create Page with Default Field Values

Where: This change applies to Lightning Experience in all editions. This change doesn’t apply to Lightning Out, Lightning communities, or the Salesforce mobile app.

How: To construct a custom button or link that launches a new record with prepopulated field values, use this sample formula:

    CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)}
  • Could you elaborate this in more detail? I tried to apply this, but all I get are errors, e.g. Error-ID: 522682101-111545 (-1922518417) With fixed values for the fields it's working perfectly, but the {!Account.Xyz} thing does not work for me. Commented Mar 26, 2020 at 10:55
  • Are you starting from an Account record page in Lightning when navigating to that URL? Commented Mar 26, 2020 at 17:37
  • I tired using this, it doesn't work for me or I am doing something wrong. My use case is, populating value from parent (my_custom1__c) to child (my_custom2__c). Also the documentation say it doesn't support record types. Atleast step in right direction.
    – mubs
    Commented Apr 20, 2021 at 2:10

For declarative use cases, Salesforce PM Kamyar Seradjfar recently did a blog series on removing javascript hacks for Lightning Experience. His suggestion for this use case is to use Quick Actions with pre-populated fields by value or formula: https://developer.salesforce.com/blogs/developer-relations/2016/09/take-the-first-steps-ways-you-can-replace-javascript-buttons.html

For code use cases, Lightning Data Service allows developers writing custom Lightning Components creating new records to pass in default field values.

See the defaultFieldValues param in the createRecords() method, documented here: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service_create_record.htm (Lightning Data Service is in Developer Preview for Winter '17, which means the force:recordPreview component may only be used in Developer Edition orgs.)

Edited to add: there is a new Trailhead module on this topic: Lightning Alternatives to JavaScript Buttons

  • The necessity to Create a new Lightning Component makes this choice very hard. Usually we want to re-use standard layout with values pre-filled. I was wondering how Salesforce do it with Calendar. This is the best example of pre filled form, you can click Any Date and Create New Event dialog automatically have the date selected to the day you clicked on. There seems to be a way to set date values dynamically here. I would like to replicate the exact same thing.
    – VarunC
    Commented Feb 9, 2017 at 7:20
  • We can use Quick action to pre-populate values, but how to add quick action as list button in related list. Its not possible. If we create VF page button, then Force:createrecord event will not be handled by one app container. So, we can't use VF also. So, in short we can't pre-populate values if we are using URL Hack in related list button. Commented Apr 26, 2017 at 10:35

As of the Summer '17 release, this is now possible when using the force:createRecord Event:

Lightning Events - Force:createRecord

Check out the section called "Prepopulating Field Values". This will hopefully make Lightning easier to develop for!

  • Yes, that`s right. An example is: var createAcountContactEvent = $A.get("e.force:createRecord"); createAcountContactEvent.setParams({ "entityApiName": "Contact", "defaultFieldValues": { 'Phone' : '415-240-6590', 613 Reference force:createRecord 'AccountId' : '001xxxxxxxxxxxxxxx' } }); createAcountContactEvent.fire();
    – Leisure
    Commented Dec 5, 2017 at 8:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .