Hi i have a table in my coda document and i want my colleagues to add new rows in the table.
I want to validate before adding a row based on some conditions.
So when someone press the “add new row” button it should not add a blank row instantly, instead it should validate if all fields are filled, submit only if all fields are filled and show an error message if a field is empty.
This is a non-trivial request, and probably a few ways to achieve that.
What I would explore is to have two tables, and a “New” button with some runActions(). First get the information from the user, save it in a temp table. Next step in the runactions is to check that all the fields needed are populated. Then, last step, moves the data from the temp table to the “real” table, and (optionally) delete the old record.
Actually, you are raising more than one issue. And, like almost always in Coda, there are many ways to achieve your goals, although you might not get it 100%. The one thing that is not possible is to add a row with blank cells: a design choice in coda is that you don’t have to save your rows - a new row (completely blank), a change, everything you do is saved. I had to get used to that, but I would not have it any other way now.
In order to never have a blank row (or blank cells), you could use an automation to delete rows with certain blank columns. I use that for maintenance (like once a day at night), but you could have the automation run upon creating a new row (runs after about a minute, automatically). It works, but it is not ideal.
For your request, I would consider the following:
Use page locking and set it to not allow changing table values (which include not adding new rows). Then use a coda form (can be embedded on the same page) for entering new rows. A form has validation (on individual field level) which gives you tons of possibilities. The form won’t submit until required fields are entered - and validation can, for example, set some requirements (you can build a check to make sure that a name field has at least two words (first and last name) before the form can be submitted.
For some of the features mentioned above you need a team license. Yes, that will set you back some dollars, but I think is is a must have. I think I changed my free subscription to a team subscription within weeks of starting with Coda and never looked back.