Trying to normalize my brewing sheets

Hi there !

In a previous topic i managed (with generous help) to make an auto filler for my brewing sheets using action button and a separate table for recipes. Action button is fed data from a recipe and some other stuff (date, serial number, …) from some formulas.

It works great but now i’m facing a second problem : my database is not made in a healthy form as it includes a lot of empty columns. For example i have 15 “malts” columns, each neighbouring a mass column, a serial number column, and so on. I understand i should normalize this and have those be lines in a separate malt table, linked with a key to their own brews.

I’m slowly developing a solution to get to this format. Here is where i bump into problems : i like having the action button creating a new line for a new brew day but i cannot get it to work with keys in a reference column. See in this example that when creating a new brew, everything gets pasted in the right place, but the reference column does not work properly. Do you have any solution to circumvent this issue ?

Ce sont de belles recettes. J’en ai ajouté une à moi pour faire quelques tests.

To fix the problem of the writing to a reference column with an action button, you must write the id of the reference table that you want. In your case, you wanted the next id of the table which you can reference with -1. So in your action column, I replaced:
["AddRecord", "Fiches_MALTS", None, {"LOT_BRASSIN": **prochain_lot**, with
["AddRecord", "Fiches_MALTS", None, {"LOT_BRASSIN": -1,
This works.

Merci pour le compliment, il manque quand même deux trois ingrédients :smiley:

I tried your solution but could not get the desired result… So i thought harder and came up with an idea : since brewing sheet creation is incremental, prochain_id = max(Fiches_de_brasse.all.id) + 1 gives the next id i need. Coupled with ["AddRecord", "Fiches_MALTS", None, {"LOT_BRASSIN": prochain_id, ... it works perfectly.

That’s a first step working…