+ Start a Discussion
Junnu NJunnu N 
Validation rule for When a Case record type of Service Sales is created or updated and the End Customer field beginning with SEE_ or end customer = xyz or the End Customer (lookup) field is not populated. Note: End customer is a lookup field.
Best Answer chosen by Junnu N
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Bhargav,

Can you try the below validation rule.
 
AND( RecordType.Name ='service' , OR ( ISBLANK( End_Customer__c ), End_Customer__r.Name ='xyz' , LEFT( End_Customer__r.Name ,4)='SSE_' ))

Replace the API name and record type API names in the above validation rule.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
DiamundoDiamundo 
Hi there.

In my lightning app I have a few components:
  • one component has a ui:inputSelect and registers an event. the ui:inputSelect has a change attribute that fires a function, wherein the selected text (an ID) is put in an event and fired.
  • one component that handles the event, is an aura:iteration list of a component that, on handling the event, should retrieve a list of items where a master-child lookup is the sent ID of the master object. This then displays all those child objects.
  • the other component that handles the event, has three inputText fields, that are supposed to display the other fields of the master object
The problem: either the event seems to not be fired, or the handlers seem to not be activated.

I put console.debug's, alerts and component.set("v.testmessage", "fired") 's in the handlers but they never execute.
I then put one of the handlers as the init-handler and then it did execute the handler (with an undefined ID since the event hadn't yet been fired, which is reasonable).

I have triple-checked the event name, event type and handler action, everything matches. I have no compilation problems, I have no errors when I am using my app. 
I also have no response whatsoever from my event. Any ideas?

**Registering component**
<aura:component controller="PrefixMasterHeaderSelectorController">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:registerEvent name="updateMaster" type="c:PrefixMasterEvent" />
    <aura:attribute name="masters" type="PrefixMaster__c[]"/>
      
    <label class="slds-master-element__label" for="masterSelector">Select a master to work with:</label>
    <div class="slds-master-element__control">
        <div class="slds-select_container">
            
            <ui:inputSelect aura:id="masterID" class="slds-select" change="{!c.masterHasChanged}">
                <aura:iteration items="{!v.masters}" var="master">
                    <ui:inputSelectOption text="{!master.Id}" label="{!master.Name}" />
                    <!-- + ' (Last modified: ' + master.LastModifiedDate + ' by ' + master.LastModifiedBy.Name + ')'}"/> -->
                </aura:iteration>	
                <ui:inputSelectOption text="newMaster" label="Create a new master" />
            </ui:inputSelect>
            
        </div>
    </div>

    <c:PrefixMasterHeaderMaster />
</aura:component>

**Registering controller**
({
    doInit : function(component, event, helper) {
        // Create the action
        var action = component.get("c.getMasters");
    
        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.masters", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
    
        // Send action off to be executed
        $A.enqueueAction(action);
    },
    
    masterHasChanged : function(component, event, helper) {
        var masterID = component.find("masterID").get("v.value");
        var masterEvent = component.getEvent("updateMaster");
        masterEvent.setParams({"master" : masterID})
        masterEvent.fire();
        
		console.debug('UPDATE MASTER = ' + masterID);
        alert('Hiya! masterEvent ' + masterEvent.getParam("master"));
    }
		
})

**List-child component**
<aura:component controller="PrefixListChildsController">
	<aura:handler name="updateForm" event="c:PrefixFormEvent" action="{!c.loadChilds}" />
    <aura:attribute name="childs" type="PrefixChild__c[]"/>
    
	<!--   	<aura:handler name="saveChild" event="c:PrefixChildEvent" action="{!c.handleAddItem}"/> -->
    <!--	to reload the masters after adding a new child -->
    
    <div>
        <header class="slds-p-top--small">
            <h3 class="slds-text-heading--small">Childs</h3>
        </header>
        
        <div id="list" class="row">
            <aura:iteration items="{!v.childs}" var="child">
                <aura:if isTrue="{!child.Order__c % 2 == 1}">
                        <div class="slds-p-around--small" style="background-color: lightblue; border-radius: 10px">
                            <c:PrefixChild child="{!child}"/>
                        </div>
                    <aura:set attribute="else" >
                        <div class="slds-p-around--small" style="background-color: none; border-radius: 10px">
                            <c:PrefixChild child="{!child}"/>
                        </div>
                    </aura:set>
                </aura:if>
            </aura:iteration>
            {!v.testEventmessage}
            <c:PrefixNewChild />
        </div>
    </div>

</aura:component>

**List-child controller.js**
({
	loadChilds : function(component, event, helper) {
 	    var action = component.get("c.getChilds");
		var masterID = event.getParam("master");    
    	action.setParams({ "masterID" : masterID });
        
        console.debug('master id = ' + masterID);
        alert('load childs ' + masterID);
        component.set("v.testEventmessage", masterID);

        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.childs", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        
        // Send action off to be executed
        $A.enqueueAction(action);
    }
})


 
Best Answer chosen by Diamundo
DiamundoDiamundo
Solved it...

After I found out that the firing component was able to handle the (component) event, but a component somewhere else (not a parent or child component, but, say, an uncle-component) was not, I changed the type of the event to application. Still didn't work, so I looked up the documentation and saw that an application-type event is registered slightly different.

**APPLICATION-TYPE EVENT:**
<aura:event type="APPLICATION" >
    <aura:attribute name="item" type="sObject__c" />
</aura:event>
**REGISTERING COMPONENT**
<aura:registerEvent name="PrefixMasterEvent" type="c:PrefixMasterEvent" />

**FIRING CONTROLLER**
var applicationEvent = $A.get("e.c:PrefixMasterEvent");
    applicationEvent.setParams({"item" : itemID})
    applicationEvent.fire();
(Note: instead of component.getEvent("eventName") you now use $A.get("e.c:EventName") !
I'm not sure what the 'e' stands for, but I'm pretty sure the 'c' part is the namespace, and be careful to put the name of the event FILE as 'EventName' in the $A.get() parameter.)

**HANDLING COMPONENT**
<aura:handler event="c:PrefixApplicationEvent" action="{!c.doAnotherFunction}" />
(Note: the main difference is: with an application event there is no need (or use) for an event 'name', and I'm not sure why it has to be specified at the registerEvent tag other than it's a required attribute of the tag.)

**HANDLING CONTROLLER**
({
    doAnotherFunction(component, event, helper) {
        var item = event.getParam("item");
        alert('The item is: ' + item);
    }
})




 
LinThawLinThaw 
Hi there,
I want to use showToast and
show message with multiple lines.
I tried as follow but \n is not working well.
({
    fireToastEvent : function(component, event, helper) {
        var toastEvent = $A.get("e.force:showToast");    
        toastEvent.setParams({
            "title": "Title",
            "message": "This is line 1. \n This is line 2. \n This is line 3.",
            "type": "success"
        });
        toastEvent.fire();
    }
})
is there any idea?

Regards,
LinThaw
 
Best Answer chosen by LinThaw
Meenal Sankhla 12Meenal Sankhla 12 
calci.js file is:

import { LightningElement  ,track} from 'lwc';
export default class Calculator extends LightningElement {}
-----------------------------------------------------------------------------------------
calci.html file is 
<template>
<ligtning-card title="Calci" icon-name="standard:formula">
<ligtning-layout multiple-rows>
<lightning-layout-item size="12"  padding="around-medium">
<lightning-input type="number" name="FirstNumber"></lightning-input>
</lightning-layout-item>
<lightning-layout-item size="12"  padding="around-medium">
    <lightning-input type="number" name="SecondNumber"> </lightning-input>
        </lightning-layout-item>
        <lightning-layout-item size="12" padding="around-medium"> 
<lightning-button-group>
<lightning-button label="Add" icon-name="utility:add" icon:position="right"></lightning-button> 
<lightning-button label="Subtract" icon-name="utlity:dash"  icon:position="right"></lightning-button>
<lightning-button label="Multiply" icon-name="utlity:close" icon:position="right"></lightning-button>
<lightning-button label="Divide" icon-name="utlity:magicwand" icon:position="right"></lightning-button>
</lightning-button-group>
</lightning-layout-item>
<lightning-layout-item size="12"  padding="around-medium">
    <lightning-formated-text value={}></lightning-formated-text>
</lightning-layout-item>
</ligtning-layout>
</ligtning-card>
</template>
--------------------------------------------------------------------------
calci.js-meta.xml file is 
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="calci">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <description> Simple calculator app build with LWC</description>
    <targets>
    <target> lightning__AppPage  </target>
    <target> lightning__HomePage</target>
    <target> lightning_RecordPage</target>
    </targets>
</LightningComponentBundle>
Best Answer chosen by Meenal Sankhla 12
Sachin HoodaSachin Hooda
Hi Meenal,
It's because the last two closing tags are misspelled in your HTML file.
Please update your HTML file,
<template>
<lightning-card title="Calci" icon-name="standard:formula">
<lightning-layout multiple-rows>
<lightning-layout-item size="12"  padding="around-medium">
<lightning-input type="number" name="FirstNumber"></lightning-input>
</lightning-layout-item>
<lightning-layout-item size="12"  padding="around-medium">
    <lightning-input type="number" name="SecondNumber"> </lightning-input>
        </lightning-layout-item>
        <lightning-layout-item size="12" padding="around-medium"> 
<lightning-button-group>
<lightning-button label="Add" icon-name="utility:add" icon:position="right"></lightning-button> 
<lightning-button label="Subtract" icon-name="utlity:dash"  icon:position="right"></lightning-button>
<lightning-button label="Multiply" icon-name="utlity:close" icon:position="right"></lightning-button>
<lightning-button label="Divide" icon-name="utlity:magicwand" icon:position="right"></lightning-button>
</lightning-button-group>
</lightning-layout-item>
<lightning-layout-item size="12"  padding="around-medium">
    <lightning-formated-text value={}></lightning-formated-text>
</lightning-layout-item>
</lightning-layout>
</lightning-card>
</template>
This should fix the issue.
 
Best Answer chosen by Sindhuja Sundarasudhan
PriyaPriya (Salesforce Developers) 
Hi sindhuja,

Please follow below

Create a report with Report type as "Users with Volunteer Shift Worker Records".
 
Your report must include the below columns:
 
Volunteer Organisation
 
Shift Hours (Note - This displays the records with SUM by default)
 
Step 1: Group by rows in 'Volunteer Organisation'
 
Step 2: Click on the arrow besides 'Volunteer Organisation' and select Sort by "Sum of Shift Hours" (This will display data as per sum of shift hours in ascending order)
 
Step 3: Click on the arrow besides 'Volunteer Organisation and select "Sort Descending" option.
 
P.S Ensure details, row counts and sub totals are off.
 
Hope this helps! 

Kindly mark it as the best answer if it helps.

Regards,
Ranjan
Ryan MeyerRyan Meyer 

Beating my head against the wall and hoping someone can point out what I'm missing. I have a basic Lightning component with a drop-down. When that drop-down changes, I'd like the controller to make a second field visible through an aura if. But I can't even get the selection onchange to trigger. 

 

Component is basically:

<aura:attribute name="rType" type="string"/>  
<lightning:select name="rType" label="Record Type" value="{!v.rType}" required="true" onchange="{!c.syncSelection}">

With controller:

