Lookup field with two caption fields, only save one

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
theyland
Veteran Member
Posts: 32
Joined: 2020-11-04 15:43

Lookup field with two caption fields, only save one

Post by theyland » 2023-10-26 14:26

Hi there,
can someone tell me how I can display 2 values via the lookup field (e.g. index and name), but only save one of them (name) in the table field?
Thanks
Thomas

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Lookup field with two caption fields, only save one

Post by jsetzer » 2023-10-26 14:54

For Lookups exactly one value is stored in DB: the primary key ('id'). Not the name nor any other text.

We cannot decide which value will be stored. It is always the PK.

Caption field + optional separator + optional caption field 2 is just for display.

Next to the PK, if you need additional data in database, consider adding another column and populate it by code or by using a calculated field.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

theyland
Veteran Member
Posts: 32
Joined: 2020-11-04 15:43

Re: Lookup field with two caption fields, only save one

Post by theyland » 2023-10-27 09:29

Maybe I did not make myself clear. I have this situation: A lookup field from a parent table with Parent caption field part 1 and Parent caption field part 2, let's assume First_name and Last_name.
When adding a new field, the First and Last name are displayed correctly, and when saving, the last and first name does get saved, but I would like to save just the last name.

(specific case, I work for an NGO and we do have a large number of farmers, each with a unique ID. When doing distributions, we look up the farmer through the name, as the farmers do not know their unique ID. In the DB, I would just like to save the ID, the name is not needed.)

Thanks
Thomas

theyland
Veteran Member
Posts: 32
Joined: 2020-11-04 15:43

Re: Lookup field with two caption fields, only save one

Post by theyland » 2023-10-27 09:47

Ignore the previous post. I understand that only the ID gets stored in the DB.
But in the AG table, both values, including the seperator are displayed. Where is that defined? I only want to display one value.
Thanks
Thomas

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1944
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Lookup field with two caption fields, only save one

Post by jsetzer » 2023-10-27 10:00

You configure caption1 + optional separator + optional caption2 for the lookup field. As mentioned before, this is only for display.

There is no separate configuration option which allows you to configure TV, DV insert, DV update and DV view differently.

Again, consider adding additional autofill fields or calculated fields or fields populated in hooks by code.
I only want to display one value.
I guess an autofill lookup should do. And you can exclude columns from TV display. Show original lookup field only in DV, hide from TV. Show autofill column in TV and DV.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 25.10 + all AppGini Helper tools

theyland
Veteran Member
Posts: 32
Joined: 2020-11-04 15:43

Re: Lookup field with two caption fields, only save one

Post by theyland » 2023-10-27 10:09

Ok, thanks for that.
Indeed, the easiest seems to be to play around with detail and table view.
I'll try the calculated field method as well, hooks are above my skill level.
Thanks again,
Greetings from Malawi,
Thomas

Post Reply