Skip to main content

Connect #ZOOM with #Salesforce using #Zapier | Salesforce Tutorials

Refresh State of Lightning Component after the lightning navigation gets changed.

How to refresh the state of Lightning Component after change of lightning navigation ?

So in my scenario I am having two record types on opportunity and I am rendering the attributes on the component based on the Record Type ID.

For example let's say I am having "RT1" and "RT2". In my doInIt method I was first checking the record type name & Id and based on that I was rendering the attributes.

At first time while creating new opportunity and selecting "RT1", it was displaying "RT1" in my doInIt method. But while I navigate to opportunity again and try creating a new opportunity with "RT2", my doInIt method didn't get triggered as the component was in his old state where the doInIt method was already triggered.

To solve this issue I added lightning:isUrlAddressable in my component as shown below :

<aura:component description="testComponent" implements="lightning:isUrlAddressable">

After adding the isUrlAddressable simply add a change handler to refresh the state as shown below :

<aura:handler name="change" value="{!v.pageReference}" action="{!c.reInit}" />


 reInit : function(component, event, helper) {

Now the component state will be refreshed automatically. Please comment below if you would like to update something in this post.

Please check below links also and subscribe if you like the content : 

Stay at Home to Stay Safe. #corona

Share this blog with your friends if you find it helpful somehow !

Keep Coding 😊


Popular posts from this blog

How to send WhatsApp from Lightning Component Salesforce ?

Send WhatsApp from Lightning Component SalesforceHi folks, in this article I will explain how you can send WhatsApp from Lightning Component using
In this example I will create a Quick Action button on Contact which will be connected with my Lightning Component.
Please follow the steps below : 
Step 1 : Create a Lightning Component & Apex as shown below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30<aura:componentcontroller="Vlog_whatsappCTRL"implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"access="global"><aura:attributename="recordId"type="String"/><aura:attributename="con"type="Contact"/><aura:attributename="msg"type="String"/><aura:handlername="init"action…

Send WhatsApp and Save Chat using Lightning Component Salesforce | Salesforce Tutorials

Hello folks,
In this article you will learn to send WhatsApp and Save the Chat using Lightning Component Salesforce. 
Prerequisite : 
Create a custom object WhatsApp__c
Create custom fields as shown below : 

Please follow the code below : 

WhatsAppComponent 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30<aura:componentcontroller="Vlog_whatsappCTRL"implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"access="global"><aura:attributename="recordId"type="String"/><aura:attributename="con"type="Contact"/><aura:attributename="msg"type="String"/><aura:handlername="init"action="{!c.doInit}"value="{!this}"/><articleclass="slds-card"><divclass="slds-card__header…

Get Parent Id when overriding standard actions with a Lightning Component in salesforce1 app

How to Get Parent Id when overriding standard actions with a Lightning Component in salesforce1 app ?
In this blog I will explain how you can get Parent Id when overriding standard actions with a lightning component.
For example I have changed my Opportunity New button action with a custom Lightning Component. 
Let's create a new account and from the related tab try creating the new Opportunity. Have you noticed any change in URL ?
Let me share the URL with you :  _________________________________________________________________________ _________________________________________________________________________
In above URL you …