Having trouble with the video? Try this link.
When you have a table, sometimes you want to make it mandatory for a user to add at least one row. Let’s take the Employee Timesheet app for example.
Here I have a table called Timesheet Details.
To ensure that someone fills out my table, I need to add or use a field outside of my table to validate it. In this case, I already have a field where I am calculating the Total Work Hours. I’ll add a validation to this field so that the total sum should be greater than zero. I can also add my own custom error message.
Here’s what it looks like in the live form when someone doesn’t fill out the table. Now, let’s look at an example where there are no numbers involved. In the Content Request App, I have a table called Image Details listing out the different images that need to be created. I want to make sure that my designer adds at least one image to the table. But you can see there are no number fields that I am totaling up.
I’ll create a number field in a new section called TableRowCheck. I’ll use this formula:
This will give the count of the number of rows.
In the validation, I’ll make sure the value is greater than zero. Also give a custom error message. (E.g. Please add a row in the table)
You can keep this as it is, but if you only want this field to display if the value is zero, we can solve that this way.
Add another field called Validation Display with the exact same formula. In the permissions under All Tasks, I’ll hide this field always. Then, I’ll go back and set a condition on my TableRowCheck field to only display if the Validation Display value is 0.
Again, here’s what it will look like in the live form. The error message will display if no rows are added.