entry id of selected entry in lookup field.

By: lauren scott | Asked: 03/25/2024
ForumsCategory: General questionsentry id of selected entry in lookup field.
lauren scott asked 9 months ago

Hey, So I created form A, that uses a lookup field for account number. When Account Number is entered, the lookup field looks for the account number in form B.  If it finds the account number in form B, the information is used to populate the remainder of the fields in form A.  This was working great until I decided to update Form A  by changing Name from "text" to "name"  , and Address from "text" to "address"   I now realize that  neither the name or address fields use the lookup feature.  Although I understad this might be available in future versions, currently I cannot pass the entry id to the form, because it does not exist until the user enters the account number on the form, so I won't have access to the entry id until the form is already loaded and the user enters the number.   I thought if I could access the entry id of the selected entry from form B in the lookup field I could use [frm-field-value field_id=727 entry="id" show=first] to populate the name and address fields. Any help or suggestions would be greatly appriciated.   Thanks

2 Answers
Victor Font answered 9 months ago
I'm not following your question. I don't understand what changing a field label has anything to do with lookup fields.
lauren scott answered 9 months ago
Victor. Thanks for your comment. I changed the field type not the field label. I was testing with text fields and when I had everything working I thought I would replace the text Fields of name and address with name type and address type fields. I didn’t realize the lookup function was not supported for name or address field types.   I would really like to use name and address field types for several reasons including geo location however I really want the autofill functionality as well. 
Until the lookup function is supported for name and address field types, I was looking for a workaround. I can’t pass the entry is in the url because it won’t exist until the user enters the account number on the form. 
Any ideas?  Thanks
Victor Font replied 9 months ago

Dynamic lookup fields are one of the most powerful ways to display lookup data in views. There is a big difference in how the different types of lookup fields work and it pays to know the difference. https://formidableforms.com/knowledgebase/dynamic-vs-lookup-fields/

In your scenario, I would use Ajax instead of lookup fields. With Ajax, when the user enters the account # on the front end, your Ajax function would do a record lookup in real time on the back end where your custom PHP callback function returns a JSON payload to the browser where you can populate the fields on the front end without the user's session being interrupted.

As a data design FYI, depending upon how you designed your forms to cooperate with each other in your application, you may run into "single source of truth" consequences. A basic data management principle is that every piece of metadata has a single origin and is stored only once. This is called "single source of truth".

In your design, you have account numbers and addresses in form B. Because you are using Form B as a lookup table, it is your primary data source and should be the single source of truth. If you are storing the address in Form A after you look it up in Form B, you no longer have a single source of truth. Your design violates the principle and the system becomes harder to maintain for your client.

lauren scott replied 9 months ago

Awesome. Thanks. I was trying to simply use the built in lookup function. Fast and easy. The wrench in the works was when I realized the lookup function is not yet available for name and address field types. I was hoping not to write any code and use formidable, but you are correct it might be best under these circumstances. And you are right on the structure but the client has specific recording keeping procedures that require duplicate data for one dataset. So, I though an autofill from form b to duplicate the data was a fast and efficient method to accomplish this goal, and it may still be the case but apparently not with the built in lookup function, so again thanks for your help. I did not think of Ajax and custom backend. Thanks again.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right