+ Start a Discussion
Ridhima Saxena 21Ridhima Saxena 21 

How to make custom Lookup Component required and does not allow to save it before filli up this field

Hii Developers,
 I have created one lookup custom component and now  i Have called it into my parent component.....Now My requirement to asked you is i wanted to make lookup component required so that if someone skip this lookup field it shows error "Please select object" and do not allow to save till it fill up the field.
Its Urgent
Thanks In Advance
ANUTEJANUTEJ (Salesforce Developers) 
Hi Ridhima.

The possible way to implement this is to have the use of application event.

If you dont want to use aura methods, The only other clean solution i can think of is using events:
1>You can use an application event in parent which will get fired it its children.
2>The child components will listen to it and do the validation and fire a component event back to parent to confirm if validation is successful.
3>The parent can listen to this component event and based on the response from children can take the next course of action save or not save

Link: https://salesforce.stackexchange.com/questions/210309/child-component-validation-on-parent-components-save

Implementation for reference: https://www.w3web.net/how-to-validate-child-component-from-parent-component/

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.  

Ridhima Saxena 21Ridhima Saxena 21
Hi @ANUTEJ i am asking for LWC not aura method 
Thanks in advance
ANUTEJANUTEJ (Salesforce Developers) 
I tried searching but I see that there are more implementations of lightning components If I find any such implementations I will update the thread so that it can be changed as per your use case.