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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Data Entity throws error during export or import due to an incorrect method override

(1) ShareShare
ReportReport
Posted on by 457
I have ExternalItemId from CustVendExternalItem table in a custom data entity, which needs to insert a new CustVendExternalItem when a new id is entered in the field. I have overriden the postLoad method for this purpose with the following code:
 
    public void postLoad()
    {
        super();
        CustVendExternalItem custVendExternalItem;
        custVendExternalItem.ModuleType = ModuleInventPurchSalesVendCustGroup::VendGroup;
        custVendExternalItem.CustVendRelation = "Foreign";
        custVendExternalItem.ItemId = this.ItemId;
        custVendExternalItem.ExternalItemId = this.ExternalItemId;
        custVendExternalItem.InventDimId = InventDim::inventDimIdBlank(); // AllBlank
        if (custVendExternalItem.validateWrite())
        {
            custVendExternalItem.insert();
        }

    }
 
 
But now the data entity throws "The record already exists" error during export or import (It was working before the override).
 
I have the same question (0)
  • Martin Dráb Profile Picture
    239,118 Most Valuable Professional on at
    postLoad() is a completely wrong method for your purpose. It's called for each record loaded from database, therefore your code is trying to insert an CustVendExternalItem record for every row to be exported. Which is a completely wrong thing to do and it's not what you wanted.
     
    First of all, think about whether data management can't create the record for you. If you're sure you need code for that, the correct methods may be mapEntityToDataSource(), insertEntityDataSource() or so. Details depends on your requirements.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,801 Super User 2026 Season 1 on at
    Hi,
     
    Try to use write instead insert method.
    custVendExternalItem.write();
    Best regards,
    Mohamed Amine MAHMOUDI

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 733

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 278 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans