apex:inputfield with lookup filter configured

I would like to expose a form (custom lightning component) with 2 fields on it.

  • Brand
  • Model

In the field settings the “Model” field is configured with a lookup filter based on the “Brand” field. Ex: If brand equals “BMW”, then only BMW models are shown.
This works fine in Classic and Lightning Experience, also works fine in VisualForce. But now we need to migrate this functionality to a lightning component.

The component I am building only does editing, no new items are created. If I edit and change the model, the lookup filter works. Read: it only shows the models of the selected brand. BUT when I update the brand to something else, then the lookup is still filtering on the initial brand.

How to fix this?

<aura:component description="CUBAConventionCarParkEdit" controller="CUBAConventionCarParkController">
    <aura:attribute access="public" type="Object" name="record" required="true" />

    <aura:handler event="c:EVTModalFooterAction" action="{!c.handleEVTModalFooterAction}"/>

    <lightning:overlayLibrary aura:id="overlayLib"/>

    <lightning:recordEditForm aura:id="editForm"
                              recordId="{!v.record.Id}"
                              objectApiName="Convention_Car_Park__c"
                                onsuccess="{!c.editFormSuccess}">
        <lightning:messages />
        <!--Other fields here-->
        <lightning:inputField fieldName="Brand__c" />
        <lightning:inputField fieldName="Brand_model__c" />
        <lightning:inputField fieldName="Number_of_cars__c" />
    </lightning:recordEditForm>

</aura:component>

Answer

Attribution
Source : Link , Question Author : Nielsm , Answer Author : Community

Leave a Comment