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 :
Microsoft Dynamics AX (Archived)

Error Cannot create a record in PurchTable, #### record already exist while importing POs with DIXF

(0) ShareShare
ReportReport
Posted on by 2,120

Hi folks,

I am importing open purchase orders using DIXF entity. There is no any PO data available in AX before. While importing data DIXF creating only first record among all records and for remaining records it is failing and throwing an error "Cannot create a record in PurchTable, the record already exist" whereas no duplicate record is present there.

I debugged the class and checked the missing indexes. There i found a record is not creating in 'SourceDocumentHeader' and 'SourceDocumentLine' table, so in purchtable this reference is going as value '0' so for next all records it is throwing an error.

I ran same source data on other environment, POs are creating there. So does there any additional values i need to pass to create record in 'SourceDocumentHeader' and 'SourceDocumentLine' table?

Or what tasks i needed to do to create records in these tables.

Please help to resolve this.

There is no any customization in standard DIXF entity.

Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Brandon Wiese Profile Picture
    17,790 on at

    The SourceDocumentHeader field is set and source document framework records created during the PurchTable.insert() method, in a call to PurchTableType.insert().  Here is the code.

            purchTable.SourceDocumentHeader = 0;
            SourceDocumentProcessorFacade::submitSourceDocumentImplementation(purchTable);
    
            purchTable.SourceDocumentLine = 0;
            SourceDocumentProcessorFacade::submitSourceDocumentLineImplementation(purchTable);
    
            purchTable.doInsert();

    So, you must be skipping the .insert() method somehow.

    Looking through DMFEntityBase, I found the .insertUpdate(..) method, with the following declaration.

    public Common insertUpdate(
      Common _target, 
      boolean _callInsertLogic = false, 
      boolean _callValidateLogic = false)

    Note here how _callInsertLogic is false by default, and what happens when it is false.

                if (_callInsertLogic)
                {
                    _target.insert();
                }
                else
                {
                    _target.doInsert();
                }

    The purchTable.insert() method is skipped in favor of a simple .doInsert(), which also skips the PurchTableType.insert() call that you need.

    This is all conjecture, but I suspect if you can figure out how to get the call to .insertUpdate() on the DMF entity to set _callInsertLogic to true, you should be fine.

  • Verified answer
    Brandon Wiese Profile Picture
    17,790 on at

    In the class DMFEntityWriter write() method, I found the call to insertUpdate.

    target = dictClass.callObject(
      methodStr(DMFEntityBase,insertUpdate), 
      entityClass, 
      target,
      (dmfDefinitionGroupEntity.RunInsertLogic && currentNode.RunInsertLogic),
      (dmfDefinitionGroupEntity.RunValidateWrite && currentNode.RunValidateWrite));
    

    So the key to your problem is to enable "Run insert logic" on the definition group and the current node (entity), since both must be enabled for the PurchTable.insert() method to be called instead of .doInsert()

  • Verified answer
    Sangram Shinde Profile Picture
    2,120 on at

    Thanks a TON Brandon, you are a genius!! I have checked the DMFDefinitionGroupEntity table. We have some issue with this data source. I have passed 'True' for RunInsertLogic here and records started importing and updating....:) this is amazing!

    Thanks a lot again!

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans