Skip to main content
Solved

How do i create order records in order table from product table with button


Hello
I have a product table. And want to use a button to order the products. And then create order records in order table (pulling 3 columns from product table) and link the two tables. product id - order id

need some help im green

John

Best answer by john_klacynski

Kamille_Parks11 wrote:

The three fields which pull information from the products table should probably be Lookup fields, which will pull in data automatically once the order has products linked to it.

Assuming you only order one product at a time, you could use a script like this one in a Scripting block:

let ordersTable = base.getTable("The name of your orders table")
let productsTable = base.getTable("The name of your products table")

let product = await input.recordAsync("Select a product", productsTable)

await ordersTable.createRecordAsync({
    "The name of the field which links Orders to Products": [{id: product.id}]
})

Then you could add a Button field to your products table and use that to run the above script.


Exactly what i need, thx for the help. Perfect

View original
Did this topic help you find an answer to your question?

2 replies

Kamille_Parks11
Forum|alt.badge.img+15

The three fields which pull information from the products table should probably be Lookup fields, which will pull in data automatically once the order has products linked to it.

Assuming you only order one product at a time, you could use a script like this one in a Scripting block:

let ordersTable = base.getTable("The name of your orders table")
let productsTable = base.getTable("The name of your products table")

let product = await input.recordAsync("Select a product", productsTable)

await ordersTable.createRecordAsync({
    "The name of the field which links Orders to Products": [{id: product.id}]
})

Then you could add a Button field to your products table and use that to run the above script.


  • Author
  • New Participant
  • 2 replies
  • Answer
  • July 20, 2020
Kamille_Parks11 wrote:

The three fields which pull information from the products table should probably be Lookup fields, which will pull in data automatically once the order has products linked to it.

Assuming you only order one product at a time, you could use a script like this one in a Scripting block:

let ordersTable = base.getTable("The name of your orders table")
let productsTable = base.getTable("The name of your products table")

let product = await input.recordAsync("Select a product", productsTable)

await ordersTable.createRecordAsync({
    "The name of the field which links Orders to Products": [{id: product.id}]
})

Then you could add a Button field to your products table and use that to run the above script.


Exactly what i need, thx for the help. Perfect


Reply