I have 2 @wire Apex methods
that will invoke code from Apex Controller. Right now the array only has value from the 1st wire (because it get called first) but not the 2nd one
.
My question is: How can I have 1 array with result from 2 wire.
HTML code:
<lightning-combobox required name="fieldList" label="Group By" onchange={handleGetPicklistFieldsOptions} options={lstOfSummarizedFields}
</lightning-combobox>
JS code:
@track lstOfSummarizedFields = [];
wireAllCurrencyRes = ''
@wire(getCurrencyTypeFields,{ strObjectName : '$sObjectType' })
wireAllCurrency(result) {
this.wireAllCurrencyRes = result;
let {error, data} = result;
if(data) {
for (let key in data) {
this.lstOfSummarizedFields.push({ label: key, value: data[key] });
}
}
if(error) {
console.log('Error in getting currency fields');
}
}
wireAllNumberRes = ''
@wire(getNumberFields,{ strObjectName : '$sObjectType' })
wireAllNumber(result) {
this.wireAllNumberRes = result;
let {error, data} = result;
if(data) {
for (let key in data) {
this.lstOfSummarizedFields.push({ label: key, value: data[key] });
}
}
if(error) {
console.log('Error in getting number fields');
}
}
- I tried to create a new array to push 2 results into one but it does not work as well.
HTML code:
<lightning-combobox required name="fieldList" label="Group By" onchange={handleGetPicklistFieldsOptions} options={lstOfAllFields}
</lightning-combobox>
JS code:
@track lstOfAllFields = [];
@track lstOfSummarizedFields = [];
wireAllCurrencyRes = ''
@wire(getCurrencyTypeFields,{ strObjectName : '$sObjectType' })
wireAllCurrency(result) {
this.wireAllCurrencyRes = result;
let {error, data} = result;
if(data) {
for (let key in data) {
this.lstOfSummarizedFields.push({ label: key, value: data[key] });
this.lstOfAllFields.push(this.lstOfSummarizedFields)//push this into an
}
}
if(error) {
console.log('Error in getting currency fields');
}
}
wireAllNumberRes = ''
@wire(getNumberFields,{ strObjectName : '$sObjectType' })
wireAllNumber(result) {
this.wireAllNumberRes = result;
let {error, data} = result;
if(data) {
for (let key in data) {
this.lstOfAllFields.push({ label: key, value: data[key] });
}
}
if(error) {
console.log('Error in getting number fields');
}
}
Thank you so much!