4

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)

4
  • 1
    is event.getParam('fields') actually returning the response object? and is your console.log actually logging the object in your dev console? if yes, you might want to include this in your post, if not, please share what is actually being logged (same for the r esponse object on success)
    – glls
    Apr 24, 2018 at 14:22
  • @glls: In dummySubmit the event.getParam('fields') is returning the fields and values that are submitted to the recordEditForm. In dummySuccess the event.getParam('response') gives the response Object.
    – Gamer2015
    Apr 24, 2018 at 14:40
  • please edit your post with the JSON for each.
    – glls
    Apr 24, 2018 at 14:41
  • 1
    This seems like a bug in Salesforce.
    – Saroj Bera
    Apr 25, 2018 at 11:18

1 Answer 1

0

If your lookup is having Master Detail relationship then Allow reparenting for that field. Records will start saving.

You must log in to answer this question.

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