Skip to main content
Remove tag that references the components created with the Aura framework. It is not the case for this post.
Link
Renato Oliveira
  • 14.4k
  • 10
  • 70
  • 146
Became Hot Network Question
Source Link
salesforce Developer
  • 3.4k
  • 12
  • 57
  • 104

Record Type Selection in LWC

I'm trying to create record Type selection screen in LWC, but getting this error

afterRender threw an error in 'c:createContact' [Cannot read property 'recordTypeInfos' of undefined]

HTML:

<template>
    <lightning-combobox name="recordType" label="Record Type" placeholder="Choose Status"
                        value={value} 
                        options={recordTypeId}>

    </lightning-combobox>
</template>

JS:

import { LightningElement, track, wire, api } from 'lwc';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import CONTACT_OBJECT from '@salesforce/schema/Contact';

export default class CreateContact extends LightningElement {
    
    @track statusOptions;
    @track value;
    @api objectApiName;

    @track objectInfo;

    @wire(getObjectInfo, { objectApiName: CONTACT_OBJECT,})
    objectInfo;


    get recordTypeId() {
        // Returns a map of record type Ids 
        console.log(this.objectInfo);
        const rtis = this.objectInfo.data.recordTypeInfos;
        return rtis;
    }
    
}