I have 2 attributes, "account" and "newContact", I want to set the default value for Account.Name for "newContact" as the value of "account" attribute, i.e. whatever will be the value of account attribute that must be assigned to Account.Name in "newContact" attribute. Can someone please help !

<aura:attribute name="account" type="String" />
<aura:attribute name="newContact" type="Contact" 
                default="{'sObjectType':'Contact', 'FirstName':'', 
                           'LastName':'', 'Account.Name':'', 

Thanks in advance !!

  • 1
    what you have write so far? Please Share it.
    – am_Aravi
    Jan 8, 2018 at 8:59
  • In your component component and helper you can perform get or set any attribute. Where exactly are you stuck?
    – Raul
    Jan 8, 2018 at 9:14
  • My parent component is setting the value for "account" attribute and on the basis of this value I want to set AccountName for my "newContact" attribute. I am not able to use "{!v.account}" inside default. Jan 8, 2018 at 9:23
  • Here the type should be sobjectType not sObjectType it's case sensitive; Jan 8, 2018 at 10:35

1 Answer 1


The Mistake you made in the Attribute Decleration of "newContact" attribute.You cannot set the the default value of Contact of Account.Name directly as a String.You should set the Account of Contact as an Object and then you can set the "account" attribute value for "newContact" like this.


<aura:attribute name="account" type="string" default="abc"/>
<aura:attribute name="newContact" type="Contact" 
            default="{'sObjectType':'Contact', 'FirstName':'', 
                       'LastName':'', 'Account':{Id:'',Name:''}, 

<aura:handler name="init" value="{!this}" action="{!c.init}"/> 


    init: function(component,event,helper){

        var contact = component.get('v.newContact');
        contact.Account.Name = component.get('v.account');
        component.set('v.contact', contact);

You must log in to answer this question.

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