Create record in Lightning with populated fields

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?

Answer

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

Attribution
Source : Link , Question Author : Louis Pujol , Answer Author : Renato Oliveira

Leave a Comment