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

a href hyperlink to navigate to SObject in lightning component

I have the following hyperlink and I'm just trying to navigate to the sObject page. However its not redirecting to the record page.
<a target="_blank" class="slds-text-link" href=""  onclick="{! c.handleTaskLink }" data-taskid="{!task.Id}">{!task.Subject}</a>

handleTaskLink : function (component, event, helper) {

        var recordId = event.getSource().getElement().getAttribute('data-taskid');

        var navEvt = $A.get("e.force:navigateToSObject");
          "recordId" : recordId,
          "slideDevName" : "detail"

AnudeepAnudeep (Salesforce Developers) 
I do not see any issues with the code. I suggest checking if the recordId is returning any value by adding a console log after var recordId = event.getSource().getElement().getAttribute('data-taskid');

Also, just to confirm, you can hardcode the recorId and see if the redirect is happening
"recordId": "00QB0000000ybNX",
      "slideDevName": "related"

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!