[SalesForce] New record Create option not available in lookup field in tag

All I have a requirement to create a custom Case form with few fields. In Contact lookup, I am not able to see the option to create Contact. Can anyone guide me what I am missing in the code.

enter image description here

HTML:

<template>
<lightning-card>
<lightning-record-edit-form object-api-name="Case" onsuccess={handleSuccess} onsubmit ={handleSubmit}>
    <lightning-messages>
    </lightning-messages>
    <lightning-input-field field-name='ContactId'></lightning-input-field>
    <lightning-input-field field-name='Subject'></lightning-input-field>
    <lightning-input-field field-name='Description'></lightning-input-field>
    <lightning-input-field field-name='Origin'></lightning-input-field>
    <lightning-button class="slds-m-top_small" type="submit" label="Create Case">
    </lightning-button>
</lightning-record-edit-form>
</lightning-card>
</template>

Javascript:

import { LightningElement,api } from 'lwc';

export default class NewRecCreate extends LightningElement {
    handleSuccess(event) {
        console.log('onsuccess event recordEditForm',event.detail.id)
    }
    handleSubmit(event) {
        console.log('onsubmit event recordEditForm'+ event.detail.fields);
    }
}

Best Answer

I would check out this link.They are able to create a reusable lookup field. I would then append a value '+ New Record' that when selected opens a model to create a new record. Then you can capture the new record Id and place that into the lookup field.

You can also look at this example.

Either way, append an option to the drop down then look for onchange to see if that option was chosen then prompt the new record create.

Related Topic