• Radha Krishna 67
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Tempate:

<template>
<lightning-card title="New Connection Registration" icon-name="standard:investment_account">
<div>
<lightning-input label="Consumer Name" name="consumerName" type="text" value={formfields.Consumer_Name__c} onchange={changehandle}></lightning-input>
<lightning-input label="Father Name" name="fatherName" type="text" value={formfields.Father_Name__c} onchange={changehandle}></lightning-input>
<lightning-input label="Mobile Number" name="Phone" type="number" value={formfields.Mobile_Number__c} onchange={changehandle}></lightning-input>
<lightning-input label="District" name="district" type="text" value={formfields.District__c} onchange={changehandle}></lightning-input>
<lightning-input label="Mandal" name="mandal" type="text" value={formfields.Mandal__c} onchange={changehandle}></lightning-input>
<lightning-input label="Pin Code" name="pincode" type="number" value={formfields.Pin_Code__c} onchange={changehandle}></lightning-input>
<lightning-input label="Purpose of Supply" name="purposeofsupply" type="text" value={formfields.Purpose_of_Supply__c} onchange={changehandle}></lightning-input>
<lightning-input label="Address" name="address" type="text" value={formfields.Address__c} onchange={changehandle}></lightning-input>
<lightning-input label="Aadhar Number" name="aadhar" type="number" value={formfields.Aadhar_Number__c} onchange={changehandle}></lightning-input>
<lightning-input label="Contract Load" name="contractload" type="number" value={formfields.Contract_Load__c} onchange={changehandle}></lightning-input>
<br/>
<lightning-button label="Submit" onclick={handleSubmit} variant="Destructive" ></lightning-button>
</div>
</lightning-card>
</template>

Controller:

import { LightningElement } from 'lwc';
import { createRecord } from 'lightning/uiRecordApi';
import NEW_CONNECTION_OBJECT from '@salesforce/schema/New_Connection__c';
import Consumer_Name_FIELD from '@salesforce/schema/New_Connection__c.Consumer_Name__c';
import Father_Name_FIELD from '@salesforce/schema/New_Connection__c.Father_Name__c';
import Mobile_Number_FIELD from '@salesforce/schema/New_Connection__c.Mobile_Number__c';
import District_FIELD from '@salesforce/schema/New_Connection__c.District__c';
import Mandal_FIELD from '@salesforce/schema/New_Connection__c.Mandal__c';
import Pin_Code_FIELD from '@salesforce/schema/New_Connection__c.Pin_Code__c';
import Purpose_of_Supply_FIELD from '@salesforce/schema/New_Connection__c.Purpose_of_Supply__c';
import Address_FIELD from '@salesforce/schema/New_Connection__c.Address__c';
import Aadhar_Number_FIELD from '@salesforce/schema/New_Connection__c.Aadhar_Number__c';
import Contract_Load_FIELD from '@salesforce/schema/New_Connection__c.Contract_Load__c';
export default class NewRegistration extends LightningElement {
    formFields={
        Consumer_Name__c:'',
        Father_Name__c:'',
        Mobile_Number__c:'',
        District__c:'',
        Mandal__c:'',
        Pin_Code__c:'',
        Purpose_of_Supply__c:'',
        Address__c:'',
        Aadhar_Number__c:'',
        Contract_Load__c:''
    }
    changehandle(event){
        const {value, name} = event.target
        this.formFields={...this.formFields,[name]:value}
    }
    handleSubmit(){
        const fields = {};
        fields[Consumer_Name_FIELD.fieldApiName]=this.formFields.Consumer_Name__c;
        fields[Father_Name_FIELD.fieldApiName]=this.formFields.Father_Name__c;
        fields[Mobile_Number_FIELD.fieldApiName]=this.formFields.Mobile_Number__c;
        fields[District_FIELD.fieldApiName]=this.formFields.District__c;
        fields[Mandal_FIELD.fieldApiName]=this.formFields.Mandal__c;
        fields[Pin_Code_FIELD.fieldApiName]=this.formFields.Pin_Code__c;
        fields[Purpose_of_Supply_FIELD.fieldApiName]=this.formFields.Purpose_of_Supply__c;
        fields[Address_FIELD.fieldApiName]=this.formFields.Address__c;
        fields[Aadhar_Number_FIELD.fieldApiName]=this.formFields.Aadhar_Number__c;
        fields[Contract_Load_FIELD.fieldApiName]=this.formFields.Contract_Load__c;
       
        let recordInput={apiName:NEW_CONNECTION_OBJECT.objectApiName, fields};
        createRecord(recordInput).then(result=>{
            this.formFields={}
            console.log('New Connection Created Successfully', JSON.stringify(result.id))
        }).catch(error=>{
            console.error(error)
        })
    }
}


Error during LWC component connect phase: [Cannot read properties of undefined (reading 'Consumer_Name__c')]. I am getting this Error, Could you please help me on this
Failed to save lightningDataServices.cmp: No INTERFACE named markup://flexipage:availableForAllpages foundNo INTERFACE named markup://flexipage:availableForAllpages found: Source