0

I have a lightning-combobox with a onchange function that calls an apex method.

From the onchange, when I select a new value I can see the method getting called and returning values.

But once the onchange function is called, I see a script error:

[NoErrorObjectAvailable] Script error.
a()@https://static.lightning.force.com/na139/auraFW/javascript/dDIdorNC3N22LalQ5i3slQ/aura_prod.js:952:169
{anonymous}()@https://static.lightning.force.com/na139/auraFW/javascript/dDIdorNC3N22LalQ5i3slQ/aura_prod.js:952:362
dispatchEvent()@https://static.lightning.force.com/na139/auraFW/javascript/dDIdorNC3N22LalQ5i3slQ/aura_prod.js:12:29820
p.dispatchEvent()@https://static.lightning.force.com/na139/auraFW/javascript/dDIdorNC3N22LalQ5i3slQ/aura_prod.js:12:2436
p.handleSelect()@https://xuz.lightning.force.com/components/lightning/combobox.js:1:5539

My combobox markup:

    <lightning-combobox
        name="object"
        label="Object To Map"
        value={value}
        options={options}
        onchange={handleChange} >
</lightning-combobox>

My JS file:

    handleChange(event){
    this.selectedObj = event.target.value;
    console.log(`the objet is ${this.selectedObj}`);
    fetchObjectSchema({
        objectSelected: this.selectedObj
    })
    .then(objectFieldMap => {
        console.log(`the return is ${JSON.stringify(objectFieldMap)}`);
        this.objectFields = objectFieldMap;
        let returnObj = objectFieldMap;
        console.log(`the firstIndex >>>> ${JSON.stringify(returnObj[0])}`);
    })
    .catch(error => {
        console.log(error);
    })

    console.log(`objectFields is ${objectFields}`);        
}

I can see the execution going into the .then block and also print out the **the firstIndex >>>> ** line.

Even then, the script error is thrown for every onchange call.

Can anyone here let me know what I seem to be mssing?

Any help is appreciated!

2

I believe this:

console.log(`objectFields is ${objectFields}`);    

objectFields is a variable, so you will have to do a this.objectFields, also is there a reason you are trying to print console.log(objectFields is ${objectFields}); outside the promise method.

1

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.