How to change a text field in a detail to a lookup/picker field programatically?

Hi,
I have a text field in a detail. Sometimes, it should be a text field. Sometimes, it should be a lookup/picker field. How can I change it programatically? Thank you.
Master-Detail

Hi @thomaslei

You can specify a generator for your column. An example can be found here: documentation.

You can also add generated column to the table. Please take a look at example here: documentation.

Regards,
Daniil.