I have Component A that Shows the details of the record. The Details are coming from apex Controller.
I have Component B that has a lightining-button which on click shows a Modal for editing the same record that is displayed in Component A.
When I click on Save the record from Component B's Modal, it is updated at the backend, but the updatations are not immediately visible on ComponentA.
How can I Refresh the Component A , after the record is updated by Component B?
Component A has the following code that fetches the data from the controller
wiredFetchData({ error, data }) {
if (data) {
console.log('result:: ' + JSON.stringify(data));
this.data = data;
console.log('data:: ' + JSON.stringify(this.data));
this.error = undefined;
this.recordid = String(this.data[0].Id);
this.name = this.data[0].Name;
this.sourceObj = this.data[0].DYNMPR__SourceObject__c;
this.targetObj = this.data[0].DYNMPR__TargetObject__c;
this.description = this.data[0].DYNMPR__Description__c;
this.active = this.data[0].DYNMPR__Active__c;
} else if (error) {
this.error = error;
this.data = undefined;
}
}
handleClick() {
refreshApex(this.data);
}
component B has the following code that handles record edit
handleSubmit(){
var dataList = {};
dataList.Id = this.data[0].Id;
dataList.Name = this.name;
dataList.DYNMPR__Active__c = this.active;
dataList.DYNMPR__SourceObject__c = this.sourceObj;
dataList.DYNMPR__TargetObject__c = this.targetObj;
dataList.DYNMPR__Description__c = this.description;;
this.newData = dataList;
this.newData = dataList;
console.log("this.EditData:: " + JSON.stringify(this.newData));
updateData({mapObjData : this.newData});
this.closeModal();
// return refreshApex(this.newData);
}
How do I displatch the refreshApex event from component b after the save is handled as shown. I checked the guide but couldn't understand. Please help.