I am trying to refresh my community page which has a LWC with a submit button. The page has a relatedlist also which is a junction object where the mapping from LWC is getting stored. What, i want when i save my records the page should auto refresh and the related list should show the updated mapping. I tried navigating to my current page but the related list isnt updating until i do a hard refresh! I have tried even putting a delay! In console i can see my records are created before the page is navigated. How can i resolve this ?
createRecord(recordInput)
.then(() => {
for (let i = 0; i < this.selectedRows.length; i++){
//alert("You selected: " + this.selectedRows[i].locationId);
const fields = {};
fields[CLIENT_FIELD.fieldApiName] = this.recordId;
fields[LOCATION_FIELD.fieldApiName] = this.selectedRows[i].locationId;
fields[STARTDATE_FIELD.fieldApiName] = this.startDate;
const recordInput = { apiName: CLIENT_LOCATION_OBJECT.objectApiName, fields };
createRecord(recordInput)
.then((clientLocation) => {
console.log('client location created >'+clientLocation.id);
counter++;
});
}
}).then(() => {
/*this.dispatchEvent(
new ShowToastEvent({
title: 'Locations are mapped.',
variant: 'success'
}),
);*/
setTimeout(() => {
this[NavigationMixin.Navigate]({
type: "standard__recordPage",
attributes: {
objectApiName: "Account",
actionName: "view",
recordId: this.recordId,
},
});
}, DELAY);
}).catch(error => {
this.dispatchEvent(
new ShowToastEvent({
title: this.label.labelError,
message: error.body.message,
variant: 'error',
}),
);
});
$A.get('e.force:refreshView').fire();
by wrapping my LWC in Aura, i am able to call refresh through events but the page doesnt do anything.