Automate “subpages” deletion when a button is triggered. Is it possible or not?

Hello dear Coda.io community,

I’m a Coda user who want to create a MVP of an app for small restaurant owners and their customers. I want to perform a specific automation but can’t achieve it. Maybe have you an idea?

TLDR: I create an app MVP with Coda and I try to find a way to automate “subpages” deletion when a button is triggered to allow the business owner to delete all the old “views” of customers orders in a single click.

As you can see in that video, I’ve actually something like this:

  • A “Welcome” page, where the customer can create a new “view” for his order;
  • A “Dependencies” page, where you can find the “order.view” table (which is simply the “cart” of the restaurant);
  • An “App model - Your order” page, as the model for the customers ordering process;
  • An “App view” folder where the view of order are located;
  • An “Database” page where all the orders are centralized, containing a button who allow restaurant owner’s to delete all the data in the view.

When the customer clic on “Order”, a new view is created with the formula below.

RunActions(
  DuplicatePage(
    [App model - Your order], 
    name: "App view - Votre commande",
    parentPage: [App views],
    copySubpages: false, 
    duplicateOptions: "duplicatedata"
  )
)

Then, when the customer confirm the order, informations are send inside the restaurant owner’s database (this s*it still need improvement to avoid "partially” complete order… but at least it work!).

RunActions(
  AddRow(
    [backofficeorder.view]
  )
  ,   
  ModifyRows(
    [backofficeorder.view].Last(),
    [backofficeorder.view].[Qty of Dagobert], 
    [cart.table].[Qté].Nth(1)
  )
  , 
  ModifyRows(
    [backofficeorder.view].Last(), 
    [backofficeorder.view].[Qty of Norvégien], 
    [cart.table].[Qté].Nth(2)
  )
  , 
  ModifyRows(
    [backofficeorder.view].Last(), 
    [backofficeorder.view].[Qty of Liégeois], 
    [cart.table].[Qté].Nth(3)
  )
  , 
  ModifyRows(
  [backofficeorder.view].Last(), 
  [backofficeorder.view].[Client name], 
  [order.clientname]
  )
  , 
  ModifyRows(
    [backofficeorder.view].Last(), 
    [backofficeorder.view].[Client address], 
    [order.clientaddress]),
    DuplicatePage(
      [App model - Confirm order], 
      name: "App view - Suivi de votre commande", 
      parentPage:[App views] , 
      copySubpages: true, 
      duplicateOptions: "DuplicateData")
  )
)

Everything work fine as expected. But I want to offer to the restaurant owner the capabilities to delete all the child from “App views” (”App view - Your order” and “App view - Confirm order”) by clicking a button inside the “Danger Zone” as I guess it gonna be very messy / slow if there’s a lot of views in the doc.

When making research, I’ve found the DeleteDoc formula inside Crossdoc package but it doesn’t seem to work for me as expected (and the formula seems to doesn’t been “recognize” anymore).


I also have found this but it doesn’t fit my need (as I’ve understand it).

Do you know any way / tips / hack to achieve my goal as expected?

Thank’s a lot in advance for your (greatly appreciated) help,
Jonathan

Hi Jonathan,

Quick question: Why do you create a page for each customer? Why not just show the customer his information from the tables?

Here is also an excellent example done by @Paul_Danyliuk for a very similar requirement: Viva Pizza

Regards
Piet

Hi Piet,

What a fast reply! Thank’s a lot. :star_struck:

The example you provided is very interesting, I will check it deeply.

Maybe I’ve done it wrong way but my “original” idea was to have a kind of “MVC-like” structure allowing multiple users to introduce an order “at the same time” (by creating a distinct view of the order model for each user). I need to check if the (awesome) example provided by @Paul_Danyliuk can achieve this. In another term: what’s happen in the example if two people complete an order at the same time.

Thank’s a lot again and have a nice day Piet!

1 Like

Hey @Jonathan_Schoonbroodt, welcome to the Community!

@Piet_Strydom is right, you most certainly don’t want to duplicate pages in a doc just for the sake of giving each user their own space. At least because that won’t prevent users from seeing and tampering other users’ pages.

In general, given that many users should have the same level of access to a certain doc and you want to give each user capability to interact with it through the same centralized interface, what you should do is implement a “view” as a single page but make it user-specific instead using this approach:

But yeah, I built Viva Pizza just for the use case you’re describing: separating the user storefront (a sandbox where each user loads an ordering interface whose lifespan is that of an opened tab — closing the tab would clear all their data) from the back-office where production is managed. And to answer your question, yeah, since every time a person opens a storefront tab they get a sandboxed environment, many people can safely make many orders at the same time and not clash with each other.

If you need help taking my doc and tailoring to your business, I’m open for hire :slight_smile: — just DM me. Most of the ropes are in place already so I don’t see it taking much time.

1 Like

Thank’s for your explanation @Paul_Danyliuk! And great doc btw.

The link to the topic about User-specific filters seems the perfect answer for me.

The doc is not for my personal business but it’s a side project I like to work to.