I am following a guide for how to get a specific record type for when creating a lightning-record-edit-form and I am getting this error thrown:
My Html looks as follows:
<lightning-record-edit-form object-api-name={caseObject} onerror= {ShowToastEventFailure} onsuccess={ShowToastEventSuccess} record-type-id={recordTypeId}>
some fields/grids here
</lightning-record-edit-form>
JS looks as follows:
import { LightningElement, api, wire, track } from 'lwc';
import { getRecord, getFieldValue, getObjectInfo } from 'lightning/uiRecordApi';
import CASE_OBJECT from '@salesforce/schema/Case';
import Id from '@salesforce/user/Id';
import NAME_FIELD from '@salesforce/schema/User.Name';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
const fields = [NAME_FIELD];
export default class Culinaryrequest extends LightningElement {
userId = Id;
caseObject = CASE_OBJECT;
@api objectApiName;
@track objectInfo;
@wire(getRecord, { recordId: '$userId', fields })
user;
@wire(getObjectInfo, { objectApiName: CASE_OBJECT })
objectInfo;
get name() {
return getFieldValue(this.user.data, NAME_FIELD);
}
get recordTypeId() {
const rtis = this.objectInfo.data.recordTypeInfos;
return Object.keys(rtis).find(rti => rtis[rti].name === 'Culinary Team Request');
}
ShowToastEventSuccess () {
const event = new ShowToastEvent ({
title: 'Success!',
message: 'Your Request to the Culinary team has been submitted',
variant: 'success',
});
this.dispatchEvent(event);
}
ShowToastEventFailure () {
const event = new ShowToastEvent ({
title: 'Oh Noes! :(',
message: 'Something is wrong with your Request please check that all required fields are filled out. If the problem persists please open a case with Real Estate Technology',
variant: 'failure',
})
this.dispatchEvent(event);
}
}
If anyone has any ideas why this is being thrown please let me know as I am new to LWC and would love to learn!