Is it possible to do validation on # of selected checkboxes on Coda form?

Hi! Question about coda forms and some validation. I have a dependency list of 6 dependencies. Checking a dependency checkbox will make 3 more sub-dependency checkboxes appear on the form for a total of 18 sub-dependency checkboxes.

Right now, I can select 2 dependencies and 6 more sub-dependencies will appear. In this use case, is it possible to make sure that there are at LEAST 2 sub-dependency checkboxes checked off before submitting the form?

Hallo @mattics ,

I believe this can be done. If you share a demo doc resembling what you are trying to do (and write some instructions in the doc), I will try to set up some validation formulas to accomplish this.

It is busy time of the year, so, depending on when you share your doc, it might take a little while to work on this, but it should not be all that complicated.

Hi @joost_mineur ! Here’s the table and the published form!

Thank you for taking the time to do this :). I really appreciate it!

Hey @mattics ,
Your setup with None and Other didn’t make it any easier, because if None is selected, you obviously don’t need to select 2 subitems. Coda is not ideal for this, but perhaps you can live with the changes I made to your doc.
There is one issue (solved): the validation does not work until you have done something with the field to which the validation formula applies. I solved that by making the sub dependency mandatory - it’s a small price to for getting the validation you want.
I also think the contains only does not work completely correct, therefore the validation formula is a bit more complex than it should have been.
Make sure to make a copy of this doc before somebody makes more (perhaps unwanted) changes.

1 Like

Hi @joost_mineur , sorry , I don’t understand what changes you made to make the validation happen. :(. I love the output and I can roll with this, thank you!

Hey @joost_mineur do you mind sharing how you implemented this?

@joost_mineur I also want to know. I was unable to see what changes they made so I was unable to replicate what was done

The validation is entered in the form-layout
This is the actual code:

Switchif(
   thisRow.dependency.ContainsOnly(None,Other) OR thisRow.dependency.ContainsOnly(None) OR thisRow.dependency.ContainsOnly(Other),CurrentValue.count() >= 0,
  CurrentValue.Count()>=2)

The critical part of this formula shows when you copy a formula and paste it - now you see the difference between ‘this row’ and ‘CurrentValue’. When building formulas in Coda, you get, when you start typing, a lot of the possible options in your display - you just have to select the right one. Very often you will see options that seem to be the same, but in reality, they are not the same:

One dependency is the currentvalue in the list (a table is a list of rows) - when the software goes trough the table, each row is evaluated (everytime a row is evaluated, that is the current value) and it is compared with something, often a value in the active row (thisRow).

You have to start and play with simple row-button formulas to get intuitive feel for the difference between these two values. Once you do, Coda Formula Language (CFL) can perform miracles.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.