Skip to main content

Hi all



Hope you can help.



Using the scripting block, how could I loop through the records and return the value of a lookup field. All other fields are fine but linked and lookup fields throw an error.



Here’s my code…



let table = base.getTable("Daily Orders");

let view = table.getView("Unfulfilled Daily Orders");

let sku = table.getField("Line Items: Sku"); //Lookup Field







let result = await view.selectRecordsAsync({

sorts: t{field: "Line Items: Variant Id", direction: "asc"}]

});



for (let record1 of result.records) {

output.text(record1.getCellValue(sku)); // throws an error

}



ERROR



Error: Unknown value ‘AlexSaleBeanieAdultCharcoal’ passed to output.text()



at main on line 12





Please help!



Thanks



Claire

Lookup fields return arrays, even if they’re only looking up from a single linked record. Instead of output.text, use output.inspect. This will display the literal item you’re receiving, even if it’s an array.


Reply