Skip to content

[Bug]: Shopify Connector: order sync fails when Shopify PO Number exceeds 35 characters (missing truncation in ShpfyProcessOrder) #10243

Description

Describe the issue

Codeunit "Shpfy Process Order".CreateHeaderFromShopifyOrder assigns the Shopify PO number to the sales header without truncation:

SalesHeader.Validate("External Document No.", ShopifyOrderHeader."PO Number");

https://github.com/microsoft/BCApps/blob/main/src/Apps/W1/Shopify/App/src/Order%20handling/Codeunits/ShpfyProcessOrder.Codeunit.al (currently line ~133)

Sales Header."External Document No." is Code[35], while the PO number field on Shpfy Order Header holds longer values coming from Shopify (B2B checkout PO numbers routinely exceed 35 characters — customers paste internal reference strings). When that happens, order creation fails at runtime with:

The length of the string is 45, but it must be less than or equal to 35 characters.

The Shopify order then sits in error state and requires manual PO editing + reprocessing. Every retry fails identically, so for affected merchants this is a recurring daily-operations burden.

Expected behavior

The PO number is truncated to the target field length (like other string fields mapped in the same procedure), so order creation succeeds. The full PO number remains available on the order in Shopify. Proposed one-line fix:

SalesHeader.Validate("External Document No.", CopyStr(ShopifyOrderHeader."PO Number", 1, MaxStrLen(SalesHeader."External Document No.")));

Steps to reproduce

  1. BC SaaS with the Shopify Connector, connected shop with B2B / draft-order flow.
  2. Create a Shopify order whose PO number is longer than 35 characters (e.g. TEST-PO-1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ).
  3. Sync the order and run Create Sales Document (or let the order sync job process it).
  4. Order processing fails with the string-length error; no sales document is created.

Additional context

Observed in production on BC 27 (SaaS) with Shopify Connector 27.x and 28.3; the assignment is unchanged on current main. All surrounding header fields are length-safe — this one assignment is the outlier. We currently work around it with a per-tenant extension subscribing to Shpfy Order Events.OnBeforeProcessSalesDocument and truncating there.

I will provide a fix for this bug (one-line change above) once the issue is approved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    IntegrationGitHub request for Integration area

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions