[Bug]: Shopify Connector: order sync fails when Shopify PO Number exceeds 35 characters (missing truncation in ShpfyProcessOrder)
Nobody has claimed this yet.
- Dominant language
- AL
- Stars
- 683
- Forks
- 459
- Avg merge
- 3d 26m
- Merged PRs (30d)
- 633
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
- BC SaaS with the Shopify Connector, connected shop with B2B / draft-order flow.
- Create a Shopify order whose PO number is longer than 35 characters (e.g.
TEST-PO-1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ). - Sync the order and run Create Sales Document (or let the order sync job process it).
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open src/Apps/W1/Shopify/App/src/Order handling/Codeunits/ShpfyProcessOrder.Codeunit.al and start at Shpfy Process Order.CreateHeaderFromShopifyOrder. Reproduce the Shopify order sync with a PO number longer than 35 characters, then verify that Create Sales Document succeeds without the string-length error and that the order is no longer left in an error state.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100