You need to sign in to do that
Don't have an account?
salesforce 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>
<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>
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
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?
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/ )
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/
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.
Sorry should I have explained what I had tried 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.
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.
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.
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,
But it still does not work on the mobile though. Any suggestions ?