[Shopify] Split fulfillment requests by location#7065
Conversation
…ion errors Shopify's fulfillmentCreate API requires all fulfillment orders in a single request to belong to the same location. When a shipment spans multiple Shopify locations, the connector now builds separate GraphQL mutations per location instead of combining them into one request. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ipped Move GraphQueryStart initialization inside the loop so it uses the first non-skipped record's location, not the first record overall. Previously, if all records for the first location were skipped (assigned or unfulfillable), the mutation would be built with the wrong location. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use an IsFirstLocation boolean instead of comparing PrevLocationId to detect the first non-skipped record. The previous approach failed when Shopify Location Id was 0 (unset), because PrevLocationId was also initialized to 0, so the condition was never true and BuildFulfillmentQueryStart was never called. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b5b5d90 to
16cbfb9
Compare
|
There was a problem hiding this comment.
Pull request overview
Updates the Shopify shipment export flow to satisfy fulfillmentCreate’s constraint that each request contains fulfillment orders from a single Shopify location, preventing "All fulfillment orders must be assigned to a single location" failures for split-location shipments.
Changes:
- Group fulfillment order lines by
Shopify Location Idand emit one GraphQL mutation per location. - Extracted GraphQL mutation start/finalization into helper procedures to reduce duplication.
- Added a supporting table key and a new unit test covering multi-location shipments.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Apps/W1/Shopify/Test/Shipping/ShpfyShippingTest.Codeunit.al | Adds a unit test verifying two separate fulfillment requests are generated for two locations. |
| src/Apps/W1/Shopify/Test/Shipping/ShpfyShippingHelper.Codeunit.al | Adds helper procedures to create order/shipment/fulfillment-order test data for multi-location scenarios. |
| src/Apps/W1/Shopify/App/src/Shipping/Codeunits/ShpfyExportShipments.Codeunit.al | Changes request generation to split mutations by location and extracts shared query-building helpers. |
| src/Apps/W1/Shopify/App/src/Order Fulfillments/Tables/ShpfyFulFillmentOrderLine.Table.al | Adds an index to support sorting/grouping fulfillment order lines by location + fulfillment order id. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
## Summary - Shopify's `fulfillmentCreate` API requires all fulfillment orders in a single request to belong to the same location. When a shipment spans multiple Shopify locations (e.g. one item split across two warehouses), the connector was combining them into one GraphQL mutation, causing a `"All fulfillment orders must be assigned to a single location"` error. - The fulfillment request builder now groups lines by `Shopify Location Id` and emits separate mutations per location. - Added a new key (`Shopify Location Id`, `Shopify Fulfillment Order Id`) to the Fulfillment Order Line table to support the grouping. - Extracted `BuildFulfillmentQueryStart` and `FinalizeFulfillmentQuery` helper procedures to eliminate duplication. Fixes [AB#617896](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/617896) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
## Summary - Shopify's `fulfillmentCreate` API requires all fulfillment orders in a single request to belong to the same location. When a shipment spans multiple Shopify locations (e.g. one item split across two warehouses), the connector was combining them into one GraphQL mutation, causing a `"All fulfillment orders must be assigned to a single location"` error. - The fulfillment request builder now groups lines by `Shopify Location Id` and emits separate mutations per location. - Added a new key (`Shopify Location Id`, `Shopify Fulfillment Order Id`) to the Fulfillment Order Line table to support the grouping. - Extracted `BuildFulfillmentQueryStart` and `FinalizeFulfillmentQuery` helper procedures to eliminate duplication. Fixes [AB#617896](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/617896) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
fulfillmentCreateAPI requires all fulfillment orders in a single request to belong to the same location. When a shipment spans multiple Shopify locations (e.g. one item split across two warehouses), the connector was combining them into one GraphQL mutation, causing a"All fulfillment orders must be assigned to a single location"error.Shopify Location Idand emits separate mutations per location.Shopify Location Id,Shopify Fulfillment Order Id) to the Fulfillment Order Line table to support the grouping.BuildFulfillmentQueryStartandFinalizeFulfillmentQueryhelper procedures to eliminate duplication.Fixes AB#617896
🤖 Generated with Claude Code