0

I'm working on a lightning component under quick action. I'm trying to navigate the user to the edit page but it's navigating to the standard view page.

 var navService = component.find("navService");
                    var pageReference =
                        {
                            type: 'standard__recordPage',         
                            "attributes": {              
                            "recordId": storeResponse,
                            "actionName": 'edit',               
                            "objectApiName":"Opportunity"              
                        }        
                    };
                    component.set("v.pageReference", pageReference);  
                    var pageReference = component.get("v.pageReference");
                    navService.navigate(pageReference);

Could you help me to achieve this?

1 Answer 1

1

Any reason why are we setting pageReference back to a variable when we already have a local variable for the same. May be your pageReference is missing.

This works very well.

clickEdit: function (component , event, helper) {
    event.preventDefault(); // Preventing any default behaviour
    const navService = component.find("navService");
    const pageReference =
        {
            type: 'standard__recordPage',
            "attributes": {
                "recordId": component.get('v.recordId'), // Pass the record Id
                "actionName": 'edit',
                "objectApiName":"Opportunity"
            }
        };
    navService.navigate(pageReference);
}
1
  • It works like a charm!!
    – Pavan tej
    Commented Nov 29, 2021 at 12:59

You must log in to answer this question.

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