syncSelection: function (component, event, helper) {
        console.log("this worked");

 

Best Answer chosen by Ryan Meyer
Naveen KNNaveen KN
I have tried to set options for the dropdown (hardcoded values) as you haven't shared the complete code. I am able to get the onchange alert
<aura:component implements="flexipage:availableForAllPageTypes" access="global">
    <aura:attribute name="rType" type="string" default="a,b"/>  
    <lightning:select name="rType" label="Record Type" value="{!v.rType}" required="true" onchange="{!c.syncSelection}">
        <option value="A" >A</option>
        <option value="A" >B</option>
    </lightning:select>
</aura:component>

controller code
syncSelection: function (component, event, helper) {
        alert("this worked");
    }

if you are still getting the issue, please share complete .cmp and controller code related to the dropdown
Durgesh VyasDurgesh Vyas 
I want to disable personalize nav bar options for users.
Best Answer chosen by Durgesh Vyas
Dinesh GopalakrishnanDinesh Gopalakrishnan
Hi Durgesh,

Please check the Below Options or check the Doc from the Below Link
  • If you don’t want your users to personalize the navigation bar for a specific app, disable personalization. From Setup in Lightning Experience, go to the App Manager. For the desired app, select App Options. Select Disable end user personalization of nav items in this app.
  • If you don’t want your users to personalize the navigation bar for any app, disable personalization. From Setup, enter User Interface in the Quick Find box, then select User Interface. Select Disable Navigation Bar Personalization in Lightning Experience. Salesforce recommends disabling navigation personalization by app instead of for the entire org.
https://help.salesforce.com/articleView?id=user_userdisplay_tabs_lex_considerations.htm&type=5

Kindly Mark this as a Best Answer if you Find this Useful!

Thanks
DineshKumar Gopalakrishnan
Saroj KushwahaSaroj Kushwaha 
Hi,
the challenge is as follows :

Create a camping component that contains a campingHeader and a campingList component.
1.The campingList component contains an ordered list of camping supplies that include Bug Spray, Bear Repellant, and Goat Food.
2.The campingHeader component contains an H1 heading style with a font size of 18 points and displays 'Camping List'.

so i made a lightening application named "camping.app" having code :

<aura:application >
    <br/><br/><br/>
    <c:campingHeader/>
    <c:campingList/>  
</aura:application>


where lightening component "campingHeader.cmp" having code :

<aura:component >
    <h1> Camping List </h1>
</aura:component>

for I have "campingHeader.css" having code :
.THIS {
}

h1.THIS {
    font-size: 18px;
}

and lightening component "campingList.cmp" having code :

<aura:component >
    <ol>
       <li>Bug Spray</li>
       <li>Bear Repellant</li>
       <li>Goat Food</li>      
    </ol>
</aura:component>

when i preview the application it is working nice; but when checking the challenge it says :
"Challenge Not yet complete... here's what's wrong: 
The 'camping' Lightning Component does not include either the campingHeader or campingList component."

please help me know where I m doing wrong. Thanx waiting for your reply
Best Answer chosen by Saroj Kushwaha
Nayana KNayana K
Instead of camping.app, create camping.component :
<aura:component >
    <br/><br/><br/>
    <c:campingHeader/>
    <c:campingList/>  
</aura:component>
Stephanie Wong 51Stephanie Wong 51 
Hi everyone,

I recently hid a custom button from Lightning and enabled it back again in the page layouts. But it does not show in Lightning, but works fine in Classic. What should I do it make it visible again?
User-added image
Best Answer chosen by Stephanie Wong 51
Stephanie Wong 51Stephanie Wong 51
Hi Abhishek,

Thanks for looking into this for me. I checked all the links you sent and that really did not solve the problem. I did find the solution though. It slipped my mind that for Lightning you would add it in the "Salesforce Mobile and Lightning Experience Actions" and for Classic it is in "Custom Buttons".


User-added image
The new LearnerThe new Learner 
HI Experts,

My below code is working fine, however, while creating a new child record, parentid is not populating automatically, again I am selecting to add that child record to parent, can anyone help me out. For example, in the account record related list if we create contact record automatically that specific accountid(name) will come on the record detail page of contact. Same functionality I need in my below component. can anyone help me out?
 
TEmpate:

<template>
<lightning-card title={titleWithCount} icon-name="standard:record">
    <lightning-button label="New" slot="actions" onclick={createNew}></lightning-button>
    <div slot="footer">
        <div  if:true={countBool}>
            <lightning-button label="View All" onclick={navigateToRelatedList}></lightning-button>
        </div>
    </div> 
    <div class="slds-m-around_medium">   
        <div if:true={listRecords}>   
            <template for:each={listRecords} for:item="rec">    
                <div key={rec.Id} class="slds-box">                         
                    <lightning-record-view-form record-id={rec.id} object-api-name={objectName}>
                        <div class="slds-grid">
                            <div class="slds-col slds-size_1-of-2">
                                <lightning-output-field field-name={field1}></lightning-output-field>
                                <lightning-output-field field-name={field2}></lightning-output-field>
                            </div>
                            <div class="slds-col slds-size_1-of-2">
                                <lightning-output-field field-name={field3}></lightning-output-field>
                                <lightning-output-field field-name={field4}></lightning-output-field>
                            </div>
                        </div>
                    </lightning-record-view-form><br/><br/>
                </div>                       
            </template>   
        </div>   
    </div>   
</lightning-card>       
</template>


JS:

import { LightningElement, api, wire, track } from 'lwc'; 
import fetchRecords from '@salesforce/apex/RelatedListController.fetchRecords'; 
import { NavigationMixin } from 'lightning/navigation';
 
export default class RelatedList extends NavigationMixin( LightningElement ) { 
 
    @api objectName; 
    @api parentObjectName;
    @api fieldName; 
    @api fieldValue; 
    @api parentFieldAPIName; 
    @api recordId; 
    @api strTitle; 
    @api filterType; 
    @api operator; 
    @api fieldsList;
    @api relationshipApiName;
    @track field1;
    @track field2;
    @track field3;
    @track field4;
    @track listRecords;
    @track titleWithCount;
    @track countBool = false;
    //@api recordid;

    connectedCallback() {

        var listFields = this.fieldsList.split( ',' );
        console.log( 'Fields are ' + listFields );
        this.field1 = listFields[ 0 ].trim();
        this.field2 = listFields[ 1 ].trim();
        this.field3 = listFields[ 2 ].trim();
        this.field4 = listFields[ 3 ].trim();
        console.log( 'Field 1 is ' + this.field1 );
        console.log( 'Field 2 is ' + this.field2 );
        console.log( 'Field 3 is ' + this.field3 );
        console.log( 'Field 4 is ' + this.field4 );

    }

    get vals() { 

        return this.recordId + '-' + this.objectName + '-' +  
               this.parentFieldAPIName + '-' + this.fieldName + '-' +  
               this.fieldValue + '-' + this.filterType + '-' + this.operator + '-' + this.fieldsList; 

    } 
     
    @wire(fetchRecords, { listValues: '$vals' }) 
    accountData( { error, data } ) {

        if ( data ) {
          
            this.listRecords = data.listRecords;
            console.log(JSON.stringify(this.listRecords));
            if ( data.recordCount ) {
               
                if ( data.recordCount > 3 ) {

                    this.titleWithCount = this.strTitle + '(3+)';
                    this.countBool = true;
               
                } else {

                    this.countBool = false;
                    this.titleWithCount = this.strTitle + '(' + data.recordCount + ')';

                }
            }

        }

    }

    createNew() {

        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: this.objectName,
                actionName: 'new'
            }
        });

    }

    navigateToRelatedList() {
       
        this[NavigationMixin.Navigate]({
            type: 'standard__recordRelationshipPage',
            attributes: {
                recordId: this.recordId,
                objectApiName: this.parentObjectName,
                relationshipApiName: this.relationshipApiName,
                actionName: 'view'
            }
        });

    }
 
}

