[SalesForce] Salesforce: is it possible to create custom Record Creation Pages with Lightning Components

I'm trying to recreate the record creation modal for an Opportunity created from a non-standard related list on Account. I've heard you can override the standard New button with lightning components.

The reason why I want to override the record creation modal is for the purpose of prepopulating fields on the record creation modal page, which as we know, is a pain in Lightning. In classic you can use the good ol URL hack but unfortunately this doesn't work in Lightning. Please don't point me towards quick actions, global actions, or publisher actions, as I would like to retain my related list buttons.

This guy overrode the record type selection modal, thus turning it into this: Custom record type selection modal

which is cool, but I'd like to take that a step further and recreate the record creation modal that is displayed when you click 'Next:
Standard record creation modal
Is this possible? I'd guess that instead of invoking c.createRecord when the Next button is clicked, you'd invoke another lightning component that displays a custom record creation modal (instead of the standard one).

Best Answer

As for your question:

Is this possible?

The answer is Yes.

Now for the below:

The reason why I want to override the record creation modal is for the purpose of prepopulating fields on the record creation modal page

Your use case of pre-populating the record creation window will be solved using force:createRecord. This is what you will need to do:

  1. Create the record type selection component, which you will use to override the New button
  2. On click of Next from that component, you will need to:
    • Invoke force:createRecord event where you will be able to pass on the record type id, and default values attribute which will be pre-populated on the next screen.

Here's the snippet from the documentation about this attribute.

Prepopulates fields on a record create panel, including fields not displayed on the panel. ID fields and rich text fields can't be prepopulated. Users must have create access to prepopulated fields. Errors during saving that are caused by field access limitations do not display error messages.

And here's the code snippet from the documentation as how you can pre-populate the values on the record creation.

var createAcountContactEvent = $A.get("e.force:createRecord");
createAcountContactEvent.setParams({
    "entityApiName": "Contact",
    "defaultFieldValues": {
        'Phone' : '415-240-6590',
        'AccountId' : '001xxxxxxxxxxxxxxx'
    }
});
createAcountContactEvent.fire();