Posted on 11/11/2021 15:22:05
Hi Dmitrij
We have talked with the client, and comparing the way that orders are created in their BC with the problem we have with code unit, I think we found a way to replicate this.
The problem occurs when a product in BC has a base unit and Default Sales Unit that is different. So for example, if a product base unit is "PC" but the default sales unit is "PACKET" and a packet is the equivalent to 500 base units (pieces). At the same time the setting "Default Item Quantity" is set to "ON".
In newer code unit (v. 1.2.0.17 and up) if XML reguest from DW has an empty "UnitId", then code unit will not return the XMLNode for "UnitId". I believe this is a logic tied to the fact that there was some issues with previous versions, where the integration would cause duplicate order lines (this forum post https://doc.dynamicweb.com/forum/integration/integration/live-integration-issue-when).
This would mean, that unless we specifically include the "UnitId" field in the XML, then there would be no "UnitId" returned from code unit. This works as intended on calculate. Problem occurs if we send an empty "UnitId" to BC on a product like described above (different base and sales quantity), then BC would create the order with the default sales quantity, resulting in the case described in previous post. This is where we send Quantity=500 in XML with no UnitId meaning 500 base units. BC will interpret it as 500 default sales units, which would then give 25000 base units, with the example described above.
We have found a work around in code ourselfes combining different notification subscribers, so the problem is fixed for this client, but we wanted to share the information found on this.
BR Chris