Hey guys, today in this post we are going to learn about How to Navigate to Record Relantionship page in LWC – Lightning Web Component Salesforce.
Here are the steps to use the navigation service.
- Navigation service uses a PageReference.And a page reference is JavaScript that describes its page type, its attributes, and the state of the page.
- First, we need to import the lightning/navigation module.
- Use this Syntax:- Import {NavigationMixin} from ‘lightning/navigation;
Apply the NavigationMixin function to your component’s base Class.
Final Output →
Other related post that would you like to learn in Salesforce
Create HTML Page →
Step 1:- Create HTML Page : navigationPageLwc.html
navigationPageLwc.html [HTML PAGE]
<template>
<!-- Navigate to Record Relationship page-->
<lightning-card title="Navigate to Record Relantionship page">
<div class="slds-m-around_medium">
<TABLE class="slds-table slds-table_bordered slds-table_col-bordered">
<tr>
<td STYLE="width:50%;">Navigation TO Record Relationship Page</td>
<td STYLE="width:50%;">
<lightning-button variant="brand" label="Navigation to Record Relationship" onclick={actionToNavigateRecordRelantionship}></lightning-button>
</td>
</tr>
</table>
</div>
</lightning-card>
</template>
Create navigationPageLwc.js →
Step 2:- Create JavaScript Page : function.js
navigationPageLwc.js [JavaScript Page]
import { LightningElement, api } FROM 'lwc';
import {NavigationMixin} FROM 'lightning/navigation';
export DEFAULT class NavigationPageLwc extends NavigationMixin(LightningElement) {
// Navigate TO Record Relantionship page
actionToNavigateRecordRelantionship(){
this[NavigationMixin.Navigate]({
TYPE:'standard__recordRelationshipPage',
attributes:{
recordId:this.recordId,
objectApiName:'Account',
relationshipApiName:'Contacts',
actionName:'view'
}
});
}
}
Create Lightning Web Component Meta XML
Step 3:- Create Lightning Web Component : navigationPageLwc-meta.xml
SFDX:Lightning Web Component >> New >> navigationPageLwc-meta.xml
navigationPageLwc-meta.xml [LWC Meta Data XML]
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
Further post that would you like to learn in Salesforce
How do I automatically redirect a page?
To redirect from an HTML page, use the META Tag. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value of the content is the number of seconds; you want the page to redirect after.
How do I go from one web page to another?
The way through which a user can move from one web page to another on a website is via the use of hyperlinks. A hyperlink is an element of a html page which links to a external or internal location of the web page. A hyperlink can point towards either an external or an internal source.
How do I jump from one page to another in HTML using button?
The first way through which you can redirect from one page to another is by clicking a button. You can use a form for this purpose. The form tag in HTML has an attribute action where you can give the URL of the webpage where you want the form button to redirect. The form tag also has another attribute method.
Related Topics | You May Also Like
Our Free Courses →
👉 Get Free Course →
📌 Salesforce Administrators 📌 Salesforce Lightning Flow Builder 📌 Salesforce Record Trigger Flow Builder |
👉 Get Free Course →
📌 Aura Lightning Framework 📌 Lightning Web Component (LWC) 📌 Rest APIs Integration |