You need to sign in to do that
Don't have an account?
Venkat B 33
Custom lookup component in Lightning (How to validate this field)
Hi All,
I am new to lightning. I implemented a custom lookup component in lightning and i embed it into another component. Now my requirement is need to validate that lookup field. If the lookup field empty an error message should display reference code:
<div class="slds-size_8-of-8" >
<label class="slds-float_left"><span style="color:red;" align="left">*</span>Account Name: </label>
<c:customLookup objectAPIName="contact" IconName="standard:contact" selectedRecord="{!v.selectedLookUpRecord}" label=""/>
</div>
I am new to lightning. I implemented a custom lookup component in lightning and i embed it into another component. Now my requirement is need to validate that lookup field. If the lookup field empty an error message should display reference code:
<div class="slds-size_8-of-8" >
<label class="slds-float_left"><span style="color:red;" align="left">*</span>Account Name: </label>
<c:customLookup objectAPIName="contact" IconName="standard:contact" selectedRecord="{!v.selectedLookUpRecord}" label=""/>
</div>
when you click on your save button first validate the selectedLookUpRecord attribute id if it is undefined it's mean your lookup don't have any value and in this case you can show a alert msg to user :
here is the sample blueprint :
javaScript controller :
javaScript helper method Thanks, hopes it will helps you
All Answers
when you click on your save button first validate the selectedLookUpRecord attribute id if it is undefined it's mean your lookup don't have any value and in this case you can show a alert msg to user :
here is the sample blueprint :
javaScript controller :
javaScript helper method Thanks, hopes it will helps you
It's working thanks for your quick responce.
Could you please share your code(.cmp, .js, .apxs) for the custom lookup lightning component on this thread. I am new to Salesforce development too and really need to create a contact detail page with a custom lookup search for Accounts.
Thanks in advance.
I'm also working on the same requirement. I have called the lookup component in another component, but saving the record function is not working. Kindly share me the code for saving the record (with lookup as a field in parent component).
Thanks & Regards
Surya