In Summer'18 release, Salesforce introduces new interface for lightning components which can be used to fetch URL parameters in lightning components.
Before this, we have to write logic in controller.js function to get current URL and split the url parameters.
If we are using lightning tab and displaying lightning component, then we can fetch URL param by using "{!v.PageReference.state.xxxxx}" where xxxxx is URL parameter name.
I have created a lightning component "SK_URLParamCmp.cmp" in order to explain the usage of this interface. Below is code snapshot:
Now I have created a lightning tab "SK_URLParam_Tab", which will open this lightning component. Pass any value in URL as "accname" as parameter. Below is sample URL:
"/lightning/n/SK_URLParam_Tab?accname=sunil"
Below is UI snapshot:
Hope this will help!!
Note:
If changes to lightning Components are not reflecting immediately in lightning tabs, then you have to disable the "Enable secure and persistent browser caching to improve performance" option under Caching section in Session settings.
For more details on this setting, please refer below URL:
Improved Performance with Secure Client-Side Caching
Before this, we have to write logic in controller.js function to get current URL and split the url parameters.
If we are using lightning tab and displaying lightning component, then we can fetch URL param by using "{!v.PageReference.state.xxxxx}" where xxxxx is URL parameter name.
I have created a lightning component "SK_URLParamCmp.cmp" in order to explain the usage of this interface. Below is code snapshot:
Now I have created a lightning tab "SK_URLParam_Tab", which will open this lightning component. Pass any value in URL as "accname" as parameter. Below is sample URL:
"/lightning/n/SK_URLParam_Tab?accname=sunil"
Below is UI snapshot:
Hope this will help!!
Note:
If changes to lightning Components are not reflecting immediately in lightning tabs, then you have to disable the "Enable secure and persistent browser caching to improve performance" option under Caching section in Session settings.
For more details on this setting, please refer below URL:
Improved Performance with Secure Client-Side Caching
I was searching an excellent blog in this topic, thanks admin for the info on latest technology.
ReplyDeleteSEO Training in Chennai
JAVA Training in Chennai
Big Data Training in Chennai
Selenium Training in Chennai
German Classes in chennai
DOT NET Training in Chennai
Java training in Anna Nagar
this is not working for me
ReplyDeletewhen am i navigating to another component, tab header is showing 'Loading.....'
ReplyDeleteCan you please help me in changing to user friendly.