Welcome to the forum @bentley
You are on the right track, but you found an old post with an old way of doing it.
Here is a query I just wrote today that used the correct pattern (with some comments added)
// Make the data I am going to pass to the query
let lineItems = []
tblInventory.selectedRows.forEach(item => {
lineItems.push({
po_id: selMakePO_POs.selectedItem.po_id,
sku: item.sku,
date_checkedin: moment().format("YYYY-MM-DD HH:mm:ss")
})
})
console.log(lineItems) // for debugging
await qryAddMultiplePOLineItems.trigger({additionalScope: {lineItems: lineItems}})
// The qryAddMultiplePOLineItems.data property will now be populated with the query results
await tblInventory.clearSelection()
await qryPOLineItems.trigger()
// The qryPOLineItems.data will now be populated and the table that uses it will be updated.
await qryProductsLowInventoryWithoutPOLineItems.trigger()
You can also do this (but make sure "Keep variable references in sync" option in the Advanced tab is checked if you are going to return results from a query.)
const newPO = await qryPONew.trigger() // Load the query return values into newPO
await qryActivePOs.trigger()
selMakePO_POs.setValue(newPO.result[0].po_id) // We can then use newPO later in the query
modNewPO.close()
You can also check to see if the query finished successfully:
const newPO = await qryPONew.trigger() // Load the query return values into newPO
if (newPO) {
// It worked, do stuff
return newPO.result[0].po_id // If another query called this one you can return values
} else {
// it failed. qryPONew.error will probably say why depending on the resource
}