Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

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

(0) ShareShare
ReportReport
Posted on by 8
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;
 
 
 
 
 
  • NB-26050925-0 Profile Picture
    NB-26050925-0 8 on at
    How to read blob data and convert into attachment on sales order
    Dear Team,
     
    Once file is attach i can't open it. getting below error. Please suggest.
     
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,595 Super User 2024 Season 2 on at
    How to read blob data and convert into attachment on sales order
    Hi, you can try the following two standard functions first. I think your needs are somewhat similar to this.
    Dynamics 365 Business Central: Use attachments from document lines while sending emails
     
    Dynamics 365 Business Central: Flow attachments to transactions (Flow to Sales Trx/Flow to Purch. Trx)
     
    Hope this helps.
    Thanks.
    ZHU
  • Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 on at
    How to read blob data and convert into attachment on sales order
    Can you share some screenshots of whats happening when you try to open the attachement?
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 12,920 Most Valuable Professional on at

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans