Add row only if it does not exist

In one table I have a list of book selections by readers. Each row represents a book and a user. When multiple user select the same book, there are multiple rows added. Works fine. I have created a roll-up table that counts how many times each book is in the books table.

I cannot figure out how to add the book to the roll-up table at the same time it is added to the books table without creating redundant rows in the roll-up table. The logic would be something like, “if book already exists in roll-up, do nothing, else, add book to roll-up table.”

Any help would be appreciated.

Are you using a native form or a custom form to add books?

1 Like

Books come up in a collection on a list. User clicks on book and Add Row action adds row the the books table.

Okay, so what you could do is add a relation column to the table that is the source of the collection, that matches the book with the books column in your rollup table. Then use the state of that relation to decide what to do. If it’s empty, add a row to your rollup table, otherwise don’t.

1 Like

I had the relation set up but did not think to use it like you have described. Where do I insert the logic on the decision to add or not add the row.

Use a custom action on the collection item click. You will have two conditional branches. One adds the extra row, and the other one doesn’t.

1 Like

Book is added to the books table AFTER the click, then the relation logic you describe can work. Best I can tell, IF logic can only be inserted at the top of the action list, not after an action. Maybe I am wrong?

“The click” would only trigger the “add row” branch if you set up the right condition for it.

In your action combo: create 2 branches.

If relation is empty > Add a row

If relation is not empty > Show a notification that the book has been added, or whatever you need to do

1 Like

The book has to be in the books table in order for the relation to work. Upon clicking a book, the action currently adds a row to the books table. Now, the relation is there. I dont think the relation approach works unless there is a book in the table. I may have to rethink all of this.

Thank you

You said that you are presenting a list of books in a collection. Where does that list come from?
Where ever it is, that’s where you need the relation.


User enters book title and Google Books API returns any titles that are close. These are displayed in a collection list. Action is set up so that upon click of a title, a row is added to the books table.

The table with the results from the API is where the relation should be. Doesn’t really matter what’s been added to the Books table, since it’s unique to each user. You are trying to determine if a book has been added to the Rollup table. The relation from the API list to the Rollup table will tell you that. Since the action should be using the API list then that’s where the relation should be.


Works. Thank you all.

1 Like

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