• Naveen Sana
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
I want to insert all the input field values of a template into custom fields of an object in LWC. Could anyone please give me a solution. Below is the code which I have written so far. But I come up with this error(insert failed. First exception on row 0; first error: INVALID_TYPE_ON_FIELD_IN_RECORD, First_Name: value not of required type: {fieldApiName=First_Name__c, objectApiName=Registration__c}: [First_Name__c])
 
    HTML:
    <lightning-input type="text" name="txtFname" label="Enter First Name" onchange={handleChange} value={regRecord.fName}></lightning-input>
      <lightning-button variant="success" label="Submit" title="Submit" onclick={saveRecord} class="slds-m-left_x-small"></lightning-button>
    
    Javascript:
    
    import FirstName_FIELD from '@salesforce/schema/Registration__c.First_Name__c';
    import saveRegRecord from '@salesforce/apex/regClass.createRecord';
    
    @track regRecord = {
            fName : FirstName_FIELD
        };
    
        handleChange(event) {
            const field = event.target.name;
            if (field === 'txtFname') {
                console.log(event.target.value);
                this.regRecord.fName = event.target.value;            
            } 
        }
    
        saveRecord(event)
        {   
            saveRegRecord({reg : this.regRecord})
            .then(result => {
                // Clear the user enter values
                console.log(this.regRecord)
                this.conrec = {};            
                window.console.log('result ===> '+result);
                alert('record inserted');
            })
            .catch(error => {
                this.error = error.message;
                console.log('error==>'+this.error);
                alert('record not inserted');
            });
        }

    Apex:
    @AuraEnabled
        public static void createRecord (Registration__c reg){  
                if(reg != null){
                    insert reg;
            } 
        }

 

I have changed the domain name of my Trailhead playground now I am unable to open my Playground. Please help me with this. I have learnt many things over there.

While opening my playground it is showing 404 Error !!!

Please help me!!!

Hi, 

How can we achieve the region details of the logged-in user by using apex?
I have a wrapper class and we are deserializing the JSON data, and now we have to send that wrapper class to another method which is in another class.

 1. Q1)How we have to send it as a parameter? 
 2. Q2)How to access it in another class?

This is what our approach till now.
 
JSONWrapper mapRequest1 = (JSONWrapper) JSON.deserialize(request.requestBody.toString(),JSONWrapper.class);

 - JSONWrapper --- Name of the Wrapper class

 - request --- Contains Json data
   
 - mapRequest1 --- Contains Deserialized data
 

I have changed the domain name of my Trailhead playground now I am unable to open my Playground. Please help me with this. I have learnt many things over there.

While opening my playground it is showing 404 Error !!!

Please help me!!!

Hi, 

How can we achieve the region details of the logged-in user by using apex?