Meta:

<?xml version="1.0" encoding="UTF-8"?> 
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="RelatedList"> 
    <apiVersion>52.0</apiVersion> 
    <isExposed>true</isExposed> 
    <targets> 
        <target>lightning__RecordPage</target> 
    </targets> 
    <targetConfigs> 
        <targetConfig targets="lightning__RecordPage"> 
            <property name="strTitle" type="String" label="Title" description="Enter the title"/> 
            <property name="objectName" type="String" label="Object Name" description="Enter the object name"/> 
            <property name="parentObjectName" type="String" label="Parent Object Name" description="Enter the parent object name"/> 
            <property name="relationshipApiName" type="String" label="Relationship Name" description="Enter the relationship API name"/> 
            <property name="parentFieldAPIName" type="String" label="Parent Field API Name" description="Enter the parent field API Name"/> 
            <property name="fieldName" type="String" label="Field Name" description="Enter the field name"/> 
            <property name="fieldValue" type="String" label="Field Value" description="Enter the field value"/> 
            <property name="filterType" type="String" label="Filter Type" description="Enter the filter type"/> 
            <property name="operator" type="String" label="Operator" description="Enter the operator"/> 
            <property name="fieldsList" type="String" label="Fields List" description="Enter the field API names separated by coma. Do not enter more than 4 fields"/> 
        </targetConfig> 
    </targetConfigs> 
