Lightning/Aura components: aura attribute default sobjectType gives error for Standard Objects

sorry for almost duplicate – but I have not enough reputation yet to comment on: Lightning/Aura components: aura attribute default sobjectType gives error in managedpackage

I am having the same issue with Standard Objects:

<aura:component >
<aura:attribute name="acc" type="Account" default="{'sObjectType':'Account', 'Name':'Account123'}"/>
</aura:component>

Trying to save, I get

“Failed to save undefined: Unable to read SObject: Source”

To my understanding of the documentation, I do not need any namespace for Standard Objects. I tried all combinations nonetheless to no avail.

Tried several standard Objects as well. All produce the same error with exception of sObjectType Event. The following can be saved but does not work:

<aura:component >
<aura:attribute 
name="demo" 
type="Event" 
default="{'sObjectType':'Event', 
'Subject':'Account123', 
'WhoId':'00300000121aAAB'}"/>
{!v.demo.WhoId}
</aura:component>

Answer

You need to use sobjectType as the attribute of default object. Not sObjectType and not SObjectType. i.e.

<aura:attribute name="acc" type="Account" default="{'sobjectType':'Account', 'Name':'Account123'}"/>

Starting from Spring 15 Lightning Compomnents markup is case sensitive (Release Notes) therefore you get an error when referencing incorrect attribute.

Attribution
Source : Link , Question Author : Christian Szandor Knapp , Answer Author : sfdcfox

Leave a Comment