Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Export and Import atta...
Finance forum

Export and Import attachment using DMF using custom entity

(0) ShareShare
ReportReport
Posted on by 10

Hello community.

I am new to dynamics 365 and I need your help or advice. 

I am trying to Export and Import attachments using a custom Data Entity. I used LedgerJournalAttachmentsEntity as an example. I am able to export attachments just fine. However, I am not able to import attachments. 

Every time I try to do import I get the error: 

Results. 'FileContents' is required when attaching a file
Results. validateWrite failed on data source 'DocuRefEntity (DocuRefEntity)'

I realize that method postLoad() supposed to set value to virtual field this.FileContents. But I checked in debugger this.RecId==0 and  this.DocumentId == emptyGuid() , so it never gets its value.

public void postLoad()
{
super();

// Virtual fields are not auto-populated from the base entity, so an extra select is necessary.
if (this.RecId && this.DocumentId != emptyGuid())
{
DocuRefEntity baseEntity;
select firstonly baseEntity where baseEntity.DocumentId == this.DocumentId;
this.FileContents = baseEntity.FileContents;
this.fieldExternallySet(fieldNum(KCertAttachmentsEntity, FileContents), false);
}
}

Any suggestion what can be causing the problem is really appreciated. 

Thank you,

newbie_s

  • Sukrut Parab Profile Picture
    71,682 Moderator on at
    RE: Export and Import attachment using DMF using custom entity

    Great to hear that . Please take your time to close the thread by making answer(s) verified which helped you.

  • newbie_s Profile Picture
    10 on at
    RE: Export and Import attachment using DMF using custom entity

    Thank you both, Sukrut and Andrew.

    I followed your suggestion and found problem in my set up, one column was not added correctly.

    Best regards,

    newbie_s

  • Verified answer
    Andrew Xu Profile Picture
    3,877 on at
    RE: Export and Import attachment using DMF using custom entity

    If you can import/export with LedgetJournalAttachmentsEntity, you should be able to do the same with your custom entity if it's customized correctly, unless there's data/configuration issue. Like Sukrut said, Running line by line debug in code should be able to help you address the cause of failure. Good luck.

  • Verified answer
    Sukrut Parab Profile Picture
    71,682 Moderator on at
    RE: Export and Import attachment using DMF using custom entity

    Did you try to use LedgerJournalAttachmentsEntity  and see of its for you ? May be your could debug the process and see what's missing in your custom entity.

  • newbie_s Profile Picture
    10 on at
    RE: Export and Import attachment using DMF using custom entity

    Hello Andrew, thank you for your reply. LedgerJournalAttachmentsEntity  was used as an example and based on it I constructed another entity that uses DocuRefEntity as master data source and my custom table as an embedded data source. It exports attachments fine, so the record exists in custom table and it can find it.

  • newbie_s Profile Picture
    10 on at
    RE: Export and Import attachment using DMF using custom entity

    Sukrut, I appreciate your reply. The example in the post is not complete, it's missing many steps. After removing entity data source I had to clear X++ code that was referencing it. Had to add a staging table. etc.

    After all changes it does not export nor import files.

  • Andrew Xu Profile Picture
    3,877 on at
    RE: Export and Import attachment using DMF using custom entity

    Does the LedgerJournalTable record of that attachment exist? Is the JournalBatchNumber of your attachment record valid?

  • Suggested answer
    Sukrut Parab Profile Picture
    71,682 Moderator on at
    RE: Export and Import attachment using DMF using custom entity

    Check below blog , this might help you

    www.cloudfronts.com/.../

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,325 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,025 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans