Dears,
I'm afraid my coding skills have aged more than I was hoping, when attempting to create a little app here for internal collection of travel CO2 footprint emissions.
Briefly: The task is to create an app which allows to store each travel of an employee (employee->contact->name) and within that, collect 1..n "transport events", such as flights, rental cars, etc., for which we calculate the CO2 emissions. All single emissions should then be aggregated into the travel data set as "total travel emissions".
(Scope 3.6 emission reporting)
travel_event
|- employee
| |- contact
| | |-$name
|- transport_event
|- transport_type
| |- types
| | |- $type (flight, rental car, taxi, train, ...)
|- $transport_emissions (CO2 kg)
Simple structure "in a nutshell", to begin with.
I have succesfully tried to use a list field and to aggregate the sum. As such, the total emissions per travel are correctly shown, but only within the list field.
Now, I could probably write the aggreate sum into a field in the travel table, but that would be a violation to normalisation of the sql data and cause (unnecessary?) redundancy.
Is there a simple way to "migrate" the result of an aggregated list field to the "master" form, maybe into a variable?
The difficulty starts when building the relation for the travel data, where I have to include the employee table and contact table, in order to show properly the common name of the employee. If I also include a relation to the transport events, I naturally get an error (or warning), which makes totally sense.
But when I skip that relation, I can also not define a local variable and use a frontend function, as the necessary data (aggregate sum from the list field) will not be available in the main form.
Maybe I'm just missing a "easy" trick here?

