You need to sign in to do that
Don't have an account?
force:inputField auto populated in Lightning component
1down votefavoriteI am trying to auto populated 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.
It is a very interesting question indeed.
- <force:inputField> is a Beta component (or even perhaps Alpha for me) if you compare with <apex:inputField>
You cannot autopopulate <force:inputField> for a lookup field from the controller (that works only with the default in the component, one value and just one default="{ 'sobjectType': 'Account', Lead__c:'id value' }"/).I have looked for many months and I cannot find the solution (+ cases for the Salesforce support indeed and they have no solution with <force:inputField> currently).
- "other types of field are working fine like picklist" ??? try to populate with a picklist restricted by a record type and try to use dependant picklists like with <apex:inputfield> (or a rich text).
Officially documentation Winter 18 (v41) : Dependent picklists and rich text fields are not supported. Required fields are not enforced client-side.https://developer.salesforce.com/docs/atlas.en-us.210.0.lightning.meta/lightning/aura_compref_force_inputField.htm
- In fact, Salesforce works on new components for .. the future:
Lightning Components Roadmap:https://help.salesforce.com/articleView?id=lightning_components_roadmap.htm&language=en_US&type=0
lightning:lookup + lightning:picklist: future.
- Many people have developed their own lookup component.
One of the best development of lookup component I found is this Lookupcomponent, developed by Mr Sam Jungleeforce (Bengaluru / Bangalore)Lookupcomponent: Use this lightning component in your project to enable users to select lookup record:
https://github.com/jungleeforce/lookupcomponent
Many other components for lookup on Github (because the Salesforce component doesn't work):
http://https://github.com/search?q=salesforce+lookup&type=
There is no example of a lookup field in the Lightning Components Developer Guide:
Zero result.
<force:inputfield> is nearly nowhere in the documentation or the release notes (??).
Best regards
Alain
I am stuck with something similar. Actually I am trying to open a record create page on click of a button on the Account detail page in lightning. I have created a lightning component and a controller as follows.
The dependent picklist isn't getting populated. Here ChildPicklist_Field__c is the dependent picklist for the ParentPicklist_field__c .The values will be fetched dynamically from an apex class. Any thoughts on this ??
Thanks
Shweta