function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
fiona gentryfiona gentry 

How To Make LWC work only for New Cases and Not on Exisiting cases

Hi team,

I have a requirement where LWC component is fired everytime when a case is opened,I want to change LWC component to work only for NEW cases,what changes needs to be done in the LWC

Here is JS code
import { LightningElement } from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';

export default class ERTCaseTypeInformation extends LightningElement {

    connectedCallback() {
        var toast = new ShowToastEvent({
                 'title': 'Case Type Level 1, level 2 and level 3 fields ',
                 'message': 'must be selected before saving'


here is HTML


here is meta xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="">
  <masterLabel>ERT CaseType Levels Info Component</masterLabel>
  <description>ERT CaseType Levels Info Component.</description>
ranjit Pisal 10ranjit Pisal 10

If you want to load/fire LWC only the first time when case is created and opened by the end-user, then you need to maintain a flag(checkbox field) on the Case object, which will tell you if previously LWC is executed or not for the particular case.

On a load of component, you will check the value of that field and can skip the rest execution of the LWC component if flag is checked.

If the value is unchecked, then you have to set the checkbox field to true and allow LWC component to load.