Dinamically Generated Code

Hi everyone,
I need to dinamically generate some Python code in formula columns. I have tried using exec() or eval() function but everytime I get errors.
I understand well that it could be very hard to manage, I’am asking if it’s possible in Grist.
Thanks for appreciated replies.
Tullio

I am far from being an expert, so I don´t have the solution… but would you please specify what exactly you are trying to do, that can´t maybe be achieved by some other trick?

I mean, the experts (not me) may think besides dynamically generating code, some other solutions to your problem that maybe don´t need to dynamically generate code.

I need to perform some complex lookupRecords operations whose column’s names are recorded in field_name of my table. In other words, my lookupRecords formula changes for every row of my table, according different value of field_name. Generally speaking Grist formula column doesn’t not change for every row occurrence, in my case it must. Therefore it is mandatory build lookupRecords formula by dinamically generated Python code and use exec() to execute it in formula column. Hope to have clarified the problem.

how many different column names there are?

What I am thinking is that if you have a limited number of different columns, you may recreate in the table one column with a lookuprecords for each of those columns, inside an IF.

Like… if X column is recorded in field_name of your table, then lookupRecords. Else “false”.

So you have ten columns and only the ones which are recorded in the field name will actually return lookupRecords, all the others will be false.

Then you have another column that will join the results from all columns which returned a result.

That will only be manageable if the number of columns is not too big, I guess.

Unfortunately this solution is really impracticable in my specific case.
My question is however a little bit more general: I see that both exec() and eval() function are supported in Grist but they can’t work and return error in very easy cases too.
Moreover I’m wondering if Grist can support differente formula column for the same column. It could be realized by dinamically generated code

maybe find a developer in another topic, and mention him here?