Is there a way to use the sforce.one.createRecord to create an Opportunity and fill in fields with data? In Salesforce Classic this was accomplished by adding parameters to the url (ex: ?name=foo).

Has Salesforce given a way to do this in Lightning?


4 Answers 4


URL hacks are not supported in Lightning Experience. The best way to prepopulate fields in Lightning Experience is to use actions.

For example:

  1. on the Account object I created an action to create a new opportunity and prepopulate some fields by going to: Setup -> Object Manager -> Account -> Buttons, Links, and Actions -> New Action.
  2. Next add whatever fields you would like to have on the layout that will popup up in LEx when the button is clicked.
  3. Then add each predefined field and the default values.

Predefined Fields

  1. Finally add the button to the page layout in the Quick Actions section for Salesforce1 and Lightning Experience Actions.

The button will be available in the top right of the account and when clicked the page layout will popup with the defaults.

Popup New Opportunity

  • Is there a way to call this action from Javascript? There are some validations that I need to make before I can call this action Apr 5, 2016 at 19:37
  • @LouisPujol looks like something is in the works according to product manager post on this idea success.salesforce.com/ideaView?id=08730000000cGX8AAM
    – Jenny B
    Apr 5, 2016 at 19:42
  • Then please vote for my idea : success.salesforce.com/ideaView?id=0873A000000cNRNQA2
    – vanessen
    Jan 6, 2017 at 11:21
  • 2
    Note that this only works when the record you're creating has a lookup field to the object you're defining the action on. In my case, we're doing it the other way around (creating a Contact from the Case detail screen, and then linking the created Contact id to the Case in question), and that's not possible using Actions as far as I can tell.
    – Sander
    Apr 17, 2019 at 13:40

From the Summer '17 Release Notes - Prepopulate Fields on a Record Create Panel

Speed up record creation with prepopulated field values. The sforce.one.createRecord function now includes defaultFieldValues (optional) so you can define fields on a record create panel, including fields not displayed on the panel. This change applies to Lightning Experience and the Salesforce1 mobile browser app.

Users must have create access to prepopulated fields. Errors during saving that are caused by field access limitations do not display error messages.

So defaultFieldValues will become the official supported mechanism to preset fields with sforce.one.createRecord.


It's not documented, so use at your own risk, but you can pass the default values on an attribute named "defaultFieldValues". So for instance, you could create a task and send defaults like this:

var evt = $A.get("e.force:createRecord");
   'defaultFieldValues': {

  • 1
    thanks your solutions works fine. Do you know how to define a callback or catch the save of the new Record? I would like to call an action on my component that fired the event instead of being redirected on the newly created record?
    – Thibault W
    Apr 25, 2017 at 10:30

@DanielBallinger's answer is correct. I just want to extend it by an example and show you the most likely pitfalls trying to make it work. Plain and simple, you can use it like this one-liner:

    AccountId : "0010Y000007uaVI",  

Caution 1:

The this feature from Summer'17 works only if you put your Visualforce Page to API v40.0 or higher.

Caution 2:

Objectnames and Fieldnames are CASE-SENSITiVE! So contact is not Contact and only Contact is correct

You must log in to answer this question.

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