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;
}
}
console.log(JSON.stringify(this.objectInfo));
to see what data you have.