</LightningComponentBundle>

 
Best Answer chosen by The new Learner
Maharajan CMaharajan C
Hi,

1. Add the the below import file in JS:

import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';

2.  You have to set the defaultfield values in state property like below:

for example i have consider the Account ==> Opportunity scenario.
 
createNew() {

	const defaultValues = encodeDefaultFieldValues({
		AccountId: this.recordId
	});

	this[NavigationMixin.Navigate]({
		type: 'standard__objectPage',
		attributes: {
			objectApiName: this.objectName,
			actionName: 'new'
		},
		state: {
			defaultFieldValues: defaultValues
		}
	});

}


When i am reading your it's looks like as generic code . So you have to set the parent Id dynamically in defaultFieldValues. Please follow the below code:


Update your JS File:

1. You need to harcode the Parent Field API Name in below property from Appbuilder then only parent lookup will be populated. For Example AccountId is the Parent Fiedl API Name for Case,Opportunity,Contact Objects.


<property name="parentFieldAPIName" type="String" label="Parent Field API Name" description="Enter the parent field API Name"/>
 
import { LightningElement, api, wire, track } from 'lwc'; 
import fetchRecords from '@salesforce/apex/RelatedListController.fetchRecords'; 
import { NavigationMixin } from 'lightning/navigation';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
 
export default class genericRelatedListComp extends NavigationMixin( LightningElement ) { 
 
    @api objectName; 
    @api parentObjectName;
    @api fieldName; 
    @api fieldValue; 
    @api parentFieldAPIName; 
    @api recordId; 
    @api strTitle; 
    @api filterType; 
    @api operator; 
    @api fieldsList;
    @api relationshipApiName;
    @track field1;
    @track field2;
    @track field3;
    @track field4;
    @track listRecords;
    @track titleWithCount;
    @track countBool = false;

    connectedCallback() {

        var listFields = this.fieldsList.split( ',' );
        console.log( 'Fields are ' + listFields );
        this.field1 = listFields[ 0 ].trim();
        this.field2 = listFields[ 1 ].trim();
        this.field3 = listFields[ 2 ].trim();
        this.field4 = listFields[ 3 ].trim();
        console.log( 'Field 1 is ' + this.field1 );
        console.log( 'Field 2 is ' + this.field2 );
        console.log( 'Field 3 is ' + this.field3 );
        console.log( 'Field 4 is ' + this.field4 );

    }

    get vals() { 

        return this.recordId + '-' + this.objectName + '-' +  
               this.parentFieldAPIName + '-' + this.fieldName + '-' +  
               this.fieldValue + '-' + this.filterType + '-' + this.operator + '-' + this.fieldsList; 

    } 
     
    @wire(fetchRecords, { listValues: '$vals' }) 
    accountData( { error, data } ) {

        if ( data ) {
          
            this.listRecords = data.listRecords;

            if ( data.recordCount ) {
               
                if ( data.recordCount > 3 ) {

                    this.titleWithCount = this.strTitle + '(3+)';
                    this.countBool = true;
               
                } else {

                    this.countBool = false;
                    this.titleWithCount = this.strTitle + '(' + data.recordCount + ')';

                }
            }

        }

    }

    createNew() {

        const key = this.parentFieldAPIName;
        console.log(' Parent Id --> ' + key);
        const defaultValues = encodeDefaultFieldValues({
            [key]  : this.recordId
        });
        console.log('defaultValues New --> ' + defaultValues );

        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: this.objectName,
                actionName: 'new'
            },
            state: {
                defaultFieldValues :  defaultValues
            }
        });

    }

    navigateToRelatedList() {

        this[NavigationMixin.Navigate]({
            type: 'standard__recordRelationshipPage',
            attributes: {
                recordId: this.recordId,
                objectApiName: this.parentObjectName,
                relationshipApiName: this.relationshipApiName,
                actionName: 'view'
            }
        });

    }
 
}

Set the Parent Field API Name in App builder.

User-added image


Thanks,
Maharajan.C