web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    Check below blog , this might help you

    www.cloudfronts.com/.../

  • Andrew Xu Profile Picture
    3,877 on at

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

  • newbie_s Profile Picture
    10 on at

    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.

  • newbie_s Profile Picture
    10 on at

    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.

  • Verified answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    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.

  • Verified answer
    Andrew Xu Profile Picture
    3,877 on at

    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.

  • newbie_s Profile Picture
    10 on at

    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

  • Sukrut Parab Profile Picture
    71,710 Moderator on at

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

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 > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans