Applies to Product – Dynamics 365 for Finance and Operations (on-premises)
What’s happening?
The synchronization with the fiscal books is presenting an error: "Cannot create a record in Inventory adjustments mapping (FBPeriodInventTrans_BR). The record already exists." This issue occurs when attempting to synchronize fiscal books after creating multiple inventory transactions that point to the same InventTransOrigin.
Reason:
The underlying cause of this is related to the method "bookApplicableInventoryAdjustments" in the class "FBFiscalDocumentBookProcessor_BR." The error is thrown because the query is only evaluated once at the beginning and not refreshed after each loop, leading to multiple insert attempts for the same InventTransId, which violates the unique index "UniqIdx" of the table FBPeriodInventTrans_BR.
Resolution:
- Create an inventory adjustment on a serialized item (change in quantity = 2, which should create multiple InventTrans records for the same InventTransOrigin).
- Open the fiscal books for the relevant period and select the month where the inventory adjustment was posted.
- On the Maintain tab, click on Sync, then confirm by clicking OK twice.
- Ensure that the InventTrans records have different InventTransIds (i.e., different serial numbers) that point to the same InventTransOrigin (same Lot IDs).
- If the error persists, check if the issue occurs in all environments (Production, UAT, and Dev) and if it affects all items or just specific ones.
- If necessary, run a trace and session ID data during the synchronization process for further analysis.
