Change field based on primary field

Hi im trying to achieve the following

when i select Vehicle example Toyota Hilux, the second field Employee should auto populate.

I got already a db table with vehicle and the employee asigned something like

carid name asigned_employee
2 Toyota Hilux 2

and i got another table with the name of the employee

thank you

For the employee field you should use an OnChange event in the Vehicle field so that when the Vehicle is selected you run the query to get the employee where the id matched to that vehicle.... if that makes sense... kind of difficult to write a solution without really seeing your db structure.

1 Like

thats the thing

works good, thank you for the tip

Glad it is solved but the one thing I notice throughout your posts for this app you're building is that your data structure seems inconsistent.... how is asignado the same as an id?
You may want to consider changing the column name in the database from asignado to user_asignado_id so that it will be easier to understand the relationships....(Just my opinion)

1 Like

yeah im using a table from a laravel app, what im doing example i created a vehicles table, and inside i will put a field named: assigned_to or assigned_id and i link that to my users or employees tables users.id

like this

this is my users table im linking the other tables vehicles, etc to that id from users

yes i got the point my column right now is assigned, thats ambigous better put assigned_user_id

one question @ScottR see i have this case

Loom | Free Screen & Video Recording Software | Loom if you see, when i select vehicle it auto completes the Employee field

on employee field i got this

image

how i can avoid that undefined text when im creating a new entry ?
image

thanks

@ScottR can i do something like

{{(select2.data == null) ? " " : {{ ${obtenerColaborador.data.first_name['0']} ${obtenerColaborador.data.last_name['0']}}}
?

i tried that but is not working, so when dropdown is empty, text field shows empty blank space, and when dropdown is selected then show those values

what i did was to concat first and last name directly on postgresql query to use only {{ obtenerColaborador.data.asignado['0'] }} and that gets me full name, and if its empty the first field then it will show as empty