We have a Lightning Component with some of this:

<aura:attribute name="editRecordId" type="string"/>
<aura:attribute name="serviceId" type="string"/>

<lightning:recordEditForm objectApiName="MyObject__c" recordId="{!v.editRecordId}">
    <lightning:inputField fieldName="Service__c" value="{!v.serviceId}"/>
    <!--That ^ is a lookup field-->

So we have a couple of aura:attributes. One to decide if (and which record) we are editing (less relevant for this question), and one to allow the input of a lookup field to come from somewhere else.
Controller side we have this:

handleRecordSelected: function(component, event, helper){
    var recordId = event.getParam("recordId");
    if (recordId){
        component.set("v.serviceId", recordId);

So what that does is set the value of serviceId to allow the lookup field Service__c to get a value from somewhere else (where is not relevant for this question).
That works.

It doesn't work if there was previously a value in the Service__c field, if the user chose it (using the standard Salesforce interface). If the user is editing and it had a value in that field that came from the DB, then the serviceId value overrides.
The specification for lightning:inputField specifically shows that the value attribute overrides the existing values.
So to reiterate: In most conditions this works. It only doesn't work if the user selects a value in the field (you know, click the lookup field, start typing, select one of the results that pop up) and then uses a different interface (one that calls handleRecordSelected) to set the value.
In that case it retains the value that the user selected in the lookup field.

1 Answer 1


Workaround, NOT a solution, based on this question.

I surrounded my <lightning:inputField fieldName="Service__c" value="{!v.serviceId}"/> with aura:if and reset it before a different record Id is forthcoming.
So I'm basically removing the inputField from the DOM and when it is added back it has no value and then my code can set its value.

  • I'm having this same problem of not being able to override a value in a lightning:inputField lookup for an existing record with a value in that field, and I'm trying to override the value. I've tried surrounding just the field with aura:if and only render it when my overridden value is set, and also surrounding the entire form in aura:if, but neither works. No matter what I do, the inputField is always shown with the existing value, never my overridden value. Aug 9, 2019 at 15:46

You must log in to answer this question.

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