Only one active row

In my app, I need to enforce the rule that there can only be one active competition at a time.

Competitions act as containers for Heats and heats are presented in a collection, but only those heats that are related to the active competition.

Here’s how I’m doing it now:
I have a table called competitions which has a boolean field called Active.
An administrator can set a competition as Active.

Only the heats that are part of the currently active competition show.
This all works. But I’m not sure how to enforce that only one competition can be active at a time.

Not sure If I’m headed in the right direction… if there’s a better way to organise the tables I’m open to suggests.

I think I’m looking for an action that updates multiple other rows.

I’ve tweaked my approach. I basically used a rollup to keep track of when a competition is active. If an active competition already exists, I have a condition that hides the ability to make other competitions active. This is good enough for my use case. When the active competition is “deactivated” then it is possible to make any other competition active.

Hopefully these notes will be useful to someone (or my future self).

Here’s a screenshot of my Rollup:

It looks for the existence of an active competition by calculating for “Some True”. If there is any active competition then all rows will have their “There_is_an_Active_Competition” field set to true. Under all other circumstances this will be false. For my use case that’s good enough for me.

1 Like