[SalesForce] How to access the user’s choice for RecordType when using a lightning component to override the New button on a custom object

I have a custom object with two different record types assigned to the standard user profile. We are using a Lightning Component to override the standard functionality of the New button, and this lightning component launches a e.force:createRecord event after the user clicks some checkboxes to agree to various terms and agreements.

Our problem is this. Overriding the new component doesn't seem to override the standard pop-up that asks the user what recordType they'd like to create. This would be fine, but I can't figure out how to access which recordType they've chosen in order to populate the e.force:createRecord event with the appropriate recordTypeId. Because I can't get the standard pop-up to disappear, I can't just ask them to select the recordType they'd like to create in my lightning component since then they are being asked to choose the recordType twice, once by salesforce and then again by my component. And finally, if I make the standard pop-up go away by unassining one of the recordTypes from the user profile so that it defaults to one and THEN I allow them to pick the recordType in my component, I can correctly fire the e.force:createRecord event for either recordType, but when they go to save the record I get an error stating that the recordType is not available for that user (because it isn't). This means that they cannot submit a record of type they aren't assigned to though they can fill out the creation form.

I am at a loss for what to do here. The only thing that seems like it would make sense is if there was a way to tell which recordType the user chose before the lightning component override happens, but I have not been able to find a way to access that choice from my lightning component.

Any help or thoughts would be appreciated, thanks.

Best Answer

Please look for the checkbox highlighted in attached image Skip record type selection page. Refer this image

This way, you can stop the first standard popup hidden. For record type selection, you can write another component which will query available record types. From custom record type selection component, you can pass selected record type id to new account custom component.

Hope this helps you.

Related Topic