microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
796 stars 622 forks source link

[Bug]: Shopify: BC Doc No. attribute sent to Shopify even in cases of errors #26516

Open JeppeBylov opened 6 months ago

JeppeBylov commented 6 months ago

Describe the issue

When a Shopify Order is imported and an error occurs after the CreateHeaderFromShopifyOrder finishes, then the order is order is reimported shortly thereafter, which currently clears the error message, making any consistent follow-up impossible. I don't know if the fact that the error message is cleared only happens in these cases or if there's a second issue where this also happens on new orders imported.

The cause is that in function CreateHeaderFromShopifyOrder there's an API call to shopify to add the BC Doc No. attribute. This update triggers a webhook notification to BC, which reimports the same order.

Expected behavior

Update of attributes in Shopify shouldn't happen until the full document has been created and any errors have been accounted for.

I would move the following lines to a separate function

https://github.com/microsoft/ALAppExtensions/blob/18455700ada751a86886a8cefdb071bd4a76ce71/Apps/W1/Shopify/app/src/Order%20handling/Codeunits/ShpfyProcessOrder.Codeunit.al#L139C1-L143C7

This function should be called just before the Auto Release check.

Steps to reproduce

Prepare a case where a sales line will return an error on creation.

  1. Create order in Shopify
  2. Import orders to BC
  3. Order is now marked with error message
  4. Open order in Shopify admin
  5. Confirm that order now has a BC Doc No.
  6. Wait approx. 5 minutes
  7. Shopify Order has now been updated in BC.

Additional context

No response

I will provide a fix for a bug

JesperSchulz commented 6 months ago

Consulted @onbuyuka. Issue approved.