0

I have a lightning-combobox which gives the options to select a field from an fetched apex collection. The component loads without any issue on the page as soon as I select an option I get a page error. When I check the details there is an error : [NoErrorObjectAvailable] Script error.

For the sake of excluding if its the controller I just added a console.log which does not give an output suggesting the error is in the lightning-combobox. What am I doing wrong

Template:

<lightning-combobox options={salesforceFields} data-target-id="lcSF" label="Field" value="" onchange={handlesffields}>
        <template for:each={SFFields} for:item="SFField">
            <option label={SFField.label} value={SFField.value} selected={SFField.selected} key={SFField}></option>
        </template>
    </lightning-combobox>

Js

handleSFFields() {
        console.log('Oops');
}

Thanks in advance

3
  • Could you tell me why you have put a template tag in between combo-box ? And why key is not string or number rather whole object ?
    – Elijah
    Jun 21, 2022 at 11:18
  • @Elijah the template tag is to get the value for the option label. For the key I added .Id but still get same error.
    – Thomas
    Jun 21, 2022 at 11:51
  • 1
    If you have populated options={salesforceFields} you don't have to add template tag. Sorry if I am not understanding your requirement. It just looks redundant to me
    – Elijah
    Jun 21, 2022 at 12:03

1 Answer 1

0

Try this.

<lightning-combobox
   name="Field"
   label="Field"
   value={value}
   placeholder="Select Field"
   options={salesforceFields}
   onchange={salesforceFields} >
</lightning-combobox>

value = 'your selected value';

salesforceFields(event) {
console.log(event.detail.value); }
1
  • In got options={SFFields} working thanks
    – Thomas
    Jun 21, 2022 at 12:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .