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 Import Blob Field using Excel Buffer in business central.

(0) ShareShare
ReportReport
Posted on by 99

I want to import Blob fields into my custom  "Service Worksheet Table".all data imported but Blob Field Data not Inserted into table.

please give me suggestion How to achieve this. 

 blob fields.

1.Fault Comment Line
2.Resolution Comment Line
3.Internal Comment Line

  local procedure ImportExcelData()
    var
        SOImportBuffer: Record "ST_Service Worksheet LineTable";
        RowNo: Integer;
        ColNo: Integer;
        LineNo: Integer;
        MaxRowNo: Integer;
    begin
        RowNo := 0;
        ColNo := 0;
        MaxRowNo := 0;
        LineNo := 0;
        SOImportBuffer.Reset();
        if SOImportBuffer.FindLast() then
            LineNo := SOImportBuffer."Line No.";
        TempExcelBuffer.Reset();
        if TempExcelBuffer.FindLast() then begin
            MaxRowNo := TempExcelBuffer."Row No.";
        end;

        for RowNo := 2 to MaxRowNo do begin
            LineNo := LineNo   10000;
            SOImportBuffer.Init();

            SOImportBuffer."Line No." := LineNo;
            Evaluate(SOImportBuffer."Serial No.", GetValueAtCell(RowNo, 1));
            Evaluate(SOImportBuffer."Service Item No.", GetValueAtCell(RowNo, 2));
            Evaluate(SOImportBuffer."Customer No.", GetValueAtCell(RowNo, 3));
            Evaluate(SOImportBuffer."Customer Name", GetValueAtCell(RowNo, 4));
            Evaluate(SOImportBuffer."Ship-to Code", GetValueAtCell(RowNo, 5));
            Evaluate(SOImportBuffer."Shipment No.", GetValueAtCell(RowNo, 6));
            Evaluate(SOImportBuffer."Shipment Date", GetValueAtCell(RowNo, 7));
            Evaluate(SOImportBuffer."Item No.", GetValueAtCell(RowNo, 8));
            Evaluate(SOImportBuffer.Description, GetValueAtCell(RowNo, 9));
            Evaluate(SOImportBuffer."Description 2", GetValueAtCell(RowNo, 10));
            Evaluate(SOImportBuffer."Fault Area Code", GetValueAtCell(RowNo, 11));
            Evaluate(SOImportBuffer."Symptom Code", GetValueAtCell(RowNo, 12));
            Evaluate(SOImportBuffer."Fault Code", GetValueAtCell(RowNo, 13));
            Evaluate(SOImportBuffer."Resolution Code", GetValueAtCell(RowNo, 14));
            Evaluate(SOImportBuffer."No. of Previous Services", GetValueAtCell(RowNo, 15));
            Evaluate(SOImportBuffer."Service Order No.", GetValueAtCell(RowNo, 16));
            Evaluate(SOImportBuffer."Fault Comment Line", GetValueAtCellBlob(RowNo, 17));
            Evaluate(SOImportBuffer."Resolution Comment Line", GetValueAtCellBlob(RowNo, 18));
            Evaluate(SOImportBuffer."Internal Comment Line", GetValueAtCellBlob(RowNo, 19));
            SOImportBuffer."Sheet Name" := SheetName;
            SOImportBuffer."File Name" := FileName;

            SOImportBuffer.Insert();
        end;
        Message(ExcelImportSucess);
    end;

    local procedure GetValueAtCell(RowNo: Integer; ColNo: Integer): Text
    begin

        TempExcelBuffer.Reset();
        If TempExcelBuffer.Get(RowNo, ColNo) then
            exit(TempExcelBuffer."Cell Value as Text")
        else
            exit('');
    end;

    local procedure GetValueAtCellBlob(RowNo: Integer; ColNo: Integer): Text
    var
        CellTextValue: text;
        RecInStream: InStream;
        TempBlob: Codeunit "Temp Blob";
        TypeHelper: Codeunit "Type Helper";
        InStream: InStream;
        Faultcomm: text;
    begin
        TempExcelBuffer.Reset();
        If TempExcelBuffer.get(RowNo, ColNo) then begin
            CalcFields("Fault Comment Line");
            "Fault Comment Line".CreateInStream(InStream, TEXTENCODING::UTF8);
        end;
    end;

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,105 Moderator on at

    Your GetValueAtCellBlob function is missing an exit statement.

    You need to add

    Exit(YourTxtValue);

    If not the return value will always be empty.

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 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans