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.


<aura:attribute name="contact" type="Contact" default="{ 'sobjectType': 'Contact' ,
                    'First Name': '',
                    'LastName': '',
                                        }" />  
<aura:attribute name="acc" type="Account" default="{ 'sobjectType': 'Account' ,
                    '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}" />




 handlePassedAccAdd :  function(component, event, helper) {

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

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

    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);

  • Fill all fields values in an Object and set the same to the contact attribute; Jun 5, 2017 at 9:34
  • @itzmukeshy7 sorry i did not understand.
    – Hamza
    Jun 5, 2017 at 9:44
  • Try this var contactData = {field1: value1, ... fieldN: valueN}; and then finally do the assignment component.set("v.contact", contactData); Jun 5, 2017 at 9:46
  • still the values are not displaying on component.
    – Hamza
    Jun 5, 2017 at 10:16
  • First - use api names in the json object ("First Name" is not possible). Second, if accAdd is an account attribute - you cannot use component.get("v.accAdd.BillingStreet") - you should use component.get("v.accAdd")` and then use the field that you want - AccAddInfo2.BillingStreet. Then third - please share more code so we could understand your problem... Jun 6, 2017 at 4:50

1 Answer 1


Try this code for assign the values

      var con = {
                'sobjectType': 'Contact',
                'First Name': '',
                'LastName': '',

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .