[SalesForce] Embed Page layout inside a lightning component

Can we use a standard page layout inside a lightning page/component?

Thanks

Best Answer

Based on your comments around requirements (as below), you are looking to be able to dynamically reflect the page layout for creating a record using a Lightning Component.

  1. Based on the record type chosen on an object, I need to take the user to a custom lightning edit page and show different page layouts on the page based on the selection by user.
  2. Based on the record type selected I need to show different fields to the user who can enter the values.

You need to use force:createRecord event for this purpose. This is what the documentation for this event mentions:

This event opens a page to create a record for the specified entityApiName, for example, "Account", or "myNamespace__MyObject__c".

To display the record create page for an object, set the object name on the entityApiName attribute and fire the event. recordTypeId is optional and, if provided, specifies the record type for the created object. defaultFieldValues is optional and, if provided, specifies values to use to prepopulate the create record form.

Now, that you want to be able to display the page layout based on the record type, you will need to use the recordTypeId attribute of the event for that purpose. You just need to pass the record type's id that was selected in the previous page and it will render the page layout associated with that record type.

Note - Though the documentation does not explicitly mention that it opens associated page layout with a record type, but once you provide the record type id, it takes care of opening the correct page layout based on the assignment (I have verified this as a test).

This is how your code should look like:

var createRecordEvent = $A.get("e.force:createRecord");
    createRecordEvent.setParams({
        "entityApiName": "Account",
        "recordTypeId": "recordtypeid"
    });
createRecordEvent.fire();