TransWikia.com

Value is not displaying in component. lightning

Salesforce Asked by Effat Naaz on December 6, 2021

Hi iam getting value from event and is being handled by handlePassedAccAdd method. I want to display value in {!v.contact.MailingCity}” which is getting alert, but it is not getting displayed in component. I don’t know where i am going wrong.

CMP

<aura:attribute name="contact" type="Contact" default="{ 'sobjectType': 'Contact' ,
                    'First Name': '',
                    'LastName': '',
                    'Phone':'',
                    'Email':'',
                    'MailingCountryCode':'US',
                    'MailingStreet':'',
                    'MailingCity':'',
                    'MailingStateCode':'',
                    'MailingPostalCode':''                                   
                                        }" />  
<aura:attribute name="acc" type="Account" default="{ 'sobjectType': 'Account' ,
                    'Name':'',                       
                    'Phone':'',
                    'Company_Email__c':'',
                    'BillingStreet':'',
                    'BillingCountryCode':'',
                    'BillingCity':'',
                    'BillingStateCode':'',
                    'BillingPostalCode':'' }" />

 <div class="slds-grid slds-grid slds-wrap slds-grid--pull-padded">

                    <div class="slds-large-size--2-of-5 slds-medium-size--5-of-12 slds-small-size--1-of-1" aura:id="dMCity">
                        <div class="slds-m-horizontal-large">
                            <div Style="margin-right:50px; margin-left:50px; margin-top:10px">
                                <label for="MCity">Mailing City</label>
                                <force:inputField aura:id="MCity" value="{!v.contact.MailingCity}" />

                            </div>
                        </div>

                    </div>

JS

 handlePassedAccAdd :  function(component, event, helper) {

    var accInfoAddr = event.getParam("acc");
    alert('^^^^^^^^^^acc^^^^^^^^^^' + JSON.stringify(accInfoAddr));

    var ContInfo = component.get("v.contact");

    component.get("v.acc"); 
    component.set("v.acc", accInfoAddr);

    var AccInfo1 = component.get("v.acc.BillingCity");
    // alert( component.get("v.acc.BillingCity"));
    ContInfo.BillingCity = component.get("v.acc.BillingCity");
    component.set("v.contact.MailingCity", ContInfo.BillingCity);

    var AccInfo2 = component.get("v.acc.BillingStreet");
    ContInfo.BillingStreet = component.get("v.acc.BillingStreet");
    component.set("v.contact.MailingStreet", ContInfo.BillingStreet);

    var AccInfo3 = component.get("v.acc.BillingCountryCode");
    ContInfo.BillingCountryCode = component.get("v.acc.BillingCountryCode");
    component.set("v.contact.MailingCountryCode", ContInfo.BillingCountryCode);

    var AccInfo4 = component.get("v.acc.BillingStateCode");
    ContInfo.BillingStateCode = component.get("v.acc.BillingStateCode");
    component.set("v.contact.MailingStateCode", ContInfo.BillingStateCode);

    var AccInfo5 = component.get("v.acc.BillingPostalCode");
    console.log('v.acc.BillingPostalCode' + component.get("v.acc.BillingPostalCode"));
    ContInfo.BillingPostalCode = component.get("v.acc.BillingPostalCode");
    component.set("v.contact.MailingPostalCode", ContInfo.BillingPostalCode);

  },

One Answer

Try this code for assign the values

      var con = {
                'sobjectType': 'Contact',
                'First Name': '',
                'LastName': '',
                'Phone':'',
                'Email':'',
                'MailingCountryCode':'US',
                'MailingStreet':acc.BillingStreet,
                'MailingCity':acc.BillingCity,
                'MailingStateCode':acc.BillingStateCode,
                'MailingPostalCode':acc.BillingPostalCode,
                }
                component.set("v.contact",con);

Answered by Swati Maheshwari on December 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP