Hey y´all,
I’m encountering some unexpected errors when trying to use trigger formulas to modify a record on docs.getgrist.com
as well as on the grist app version. I’ve managed to reproduce this with a minimal test case
GOAL:
pretty simple: I want a trigger formula to uncheck a checkbox in the same row when that checkbox is ticked.
- Table:
Table1
(a new, empty table) - Column A: Named
MyCheckbox
Type:Checkbox
Behavior: Data Column - Column B: Named
MyTrigger
Type:Text
(or Any)
Behavior:Trigger formula
Trigger formula settings: “Apply on changes to:”MyCheckbox
Attempt 1: Using rec.FieldName = Value
I used the following code in the MyTrigger
formula column:
Test 1: Using rec.FieldName = Value
if $MyCheckbox:
rec.MyCheckbox = False # This is line 2 of the code block if the comment is ignored
return “Checkbox was ON and reset”
else:
return “Checkbox is OFF”
Observed Behavior (Attempt 1): When I check the MyCheckbox
, the MyTrigger
cell displays: SyntaxError: You can't assign a value to a column with
=. If you mean to check for equality, use
==instead. (usercode, line 2)
(Note: The line number reported was line 2 when the code above was pasted without the initial comment line. The error points to the rec.MyCheckbox = False
line.)
The else
part of the formula (returning “Checkbox is OFF”) works correctly if the checkbox is not checked.
Attempt 2: Using table.updateRecord()
I then tried using table.updateRecord()
as an alternative:
Test 2: Using table.updateRecord with keyword arguments
if $MyCheckbox:
table.updateRecord(rec, MyCheckbox = False) # Corrected column name here
return “Checkbox was ON and updateRecord (keyword) attempted”
else:
return “Checkbox is OFF”
Observed Behavior (Attempt 2): When I check MyCheckbox
, the MyTrigger
cell displays: AttributeError: 'UserTable' object has no attribute 'updateRecord'
The else
part also works correctly here.
Summary: It seems that standard methods for modifying the current record’s fields from within a trigger formula are not working as expected on https://www.google.com/url?sa=E&source=gmail&q=docs.getgrist.com
in my testing. The rec.FieldName = Value
syntax results in a SyntaxError
, and the table.updateRecord()
method results in an AttributeError
suggesting the method isn’t available on the table
object provided to the trigger formula.
Question: Is this behavior expected, a known issue, or a potential bug? Am I perhaps misunderstanding a fundamental aspect of how assignments or record updates are intended to work within trigger formulas in this context on https://www.google.com/url?sa=E&source=gmail&q=docs.getgrist.com
? Not sure and working on it for hours.
Browser: Microsoft Edge
Version 136.0.3240.76 (Official build) (64-bit)
Win 10 Pro
Thanks for your help and any insights you can provide!!