I am a beginner in LWC, hence please pardon for any mistakes, and would appreciate suggestions to improve. I am trying to create an LWC picklist (lightning-combobox) with options that are basically comma separated values in a Contact text field. Also, this component needs to run in the community. I also tried using getFieldValue and getFieldDisplayValue, but nothing worked. Thanks!
Contact.Test_Field__c = abc,def,ghi
Expected Output: LWC Picklist
- abc
- def
- ghi
HTML
<template>
<lightning-card>
<lightning-combobox name="progress" label="Status" value={value}
placeholder="Select Progress" options={options} onchange={handleChange}>
</lightning-combobox>
</lightning-card>
</template>
JS
import {LightningElement, wire, } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import CONTACT_ID_FIELD from "@salesforce/schema/User.ContactId";
const FIELDS = [
'Contact.Test_Field__c'];
export default class lwcTest extends LightningElement {
@wire(getRecord, { recordId: CONTACT_ID_FIELD , fields: FIELDS })
contact;
//need help in this block to convert array of strings to picklist values
get options() {
return this.contact.data.fields.Test_Field__c.value.split(',');
}
handleChange() {}
}