var
FromRecReff: RecordRef;
ph: Record /Purchase Header/;
instream1: InStream;
ins1: InStream;
DocAttach: Record /Document Attachment/;
begin
ph.Reset();
ph.SetRange(/No./, PurchaseHeader1./No./);
ph.SetRange(/Document Type/, ph./Document Type/::Invoice);
if ph.FindFirst() then
FromRecReff.GetTable(ph);
PurchaseStaging.CalcFields(Base64);
PurchaseStaging.Base64.CreateInStream(ins1);
Base64String := Base64convert.ToBase64(ins1);
tempBlob.CreateOutStream(outstream);
Base64convert.FromBase64(Base64String, outstream);
tempBlob.CreateInStream(Instream1);
DocAttach.SaveAttachment(FromRecReff, 'test.pdf', tempBlob);
// end;
end;