[SalesForce] Anyone got a lightning:inputField working for a lookup

I have a lightning:recordEditForm containing lightning:inputFields that I want to use to create a simple custom object. The 3 fields are:

  • A picklist
  • A lookup to Contact
  • A lookup to Account

presented like this:

<lightning:recordEditForm objectApiName="MyObject__c">
    <lightning:messages />
    <lightning:inputField fieldName="Type__c" />
    <lightning:inputField fieldName="Contact__c"/>
    <lightning:inputField fieldName="Account__c"/>
    <lightning:button  variant="brand" class="btn" type="submit" label="Create" />
</lightning:recordEditForm>

The lookup fields work to some degree except that the generated HTML has and displays as placeholder:

placeholder="[LightningLookup.placeholder]"

and this text is displayed at the top of the list of recent objects:

[LightningLookup.recentObject]

and when there are no matching search results this text is displayed that is a working link to a more comprehensive search/add UI:

[LightningLookup.searchForInObject]

and only the FirstName is displayed in the list of matches for the Contact lookup not the Name.

And double clicking after the selection has been made blows up the page.

Looks like incomplete code; I'm working in a scratch org created on 8 Feb 2018: is this working fully for anyone?

PS

The submit is also failing. I see this via the onsubmit event (note that cvux__Intake__c has a defined Id value here):

"{"_name":"submit","_source":{},"_params":{"fields":{"cvux__Intake__c":"a04Z000000BOx02IAD","cvux__Type__c":"Assignee","cvux__Contact__c":"003Z000002clzNGIAY","cvux__Account__c":"001Z000001IuNbbIAF"}},"target":{},"currentTarget":{}}

and get a bland error message displayed that inside the onerror has more detail:

"data":{"message":"An error occurred while trying to update the
record. Please try
again.","statusCode":400,"enhancedErrorType":"RecordError","output":{"errors":[],"fieldErrors":{"cvux__Intake__c":[{"constituentField":null,"duplicateRecordError":null,"errorCode":"REQUIRED_FIELD_MISSING","field":"cvux__Intake__c","fieldLabel":"Intake","message":"Required
fields are missing:
[cvux__Intake__c]"}]}}},"id":"-829756038"}},"target":{},"currentTarget":{}}"

where cvux__Intake__c is a master-detail to a parent object reported as missing.

PPS

Changing the cvux__Intake__c to a lookup fixes the submit problem.

Best Answer

For now quick fix is CHECK "Allow reparenting" checkbox for the Master-Detail field on the child object. You will not get error

Related Topic