Skip to main content
Suggested answer

How to read blob data and convert into attachment on sales order

editSubscribe (0) ShareShare
ReportReport
Posted on by 4
Dear Team,
 
i have requirment were user is passing attachment in blob field. i want to read the blob field and convert into attachment on sales order. but when i try to open attachment its not opening. Below is my code.can anyone suggest?
 
 procedure CreatePurchaseInvoiceAttachment(): Boolean
    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;
 
 
 
 
 
Categories: