I'm struggling to obtain the values that are part of the Selected list on a lightning-dual-box field.
This is the field:
<lightning-dual-listbox
name="Mass_Payments__c"
label="Mass Payment"
source-label="Available"
selected-label="Selected"
required
value={currentMassPayment}
options={picklistMassPayments}>
</lightning-dual-listbox>
On the UI looks like this:
This are parts of the JS that affects that dual listbox, all the other fields are working just fine:
import { getFieldValue, getRecord } from 'lightning/uiRecordApi';
import MASS_PAYMENT_FIELD from '@salesforce/schema/Opportunity.Mass_Payments__c';
export default class Createdealmasspayments extends LightningElement {
opportunityObject = OPPORTUNITY_OBJECT;
@wire(getRecord, {
recordId: '$recordId', fields: [MASS_PAYMENT_FIELD]
})
record;
@wire(getObjectInfo, { objectApiName: OPPORTUNITY_OBJECT })
handleResult ({ error, data }) {
if (data) {
this.rtId = data.defaultRecordTypeId;
}
}
@wire(getPicklistValues, { recordTypeId: '$rtId', fieldApiName:
MASS_PAYMENT_FIELD })
getPicklistValuesMassPayments ({ error, data }) {
if (data) {
this.picklistMassPayments = data.values;
}
}
// All good until now, this getter is not doing his job
get currentMassPayment () {
return this.record.data ? getFieldValue(this.record.data, MASS_PAYMENT_FIELD) : '';
}
If I select an option and pass it to the 'Selected' block after clicking the correct arrow on the record page layout, before opening this form, the option don't stay on the 'Selected' block. All options are back to the 'Available' block... any ideas on how to work around this?