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