Limit the number of child entries

You’re welcome

Hey @LeventK

If you don’t mind, is there a way to limit one child entry per parent entry?

Sure. Your question is same than @Will_Henry 's actually. Just set it to <=1 basically if that’s what you’re asking.

@LeventK I believe @Jeremy_F is meaning one child record per parent record.

One way simple way is if you use the Parent record’s key column as a key column for your child record (with initial value). Then it’s not possible to save with the same key value.

This won’t remove the “add” button, though it prevents more than one child record per parent record

I want to allow only one child record per parent record, which means removing the “add” button once I add one child record

Then you would need to add a slice (read_only) and create the second Ref_Rows virtual list for that slice. Hide the original virtual list column when COUNT([Related child records]=1 and show this additional virtual list column. It will hide that “New” button.

1 Like

@Jeremy_F there are three ways you can think of solving your problem:

  1. Dynamic control of the table update mode. This is the solution @LeventK proposed. When you do this, the app will remove the New button automatically. This also applies to changes made via workflow rules or REST API. So it is a very logical change.
  2. Control of the display of the New action. This is an option in the definition of the Add action and just controls whether the action is shown or not. You can use the same expression there. This is more fragile — it does not apply to changes in the workflow rules or API.
  3. Validation constraints on the data. @Aleksi originally proposed one solution in this category. The user doesn’t see any difference, they can make changes, but when there is an attempt to save or sync the data, it will fail. This is generally sensible for exception cases rather than for mainstream cases. As you pointed out, this is still confusing for the user.

Of these three, option #1 is the best for you. However, there is a limitation in AppSheet today. The condition specified in the table update mode cannot be different per row. So you should probably go with option #2. In the Add action definition for the child table, the Show_If condition would be something like this: COUNT(SELECT(ParentTable[KeyColumn], [KeyColumnd] = [_THISROW].[ParentRefColumn])) = 0

@Aleksi also proposed a different UI-based way of achieving the same outcome — more directly controlling the UI shown by using a different virtual column. This is a somewhat indirect way to achieve the outcome though, so I’d suggest try my approach first to see if it will work for you.


Thanks for the suggestions. I already implemented the suggestion by @Aleksi,and it works perfectly, as the actions apply on per row basis

I am triying to implement your number 2 solution, using the add action definition but is not working, can you elaborate more detail

This does not seem to remove Add from the inline view of the child entries, in the parent detail view

If you don’t need the action to show anywhere else, you can simply set it to “Do not display” and it drops off.

That is not conditional on the number of child rows

No, but what I meant was, that if you aren’t explicitly using that specific system Add action, you can hide it completely. For example, you could be adding the children from a different action that you created that is visible for the parent table. You can easily make that conditionally disappear after a set number of children. And then you completely hide the child’s Add action. I didn’t have any details of your app to go on, so I couldn’t be more specific earlier.

Im taking different approach when i want to limit the number of child row to be added to one parent.

First, to make the inline child view set to parent table out of slice which is update, delete only (not able to add.)

Make a virtual column to parent table to dynamically calculate the number of child rows.

Make action attahced to parent table, which will open the form to add to it child table.

The action button is made visible only when this Virtula column value is less than and equal N.

For this quick demo, i set app that the user can add max 3 rows to child per parent record.


I got this to work but I need to have a different limit per user. One user can have 10 entries but another might only be able to have 5. Is this possible?

Yes certainly possible.

Create your own user table where you hold a value in number type in a field how many row each user can add.

Then use expression to pull that value to see how many row each log in user can add . This expression will be used in show if constrain for action button to add child rows.


What would that expression look like?

This is what I have going on right now:

[Allowance] Column in Parent Table with the number of entries I want to allow
[Request] Virtual Column in Parent Table with COUNT([Related Request])
[Remaining Request] Virtual Column in Parent Table with ([Allowance] - [Request])

Action in Parent Table to open form and add request in Child Table with condition [Remaining Request] > 0

The Action works, I just can’t figure out how to apply it to the Child Table system Add action.

I dont understand this part.
You dont need to set any action in child table, for this caes.

      "Child Table",
      ([Email] = USEREMAIL())
    "Child Limit"

Substitute your table and column names as appropriate.