How to navigate to a page in LWC after button click/record creation
bhanukarkra
Posted on June 28, 2022
use navigation mixing
1)Add library
import { NavigationMixin } from 'lightning/navigation';
2)add navigation mixing in default class
export default class ObservationCreationPage extends NavigationMixin(LightningElement) {
3)add navigation mixing in function
handleSuccess(event) {
this.loaded = true;
this.closeQuickAction()
Successfully!! ${event.detail.id}`, "success")
console.log("handle Success",JSON.stringify(event.detail))
this.showToast("Success!!", `Observation Created Successfully!! Obs No.: ${event.detail.fields.Name.value}`, "success")
this[NavigationMixin.Navigate]({
type: 'standard__recordPage',
attributes: {
recordId: event.detail.id,
actionName: 'view'
}
});
}
💖 💪 🙅 🚩
bhanukarkra
Posted on June 28, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.