Sync Document Attachment from Company A to Company B

julkifli33julkifli33 Member Posts: 1,092
edited 2022-02-22 in NAV Three Tier
Hi All ,
how do we sync Document Attachment from Company A to Company B?
let's say i have attachment in customer card.
then this customer, i want to sync to another company.

Customer table no issue.
but document attachment has issue
FromDocumentAttachment.reset;
FromDocumentAttachment.Setrange(FromDocumentAttachment."Table ID", 18);
FromDocumentAttachment.Setrange(FromDocumentAttachment."No.", ParCustomerNo);
if FromDocumentAttachment.findset then begin
ToDocumentAttachment.ChangeCompany(ParCompanyName);
    repeat
          ToDocumentAttachment.Init();
          ToDocumentAttachment.TransferFields(FromDocumentAttachment);
          ToDocumentAttachment.Insert(true);
   until FromDocumentAttachment.Next = 0;
end;

it's successfully inserted to another company.
but when i download the attachment.
it is nothing.
0 kb.

any idea?
do i miss something here?

Best Answer

  • BertVerbBertVerb Member Posts: 24
    Answer ✓
    You must export and import the field "Document Reference ID" again in the media field.

Answers

  • BertVerbBertVerb Member Posts: 24
    Answer ✓
    You must export and import the field "Document Reference ID" again in the media field.
  • julkifli33julkifli33 Member Posts: 1,092
    hi @BertVerb thank you so much.

    this code works !
     TempBlob.CreateOutStream(DocOutStream);
                        FromDocumentAttachment."Document Reference ID".ExportStream(DocOutStream);
                        TempBlob.CreateInStream(DocInStream);
                        ToDocumentAttachment.Init();
                        ToDocumentAttachment.TransferFields(FromDocumentAttachment);
                        ToDocumentAttachment."Document Reference ID".ImportStream(DocInStream, '');
                        ToDocumentAttachment.Insert(true);
    
Sign In or Register to comment.