Posts

Showing posts from March, 2018

Troubleshooting Error: Component Class Instance Initialization Error in Salesforce Lightning

Image
If you're working with Salesforce Lightning and encounter the error message: Error: Component class instance initialization error [Cannot read property 'g' of undefined] you're not alone. This error often arises from a mistake in the doInit event handler configuration in your component. Let's delve into the issue and how to resolve it. Understanding the Error The error is triggered when the doInit action is called improperly. In this case, it happened because of a custom event name defined in the <aura:handler> tag. Let’s take a look at the problematic code: Original Code < aura:component controller = "skb_bugSolving1" > < aura:attribute name = "myAccount" type = "Account[]" /> < aura:handler name = "getAccount" value = "{!this}" action = "{!c.doInit}" /> < div class = "demo-only" style = "width: 320px;" > </ d...

Troubleshooting Error: Unknown Controller Action 'doInit' in Salesforce Lightning

Image
If you’ve encountered the error message: Error : Unknown controller action 'doInit' you’re not alone. This error commonly occurs when using the doInit event in Salesforce Lightning components. Let’s explore why this happens and how to fix it. Understanding the Error The doInit event is automatically fired when a Lightning application or component is initialized, prior to rendering. This means that when the page loads, the doInit event is triggered and the system looks for the corresponding JavaScript function in the component's controller. If the JavaScript controller does not contain a valid doInit function, you will encounter the "Unknown controller action 'doInit'" error. This highlights the importance of ensuring that your controller is properly set up to handle this event. Key Takeaway Whenever you use the doInit event in your Lightning component, it’s crucial to define a valid doInit function in your JavaScript controller. Failing to do so w...