The modal that I want to pop-up can be seen, for instance, by clicking Edit in the dropdown menu in the related list of Opportunities for an Account.

To do this in Aura, Salesforce gives this description, which involves firing a force:editRecord event. But I am not programming in Aura, I am doing 100% LWC.

So I tried to emulate it in LWC like this:

const selectedEvent = new CustomEvent('force:editRecord', { recordId: selectedItemValue });

But that doesn't do anything.

So: how to pop-up that standard Edit-record modal? It doesn't have to involve events, in fact I'd prefer a method without them. It just seems a bit complicated.

1 Answer 1


You need to use lightning navigation service.

  1. Import the navigation in lwc.

import { NavigationMixin } from "lightning/navigation";

  1. Extend the NavigationMixin class in your lwc component.

export default class YourComponent extends NavigationMixin(LightningElement) {

  1. Use the below code to open the edit page.
    type: 'standard__recordPage',
    attributes: {
        recordId: recordId, // pass the record id here.
        actionName: 'edit',


  • But the question was asking about popping this page up in a modal - this just navigates to a new page, doesn't it?
    – jbyrd
    Aug 12, 2021 at 14:20
  • Nope, it pops up the standard edit form on the same page. @jbyrd Aug 12, 2021 at 14:38
  • Ohhh - is that b/c of the actionName: 'edit'? If we had set that to view, it would then navigate to a new page?
    – jbyrd
    Aug 12, 2021 at 15:37
  • 1
    correct @jbyrd, in case of view it navigates but in case edit it doesn't Aug 12, 2021 at 15:41
  • So then is there a way to get the view into a modal without navigating?
    – jbyrd
    Aug 12, 2021 at 15:48

You must log in to answer this question.

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