2

Using the LDS native functionality we can modify the contents of a lookup field using a lightning:inputfield element, however clearing the field out and saving has no effect. See the inputfield assigned to ContactId on Cases below.

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName">

<aura:attribute name="record" type="Object"/>
<aura:attribute name="simpleRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<force:recordData aura:id="recordLoader"
                  recordId="{!v.recordId}"
                  layoutType="FULL"
                  targetRecord="{!v.record}"
                  targetFields="{!v.simpleRecord}"
                  targetError="{!v.recordError}"
                  mode="EDIT"
                  recordUpdated="{!c.handleRecordUpdated}"
                  />

<div class="slds-box">
    <lightning:recordEditForm recordId="{!v.recordId}"
                              aura:id="recordEditForm" 
                              objectApiName="Case" >
        <div>
            <lightning:layout multipleRows="true">
                <lightning:layoutItem >
                    <lightning:inputField fieldName="Description" />
                </lightning:layoutItem>
            </lightning:layout>
        </div>
        <lightning:inputField fieldName="Description" />
        <lightning:inputField fieldName="ContactId" />
        <lightning:button type="submit" name="update" label="Update" />
    </lightning:recordEditForm>
</div>

Are there any workarounds to this limitation?

1

One thought is to give the inputFields an aura:id so you can attach a change event handler where you have a custom function that evaluates truthiness and clears out the value by hand.

That's a bit heavy handed, but I've used onchange handlers on force namespaced components because their internal change event wasnt behaving as expected.

This might be the same case?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.