I am trying to auto populated a lookup field using the force:inputfield but its not working, is there some specific way to populating as other types of field are working fine like picklist, text, date & checkbox
Here is the code
Component
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="recordId" type="Id"/>
<aura:attribute name="account" type="Account" default="{ 'sobjectType': 'Account' }"/>
<!-- lookup to lead on account object -->
<force:inputField aura:id="accNe2" value="{!v.account.Lead__c}"/>
Here is the controller
doInit: function(component) {
var action = component.get("c.getAccountFieldValues");
action.setParams({ recordId : component.get("v.recordId") });
action.setCallback(this, function(actionResult) {
var infos = actionResult.getReturnValue();
component.set("v.account", infos);
});
$A.enqueueAction(action);
},
And the apex method has normal SOQL returning account record.
Best Answer
My assumption is that
Lead__c
is of type "Lookup" even if you did not explicitly stated so.Now I can see two possible reasons:
force:inputField
in general and Lookups in particular that I wouldn't wonder.Lead__c
an relation to the lead out of which the Account has been converted (fishing in the dark, this is again only an assumption since your questions isn't clear on that) the fact that the lookup points to an converted lead might be the reason. Converted leads behave differently in many ways.To narrow it down you should state your field type. If field type is Lookup, try to create another test-lookup field on Account e.g. looking up contacts and test-populate it on your test record using the standard UI to ensure it is populated correctly. Now change your compo for testing to this new lookup field instead of
Lead__c
. If this still doesn't work I think it's a bug inforce:inputField