Is it just me or is this an error in the salesforce standard lightning components?
Here is what happened up until now:
- I want to create a new record with lightning:recordEditForm.
- This record has a lookup field to account
- I have a lightning:inputField inside the recordEditForm
The problem is: When searching for an account in the popup search dialog, when selecting or creating a new account or contact then the selected accounts/contacts are not saved in the record created by recordEditForm after pressing on the submit button.
I've compiled it down to have the simple example below using a custom object with a lookup field.
The elfSKAccount__c
has no value in the submit action handler when selecting the Record like above, so it seems like the bug is in the inputField itself.
Also, when printing the data using a simple print function it also shows null
when selecting the Record like above.
Component:
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome" access="global">
<lightning:recordEditForm objectApiName="elfSKDummyObject__c" onsuccess="{!c.dummySuccess}" onsubmit="{!c.dummySubmit}">
<lightning:inputField fieldName="elfSKAccount__c" aura:id="accId" />
<lightning:button type="submit" label="Submit" variant="brand" />
<lightning:button onclick="{!c.printValue}" label="Print" />
</lightning:recordEditForm>
</aura:component>
Controller:
({
dummySubmit : function(component, event, helper) {
console.log("submit");
var response = event.getParam('fields');
console.log("response", JSON.parse(JSON.stringify(response)));
},
dummySuccess : function(component, event, helper) {
console.log("success");
var response = event.getParam('response');
console.log("response", JSON.parse(JSON.stringify(response)));
},
printValues : function(component, event, helper) {
console.log("accountId: ", component.find('accId').get('v.value'));
}
})
(Here is a link to the recordEditForm reference: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_recordEditForm.htm)