Quite new to Grist, please apologize if this is a very basic thing I am struggling with here…
Is it possible to reference the record that filters the data in the linked table, in a function used in one of its columns?
What I want to do is to auto-fill a cell in the linked and filtered table when a new record is created there. In particular, I want to avoid having to specify the value the data is filtered by, as it is a bit redundant, and prone to human error when entering the value.
On the other hand, I understand that it might not be possible this way, as I assume such a column definition would be nonsensical if the table is used in another page without being linked like this.
Is there some way, or workaround, to achieve this?
Hey @SHK, welcome! Using the linked record in a formula is indeed not possible, probably for the reasons you stated. But I think what you’re looking for here is trigger formulas. In the creator panel on the right, you can attach a trigger formula to any normal data column and have that trigger “on new record” to compute a value that Grist should put in the column by default when a new record is created. If you want just a flat value without computing anything, simply use a formula like return "your text goes here". Maybe that’ll do the trick?
Are the two tables linked via a reference column? If so, this should be auto-filling already. For example, in our Lightweight CRM template, you select a record in the Contacts table and the Interactions table updates to only show interactions for that contact.
Let’s say you want to add an interaction here. When I add detail into one of the columns, Contact automatically populates. In the screenshot below, I created a new Interaction record by adding a Date. Contact auto-populated based on the value selected in the Contacts table.
In the actual template, the Contact column is hidden in the Interactions table because this linking is done automatically - so there’s no reason to clutter up your view with it. You can add it to the template to test this out by clicking the + icon at the far right of the Interactions table then select Contact from under the list of Hidden Columns.
Thank you for your reply, TomNit, but for using a trigger formula to do what I wanted to do I would need to be able to access the value of the selected record programmatically to use in the formula. But as I saw from Natalie’s post, I was thinking much too complicated anyway