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
    Commented Aug 12, 2021 at 14:20
  • Nope, it pops up the standard edit form on the same page. @jbyrd Commented 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
    Commented Aug 12, 2021 at 15:37
  • 1
    correct @jbyrd, in case of view it navigates but in case edit it doesn't Commented Aug 12, 2021 at 15:41
  • 1
    @RahulGawale, thank you so much for sharing your knowledge! I got this to work on my LWC, and as a brand new developer with limited LWC knowledge, this saves me a ton of time! Thank you!! Commented Oct 18, 2023 at 15:28

You must log in to answer this question.

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