I have a custom lwc that has a wire call that retrieves a list of records and some required information to be displayed:

public static InterPlanetaryCasesController.IPCasesData getInfo(){
    String query;

    //Method result
    Class.IPCasesData result = new Class.IPCasesData();

    //Fill fieldset and generate query
    query = 'SELECT ';
    for(Schema.FieldSetMember fsm : Class.getInterPlanetaryCasesTableFS()){
        query += fsm.getFieldPath() + ', ';
        //Contact Name for datatable proper data display
        if(fsm.getFieldPath().equals('ContactId')){ query += 'Contact.Name, '; }
        //Add fieldset member to list
        result.fieldSetLIST.add(new Class.PicklistValue(fsm.getFieldPath(), fsm.getLabel()));
    query += 'Id FROM Case WHERE IsClosed = false AND Planet__c != null ORDER BY CreatedDate ASC LIMIT 5';

    //Fill case list
    result.caseLIST = Database.query(query);

    return result;

private static List<Schema.FieldSetMember> getInterPlanetaryCasesTableFS() {
    return SObjectType.Case.FieldSets.InterPlanetaryCase.getFields();

My issue is that I want this lwc to refresh each time a new record is being added or modified. Is this even possible? And if so, how can I achieve this?


  • Using refreshApex might help, Check this blog1 blog2 Jul 17, 2021 at 17:36
  • @AbhinavThakur Hi, thanks for your response! But what I want is to capture from a lwc inserted into a custom tab if a new (for example) Case has been inserted or a existing one has been updated to automatically refresh my data. Is this possible?
    – molinet
    Jul 17, 2021 at 17:46

1 Answer 1


You can use lightning-emp-api to subscribe to a Change Data Capture channel, in which your component will then be notified of any creations or updates. In general, you just import the subscribe and unsubscribe methods from lightning-emp-api, subscribe to the object you want to trigger change data capture notifications for, and then handle them in the event handler. Note that there are limits to this feature, so you should be aware of those to see if CDC is suitable for you.

  • Thanks a lot! It worked perfectly
    – molinet
    Jul 22, 2021 at 7:54

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.