+ Start a Discussion
salesforce codersalesforce coder 

Issue with Lookup and InputField - lightning

I am trying to create a new contact record like below. Someone the Lookup "AccountID" does not work !! What is wrong ? Please help !! 

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,lightning:actionOverride" access="global">
    <div class="slds">
    <ui:scrollerWrapper class="scroll_down">
    <div class="slds-p-bottom_large slds-p-left_large slds-size--2-of-2 slds-medium-size--1-of-1 slds-large-size--2-of-2" >
        
        <lightning:recordEditForm aura:id="recordViewForm" 
                                  recordTypeId="01220000000jDS7"
                                  objectApiName="Contact">
            <lightning:messages /><!--01220000000jDzL inactive-  01220000000jDS7 active-->
            <lightning:inputField fieldName="Salutation__c" />
            <lightning:inputField fieldName="FirstName" />
            <lightning:inputField fieldName="LastName" />
            <lightning:inputField fieldName="AccountId" />
            <lightning:button aura:id="submit" type="submit" label="Save" class="slds-m-top_medium" />
            <lightning:button aura:id="cancel" label="Cancel" class="slds-m-top_medium" onclick={!c.closeCreationWindow} />
        </lightning:recordEditForm>
    </div> 
    </ui:scrollerWrapper>
    </div>
</aura:component>
Best Answer chosen by salesforce coder
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Hi,

Looks like the issue is when you using the component in lightning app, what is the exact use case? can you use the component itself as an action override in "Contact New" button or can you as component tab?

Thanks,

All Answers

Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Hi,

Is it the scroll making you not show the lookup dropdown? if not could you please give more info? what is the behaviour any screenshot?
Anil SomasundaranAnil Somasundaran
@salesforce coder

I have made few changes in the above snippet.

changes are, "recordTypeId" is given instead of "recordId  and the double quotes are missing in the button click event.

<lightning:inputField fieldName="AccountId" /> - This input field displays the account name and it is providing you with the facility of lookup but logging few errors in the console. So it would be better to create a custom lookup instead of lightning:inputField.  Please refer my blog to the custom lookup. 
https://techevangel.com/2018/04/29/custom-lookup-component-for-lightning/   (https://techevangel.com/2018/04/29/custom-lookup-component-for-lightning/ )
<div class="slds">
    <ui:scrollerWrapper class="scroll_down">
    <div class="slds-p-bottom_large slds-p-left_large slds-size--2-of-2 slds-medium-size--1-of-1 slds-large-size--2-of-2" >
        
        <lightning:recordEditForm aura:id="recordViewForm" 
                                  recordId="0037F00000O1UzUQAV"
                                  objectApiName="Contact">
            <lightning:messages />
            <lightning:inputField fieldName="Name" />
            <lightning:inputField fieldName="Email" />
            <lightning:inputField fieldName="AccountId" />
            <lightning:button aura:id="submit" type="submit" label="Save" class="slds-m-top_medium" />
            <lightning:button aura:id="cancel" label="Cancel" class="slds-m-top_medium" onclick="{!c.closeCreationWindow}" />
        </lightning:recordEditForm>
    </div> 
    </ui:scrollerWrapper>
    </div>


Please mark this as best answer and upvote if your query has been resolved. Visit my blog to find more about lightning https://techevangel.com/author/anilsomasundaran/
salesforce codersalesforce coder
It is of course not the scroller. Cox I tried even w/o scroller and it did not work. 
And I need it to be recordTypeId , cox it supports both recordTypeId and RecordId. RecordTypeId specifications will help me when I use picklist fields in input fields. They will fetch accordingly. And I will not have a recordId yet , cox I am doing this on creation. 

Errors in console , of course. So I guess it is a salesforce bug and nothing to do with my code. 
 
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Hi Salesforce Coder,

Sorry should I have explained what I had tried
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,lightning:actionOverride" access="global">
    <div class="slds">
    <ui:scrollerWrapper class="scroll_down">
    <div class="slds-p-bottom_large slds-p-left_large slds-size--2-of-2 slds-medium-size--1-of-1 slds-large-size--2-of-2" >
    <lightning:recordEditForm aura:id="recordViewForm" objectApiName="Contact" recordTypeId="0121p0000006wm2AAA">
        <lightning:messages />
        <lightning:inputField fieldName="Level__c" />
        <lightning:inputField fieldName="FirstName" />
        <lightning:inputField fieldName="LastName" />
        <lightning:inputField fieldName="AccountId" />
            <lightning:button aura:id="submit" type="submit" label="Save" class="slds-m-top_medium" />
            <lightning:button aura:id="cancel" label="Cancel" class="slds-m-top_medium" onclick="{!c.closeCreationWindow}" />
    </lightning:recordEditForm></div> 
    </ui:scrollerWrapper>
    </div>
</aura:component>
I tried a similar example as you had with just the level field as different and used a recordTypeId on contact, I was able to search for Account in the AccountId field and also save the record did not get any console errors. I just restricted the level__c picklist values on that recordType no other config was done.

User-added image

That is why was asking for more info if you had any errors in console or anything but all said it could also be some issue in the component as well when used with some additional configuration on the recordtype.
salesforce codersalesforce coder
This time I did the same thing that you are doing. No luck though. 
See this.. All I get is just a spinner. 
I guess  it has something to do with the debug mode on lightning components or the API version. Not sure. 


User-added image
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Hi,

Looks like the issue is when you using the component in lightning app, what is the exact use case? can you use the component itself as an action override in "Contact New" button or can you as component tab?

Thanks,
This was selected as the best answer
salesforce codersalesforce coder
You are right. I used it as a quick action and that resolved the problem. 
But it still does not work on the mobile though. Any suggestions ?