Aug 14, 2020 10:15 PM
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: [{field: "Line Items: Variant Id", direction: "asc"}]
});
for (let record1 of result.records) {
output.text(record1.getCellValue(sku)); // throws an error
}
Error: Unknown value ‘AlexSaleBeanieAdultCharcoal’ passed to output.text()
at main on line 12
Please help!
Thanks
Claire
Solved! Go to Solution.
Aug 14, 2020 10:30 PM
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.
Aug 14, 2020 10:30 PM
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.