function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sumedha psumedha p 

How to validate lookup lightning input field in record Edit form

I have a record edit form with multiple custom lookup fields. Standard validation rules on lookup fields with an invalid input would give an error message "An invalid option has been choosen". Looks like lightning:inputfield for lookup doesnot fire these validations. Any workaround would be greatly appreciated.
User-added imageOn submit, it would not error out and would not save this invalid value.
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sumedha,

Greetings to you!

I tried to research your problem and found that this is a known issue: https://success.salesforce.com/issues_view?id=a1p3A000000JX0XQAW

Also, please take a look at these known issues as well: https://success.salesforce.com/issues_view?id=a1p3A000000JWo7QAG&title=lightning-inputfield-does-not-respect-disabled-attribute-when-field-type-is-lookup

https://success.salesforce.com/issues_view?id=a1p3A000000FmjRQAS&title=lightning-recordform-not-capturing-validation-errors-in-component-s-controller

Unfortunately, there is no workaround available at this time. However, it is in a review and we may get a solution for this soon. Keep watching this issue until get fixed.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Mateusz OtrebaMateusz Otreba
Here is an example which explain how you can validate your recordEditForm https://salesforceprofs.com/custom-validation-with-lightningrecordeditform/