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':'',
'Birthdate':''}"/>
Thanks in advance !!
Best Answer
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.
Component:
Controller: