1

I have written wire and if data is received successfully I am calling function in which apex method is called imperatively, so how can I refresh results of that apex call for example on button click without refreshing the whole page? I tried to use refreshApex but that can only be used with wired result but it is not refreshing data which is returned after I call the function inside that wire, so here is the code:

import {
    LightningElement,
    track,
    wire
} from 'lwc';
export default class Sf_addProducts extends LightningElement {
    records = [];
    @wire(getFieldsLabelsMap) wiredQlis(result) {
        if (result.data) {
            this.getQliRecords(result.data);
        } else if (result.error) {
            console.log(result.error);
        }
    }
}

getRecords(fldsMap) {
    getQlis({
        quoteId: this.quoteId,
        fieldsToQUery: fieldNames
    }).then(res = {
        if (res.length > 0) {
            this.records = res;
        }
    })
}

handleButtonClick() { //refresh getRecords without refreshin the whole page

}
3
  • if no dml is happening on apex side then use @wire otherwise you will have to call function again to get latest data from imperative call
    – Elijah
    Jun 16, 2022 at 9:05
  • @Elijah so how can I call wire from another wire? is it possible?
    – Nikolas
    Jun 16, 2022 at 9:45
  • You can't call wire from another wire but you can certainly chain them. Ref- salesforce.stackexchange.com/questions/255958/…
    – Elijah
    Jun 16, 2022 at 9:56

0

This site is temporarily in read-only mode and not accepting new answers.

Browse other questions tagged .