You need to sign in to do that
Don't have an account?
SFDC coder
how to create reusable lightning lookup with dynamic fields to display?
I have a use case where in i need to develop a reusable lightning component but with dynamic fields to display
For eg: the lookup component should display A,B,C fields in one part and
X,Y,Z fields on another part in the same application
how can i achieve this using one component only?
Any help would be appreciated
For eg: the lookup component should display A,B,C fields in one part and
X,Y,Z fields on another part in the same application
how can i achieve this using one component only?
Any help would be appreciated
Create Apex Class Controller.
Apex class [customLookUpController.apxc]
Step 2 : Create Lightning Event
from developer console >> file >> new >> Lightning Event >> enter name >> selectedsObjectRecordEvent >> save
lightning Event [selectedsObjectRecordEvent.evt]
Component Blue Print
Step 3 : Create Child Component For Display the Search Result List
Lightning Component [customLookupResult.cmp]
JS Controller [customLookupResultController.js]Step 4 : Create Lightning Custom Lookup Component [Parent]
Lightning Component [customLookup.cmp]
JS Controller [customLookupController.js] JS Helper [customLookupHelper.js] Style Tab Code [customLookup.CSS] TestApp.appThis is a dynamic Re-Usable Lightning Component you have need to pass the objectAPIName , IconName, selected Recordand Field Label Name Attribute when use this Custom Lookup component.
How to Use – Example Custom Lookup Component
Now we are create a simple and small Lightning Component to create Contact Record Using custom Account Lookup and Name field.
Apex Controller
Lightning Component JavaScript ControllerHope this helps.
Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks,
Nagendra
i have this code working but what m looking for is how to display dynamic columns. in the above example there is one static field i.e queried eg: name. i want to display eg: name,location,address in one component and name,email,phone in another component inside the lookup pop up. how can i achieve this?
For this, you can pass an additional String parameter from customLookup.cmp to customLookupResult.cmp to capture the different components and manage what to display based on the passed value using aura:if.
For example, if you are calling the component for Account and Contact, have a separate String attribute that passess 'account' or 'contact' based on what it is for to the customLookupResult.cmp, and within that, for Account, you can display address, location, etc but for Contact, you can display name, email and phone.
Hope this helps.
Bhargav
i want to create a dynamic form and it is reusable that means if the object is account then the form must be displayed with account obj fields and if the object is contact then the form must be displayed with contact obj fields and the code must be in aura
please help me to write this code
Thank you
If didn't work for my purposes as I had similar requirments as the original post plus others, so ended up doing my own.
Couple of extra things: disable state, default loaded record if you know the recordId, flexible search using multiple fields and flexible field selection for search results, show recent records, create and relate, etc... The closest to the native component and functionality I was able to get.
Code is available on github (https://github.com/Chaos-Tech-Corp/Input-Field-Lookup).