2

I have a global quick action that invokes lwc in Field Service mobile app. When deleting resource absence record, and call 'refreshApex', I expect the list retrieved by the wire service to be updated, removing the deleted record. However, upon closing and reopening the component, the list still contains the deleted record. Although it's deleted from the homepage and server-side.

How to remove the deleted record when reopening the component?

import { LightningElement, api, track, wire } from 'lwc';
import { deleteRecord } from 'lightning/uiRecordApi';
import { refreshApex } from "@salesforce/apex";
import getResourceAbsenceList from "@salesforce/apex/ResourceAbsenceDisplayController.getResourceAbsenceList";

import userId from '@salesforce/user/Id';       

export default class ResourceAbsenceDisplay extends LightningElement {
    @api recordId;

    wiredAbsenceResult;
    resourceAbsenceRecords;
   
    get isMobile() {
        return FORM_FACTOR != 'Large';
    }

    get serviceResourceId(){
        return this.isMobile ? userId : this.recordId;
    }          

    @wire (getResourceAbsenceList, { recordId: '$serviceResourceId', isMobile: '$isMobile'})
    wierdRecords(result){
        this.wiredAbsenceResult = result;
        const { data, error } = result;
        if(data){
            this.resourceAbsenceRecords = JSON.parse(JSON.stringify(data));
        }
        else if(error){
            console.error(error);;
        }
    }    

    async handleDeleteRecord(event){
        let recordNumber = event.target.dataset.number;
        try {
            let item = this.resourceAbsenceRecords.find(el => el.number == recordNumber);
            await deleteRecord(item.id);
            await refreshApex(this.wiredAbsenceResult);
         } catch (error) {
            console.error('handleDeleteClick error', error);
        }
    }
}

0

You must log in to answer this question.