
I am working on an Integration between Dataverse (CRM) and Business Central.
I have 2 custom entities in CRM: Purchase Order and Offer that are mapped to the Purchase Header and Purchase Line tables respectively.
The Purchase Header integration works with no issues (Purchase Headers are created in Business Central)
However, the Purchase Line integration throws the following error:
The data could not be updated because of the following error: The field Document No. of table Purchase Line contains a value (ORDER) that cannot be found in the related table (Purchase Header).
Here is the AL Code Mapping List for the Purchase Headers field mappings:
InsertIntegrationFieldMapping('PURCHASE HEADER', PurchaseOrder.FieldNo("Buy-from Vendor No."), CDSPurchaseOrder.FieldNo(and_VendorId), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
InsertIntegrationFieldMapping('PURCHASE HEADER', PurchaseOrder.FieldNo("Buy-from Vendor Name"), CDSPurchaseOrder.FieldNo(and_VendorIdName), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
InsertIntegrationFieldMapping('PURCHASE HEADER', PurchaseOrder.FieldNo("Pay-to Vendor No."), CDSPurchaseOrder.FieldNo(and_VendorId), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
InsertIntegrationFieldMapping('PURCHASE HEADER', PurchaseOrder.FieldNo("Pay-to Name"), CDSPurchaseOrder.FieldNo(and_VendorIdName), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
InsertIntegrationFieldMapping('PURCHASE HEADER', PurchaseOrder.FieldNo("Vendor Invoice No."), 0, IntegrationFieldMapping.Direction::Bidirectional, 'Placeholder', true, false);
InsertIntegrationFieldMapping('PURCHASE HEADER', PurchaseOrder.FieldNo("Document Type"), 0, IntegrationFieldMapping.Direction::Bidirectional, 'Order', true, false);
InsertIntegrationFieldMapping('PURCHASE HEADER', PurchaseOrder.FieldNo("No."), CDSPurchaseOrder.FieldNo(and_name), IntegrationFieldMapping.Direction::ToIntegrationTable, '', true, false);
Here is the AL code Mapping List for the Purchase Lines field mappings:
InsertIntegrationFieldMapping('PURCHASELINE-OFFER', PurchaseLine.FieldNo("Document No."), CDSOffer.FieldNo(and_PurchaseOrderId), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
InsertIntegrationFieldMapping('PURCHASELINE-OFFER', PurchaseLine.FieldNo("Document Type"), 0, IntegrationFieldMapping.Direction::Bidirectional, 'Order', true, false);
InsertIntegrationFieldMapping('PURCHASELINE-OFFER', PurchaseLine.FieldNo("Type"), 0, IntegrationFieldMapping.Direction::Bidirectional, 'Item', true, false);
InsertIntegrationFieldMapping('PURCHASELINE-OFFER', PurchaseLine.FieldNo("No."), CDSOffer.FieldNo(and_ExistingProduct), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
InsertIntegrationFieldMapping('PURCHASELINE-OFFER', PurchaseLine.FieldNo("Quantity"), CDSOffer.FieldNo(and_OrderQuantity), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
InsertIntegrationFieldMapping('PURCHASELINE-OFFER', PurchaseLine.FieldNo("Direct Unit Cost"), CDSOffer.FieldNo(and_Cost), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
I have tried several modifications to the Purchase Line field mappings of "Document No." such as mapping to the BC PO number (instead of the Dataverse Purchase Order ID) but with no luck. I get a similar error:
The data could not be updated because of the following error: The field Document No. of table Purchase Line contains a value (106035) that cannot be found in the related table (Purchase Header).
(to confirm, PO 106035 does exist in BC).
Has anyone ever run into this issue before or have any ideas on how to fix?
Thank you.
Hello,
We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.
dynamicsuser.net/.../developers
I will open this up to the community in case they have something to add.
Thanks.