Here is a link to the code I have working: https://codepen.io/reuel3/pen/EMEGQy It works as expected there.
I get an error message when attempting same thing in wire adapter function:
[LWC component's @wire target property or method threw an error during value provisioning. Original error:
[Cannot assign to read only property 'values' of object '#<Object>']]
code:
@wire(getPicklistValuesByRecordType, { objectApiName: LINEITEM_OBJECT, recordTypeId: '$recordTypeId' })
getPickListOptions( {error, data}) {
try {
if (!!data) {
this.pickListOptions = Object.create(data); //Object.assign({}, data);
//error on next line
this.pickListOptions.picklistFieldValues.Body__c.values = [...this.pickListOptions.picklistFieldValues.Body__c.values, {attributes: null, label:"--None--", validFor: [], value: ""}];
} else if(!!error) {
console.log('error----2---', JSON.stringify(error));
}
} catch (err) {
console.error('err---3----', JSON.stringify(err));
}
}
The data from pickListOptions is in the link above. How can I get around the read-only array?