Hi,
I finished scripting my use case of iterating over 500+ rows and POSTing to Shopify APIs in order to update inventory data in Shopify.
I would like to append a "RESULTS" column to the table using a JavaScript query and update it with the JSON response data for each row. I tried just setting the value in a loop for a column I created but no dice:
table1.data.forEach(row => fetchInvId.trigger({
additionalScope: {
passSKU: row.SKU
},
onSuccess: function(data) {
console.log(row.SKU)
//If statement checking if the inventory item is present within the response JSON
if (Object.values(data)[0].productVariants.edges.length == 0) {
console.log("Item " + row.SKU + " does not exist in Shopify")
} else {
var shopifyInvId = Object.values(data)[0].productVariants.edges[0].node.inventoryItem.id
shopifyInvId = /[^/]*$/.exec(shopifyInvId)[0]
console.log(shopifyInvId)
console.log(row.QUANTITY)
setInventoryLevels.trigger({
additionalScope: {
passLoc: locationId,
passInvId: shopifyInvId,
passQuantity: row.QUANTITY
},
onSuccess: function(data) {
row.RESULTS = data
},
onFailure: function(data) {
row.RESULTS = data
}
})
}
}
}))