6

Final update

See my answer below for the issues. I believe there is a bug in the implementation as well. The lookup will not work if the field is not on the page layout configuration.

The weird part is, as long as any field that looks up to the same object is on the layout then the field you are actually using for the form does not have to be on the layout....

Question for reference

On a scratch org....

This is on a Lightning Tab NOT a record detail page. I am populating the recordId via attribute and it is working to get the record as the lookup to a custom object for the record is working. Only standard object lookups are not working.

Trying to build a simple form to populate an account lookup on a record. The Account object is supported according to the documentation but the following does not work:

Markup - Nothing else exists. Sitting on a lightning tab

<aura:component description="testcmp" implements="force:appHostable">
    <aura:attribute name="theFields" type="List" default="
           ['Name','ns__Lookup_ToCustom__c', 'ns__Account__c']" />

    <lightning:recordForm aura:id="recordViewForm"
                          recordId="{!v.theId}"
                          objectApiName="ns__CustomObject__c"
                          mode="edit" columns="2" fields="   
                          {!v.theFields}"
    >
<aura:component>

When the above is used the ns__LookupToCustom__c works just fine but the lookup to Account - ns__Account__c does not works and the following error is thrown in the console for the Account lookup field:

TypeError: Cannot read property 'label' of undefined
    at wiredItems.c.map.a (lightning-lookup-desktop.js:2)
    at Array.map (<anonymous>)
    at U.wiredLookups (lightning-lookup-desktop.js:2)
    at r.dispatchEvent (aura_prod.js:3)
    at Object.next (force-wire-adapter.js:2)
    at W.next (force-lds-cache.js:2)
    at X.v (force-lds-cache.js:2)
    at subscriptions.size.subscriptions.forEach.t (force-lds-cache.js:2)
    at Set.forEach (<anonymous>)
    at X.emitValue (force-lds-cache.js:2)

System admin profile with access to the Account Field...APIVersion 43.0

All I am trying to do is a quick form with a lightning lookup and since there is no component to perform a lookup with typeahead etc this was a quick way to do it but.....

Anyone know of a way to get the lookup to the Account working?

Note: I added a contact lookup and tried that and the same thing happened. So happens on both account and contact

Images...

  1. The first lookup is a lookup to a custom object and it works
  2. The second lookup is to the account object and does not work, console shows above error

enter image description here enter image description here

I tried to change the field list attribute to:

<aura:attribute name="theFields" type="String[]" default="Name,     
    ns__Lookup_ToCustom__c, ns__Account__c"/>

and the weird thing that happened is the Account lookup was removed from the form completely......

Thinking maybe something to do with a namespace custom object having a look up to a standard object?

4
  • I'm getting the same kind of error on with a Lightning custom component on a record page for opportunity. My record page is cloned from the Salesforce default, and I placed the custom component in a tab in the main section. The error I get with lookup fields in the custom component is Cannot read property 'color' of undefined. When I place the lookup field on the page layout, then it works fine. Commented Oct 29, 2018 at 23:06
  • Salesforce support has confirmed that this is a bug. Commented Nov 2, 2018 at 5:02
  • 1
    Here is known issue link: success.salesforce.com/…
    – Ayub
    Commented Apr 25, 2019 at 15:42
  • had a similar issue with lightning-record-edit-form as well.
    – sam_s
    Commented Aug 16, 2019 at 19:59

2 Answers 2

3
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

    <aura:attribute name="contactfield" type="String[]" default="LastName,AccountId"/>    
    <Lightning:Card class="slds-card__body slds-card__body_inner" iconname="Standard:Contact"
                    title="quick contact">
    <lightning:recordForm aura:id="brokerForm"
                                recordId="{!v.recordId}"
                                objectApiName="Contact"
                                fields="{!v.contactfield}"
                                mode="edit"/>
    </Lightning:Card>
</aura:component>

This works for me. May be this recordId="{!v.theId}" is creating peoblem for you. Are you getting any error while adding component to layout?enter image description here

Update:-

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

<aura:attribute name="Branchfield" type="String[]" default="Name,ACCOUNTCHILD__c,Account__c"/>    
<Lightning:Card class="slds-card__body slds-card__body_inner" iconname="Standard:Contact"
                title="quick Branch">
<lightning:recordForm aura:id="brokerForm"
                            recordId="a0T7F000006EEbPUAW"
                            objectApiName="Branch__c"
                            fields="{!v.Branchfield}"
                            mode="edit"/>
</Lightning:Card>

Here i tried with Lightning tab on custom object having a standard object and another with custom object lookup. Is that matching with you what you want? enter image description here

Update:-

I tried with custom Object having a namespace and working fine:-

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

<aura:attribute name="Branchfield" type="list" default="['Name','sa_nket__ACCOUNTCHILD__c','sa_nket__Account__c']"/>    
<Lightning:Card class="slds-card__body slds-card__body_inner" iconname="Standard:Contact"
                title="quick Branch">
<lightning:recordForm aura:id="brokerForm"
                            recordId="a0T7F000006EEbP"
                            objectApiName="sa_nket__Branch__c"
                            fields="{!v.Branchfield}"
                            mode="edit"/>
</Lightning:Card>

enter image description here

1
  • Just to comment while this may work for the person answering, this does not work for me in the scratch org
    – Eric
    Commented Aug 19, 2018 at 22:09
1

Alright, chalk this up to beta testing mac OS software.

Answer

The FLS for the lookup had read only checked true.

Bug (I believe)

  • The field or another field looking to the same object MUST be on the layout.....

Unfortunately the beta of the new mac OS hides the checkboxes so I could not tell it was set to true....

Doh!

Thanks sanket for your answer. It got me to do some serious digging knowing that you found it working......

2
  • welcome :) I thought and asked the same earlier in comment, thank god finally you found it. Commented Aug 20, 2018 at 1:00
  • @sanketkumar - Yes you did but I could not see that the checkbox was checked. Not sure how it was set to read only.) so I was sure it was not checked (doh Thats what I get for beta testing an OS....Would have been helpful if a proper error message was shown though!
    – Eric
    Commented Aug 20, 2018 at 1:03

You must log in to answer this question.

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