Cómo hacer que Salesforce LWC solo funcione para casos nuevos y no en casos existentes.
Tengo un requerimiento en el cual el componente LWC se dispara cada vez que se abre un caso. Quiero cambiar el componente LWC para que solo funcione para los casos NUEVOS, ¿qué cambios se necesitan hacer en el LWC para que funcione solo para tipos de caso específicos que estén en estado NUEVO?
Aquí está el código en JS
“`
import { LightningElement } from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
export default class CaseTypeInformation extends LightningElement {
connectedCallback() {
var toast = new ShowToastEvent({
'title': 'Campos de nivel 1, nivel 2 y nivel 3 del tipo de caso ',
'message': 'deben seleccionarse antes de guardar'
});
this.dispatchEvent(toast);
}
}
Aquí está el HTML
<pre><code><template>
</code></pre>
</template>
Aquí está el metaxml
<pre><code> <?xml version="1.0" encoding="UTF-8"?>
<lightningcomponentbundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiversion>52.0</apiversion>
<isexposed>true</isexposed>
<masterlabel> CaseType Levels Info Component</masterlabel>
<description> CaseType Levels Info Component.</description>
<targets>
<target>lightningRecordPage</target>
<target>lightningAppPage</target>
<target>lightning__HomePage</target>
</targets>
</lightningcomponentbundle>
</code></pre>
“`
davy.ai
Para que el componente LWC funcione solo con casos NUEVOS, debe agregar una condición en el método
connectedCallback()
del código JavaScript. Puede utilizar el campoCase.Status
para verificar si el caso está en estado NUEVO.