Array of RECORD_IDS -> createRecordsAsync

Topic Labels: Scripting extentions
1790 0
Showing results for 
Search instead for 
Did you mean: 
6 - Interface Innovator
6 - Interface Innovator

How do I loop through an array that is a set of (Product) RECORD_IDs; creating a record in the ‘Order Items’ table forEach Product, and also linking to the related order?

For example, Brutus the Buckeye has the ‘CertainTeed - Highland Slate’ product package applied to his Order.
I am having trouble wrapping my head around creating records in the ‘Order Items’ table. This was somewhat inspired from the record template example. This would allow for very common/repetitive list of pre-determined “packages” to be automatically applied as ‘Order Items’ for ‘Orders’.

// pick order
let order_table = base.getTable("Orders");
let order = await input.recordAsync('Pick an order', order_table)
if (order) {
    output.text(`You picked '${order.getCellValueAsString("Order Name")}'`)

// pick a package(template)to apply to an order
let product_package_table = base.getTable("Product Packages")
let packagE = await input.recordAsync('Pick a product package', product_package_table)
if (packagE) {
    output.text(`You picked the '${packagE.getCellValueAsString('Package Name')}' for the '${order.getCellValueAsString("Order Name")} Order'`)

//array of product's record_ids that belong to 'packagE'
let product_ids = packagE.getCellValue('Products')
let product_list = =>;

// for every item in product_list array, create record linking to the corresponding 'Product' and with every line item linked to the related order
let order_items_table = base.getTable("Order Items")

CleanShot 2020-04-27 at 08.12.03
CleanShot 2020-04-27 at 08.11.43
CleanShot 2020-04-27 at 08.06.34

0 Replies 0