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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Unable to insert values into the table.

(0) ShareShare
ReportReport
Posted on by 65

Hi, All.

 

I hava a issue which i'd like to solve.

See the pictures below as examples for more info.

_B930AF30EA30FC30F330B730E730C330C830_-2021_2D00_01_2D00_19-104230.png

_B930AF30EA30FC30F330B730E730C330C830_-2021_2D00_01_2D00_19-104504.png

I created a function for Excel file import with AL.
I wrote a process to import data from Excel file, and then insert it into the table, but No records are inserted into the table.

How do I insert the records in the table?

Here is the source code of Excel Import:

procedure ImportSalesOrderExcel()
    var
    begin
        Rec_ExcelBuffer.DeleteAll();
        Rows := 0;
        Columns := 0;
        FileUploaded := UploadIntoStream('インポートするファイルを選択してください', '', '', Filename, Instr);

        if Filename <> '' then
            Sheetname := Rec_ExcelBuffer.SelectSheetsNameStream(Instr)
        else
            exit;

        Rec_ExcelBuffer.Reset;
        Rec_ExcelBuffer.OpenBookStream(Instr, Sheetname);
        Rec_ExcelBuffer.ReadSheet();

        Commit();
        Rec_ExcelBuffer.Reset();
        Rec_ExcelBuffer.SetRange("Column No.", 1);
        if Rec_ExcelBuffer.FindFirst() then
            repeat
                Rows := Rows   1;
            until Rec_ExcelBuffer.Next() = 0;

        Rec_ExcelBuffer.Reset();
        Rec_ExcelBuffer.SetRange("Row No.", 1);
        if Rec_ExcelBuffer.FindFirst() then
            repeat
                Columns := Columns   1;
            until Rec_ExcelBuffer.Next() = 0;

        for RowNo := 2 to Rows do begin
            SalesOrderImportBuffer_R.Reset();
            if SalesOrderImportBuffer_R.Get(GetValueAtIndex(RowNo, 1), GetValueAtIndex(RowNo, 2)) then begin
                Evaluate(SalesOrderImportBuffer_R."Document No.", GetValueAtIndex(RowNo, 3));
                SalesOrderImportBuffer_R.Validate("Document No.");
                //
                
                
                SalesOrderImportBuffer_R.Modify(true);
                Commit();
            end

            else begin
                SalesOrderImportBuffer_R.Init();
                Evaluate(SalesOrderImportBuffer_R."Entry No.", GetValueAtIndex(RowNo, 1));
                Evaluate(SalesOrderImportBuffer_R."Sell-to Customer No.", GetValueAtIndex(RowNo, 2));
                Evaluate(SalesOrderImportBuffer_R."Document No.", GetValueAtIndex(RowNo, 3));
               
                //trueを追加
                SalesOrderImportBuffer_R.Insert(true);
                Commit();
            end;
        end;

        Message('Successfully imported %1 Records', Rows - 1);

    end;

and Here is the source code of GetValueAtIndex:

  local procedure GetValueAtIndex(RowNo: Integer; ColNo: Integer): Text
    var
    begin
        Rec_ExcelBuffer.Reset();
        if Rec_ExcelBuffer.Get(RowNo, ColNo) then
            exit(Rec_ExcelBuffer."Cell Value as Text");
    end;

Thanks in advance.

I have the same question (0)
  • Suggested answer
    nagatak Profile Picture
    65 on at

    This problem has been solved. Thanks to those who considered it.

  • Verified answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    If possible, please share final outcome / solution.

    Thanks.

  • nagatak Profile Picture
    65 on at

    Hi, @Macro Mels!

    I was using DeleteAll function to initialize the record. However, I changed to Init function and that solved the problem.

    That's all.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,948 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 936 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 616 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans