Trying to filter a reference column's drop-down and getting errors

I have a task list with a “project” field, where I only want to be able to select projects that are active, where the inactive ones are indicated with a “.” at the start of the name.

I thought what I was doing would be simple. I tried “not $Project.Name.startswith(‘.’)”, and then tried “$Name.startswith(‘.’)” after the AI told me that the formula would be evaluated in the context of the “Project” table.

Neither worked. The error I get is “Error in dropdown condition” when I click on the field in the table.

If I try different ways like “not $Name[:1] == ‘.’”, I get “SyntaxError Unsupported syntax at 1:5 on line None Col None”.

If I do something simple like “True”, it returns the whole list, so it’s not just failing to run a formula or needing a “=” or something.

Any ideas? This is really frustrating.

Hi @SESummers.

Dropdown conditions are like access rules in that they aren’t quite full-fledged Python formulas. The syntax is similar to Python, but you can’t call methods like startswith, for example.

What you could do instead is add a hidden formula column to your projects table with the same formula you mentioned (not $Name.startswith(‘.’)), and then make your dropdown condition something like choice.Active, where Active is the name of the formula column you added earlier.

George

Can you direct me to the right place in the documentation to understand the syntax for this? I had to flip the logic (I wanted a checkbox to mean “Done”), so I set that manually for all the ones that had a “.”, and set the filter condition to
“not $Project.Done”.

This shows all the entries, and if I change it to just “$Project.Done”, it says no entries match that, despite having several set to “Done=True”.

What could I be missing?

This is meant for access rules, but most of it should apply to dropdown conditions as well: https://support.getgrist.com/access-rules/#access-rule-conditions . This tutorial may also be helpful: https://support.getgrist.com/col-refs/#filtering-reference-choices-in-dropdown-lists.

You’re saying your dropdown condition was $Project.Done, right? If so, the problem is that this condition always evaluates what the value of the Project.Done column is in the record you opened the dropdown. Here, $Project is shorthand for rec.Project, meaning the Project column of the current record. When you open a dropdown, $Project will always be the project of the record you opened the dropdown in.

What you need to do instead is use a condition that uses choice instead of $Project. Here, choice means one of the values/references in the dropdown. The condition will then be evaluated for each possible choice, and only the ones that evaluated to true will be shown in the dropdown. So your full condition would be something like not choice.Done.

You can imagine that when you open a dropdown, Grist scans through all of the possible choices/references, and for each one, substitutes their record/value for choice in your dropdown condition. Then, only the ones where the condition returned true are shown.

George