Text Field Default Lookup Value Issue

By: Russell Guilfoile | Asked: 01/04/2023
ForumsCategory: General questionsText Field Default Lookup Value Issue
Russell Guilfoile asked 2 years ago

Im having trouble getting a lookup field to work how I think its supposed to. I put the link to a demonstration of the problem here: https://www.loom.com/share/47579fc996494474a757b9acab0ec112   Essentially, I have Form_1, Form_2, Form_3. Form_1 is a user agreement for different services. A service is selected from field_a in Form_1. field_a is a lookup field that gets its values from entries in field_z in Form_3. A user must be signed in to submit Form_1 and field_a is a required field. Form_2 has field_b which is a lookup field that pulls value from entries in field_z in Form_3. There is also field_c in Form_2 that is meant to check if, when the signed in user selects a service in Form_2, field_b whether they have submitted a Form_1 with the same service selected in field_a. If so, it is supposed to render the name of the service (or really any value). field_c, Form_2 is a text field where the default value is a lookup of Form_1, field_a watching Form_2, field_b. My issue is that field_c in Form_2 is essentially not responsive (never renders a value). It does not appear to be pulling the Lookup/Watchlist value. I hope between the description above and the video description this makes sense.

2 Answers
Victor Font answered 2 years ago
Lookup fields can only look at one watch field. Because you are searching on 2 variables, the approach I would take is to create a custom Ajax routine to get the value for the signature record. Ajax will return the result in real time while the form is being filled out. If you've never written code for Ajax before, there are both PHP and jQuery components. jQuery triggers a call to the server where the PHP is executed to return your result to the browser as JSON. You have to convert the JSON into a standard object that you parse for the result and apply it to the field.
Russell Guilfoile replied 2 years ago

Victor. Thank you for the response. I'll take a crack at implementing this.

Bobby Clapp answered 2 years ago
Is there any reason you can't use some simpler javascript to compare "For which service is this Proposal being submitted?" with "Check if RFP Code matches Service"? and then the lookup that pulls the user id with the current user id trying to enter the form and then if all 4 match, populate this field with whatever you value you want?

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