• Nikhil Shah 14
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi,

In LWC, there is a way to automatically update the content in it when the record is updated without having to refresh the page. This is possible if we use getRecordNotifyChange.

My question is how do we detect a change in the related list in a custom LWC? For example, when I delete a file from the Files related list, I see the spinner appear on each of the standard related lists meaning that they are getting automatically refreshed when I delete the related file. So, how do I get a custom LWC also to refresh itself when a related record or atleast a related file is deleted?
Hi,
I have a custom LWC residing in record detail page. This LWC is displaying the files associated with the record. When user clicks on the file, I'm using NavigationMixin with 'standard__namedPage' and 'filePreview' to preview the file to the user. If the user deletes this file from the preview, then my LWC is not updating to remove the deleted file.

The LWC updates only when the user manually refreshes the page. But I see other standard related lists automatically refreshing when I delete the file from the preview because I see the spinner on each of those related lists.

When deleting a related file, how is it automatically refreshing the standard related lists on the record detail page? Which event/message do I need to subscribe to in my custom LWC to refresh itself too?

I searched everywhere, and everyone only talk about refresh the standard related lists automatically when custom component does something. But no one talks about the other way round - how to detect a change, or in my case a deletion of record in related list, in a custom LWC residing on the same record detail page?
Would anyone have a validation rule for the following:
A rule will trigger when trying to close won an opportunity. It can only be closed won if a checkbox is true. 
Apex Code: 
public with sharing class userListApexClassForLWC {
    @AuraEnabled(cacheable=true)
    public static List<User> userList() {
        return [Select Id, FirstName, LastName, Email, profile.Name, IsActive FROM  User Where IsActive=true LIMIT 5];
    }
}

LWC JS:

import { LightningElement, wire, track} from 'lwc';
import userListApexClassForLWC1 from '@salesforce/apex/userListApexClassForLWC.userList';
export default class UserListInLWC extends LightningElement {
  
    @track error;
    @track FirstName;
    @track LastName;
    @track Email;
    @track profile;
    @track IsActive;
    profileName;
   
    data=[]
    columns = []
   
     @track columns = [
        { label: 'First Name', fieldName: 'FirstName', type: 'text'  },
        { label: 'Last Name', fieldName: 'LastName', type: 'text' },
        { label: 'Email', fieldName: 'Email', type: 'email' },
        { label: 'Profile', fieldName: 'profileName', type: 'string' },
        { label: 'IsActive', fieldName: 'IsActive', type: 'boolean' },
    ];
    @wire(userListWrapper, {currentRecordId: '$recordId'})
    dataFn({data}){
        this.data = data;
    }
    @wire (userListApexClassForLWC1) wireduser ({error,data})
    {
        if (error) {
           this.error = error ;
        } else if (data) {
            this.data = data;
            profileName= data.profile.name;
            console.log(data);
        }
    }
}

LWC HTML:

<template>
    <lightning:card>
    <div style="height: 500px;">
        <template if:true={data}>
            <lightning-datatable
                     key-field="id"
                     data={data}
                     columns={columns}>
        </lightning-datatable>
        </template>
        </div>
    </lightning:card>
</template>
 
Hi guys,plesae help me out with this scenario:
Here the  list view named of Object Sla_sanpshot__c who is a child of sla__c object.
In list view there is fields like A__c  AND B__c from Sla_snapshot__c so if i will update this fields then i want to change the value in my formula which is like (A/B)*100...SO writing trigger to update but it is throwning me an error:

if(trigger.isbefore)
{
    if(Trigger.isUpdate || Trigger.isInsert)
    {
        for(SLA_Snapshot__c s: Trigger.new)
        {
            s.Formula__c  = s.Formula__c != null ? string.valueof(s.Formula__c) : '';
           string.valueof(s.Formula__c).replace('A',s.A__c); 
        } 
    }
}User-added imageUser-added image