You need to sign in to do that
Don't have an account?
Antoine Fauque 10
Get RecordTypeId in Lightning Web Component
Hi guys, i'm trying to get RecordTypeId in a Lightning Web Component which is located on the Account record page.
I'll explain this component accesses a picklist field that is different depending on the record type. So I wanted to add record-type-id to the lightning-record-edit-form that is present on my component but in don't know how to get this id in my JS.
I tried this :
"Cannot read property 'fields' of undefined"
I'm not sure what to do to make it work.
If someone can help me on this or give me other way to get this recordTypeId
I'll explain this component accesses a picklist field that is different depending on the record type. So I wanted to add record-type-id to the lightning-record-edit-form that is present on my component but in don't know how to get this id in my JS.
I tried this :
import { LightningElement, api, wire } from "lwc"; import { getRecord } from "lightning/uiRecordApi"; import ACCOUNT_RECORDTYPE_FIELD from '@salesforce/schema/Account.RecordTypeId'; export default class Account_Redirect extends NavigationMixin(LightningElement) { @api recordId; @api objectApiName; @wire(getRecord, { recordId: '$recordId', fields: [ACCOUNT_RECORDTYPE_FIELD] }) acc; get recordTypeId() { return this.acc.data.fields.RecordTypeId.value; } }But i have the following error :
"Cannot read property 'fields' of undefined"
I'm not sure what to do to make it work.
If someone can help me on this or give me other way to get this recordTypeId
All Answers