I'm trying to setup a search filter for opportunity stage field through lightning combo box but however getting an error "cannot read properties of undefined while loading the component"

            label="Opportunity Stage"
            onchange={handleChange} >

Client Side Controller

import { LightningElement, api, wire, track} from 'lwc';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import OPPORTUNITY_OBJECT from '@salesforce/schema/Opportunity';
import STAGE_NAME from '@salesforce/schema/Opportunity.StageName';

export default class Accounts extends LightningElement {
@api recordId;
@wire(getObjectInfo, { objectApiName: OPPORTUNITY_OBJECT })

        recordTypeId: '$opportunityMetadata.data.defaultRecordTypeId',
        fieldApiName: STAGE_NAME

1.- what is undefined? there is surely more information as to what variable is undefined.

2.- naming a property value is generally speaking a bad practice. please do not do that.

3.- consider wiring your property to a function instead and add some error handling Ex:

    wiredFunctionName({ error, data }) {
        if (data) {
           //do something
        } else if (error) {
            //catch error

once you have refactored your code, you should be able to either provide a more detailed error and/or solve it yourself =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.