I packaged(managed) sample expense app provided by salesforce in lightning component tutorial. When I tried to access "expenseForm" component from the installation org I got following error

"Failed to save undefined: Unable to read SObject: Source"

Then I tried to get the root cause by packaging line by line and installing on an org. Found that following line of code is causing the error:

<aura:attribute name="newExpense" type="namespace__Expense__c"
             default="{ 'sobjectType': 'namespace__Expense__c',
                         'Name': '',
                         'namespace__Amount__c': 0,
                         'namespace__Client__c': '',
                         'namespace__Date__c': '',
                         'namespace__Reimbursed__c': false

Looks like the issue is with setting the sobject type. Not sure how to resolve this and why the problem is occurring.

  • Were you able to resolve the issue? I'm having the same issue here myself.
    – VarunC
    Commented Dec 9, 2015 at 15:10

3 Answers 3


Based on page 44 of the PDF, it looks like you should use type="yournamespace.Expense__c" instead of type="yournamespace__Expense__c". This does contradict page 16, but seems substantiated on page 26. I haven't had a chance to test it.

  • Developer Console is auto changing the namespace prefixing in Package Dev org from type="yournamespace.Expense__c" format to type="yournamespace__Expense__c" on Save. Try saving the Form and reopening the Lightning Component again, it reverts back to namespace__ format instead of namespace. format as mentioned in Documentation - namespace_using_reference
    – VarunC
    Commented Dec 9, 2015 at 15:14

Replace "namespace__" with the namespace defined in your org.

You can check or set your org namespace by using following steps:- Setup->AppSetup->Developer Setting->Namespace Prefix

Thanks, Vikas Khandelwal


Will you please clear what is that -namespace- it is the name of your lightning namespace if you have. I also do that lightning Pdf but doesn't get any error like that. Here is my code:

<aura:attribute name="newExpense" type="Lightning_Sales__Expense__c"
                default="{ 'sobjectType':'Lightning_Sales__Expense__c',
                         'Lightning_Sales__Amount__c': 0,
                         'Lightning_Sales__Date__c' : '',
                         'Lightning_Sales__Reimbursed__c' : false

please let me know if this help you.

  • "namespace" is namespace prefix of my managed packaged. I created this package by packaging the contents of app which we created using lightning pdf. Did you try creating the package and adding your component to an application in installation org?
    – RAr
    Commented Jun 26, 2015 at 9:12

You must log in to answer this question.

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