Button - is it possible to use the same one for both "create" and "delete" action?

Hello everyone,

seeking for help - I was somewhy confident the flow I have in mind is something I can easily implement, however I unexpectedly got stuck trying to implement the idea.

The flow is supposed to be:

  • You have a List with books. Each book has a “bookmark” button.
  • You click on a button → “create” action is triggered, record added to Collection.
  • After clicked, button should change to “bookmarked” icon.
  • You click on the button again → “delete” action is triggered, record deleted from the Collection.
  • Button change back to “bookmark” button.

So, two stages for the button, with two icons changing each other. I thought to implement this through “sometimes visible” condition, however it looks like I am missing something, most probably in terms of relationship between Collections (steps 1-2 from the flow work as they should, but then I am struggling to set up a correct relation)

P.S. The Collections that I have:
“Users” Collection
“Books” Collection
“Bookmarks” Collection

If anyone has ever tried a similar scenario or has any thoughts of how to implement it better than I am trying to, will be grateful for feedback.

Hi @dmitrya,

You can’t do this with one button. Here is the problem: you can easily add new record to the collection with one button. But there is no way the same button can know about which record should be deleted.

There are 2 possible ways to do it:

  1. Use many-to-many relationship between “Users” and “Books”. Here is the “Favorites” tutorial, you can implement something similar: How to create a "Favorite" button - Adalo Resources
    Downside of this approach - you can’t really store any info about the “bookmark”, you can just set and un-set the relationship. 2nd problem - many-to-many relationships could be slow sometimes.

  2. Another approach (if you need to store info about the bookmark itself) would require creating a mix of a “add” button and a single-item list which, in turn, will allow to delete the record from the “Bookmarks” collection. Probably I’ll create a video about this, as it’s not very obvious how to create such solution.

Best regards, Victor.

Hi Victor,

thank you so much for the feedback!
Right, I was sure it is something with the way I want the button to work or due to the way I set relationship between the collections. Thank you for clarifying why that way would not work.
Going through the options you propose:

  1. Sounds as a good one, though indeed doesn’t fully to my case as I need to story an info about the bookmark (I wanna use it for some other things in the app). Still, I am going to play around just to see how it works.
  2. I kinda can imagine what you mean and I think it would work, but a short video explaining this approach would be definitely helpful indeed. Would it be too much of an impertinence to ask you to record one?


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