You need to sign in to do that
Don't have an account?

Get and Pass Record Type from Aura component to LWC
I am overriding a new button on a custom object with an aura component(LWC wrapped inside Aura). How do I get the record Type that the user has selected and pass it to the LWC? The reason I need this is that the picklist values are based on the record type.
Thanks
P
Thanks
P
Your question has 2 parts first is how you will get the recordtype id in aura component which you have used to override the button.
And then you want to pass that value to LWC component.
So for first step you need to use "lightning:hasPageReference" in your component. This will help you to get/access to the pageReference attribute.
This will help you to get the recordtypeId. Refer below link:
https://www.biswajeetsamal.com/blog/get-selected-record-type-id-in-standard-button-overrides-lightning-component/
Next is to pass this value to LWC you need to have a variable with @api annotated in LWC for example, where you can set the value from aura compoenent :
You can use below syntax to pass the value, where "recTypeId" is a variable in LWC and "selectedRecordId" is an attribute in AURA.
If it helped then can you please mark it as the best answer so that it can be used by others in the future.
Regards,
Santosh Kumar
All Answers
Your question has 2 parts first is how you will get the recordtype id in aura component which you have used to override the button.
And then you want to pass that value to LWC component.
So for first step you need to use "lightning:hasPageReference" in your component. This will help you to get/access to the pageReference attribute.
This will help you to get the recordtypeId. Refer below link:
https://www.biswajeetsamal.com/blog/get-selected-record-type-id-in-standard-button-overrides-lightning-component/
Next is to pass this value to LWC you need to have a variable with @api annotated in LWC for example, where you can set the value from aura compoenent :
You can use below syntax to pass the value, where "recTypeId" is a variable in LWC and "selectedRecordId" is an attribute in AURA.
If it helped then can you please mark it as the best answer so that it can be used by others in the future.
Regards,
Santosh Kumar
Thanks for the reply @Santosh. Do you know how to render teh Record type on a lightning-record-edit-form? If I hardcode the recordtype and use record-type-id= "01241144444" I see the record type. But If I use record-type-id={recTypeId} its blank. Just want to confirm its coming over. Thanks
P
Try to print and see if you are getting proper value in "recTypeId".