I have a lightning card placed on a component and it has a lightning button menu , the first button is view where on clicking it, it needs to open a record detail page in a seperate tab, The record id of that record is in a string variable. I used navigatetosobject in side of onselect for lightning button menu but it is not working, can someone tell me how to acheive this.

This is the html for the button menu :

 <div class="slds-dropdown_right">
     <lightning:buttonMenu alternativeText="Toggle menu"  menuAlignment="right" class="slds-m-left_xx-large" onselect="{!c.handleMenuSelect}">
         <lightning:menuItem label="View" value="view"/>
         <lightning:menuItem label="Completed-Payment" value="completedPayment"/>
         <lightning:menuItem label="Uncollectible" value="uncollectible"/>
         <lightning:menuItem label="Already Paid" value="alreadyPaid"/>

This is the function in helper :

navToDelDetails: function (component, event, helper){
var navEvt = $A.get("e.force:navigateToSObject");

This is the controller where i called the helper inside onselect :

  handleMenuSelect: function(component, event, helper) {
    var selectedMenu = event.detail.menuItem.get("v.value");
    console.log('selectedMenu-' + selectedMenu);
    switch(selectedMenu) {
        case "view":
        case "uncollectible":
            //do delete
        case "alreadyPaid":
            //do edit

1 Answer 1


There are a couple things here. Your helper method does not have the same signature as your are passing the data to it. On your controller you are passing two variables:


But on your helper method, you have these three variables:

navToDelDetails: function (component, event, helper) 

Then in your helper you are trying to set v.delRecordId as the source to navigate to, but you you are using this as a string, so literally "v.delRecordId" is the id you are trying to pass.

You have two ways to change this:

  1. change the signature of the helper method to have the second variable something you want to use (component,delRecordId). Then in your setParams, use the variable instead of a string delRecordId.

navEvt.setParams({"recordId": delRecordId });

  1. Set your delRecordId in your component before you pass over the helper. In this case you are closer to what you are trying to do in v.delRecordId. You have to set this value first in the controller, then in your helper, read the value again.


navEvt.setParams( {"recordId": component.get("v.delRecordId") });
  • Thanks a lot, Cyberjus for your suggestion, i have changed accordingly as you told me to , the value for delRecordId is actually set in another function in the helper, i have simply set the return value of the apex class to delRecordId. That i have passed to the lightning record view form. Now after the suggestions i have changed accordingly yet im not getting any output and im getting an error saying This page has an error. You might just need to refresh it. First, would you give us some details? (We're reporting this as error ID: 1207004513) , Commented Jul 16, 2021 at 17:31
  • Case caseDetail = [SELECT Id, Delinquency_Outreach__c FROM Case WHERE Id=:caseId]; return caseDetail.Delinquency_Outreach__c; This is how im storing the record id of the parent object and this is how im storing it in the variable in the helper ` component.set("v.delRecordId",result.getReturnValue());` Commented Jul 16, 2021 at 17:34
  • That is an internal error which is hard to debug. Try to breakpoint down to exactly where is it happening. Check that the return type from your method is the correct type.
    – CyberJus
    Commented Jul 16, 2021 at 20:09
  • thanks a lot, Cyberjus, I will look into it, can u help me with another issue with the same process I explained in the another question. link Commented Jul 17, 2021 at 3:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .