Apply action to all items of a one to many relation

Hi,

I would like to create a custom action that loop over all the items in a one-to-many relation to add rows in another table.

My use case is as follows:

  • I am creating an expense sharing app: nocount.glideapp.io that I intend to publish as a template
  • when I create a new expense, I want to automatically add all the users to this expense
  • I could do this with a google app script but I’d like to do it with glide because glide does not sync well data updated from a script (I had to do so for computing the settlements)

thanks

1 Like

Currently with a custom action you can write data through a single relationship and it is not possible through a multiple relationship.
However, to solve your case, you could do in my opinion in other ways; for example you might have a sheet to record each expense and then head a multiple relation column from your users sheet to your expense sheet. In this way, to have a total of the expenses to be attributed to each user, it would be enough to create a rollup column with the sum of the expenses that are in the “Expenses” table.

2 Likes

Hi Roldy, thanks for your input.

I do have actually an expenses sheet and users sheet with a many-to-many relationship
Indeed, an expense has:

  • an amount
  • a paying user
  • some receiving users (the expense may not concern everyone)

When a user creates a new expense, he needs to manually add all the receiving users he wants for this given expense. Instead of starting with an empty list, I’d like to make it smoother by starting with all the users by default (most frequent case)

The app is designed in French but hopefully it easy enough to jump in.

Disclaimer: I don’t collect any personal email and you don’t need to trust me: the free plan does not even allow for doing it