Pass Document Attachment from Company A to Company B
julkifli33
Member Posts: 1,100
Hi All,
I am using cloud BC.
any idea how to pass Document attachment from Company A to Company B?
so I have Posted Purchase in Company A, i want to pass all these records to Unposted Purchase Invoice in Company B.
Purchase Header and Purchase Line no problem.
the thing is how about Document Attachment.
My Code :
it is inserted to the Company B as attachment.
but attachment is all 0 KB.

Do i miss something?
I am using cloud BC.
any idea how to pass Document attachment from Company A to Company B?
so I have Posted Purchase in Company A, i want to pass all these records to Unposted Purchase Invoice in Company B.
Purchase Header and Purchase Line no problem.
the thing is how about Document Attachment.
My Code :
FromDocumentAttachment.Reset;
FromDocumentAttachment.Setrange(FromDocumentAttachment."Table ID", 122);
FromDocumentAttachment.SetRange(FromDocumentAttachment."File Type", FromDocumentAttachment."File Type"::Image);
if FromDocumentAttachment.FindSet() then begin
ToDocumentAttachment.ChangeCompany(SyncCompany.Name);
ToDocumentAttachment.Reset;
ToDocumentAttachment.Setrange(ToDocumentAttachment."Table ID", 38);
if ToDocumentAttachment.FindLast() then
LastEntryNo := ToDocumentAttachment.ID
else
LastEntryNo := 0;
repeat
LastEntryNo := LastEntryNo + 1;
ToDocumentAttachment."Table ID" := 38;
ToDocumentAttachment."No." := FromDocumentAttachment."No.";
ToDocumentAttachment."Document Type" := ToDocumentAttachment."Document Type"::Invoice;
ToDocumentAttachment."Line No." := 0;
ToDocumentAttachment.ID := LastEntryNo;
ToDocumentAttachment."File Extension" := FromDocumentAttachment."File Extension";
ToDocumentAttachment."File Name" := FromDocumentAttachment."File Name";
case LowerCase(ToDocumentAttachment."File Extension") of
'jpg', 'jpeg', 'bmp', 'png', 'tiff', 'tif', 'gif':
ToDocumentAttachment."File Type" := ToDocumentAttachment."File Type"::Image;
'pdf':
ToDocumentAttachment."File Type" := ToDocumentAttachment."File Type"::PDF;
'docx', 'doc':
ToDocumentAttachment."File Type" := ToDocumentAttachment."File Type"::Word;
'xlsx', 'xls':
ToDocumentAttachment."File Type" := ToDocumentAttachment."File Type"::Excel;
'pptx', 'ppt':
ToDocumentAttachment."File Type" := ToDocumentAttachment."File Type"::PowerPoint;
'msg':
ToDocumentAttachment."File Type" := ToDocumentAttachment."File Type"::Email;
'xml':
ToDocumentAttachment."File Type" := ToDocumentAttachment."File Type"::XML;
else
ToDocumentAttachment."File Type" := ToDocumentAttachment."File Type"::Other;
end;
ToDocumentAttachment.User := FromDocumentAttachment.User;
ToDocumentAttachment."Document Flow Purchase" := True;
TempBlobPurch.CreateOutStream(PurchOutStr);
FromDocumentAttachment."Document Reference ID".ExportStream(PurchOutStr);
TempBlobPurch.CreateInStream(PurchInStr);
CopyStream(PurchOutStr, PurchInStr);
ToDocumentAttachment."Document Reference ID".ImportStream(PurchInStr, 'XYZ', FromDocumentAttachment."File Name");
ToDocumentAttachment.INSERT;
until FromDocumentAttachment.Next() = 0
it is inserted to the Company B as attachment.
but attachment is all 0 KB.

Do i miss something?
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 323 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions