Thursday, 7 June 2018

Import document handling (attachment) files #MSDyn365FO

Out of the box you have limited data entities for migrating attachments. If you search what is already in the AOT, you will see a few various examples. I suggest you look at the LedgerJournalAttachmentsEntity as it is the simplest and cleans to copy from. I wont go into detail but I will give a quick run down of what it looks like.

  1. Use the DocuRefEntity as your main datasource. It does most of the work for you.
  2. Set your table you want to import for as the child datasource
  3. Add the Key


You will need to add the postLoad method. There is minor code to update the virtual field FileContents.


Below is an export I did for the general journal attachments. The import zip structure should be the same way.

It will create the usual artifacts such as the excel, manifest and package header xml files. You will see a Resources folder under that.


If you drill down to the resources you will see the attachments. This is an export and it used the document GUID for uniqueness. The other thing is the extension isn’t added to the file name. When you are importing you are ok to leave the extension name.


The Excel file looks like this.


Hope it helps.


Ray Norman said...

Once I initially commented I clicked the -Notify me when new feedback are added- checkbox and now every time a comment is added I get four emails with the same comment. Is there any manner you can take away me from that service? Thanks! real money casino

John said...

Hi Munir,
I want to add documents to customer table programmatically, can you please suggest how to do this.