Development questions
How do you navigate to a record page or another page from an LWC?
DevelopmentEasy
Use NavigationMixin from lightning/navigation:
javascript
import { NavigationMixin } from 'lightning/navigation';
export default class Nav extends NavigationMixin(LightningElement) {
goToRecord() {
this[NavigationMixin.Navigate]({
type: 'standard__recordPage',
attributes: { recordId: this.recordId, actionName: 'view' }
});
}
}
Common type values: standard__recordPage, standard__objectPage, standard__webPage, standard__navItemPage, comm__namedPage (Experience Cloud). Use GenerateUrl to get a URL instead of navigating.
lwcnavigation
More Development questions
- What is an Apex Trigger in Salesforce and when should you use it over Flows?
- What is the difference between before triggers and after triggers?
- Explain all Trigger context variables (isInsert, isUpdate, isDelete, isUndelete, isBefore, isAfter, isExecuting, size, operationType).
- What is the difference between Trigger.new and Trigger.old?
- In which trigger events are Trigger.new and Trigger.newMap available?
- In which trigger events are Trigger.old and Trigger.oldMap available?