Export / Import attachments in Dynamics 365 Finance
Export / Import attachments in Dynamics 365 Finance
Document Management – Storing attachment and notes in D365 FO is a simple and easy go process . More information on configuring Document management is detailed in Microsoft document site.
Microsoft has provided an easy way to restore data from Tier-2 environments to other sandbox environments. But Attachment details are not exported in this case. So it would be a tedious job if the project is handling voluminous data with attachments.
More details on other missing data when exported is given as a screenshot below from the MS site,

Now, coming back to our main topic on how to export / import attachments in D365 FO.
There are many out of box entities in D365 FO to support in the export and import of document – Like CustomerAttachmentsEntity , EcoResDocumentAttachmentEntity etc.
For more entities, search in AOT with the below filter.

I tried using CustomerAttachmentsEntity for exporting the data, but it doesn`t export the field ‘FileContents’ which is needed while importing.
So I duplicated this entity and brought the logic for FileContents in POSTLOAD method.

/// /// Entity used to Dual-Write document attachments for the CustomerAttachmentsEntity table. ///
public class AECustomerAttachmentsEntity extends common
{
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/// <summary> /// /// </summary> public void postLoad() { super(); if(this.RecId && this.DocumentId!= emptyGuid()) { DocuRefEntity baseEntity; select firstonly baseEntity where baseEntity.DocumentId == this.DocumentId; this.FileContents = baseEntity.FileContents; this.fieldExternallySet(fieldNum(AECustomerAttachmentsEntity, FileContents), false); } } } |
Build and sync the changes.
Now, let us configure a data project and export this entity as XML format. (any format is supported). On exporting, with the File contents would be exported as Resources folder in export package.

Now, let us see on importing the package in another environment

Upload and add the package which we downloaded in the previous step.
After the successful import, we will be able to see the attachment in the customer record
posted on 2025-02-18 15:47 lingdanglfw 阅读(12) 评论(0) 收藏 举报