0

I am getting the above error with this component, which is used as an action override on the Account object:

<aura:component implements="lightning:actionOverride,force:hasRecordId,flexipage:availableForRecordHome" access="global" >  
    <aura:attribute name="account" type="Account" default="{ SObjectType: 'Account' }"/>
    <force:inputField value="{!v.account.Business_Name__c}"/>
</aura:component>

The full error message is:

aura://ComponentController: org.auraframework.throwable.AuraExecutionException: ui.force.components.controllers.field.InputFieldProvider: org.auraframework.throwable.AuraRuntimeException: Error Retrieving Field for: v.account.Business_Name__c

What am I doing wrong here?!

Mossi2
  • 469
  • 9
  • 21
  • Provide an Id for the default value or associate an account record by queryibg in apex controller. You have set sobjecttype amd input field needs a record reference – Rao Jul 19 '17 at 00:13
  • @Rao This is supposed to be an input form for a new Account record. I just followed several online suggestions, including this SFSE post: https://salesforce.stackexchange.com/questions/64580/lightning-how-to-use-forceinputfield – Mossi2 Jul 19 '17 at 00:31
  • 1
    I am guessing it is because of the default= SobjectType, lightning is case sensitive, make it default="{ sobjectType: 'Account' }"/> and see if the error resolves – Rao Jul 19 '17 at 00:38
  • @Rao Tried it and didn't work :( Also tried putting sobjectType in quotes, just to be safe, and same thing. – Mossi2 Jul 19 '17 at 00:44
  • is Business_Name__c a lookup/multiselect field? – Rao Jul 19 '17 at 01:06
  • 1
    @Rao Hey! It was the case-sensitivity of sobjectType!! It seems my browser didn't get the updated code when I refreshed it yesterday (not sure why Chrome takes a while to clear its cache -Edge doesn't have this problem..). I created a fresh new component containing Eric's code and it worked. – Mossi2 Jul 19 '17 at 17:32
  • Mischief managed :D!!! Phew – Rao Jul 19 '17 at 17:34
  • I thought for a sec, I found the solution. I am getting same error message for Campaign__c field. It is lookup to standard campaign object.

    Here is the component code

    <aura:component controller="MyController" implements="force:lightningQuickAction,force:hasRecordId" > <aura:attribute name="cmp" type="Custom_Object__c" default="{ 'sobjectType': 'Custom_Object__c' }"/> <aura:handler value="{!v.cmp.Campaign__c}" name="change" action="{!c.getChildRecords}"/> <force:inputField aura:id="campaignName" value="{!v.cmp.Campaign__c}" required="true"/></aura:component>

    – Mitesh Sura Jul 21 '17 at 15:12
  • Well, my issue was because of missing namespace in object and field. I would have deleted by previous comment but it may help someone who stumbles on this thread for the same reason I did. – Mitesh Sura Jul 21 '17 at 15:53

1 Answers1

2

Your sObjectType was not the proper case (with the case you have I get the same error). Also note that it works with and without the sobjectType in the single quote, here I have it in the single quote.

This works for me when placed on the Account Lightning Page (Bundle version 40.0):

<aura:component description="myTestComponent" implements="lightning:actionOverride,force:hasRecordId,flexipage:availableForRecordHome" access="global" >
    <aura:attribute name="account" type="Account" default="{ 'sobjectType' : 'Account' }"/>
    <force:inputField value="{!v.account.CustomerPriority__c}"/>
</aura:component>

I also tested using this as an override to the new button and it worked just fine

Eric
  • 54,152
  • 11
  • 100
  • 195
  • Eric can you try a custom lookup field/ multiselect picklist? – Rao Jul 19 '17 at 01:29
  • @Rao - MultiSelect works fine. User Lookup throws a different error when clicking in the field (Access Check Failed! AttributeSet.get(): attribute 'inContextOfRecordId' of component 'markup://c:myTestComponent {1:422;a}' is not visible) but after closing the errors the field does work, until I click a user. But that is a different issue – Eric Jul 19 '17 at 01:34
  • Standard user lookup renders fine through force:inputfield for me, custom user lookup throws an error " "Aura.loadComponent(): Failed to initialize application. An internal server error has occurred Error ID: 887422595-11863 (-485973904)"" – Rao Jul 19 '17 at 01:42
  • 1
    @Rao - At least the inconsistencies are consistent lol – Eric Jul 19 '17 at 01:43
  • I guessed the same about sobjectType and the OP seems to have issue with this component. I assume this is error has something to do with the type of the field. – Rao Jul 19 '17 at 01:43
  • @Rao - I saw that. I find when troubleshooting lightning, especially when giving answers here, it is extremely helpful to provide a self contained working example. Once that is working all the other stuff can be added in until it breaks. Thats the only reason I added this as an answer given you already stated it as a comment – Eric Jul 19 '17 at 01:45