1

If you use the out of the box lookup field via the Page Layout in Salesforce the agents have a choice to add a contact. Now that we moved over to an LWC they no longer have that functionality. Does anyone have any idea we can allow users to add contacts via the LWC lookup component?

HTML:

                <lightning-input-field field-name="ContactId" required>
                </lightning-input-field>

LWC enter image description here

Out of the box Page Layout enter image description here

  • I know for sure in aura components, when you search in the field, and hit enter, it opens up the search dialog and provides you the option to create new record. Try hitting enter after your search term and see if the behavior is same in LWC – Jayant Das Mar 24 at 17:47
  • That was the first thing I tried. There was no luck in doing that though. – Gunner1714 Mar 24 at 19:07
0

it is kind of limitation in Lightning Data Service. You cannot get it. You have to rely on a custom lookup field which allows you to do so. You need to pass the selected record id during onsubmit event.

| improve this answer | |
  • Do you have any working custom LWC that does this? – Gunner1714 Mar 24 at 17:06
  • You can check out this – sanket kumar Mar 24 at 17:35
0

So the answer is no that the default lookup doesn't allow you to create a record. You would need to create a custom lookup and add a selection at the bottom to allow the user to create a record.

I did attempt this but ended up going to an easier route of just creating a button for the user to select under the picklist value and this will auto feed the ID back into the lookup once the record is created.

This may not be the ideal solution but was the fastest way to accomplish this.

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.