web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
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 12
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;
 
 
 
 
 
I have the same question (0)
  • Suggested answer
    Gerardo Rentería García Profile Picture
    25,230 Most Valuable Professional on at
  • Inge M. Bruvik Profile Picture
    1,111 Moderator on at
    Can you share some screenshots of whats happening when you try to open the attachement?
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
    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
  • NB-26050925-0 Profile Picture
    12 on at
    Dear Team,
     
    Once file is attach i can't open it. getting below error. Please suggest.
     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,362

#2
YUN ZHU Profile Picture

YUN ZHU 867 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans