html code

Exploring System Events in Salesforce -Your Comprehensive Guide

“The Lightning framework autonomously triggers system events during component initialization, alterations in attribute values, rendering procedures, and more. All components have the capability to subscribe to system events within their HTML markup.

These events are manageable within Lightning apps, components, and even the Salesforce mobile app. A handful of examples of system events are provided below.”

“Names of Events”

“1. aura:doneRendering”

“The aura:doneRendering event is now deprecated. Instead, opt for the render event. Unless your component operates entirely independently within a standalone app, without integration into complex environments such as Lightning Experience or the Salesforce mobile app, the enclosing application might trigger your event handler multiple times. This behavior complicates responsive actions for various scenarios.

This event is automatically invoked when no other components necessitate rendering or rerendering due to attribute value alterations.

Exercise caution regarding aura:completed.

A rendering event takes place within a client-side controller. Handling this event is limited to one aura:handler tag per component.”

“2. aura:valueChange Event”

“In Salesforce’s Lightning components, the aura:valueChange event is employed to handle modifications in attribute values.”

“3. aura:ValueDestroy”

“When a component undergoes destruction, this event is activated. If you require custom cleanup procedures following the component’s destruction, manage this event.

Imagine you’re interacting with a component within the Salesforce app. Upon selecting an alternate menu item from the Salesforce mobile navigation menu, the aura:valueDestroy event is initiated, leading to the component’s dismantling. In such an instance, the value parameter within the event offers insight into the component undergoing destruction.”

“4. aura:ValueInit”

“Before the rendering process begins, this event is triggered when an app or component is initialized. Utilize the aura:handler tag to address this event.

Managing system events is straightforward. If you intend to incorporate logic during the unfolding of any of the previously mentioned events, you can achieve this by including the following code in your HTML markup:”

<aura:handler name="name of the event" value="!this" action="!c.handleSystemEvent"/> 
<aura:handler name="name of the event" value="!this" action="!c.handleSystemEvent"/> 
<aura:handler name="name of the event" value="!this" action="!c.handleSystemEvent"/>

“Note: The ‘name of the event’ can take on any of the subsequent values: init, render, destroy, change, and aura:systemError.”

“Presently, you can employ the following syntax to craft the logic you wish to execute within the JS controller:

(do your logic) (handleSystemEvent: function (component, event, helper)

The advantage lies in the reusability of all these components. However, a limitation of JavaScript is that the JavaScript of one component cannot directly interact with that of another component.

How can these components effectively communicate with each other? This is where the concept of Events comes into the picture. In essence, Lightning Events serve as the bridge between these two realms. This article delves into Salesforce Lightning Framework Events, detailing their usage scenarios and significance.”