Covers all questions related to inventory management, order fulfillment, and shipping.
I have been using the graphQl inventorySetOnHandQuantities mutation to update stock and recently some of my batches have been failing because individual items return the SET_ON_HAND_QUANTITIES_FAILED error:
"{
field: null,
message: "The on-hand quantities couldn't be set. Try again."
}"
Why am I getting this error? What does it mean? What can I do to solve this problem?
Hi Barnaby,
What's the full mutation request you're trying to make?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hey @Liam, I'm getting the same error with the following query:
mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) {
inventorySetOnHandQuantities(input: $input) {
userErrors {
field
message
}
}
}
{
"input": {
"reason": "correction",
"setQuantities": [
{
"inventoryItemId": "gid://shopify/InventoryItem/42431172739133",
"locationId": "gid://shopify/Location/64617152573",
"quantity": 0
},
# 249 more times for different locations but with the same inventory item id
]
}
}
Hi Kcamel
Just to confirm - do you have the write_inventory
access scope, as well as the permission to update an inventory? Also which API version are you using?
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thanks for the quick reply @Liam.
Yes indeed I do have the `write_inventory` (how do you add inline code?) scope and is running successfully for other Inventory Items.
I manged to resolve this on my end. It turns out that of the 250 locations (all at for the same inventory item) I was trying to set one of them was not activated yet. I was able to find out which one it was by trying to up date them one at a time and then finally activating it using the `inventoryActivate` mutation.
It would be nice if the `inventorySetOnHandQuantities` mutation offered more details as to why to why the mutation failed. Ideally it would specifically let you know that the inventory could not be set because the location is not active. Instead of just the generic abstract message "The on-hand quantities couldn't be set. Try again.".
Thanks for your help Liam.
I hope this might be helpful to someone else.
Hi again Kcamel - glad you figured this out and thanks for coming back to post your solution.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi @Liam,
mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) { inventorySetOnHandQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason changes { name delta } } } }