How To : Build a body from 2 tables to add multiple rows in glide table

Hello,
I want to build a body for a webhook to update a table (raw materials order).
To do this, I need to use two other tables.

  • a master table (final product Order) with an index of 4 columns.
  • a slave table (links between final product and raw materials) with an index of 2 columns which is used as a link with the master table.

The wanted Body must combine each item in the slave table with the full index of the master table.
The final objective is to add new rows to the raw materials order table including the index of the master table and the linked items in the slave table.

In my example, the expected result something like this

{
  "appID": "pZMlOHIHoGajs5KrKs1Z",
  "mutations": [{
      "kind": "add-row-to-table",
      "tableName": "native-table-ANLUcAcAMqoZTzE0elRP",
      "columnValues": {
        "Ref": "707827",
        "Col": "1430"
        "Cde_PF": "3"
        "Plan_no": "1"
        "item": "PAK00002"
   }
}, {
      "kind": "add-row-to-table",
      "tableName": "native-table-ANLUcAcAMqoZTzE0elRP",
      "columnValues": {
        "Ref": "707827",
        "Col": "1430"
        "Cde_PF": "3"
        "Plan_no": "1"
        "item": "FIL00227"
   }
},{
      "kind": "add-row-to-table",
      "tableName": "native-table-ANLUcAcAMqoZTzE0elRP",
      "columnValues": {
        "Ref": "707827",
        "Col": "1430"
        "Cde_PF": "3"
        "Plan_no": "1"
        "item": "TRI00155"
   },{
      "kind": "add-row-to-table",
      "tableName": "native-table-ANLUcAcAMqoZTzE0elRP",
      "columnValues": {
        "Ref": "707827",
        "Col": "1430"
        "Cde_PF": "3"
        "Plan_no": "1"
        "item": "TRI00156"
   },

…
   }

]
}

Not sure if I’m missing something here, but what’s your input? Do you want to combine info from the rows that already exist to do an API call, or your items’ info come from somewhere else?

Rows already exist in Glide tables concerning.

  • Master table = Plan Gamme updated by Customer when an order is submitted
  • Slave table = Nomenclature updated by Admin only when product team defines a new product.

Concerning the use case,
1-The customer creates a final product order (a row is added in Plan Gamme Table).
2-The raw materials is estimated by the App based on informations in Nomenclature and the created order. this estimation is provided thanks to the relation beetween the 2 tables.
3-When the Customer confirms the order , the apps creates an raw materials order from a webhook + call API (multiple rows is added in the 3rd table).

Solved by adding a work area in the Nomenclature table and in the Users table to temporarily retrieve the necessary datas for the duration of the transaction (connected customer & datas from the final product order being processed). So when the order is submitted, I generate the start of the json in the Nomenclature table using the work area. And I consolidate the json and the body in the Plan Gamme table.




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