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

Notifications

Announcements

No record found.

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. 

Categories:
  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: Business Central Dataverse Integration - Purchase Line Error

    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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

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

Featured topics

Product updates

Dynamics 365 release plans