Copy information from 2 different tables to the same row

Hi, I need help with something that seems simple to me but I don’t know how to do it, in this doc I have 3 tables; Products, GenerateOrder, and Order. I would like to go to GenerateOrder, put the order number and customer information and that all the rows of the product table that have that customer with the order ide will be copied to the Order table. I can’t send the order id along with the rows and the best I’ve achieved is that everything is created within the same cell instead of one row per product with its order id. I would greatly appreciate your help.
https://coda.io/d/TEST_dfwUsIkYL3Q/TEST_suRdH#_lu3Zr

Hi @exeinformatica_microsshop :blush: !

I’m not entirely sure but is this what you were trying to accomplish ? :innocent:
(See the blue button in the field [Generate 2] )

The Action formula within the button is this one :

Products.Filter(Client.Contains(thisRow.Client)).ForEach(
  CurrentValue.WithName(Product,
      AddRow(
        Order,
        Order.[Order id],
        thisRow.[Order Id],
        Order.Product,
        Product.Name,
        Order.Client,
        Product.Client
      )
   )
)

The 1st step is to create the list of rows from your table Products where CurrentValue.Client contains thisRow.Client (You could also use ContainsText() instead of Contains(), depending on your actual doc setup :blush: ).

Then each row in the list coming from the Products table is stored within the value Product using WithName() and for each Product, I ask the button to add a row in the table Order where:

  • Order.[Order id] gets the value in thisRow.[Order Id]

  • Order.Product gets the value in the field Name for this current Product (as Product stores a row from the table Products)

  • Order.Client gets the value in the field Client for this current Product

I hope this helps :innocent: !
(If I was going into the right direction with this :sweat_smile: )

2 Likes

It is perfect. thanks a lot. I was stuck and didn’t know how to do it. It’s great to have received such good help and so soon.

My pleasure @exeinformatica_microsshop :grin: !

I’m very glad to know this works as expected and helped you moving forward :blush: !

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