Thanks @TomNit for your kind reply. Indeed I should have provided more context. What I am trying to build is a piece of “Reusable user code”, i.e. a python function, that:
is called as a trigger in a column of table S (see next point)
takes as input the names of two tables S=source and D=destination and two dicts C=condition and A=action
all records in D which match conditions in C are updated as specified in A
(e.g. rows where name=John and surname=Doe are updated with found=true and year=2024)
The fact that I would like to have S and D as strings makes, correct me if I am wrong, your suggestion of using YourTableName.lookupOne(…) inapplicable.
I can however, and this is what I will do if my preferred option is unviable, search the records according to your suggestion and then pass those to a function which does the update.
Thanks again!
@TomNit thanks again. What you suggest is what I planned and mostly did (your point 1. and the Record.update from the repo). What troubles me is: can I simply substitute YourTable with S?
Without bothering you more, I will just try and keep my fingers crossed.
@TomNit great everyting works! But…
The function is called from a trigger column on “new record” and the table is populated by a form.
Everyting is fine if I add records after logging in Grist however the function fails when a new record is created from the form. I suspect this has to do with the privileges but the error message from the form doesn’t give any useful information. Any idea how to trace/debug the problem? I am running self hosted.
@Piergiorgio_Alotto Unfortunately, I don’t think I can help you with that. I fiddled around with forms the other day and had kind of the same experience. It seems to me that something ACL-related is quite broken for forms at the moment, at least if trigger formulas are involved. If someone from the team could shed some light on this, I’d appreciate it.
@TomNit you helped me already more than enough. Thanks again for that.
I would also appreciate if the team could have a look at what happens when a form feeds data into a table which has trigger functions.
Did anybody from the team have the time to confirm that there is indeed an issue with forms feeding data into tables which have trigger functions? Thanks!