2

I created a lightning:inputField which supposed to show the lookup field for customer. However, when I double click on the field or when I try to select the current entry I get an error message.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="contract" type="Contract__c" default="{ 'sobjectType': 'Contract__c' }" access="public"/>
<aura:handler name="init" value="{!this}" action="{!c.init}" /> 
<div class="slds-clearfix slds-card forceDetailPanelDesktop inlineEditEnabled">             
    <lightning:recordEditForm recordId="{!v.recordId}" objectApiName="Contract__c">
         <div class="slds-p-horizontal--small slds-size--1-of-3">
                <div class="slds-form-element slds-hint-parent slds-p-around--x-small hasDiv">
                    <div class="slds-form-element__control slds-has-divider--bottom" style="min-height: 18px;">
                          <lightning:inputField fieldName="Customer__c" />
                    </div>
                </div>
            </div>  
    </lightning:recordEditForm>
</div>

Error

5
  • 1
    Can you please share your code as well?
    – Mahmood
    Feb 8, 2018 at 9:34
  • Can you please COPY and PASTE your piece of code that has the issue? Good thing here is, you could format it to have a good indentation as well.
    – SatyaV
    Feb 8, 2018 at 14:18
  • I added the code
    – Chris K.
    Feb 8, 2018 at 15:22
  • Why us this question off-topic?
    – Chris K.
    Feb 8, 2018 at 19:56
  • Not sure why others voted so. I kind of agree with you here, but since it's a gack all we can do is tell you to contact support.
    – Adrian Larson
    Feb 9, 2018 at 0:40

2 Answers 2

1

I was having the same issue (among others) so eventually I abandoned all hope and started to use the strike lookup component instead. It works much better although as mentioned in the following post the New Record option doesn't work properly: lightning:inputField as lookup missing "New Record" option

If you go with strike be advised that to continue using lightning:recordEditForm you will need to load the parent Id manually into the strike lookup field after form-load (handle the onload event) and also sync back any changes like this:

onFormLoad : function(component, event, helper) {
    // set contactId
    component.set('v.contactId', component.find('input_contactId').get('v.value'));
},

copyContactId : function(component, event, helper) {
    var contactId = component.get('v.contactId');
    component.find('input_contactId').set('v.value', contactId);
}

Component markup:

<aura:handler name="change" value="{!v.contactId}" action="{!c.copyContactId}"/>

<lightning:recordEditForm onload="{!c.onFormLoad}" ...>
    <!-- Workaround to fix lookup component -->
    <lightning:inputField fieldName="Contact__c" class="hidden" aura:id="input_contactId"/>
    <c:strike_lookup value="{!v.contactId}" .../>
</lightning:recordEditForm>
0

I found another workaround. The idea is to prevent the event from being fired. I created a controller function and assigned this function to the lightning:inputField for the onmouseup-event. I still believe that this is a bug.

preventDefault: function(component, event, helper){
     event.preventDefault();       
 },

<lightning:inputField fieldName="Customer__c" onmouseup="{!c.preventDefault}" />

You must log in to answer this question.

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