Apex Refresh data-table is not working on LWC. Can anyone please help me what I'm missing below.


<div class="slds-p-top_x-large">
                            <lightning-datatable key-field="Id" data={data} columns={columns}
                                draft-values={draftValues} hide-checkbox-column="true"

 <div class="slds-size_2-of-2">
                                        <lightning-button type="submit" variant="brand" value="AddParent"
                                            name="AddParent" label="Save" onclick={handleonClickParent}>


import { refreshApex } from "@salesforce/apex";

@track error;
@track data;

@wire(getParentdetails, { enrollmentName: "a082w000000YUH5AAO" })

getContacts(response) {
console.log("data -->" + response);
this.wiredDataRefresh = response;
const data = response.data;
const error = response.error;
if (data) {
  this.data = data;
} else if (error) {
  this.error = error;

 handleonClickParent() {
 return refreshApex(this.wiredDataRefresh);

refreshData() {
return refreshApex(this.wiredDataRefresh);


@AuraEnabled (cacheable = true)
public static List<Contact> getParentdetails(Id enrollmentName) {
     return   [select  Id, Firstname, LastName, Email, Phone, Student_Relation__c
              from Contact WHERE Enrollment_Name__c=:enrollmentName];
  • 2
    enrollmentName is expecting an ID but in your sample you're putting "man" – Brian Miller Mar 2 '20 at 13:34
  • 1
    You define refreshData() but doesn't look like you ever call it elsewhere in your code – Brian Miller Mar 2 '20 at 13:35
  • @BrianMiller I have save button in my form, onclick of save button handleonClickParent is called. Edited my questions – user3214361 Mar 2 '20 at 13:46
  • Also include that save button code. Could be something simple like the names not matching because of being case sensitive, etc – Brian Miller Mar 2 '20 at 14:02
  • Added the save button code – user3214361 Mar 2 '20 at 14:10

wiredDataRefresh is not declared in the js file as per your code snip. Could you see if that is the case?

Note: I don't have enough reputation to comment hence writing my comment as an answer. Sorry for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.