Navigate a user to a record page in edit mode in LWC
In case you are interested in navigating an user to the standard edit form on click of a button (not using quick actions) then we can use NavigationMixin
In a way, this is similar to e.force:editRecord
in Aura
Here is the snippet!
- We are importing
NavigationMixin
fromlightning/navigation
- We are providing a config object to
this[NavigationMixin.Navigate]
- The config object is going to have information about the destination. The key is providing
edit
for the keyactionName
import { LightningElement } from "lwc";
import { NavigationMixin } from "lightning/navigation";
export default class ExploreNavigation extends NavigationMixin(
LightningElement
) {
handleNavigate() {
const config = {
type: "standard__recordPage",
attributes: {
recordId: "00QXXXXXXXXXXlEAJ",
objectApiName: "Lead",
actionName: "edit"
}
};
this[NavigationMixin.Navigate](config);
}
}
Hope this helps!