I built a screen action LWC that uses lightning-record-edit-form
and lightning-input-field
to create a new record. The quick action is placed on a parent record page and adds a related child record to the parent record. The quick action can create a record but after closing the modal, the related list shows the old information. I'd like to refresh the related list after closing the modal but don't know how to implement it.
I already tried getRecordNotifyChange()
but it seems to be only applicable when editing a record, not when creating a record.
I also have tried updateRecord({ fields: { Id: this.recordId }})
seeing the following question but it seems to be only applicable when creating a record by an Apex method, not the lightning-record-edit-form
feature:
Force refresh view in LWC
Can anybody help to solve this issue? Thanks.
My related markup:
<lightning-quick-action-panel header="Create a Question">
<lightning-record-edit-form
object-api-name="question__c"
onsuccess={close_modal}
>
<lightning-messages></lightning-messages>
<lightning-input-field field-name="Name"></lightning-input-field>
<div class="slds-m-top_medium">
<lightning-button class="slds-m-around_xx-small" label="cancel" onclick={handleReset}></lightning-button>
<lightning-button class="slds-m-around_xx-small" type="submit" variant="brand" label="Save"></lightning-button>
</div>
</lightning-record-edit-form>
</lightning-quick-action-panel>
My JS function:
close_modal() {
this.dispatchEvent(new CloseActionScreenEvent());
this.dispatchEvent(
new ShowToastEvent({
title: 'Success',
message: 'Record is created',
variant: 'success'
})
);
}