web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Business Central Dataverse Integration - Purchase Line Error

(0) ShareShare
ReportReport
Posted on by 65

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);

pastedimage1634675037886v1.png

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);

pastedimage1634675120269v2.png

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. 

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    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.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,713 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,032 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 914 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans