Skip to content

[Shopify] Improve Fulfillment Order Line matching using Line Item ID#6157

Merged
onbuyuka merged 3 commits intomainfrom
bug/617896-ShpfyFulfillmentOrderConnection
Jan 21, 2026
Merged

[Shopify] Improve Fulfillment Order Line matching using Line Item ID#6157
onbuyuka merged 3 commits intomainfrom
bug/617896-ShpfyFulfillmentOrderConnection

Conversation

@onbuyuka
Copy link
Copy Markdown
Contributor

@onbuyuka onbuyuka commented Jan 14, 2026

Summary

This PR improves the reliability of matching Shopify fulfillment order lines to Business Central sales shipment lines by using the Line Item Id directly from Shopify's API, instead of the previous matching logic based on variant, location, and delivery method type.

Problem

The previous implementation used a combination of Shopify Variant Id, Location Id, and Delivery Method Type to match fulfillment order lines. This approach was fragile and could fail in scenarios with:

  • Multiple order lines for the same variant
  • Split shipments across different fulfillment orders
  • Complex delivery configurations

Solution

  • Import and store Line Item ID: Fetch lineItem.legacyResourceId from Shopify's FulfillmentOrderLineItem GraphQL response and store it in the new "Line Item Id" field on the "Shpfy FulFillment Order Line" table
  • Direct matching: Match fulfillment order lines to order lines using the Line Item Id instead of variant-based matching
  • Handle split quantities: Loop through multiple fulfillment lines when a single order line is split across fulfillment orders

Changes

Schema Changes:

  • Added field "Line Item Id" (BigInteger) to "Shpfy FulFillment Order Line" table
  • Added Key4 on "Shopify Order Id", "Line Item Id" for efficient filtering

GraphQL Queries:

  • Updated ShpfyGQLOpenFulfillmOrdLines and ShpfyGQLNextOpenFFOrderLines to fetch lineItem.id (legacyResourceId)

Import Logic:

  • ShpfyFulfillmentOrdersAPI: Populate "Line Item Id" when importing fulfillment order lines
  • ShpfyImportOrder: Filter by "Line Item Id" instead of "Shopify Variant Id" in UpdateLocationIdAndDeliveryMethodOnOrderLine

Export Logic:

  • ShpfyExportShipments: Simplified CreateShopifyFulfillment by removing query-based location/delivery method grouping
  • Rewrote FindFulfillmentOrderLine -> FindFulfillmentOrderLines to handle multiple fulfillment lines per order line with quantity tracking
  • Removed LocationId and DeliveryMethodType parameters from CreateFulfillmentOrderRequest

Cleanup:

  • Deleted ShpfyShipmentLocation query (no longer needed after refactor)
  • Removed query permission from ShpfyObjects.PermissionSet.al

Testing

  • Updated ShpfyShippingHelper test helper to populate "Line Item Id"
  • Updated all test calls in ShpfyShippingTest to use the new CreateFulfillmentOrderRequest signature

Fixes AB#617896

@onbuyuka onbuyuka requested a review from a team as a code owner January 14, 2026 22:13
@github-actions github-actions bot added the AL: Apps (W1) Add-on apps for W1 label Jan 14, 2026
@github-actions github-actions bot added this to the Version 28.0 milestone Jan 14, 2026
- Remove ShpfyShipmentLocation.Query.al (no longer needed after refactor)
- Remove query permission from ShpfyObjects.PermissionSet.al
@onbuyuka onbuyuka changed the title Improve Fulfillment Order Line matching using Line Item ID [Shopify] Improve Fulfillment Order Line matching using Line Item ID Jan 14, 2026
@onbuyuka onbuyuka enabled auto-merge (squash) January 20, 2026 12:38
@onbuyuka onbuyuka merged commit 42917db into main Jan 21, 2026
48 checks passed
@onbuyuka onbuyuka deleted the bug/617896-ShpfyFulfillmentOrderConnection branch January 21, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants