function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rahul Rana 32Rahul Rana 32 

How to navigate to a record by clicking on the link in lightning:tile ?

Hi Salesforce Lightning Experts,

I am trying to navigate to a record by clicking on the link in lightning:tile as shown below:

User-added imageI am trying to call the JS controller from 'href' attribute and trying to use <lightning:navigation/> to navigate to the record as shown below But it is not working : 

<lightning:navigation aura:id="navigation"/>
<lightning:tile label="{!emp.Name}" href="{!c.navigateToAlert}">


To me, it looks like we cannot call JS controller from href. Can someone explain a way to navigate to the particular record. It is to be kept in mind that I'm showing multiple lightning:tiles by iterating over a list. So navigation will be dynamic based on the record we are clicking.

Kindly suggest. Thanks in advance.
Bhawana Mehta SFDCBhawana Mehta SFDC
@Rahul : You can not call JS controller from href. href refers to the url want to navigate to. What you can do instead is, You can dynamically built the url in JS and use that url in href. You can refer to below documentation to see if how the Url is built dynamicaly.

https://developer.salesforce.com/docs/component-library/bundle/lightning:navigation/documentation