[SalesForce] Getting RecordTypeId selected from ‘Record Type Selection’ Page, in a lightning component that overrides create screen

We have about three different record types for a custom object, for which I am trying to create a lightning component that will override the standard behaviour. In lightning experience, we are presented with the "Record Type selection screen" as shown below.

Record Type Selection Screen

Once we select a record type the lightning component shows up however I am unable to find any standard way to get the recordTypeId from the previous selection window.

It is available in the url as /new?recordTypeId=012360000008N3z&additionalParams....

My question is regarding any standard technique for getting the record type Id. Maybe, something similar to force:hasRecordId interface like force:hasRecordTypeId.

I have looked through the lightning documentation to no avail and I might have to fallback to URL parsing.

<!-- My Component implements the following interface -->
<aura:component implements="force:hasRecordId,lightning:actionOverride">
 ...
</aura:component>

Best Answer

Summer'18 update provided a new interface 'lightning:hasPageReference'. You can now access the recordTypeId in your controller as below:

var recordTypeId = component.get("v.pageReference").state.recordTypeId;

https://developer.salesforce.com/docs/component-library/bundle/lightning:hasPageReference/documentation